Exemplo n.º 1
0
 public function testPermsAdminWorkflowTrackerRegisteredUser()
 {
     $request_admin_workflow_tracker = new MockCodendi_Request($this);
     $request_admin_workflow_tracker->setReturnValue('get', Workflow::FUNC_ADMIN_TRANSITIONS, array('func'));
     // registered user can NOT access tracker admin part
     $this->tracker->expectNever('getWorkflowManager');
     $this->tracker->process($this->tracker_manager, $request_admin_workflow_tracker, $this->registered_user);
 }
Exemplo n.º 2
0
 public function testGetNotMatchingElement()
 {
     $request_artifact = new MockCodendi_Request($this);
     $request_artifact->setReturnValue('get', '5', array('group_id'));
     $exeptionThrown = false;
     try {
         $this->url->getDispatchableFromRequest($request_artifact, $this->user);
     } catch (Exception $e) {
         $exeptionThrown = true;
         $this->assertIsA($e, 'Tracker_NoMachingResourceException');
     }
     $this->assertTrue($exeptionThrown, "Exception not thrown");
 }
 function testSynchronizerToken_check()
 {
     $GLOBALS['Response']->expectCallCount('addFeedback', 2);
     $GLOBALS['Response']->expectAt(0, 'redirect', array('/path/to/redirect'));
     $GLOBALS['Response']->expectAt(1, 'redirect', array('/path/to/url/3'));
     $GLOBALS['Response']->expectCallCount('redirect', 2);
     $user = new CSRFUserTestVersion_MockPreferences($this);
     $user->setReturnValue('getSessionHash', 123);
     $token1 = new CSRFSynchronizerTokenTestVersion($this);
     $token1->setReturnReference('getUser', $user);
     $token1->__construct('/path/to/url/1', 'challenge1');
     $token2 = new CSRFSynchronizerTokenTestVersion($this);
     $token2->setReturnReference('getUser', $user);
     $token2->__construct('/path/to/url/2', 'challenge2');
     $token3 = new CSRFSynchronizerTokenTestVersion($this);
     $token3->setReturnReference('getUser', $user);
     $token3->__construct('/path/to/url/3', 'challenge3');
     $request = new MockCodendi_Request();
     $request->setReturnValue('get', $token1->getToken(), array('challenge1'));
     $request->setReturnValue('get', md5('pouet'), array('challenge2'));
     $request->setReturnValue('get', false, array('challenge3'));
     $request->setReturnValue('existAndNonEmpty', true, array('challenge1'));
     $request->setReturnValue('existAndNonEmpty', true, array('challenge2'));
     $request->setReturnValue('existAndNonEmpty', false, array('challenge3'));
     $token1->check('/should/not/be/redirected', $request);
     //token1 is good
     $token2->check('/path/to/redirect', $request);
     //token2 is invalid
     $token3->check(null, $request);
     //token3 is invalid. return to default url
 }
Exemplo n.º 4
0
 public function testSearchAllTrackerDisplaySearchNotCalled()
 {
     $request = new MockCodendi_Request($this);
     $request->setReturnValue('exist', false, array('tracker'));
     $this->tracker->setReturnValue('userCanView', true, array($this->user));
     $this->tracker->expectNever('displaySearch');
     $this->tm->search($request, $this->user);
 }