From 2994cbc586449caaa07d0a5a1934848da0a3ffa5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 30 Nov 2016 14:59:59 +0100 Subject: fix login controller tests Signed-off-by: Arthur Schiwon --- tests/Core/Controller/LoginControllerTest.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tests/Core') diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index 72f921724a5..51592c2c43a 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -334,6 +334,7 @@ class LoginControllerTest extends TestCase { $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('uid')); + $loginName = 'loginli'; $user->expects($this->any()) ->method('getLastLogin') ->willReturn(123456); @@ -362,10 +363,10 @@ class LoginControllerTest extends TestCase { ->will($this->returnValue($user)); $this->userSession->expects($this->once()) ->method('login') - ->with($user, $password); + ->with($loginName, $password); $this->userSession->expects($this->once()) ->method('createSessionToken') - ->with($this->request, $user->getUID(), $user, $password, false); + ->with($this->request, $user->getUID(), $loginName, $password, false); $this->twoFactorManager->expects($this->once()) ->method('isTwoFactorAuthenticated') ->with($user) @@ -387,7 +388,7 @@ class LoginControllerTest extends TestCase { ); $expected = new \OCP\AppFramework\Http\RedirectResponse($indexPageUrl); - $this->assertEquals($expected, $this->loginController->tryLogin($user, $password, null, false, 'Europe/Berlin', '1')); + $this->assertEquals($expected, $this->loginController->tryLogin($loginName, $password, null, false, 'Europe/Berlin', '1')); } public function testLoginWithValidCredentialsAndRememberMe() { @@ -396,6 +397,7 @@ class LoginControllerTest extends TestCase { $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('uid')); + $loginName = 'loginli'; $password = 'secret'; $indexPageUrl = \OC_Util::getDefaultPageUrl(); @@ -421,10 +423,10 @@ class LoginControllerTest extends TestCase { ->will($this->returnValue($user)); $this->userSession->expects($this->once()) ->method('login') - ->with($user, $password); + ->with($loginName, $password); $this->userSession->expects($this->once()) ->method('createSessionToken') - ->with($this->request, $user->getUID(), $user, $password, true); + ->with($this->request, $user->getUID(), $loginName, $password, true); $this->twoFactorManager->expects($this->once()) ->method('isTwoFactorAuthenticated') ->with($user) @@ -437,7 +439,7 @@ class LoginControllerTest extends TestCase { ->with($user); $expected = new \OCP\AppFramework\Http\RedirectResponse($indexPageUrl); - $this->assertEquals($expected, $this->loginController->tryLogin($user, $password, null, true)); + $this->assertEquals($expected, $this->loginController->tryLogin($loginName, $password, null, true)); } public function testLoginWithoutPassedCsrfCheckAndNotLoggedIn() { -- cgit v1.2.3 From 7b3fdfeeaac1ae8e7277ccb0118fd62611c0e302 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 30 Nov 2016 13:28:36 +0100 Subject: do login routine only once when done via LoginController Signed-off-by: Arthur Schiwon --- tests/Core/Controller/LoginControllerTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/Core') diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index 51592c2c43a..aa6ebe49385 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -362,8 +362,8 @@ class LoginControllerTest extends TestCase { ->method('checkPassword') ->will($this->returnValue($user)); $this->userSession->expects($this->once()) - ->method('login') - ->with($loginName, $password); + ->method('completeLogin') + ->with($user, ['loginName' => $loginName, 'password' => $password]); $this->userSession->expects($this->once()) ->method('createSessionToken') ->with($this->request, $user->getUID(), $loginName, $password, false); @@ -422,8 +422,8 @@ class LoginControllerTest extends TestCase { ->method('checkPassword') ->will($this->returnValue($user)); $this->userSession->expects($this->once()) - ->method('login') - ->with($loginName, $password); + ->method('completeLogin') + ->with($user, ['loginName' => $loginName, 'password' => $password]); $this->userSession->expects($this->once()) ->method('createSessionToken') ->with($this->request, $user->getUID(), $loginName, $password, true); @@ -606,8 +606,8 @@ class LoginControllerTest extends TestCase { ->method('checkPassword') ->will($this->returnValue($user)); $this->userSession->expects($this->once()) - ->method('login') - ->with('john@doe.com', $password); + ->method('completeLogin') + ->with($user, ['loginName' => 'john@doe.com', 'password' => $password]); $this->userSession->expects($this->once()) ->method('createSessionToken') ->with($this->request, $user->getUID(), 'john@doe.com', $password, false); @@ -673,8 +673,8 @@ class LoginControllerTest extends TestCase { ->method('checkPassword') ->will($this->returnValue($user)); $this->userSession->expects($this->once()) - ->method('login') - ->with('john@doe.com', $password); + ->method('completeLogin') + ->with($user, ['loginName' => 'john@doe.com', 'password' => $password]); $this->userSession->expects($this->once()) ->method('createSessionToken') ->with($this->request, $user->getUID(), 'john@doe.com', $password, false); -- cgit v1.2.3