diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index fc5788ebc..e7c689ae0 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -500,13 +500,13 @@ class AuthTest extends CakeTestCase { $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockTwoAuthorize', false); $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockThreeAuthorize', false); - $this->Controller->Auth->authorize = array( + $this->Auth->authorize = array( 'AuthMockOne', 'AuthMockTwo', 'AuthMockThree' ); - $mocks = $this->Controller->Auth->constructAuthorize(); - $request = $this->Controller->request; + $mocks = $this->Auth->constructAuthorize(); + $request = $this->Auth->request; $this->assertEquals(3, count($mocks)); $mocks[0]->expects($this->once()) @@ -522,7 +522,29 @@ class AuthTest extends CakeTestCase { $mocks[2]->expects($this->never()) ->method('authorize'); - $this->assertTrue($this->Controller->Auth->isAuthorized(array('User'), $request)); + $this->assertTrue($this->Auth->isAuthorized(array('User'), $request)); + } + +/** + * test that isAuthorized will use the session user if none is given. + * + * @return void + */ + function testIsAuthorizedUsingUserInSession() { + $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockFourAuthorize', false); + $this->Auth->authorize = array('AuthMockFour'); + + $user = array('user' => 'mark'); + $this->Auth->Session->write('Auth.User', $user); + $mocks = $this->Auth->constructAuthorize(); + $request = $this->Controller->request; + + $mocks[0]->expects($this->once()) + ->method('authorize') + ->with($user, $request) + ->will($this->returnValue(true)); + + $this->assertTrue($this->Auth->isAuthorized(null, $request)); } /** @@ -1120,4 +1142,16 @@ class AuthTest extends CakeTestCase { $this->assertEquals('/users/home', $result); $this->assertFalse($this->Auth->Session->check('Auth.redirect')); } + +/** + * test password hashing + * + * @return void + */ + function testPassword() { + $result = $this->Auth->password('password'); + $expected = Security::hash('password', null, true); + $this->assertEquals($expected, $result); + + } }