diff options
Diffstat (limited to 'tests/lib/User/SessionTest.php')
-rw-r--r-- | tests/lib/User/SessionTest.php | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index e7df7578c7d..c96a07eb9af 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -67,7 +67,7 @@ class SessionTest extends \Test\TestCase { $this->timeFactory = $this->createMock(ITimeFactory::class); $this->timeFactory->expects($this->any()) ->method('getTime') - ->will($this->returnValue(10000)); + ->willReturn(10000); $this->tokenProvider = $this->createMock(IProvider::class); $this->config = $this->createMock(IConfig::class); $this->throttler = $this->createMock(Throttler::class); @@ -105,12 +105,12 @@ class SessionTest extends \Test\TestCase { $expectedUser = $this->createMock(IUser::class); $expectedUser->expects($this->any()) ->method('getUID') - ->will($this->returnValue('user123')); + ->willReturn('user123'); $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); $session->expects($this->at(0)) ->method('get') ->with('user_id') - ->will($this->returnValue($expectedUser->getUID())); + ->willReturn($expectedUser->getUID()); $sessionId = 'abcdef12345'; $manager = $this->getMockBuilder('\OC\User\Manager') @@ -119,25 +119,25 @@ class SessionTest extends \Test\TestCase { $session->expects($this->at(1)) ->method('get') ->with('app_password') - ->will($this->returnValue(null)); // No password set -> browser session + ->willReturn(null); // No password set -> browser session $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($sessionId) - ->will($this->returnValue($token)); + ->willReturn($token); $this->tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, $sessionId) - ->will($this->returnValue('passme')); + ->willReturn('passme'); $manager->expects($this->once()) ->method('checkPassword') ->with('User123', 'passme') - ->will($this->returnValue(true)); + ->willReturn(true); $expectedUser->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(true)); + ->willReturn(true); $this->tokenProvider->expects($this->once()) ->method('updateTokenActivity') @@ -146,7 +146,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($expectedUser->getUID()) - ->will($this->returnValue($expectedUser)); + ->willReturn($expectedUser); $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher); $user = $userSession->getUser(); @@ -178,7 +178,7 @@ class SessionTest extends \Test\TestCase { $user = new User('sepp', null, $this->createMock(EventDispatcherInterface::class)); $userSession->expects($this->once()) ->method('getUser') - ->will($this->returnValue($isLoggedIn ? $user : null)); + ->willReturn($isLoggedIn ? $user : null); $this->assertEquals($isLoggedIn, $userSession->isLoggedIn()); } @@ -195,7 +195,7 @@ class SessionTest extends \Test\TestCase { $user = $this->createMock(IUser::class); $user->expects($this->once()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher); $userSession->setUser($user); @@ -240,17 +240,17 @@ class SessionTest extends \Test\TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('isEnabled') - ->will($this->returnValue(true)); + ->willReturn(true); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $user->expects($this->once()) ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue($user)); + ->willReturn($user); $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) @@ -304,14 +304,14 @@ class SessionTest extends \Test\TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('isEnabled') - ->will($this->returnValue(false)); + ->willReturn(false); $user->expects($this->never()) ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue($user)); + ->willReturn($user); $this->dispatcher->expects($this->never()) ->method('dispatch'); @@ -355,7 +355,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue(false)); + ->willReturn(false); $this->dispatcher->expects($this->never()) ->method('dispatch'); @@ -380,7 +380,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->login('foo', 'bar'); } @@ -404,12 +404,12 @@ class SessionTest extends \Test\TestCase { $this->tokenProvider->expects($this->once()) ->method('getToken') ->with('bar') - ->will($this->returnValue($token)); + ->willReturn($token); $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->login('foo', 'bar'); } @@ -435,7 +435,7 @@ class SessionTest extends \Test\TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('token_auth_enforced', false) - ->will($this->returnValue(true)); + ->willReturn(true); $request ->expects($this->any()) ->method('getRemoteAddress') @@ -471,7 +471,7 @@ class SessionTest extends \Test\TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('token_auth_enforced', false) - ->will($this->returnValue(false)); + ->willReturn(false); $manager->method('getByEmail') ->with('unexist') ->willReturn([]); @@ -492,11 +492,11 @@ class SessionTest extends \Test\TestCase { $userSession->expects($this->once()) ->method('isTokenPassword') - ->will($this->returnValue(true)); + ->willReturn(true); $userSession->expects($this->once()) ->method('login') ->with('john', 'I-AM-AN-APP-PASSWORD') - ->will($this->returnValue(true)); + ->willReturn(true); $session->expects($this->once()) ->method('set') @@ -539,12 +539,12 @@ class SessionTest extends \Test\TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('token_auth_enforced', false) - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->expects($this->once()) ->method('isTwoFactorEnforced') ->with('john') - ->will($this->returnValue(true)); + ->willReturn(true); $request ->expects($this->any()) @@ -592,18 +592,18 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($user)); + ->willReturn($user); $this->config->expects($this->once()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue([$token])); + ->willReturn([$token]); $this->config->expects($this->once()) ->method('deleteUserValue') ->with('foo', 'login_token', $token); $this->random->expects($this->once()) ->method('generate') ->with(32) - ->will($this->returnValue('abcdefg123456')); + ->willReturn('abcdefg123456'); $this->config->expects($this->once()) ->method('setUserValue') ->with('foo', 'login_token', 'abcdefg123456', 10000); @@ -617,7 +617,7 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('renewSessionToken') ->with($oldSessionId, $sessionId) @@ -628,7 +628,7 @@ class SessionTest extends \Test\TestCase { $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $userSession->expects($this->once()) ->method('setMagicInCookie'); $user->expects($this->once()) @@ -636,11 +636,11 @@ class SessionTest extends \Test\TestCase { $setUID = false; $session ->method('set') - ->will($this->returnCallback(function ($k, $v) use (&$setUID) { + ->willReturnCallback(function ($k, $v) use (&$setUID) { if ($k === 'user_id' && $v === 'foo') { $setUID = true; } - })); + }); $userSession->expects($this->once()) ->method('setLoginName') ->willReturn('foobar'); @@ -681,11 +681,11 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($user)); + ->willReturn($user); $this->config->expects($this->once()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue([$token])); + ->willReturn([$token]); $this->config->expects($this->once()) ->method('deleteUserValue') ->with('foo', 'login_token', $token); @@ -694,7 +694,7 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('renewSessionToken') ->with($oldSessionId, $sessionId) @@ -702,7 +702,7 @@ class SessionTest extends \Test\TestCase { $user->expects($this->never()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $userSession->expects($this->never()) ->method('setMagicInCookie'); $user->expects($this->never()) @@ -744,11 +744,11 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($user)); + ->willReturn($user); $this->config->expects($this->once()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue(['anothertoken'])); + ->willReturn(['anothertoken']); $this->config->expects($this->never()) ->method('deleteUserValue') ->with('foo', 'login_token', $token); @@ -794,11 +794,11 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue(null)); + ->willReturn(null); $this->config->expects($this->never()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue(['anothertoken'])); + ->willReturn(['anothertoken']); $this->tokenProvider->expects($this->never()) ->method('renewSessionToken'); @@ -825,9 +825,9 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function ($uid) use ($users) { + ->willReturnCallback(function ($uid) use ($users) { return $users[$uid]; - })); + }); $session = new Memory(''); $session->set('user_id', 'foo'); @@ -873,10 +873,10 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue($user)); + ->willReturn($user); $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($password) @@ -914,10 +914,10 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue($user)); + ->willReturn($user); $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($password) @@ -959,18 +959,18 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue($user)); + ->willReturn($user); $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($password) - ->will($this->returnValue($token)); + ->willReturn($token); $this->tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, $password) - ->will($this->returnValue($realPassword)); + ->willReturn($realPassword); $this->tokenProvider->expects($this->once()) ->method('generateToken') @@ -994,7 +994,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue(null)); + ->willReturn(null); $this->assertFalse($userSession->createSessionToken($request, $uid, $loginName, $password)); } @@ -1021,18 +1021,18 @@ class SessionTest extends \Test\TestCase { $request->expects($this->once()) ->method('getHeader') ->with('Authorization') - ->will($this->returnValue('Bearer xxxxx')); + ->willReturn('Bearer xxxxx'); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with('xxxxx') - ->will($this->returnValue($token)); + ->willReturn($token); $manager->expects($this->once()) ->method('get') ->with('fritz0') - ->will($this->returnValue($user)); + ->willReturn($user); $user->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->tryTokenLogin($request); } @@ -1055,23 +1055,23 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('get') ->with('app_password') - ->will($this->returnValue('APP-PASSWORD')); + ->willReturn('APP-PASSWORD'); $tokenProvider->expects($this->once()) ->method('getToken') ->with('APP-PASSWORD') - ->will($this->returnValue($token)); + ->willReturn($token); $timeFactory->expects($this->once()) ->method('getTime') - ->will($this->returnValue(1000)); // more than 5min since last check + ->willReturn(1000); // more than 5min since last check $tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, 'APP-PASSWORD') - ->will($this->returnValue('123456')); + ->willReturn('123456'); $userManager->expects($this->never()) ->method('checkPassword'); $user->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(false)); + ->willReturn(false); $tokenProvider->expects($this->once()) ->method('invalidateToken') ->with('APP-PASSWORD'); @@ -1099,14 +1099,14 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('get') ->with('app_password') - ->will($this->returnValue('APP-PASSWORD')); + ->willReturn('APP-PASSWORD'); $tokenProvider->expects($this->once()) ->method('getToken') ->with('APP-PASSWORD') - ->will($this->returnValue($token)); + ->willReturn($token); $timeFactory->expects($this->once()) ->method('getTime') - ->will($this->returnValue(1000)); // more than 5min since last check + ->willReturn(1000); // more than 5min since last check $tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, 'APP-PASSWORD') @@ -1135,25 +1135,25 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('get') ->with('app_password') - ->will($this->returnValue('APP-PASSWORD')); + ->willReturn('APP-PASSWORD'); $tokenProvider->expects($this->once()) ->method('getToken') ->with('APP-PASSWORD') - ->will($this->returnValue($token)); + ->willReturn($token); $timeFactory->expects($this->once()) ->method('getTime') - ->will($this->returnValue(1000)); // more than 5min since last check + ->willReturn(1000); // more than 5min since last check $tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, 'APP-PASSWORD') - ->will($this->returnValue('123456')); + ->willReturn('123456'); $userManager->expects($this->once()) ->method('checkPassword') ->with('susan', '123456') ->willReturn(false); $user->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(true)); + ->willReturn(true); $tokenProvider->expects($this->never()) ->method('invalidateToken'); $tokenProvider->expects($this->once()) @@ -1179,11 +1179,11 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $tokenProvider->expects($this->once()) ->method('getToken') ->with($sessionId) - ->will($this->returnValue($token)); + ->willReturn($token); $tokenProvider->expects($this->once()) ->method('setPassword') ->with($token, $sessionId, $password); @@ -1218,11 +1218,11 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $tokenProvider->expects($this->once()) ->method('getToken') ->with($sessionId) - ->will($this->returnValue($token)); + ->willReturn($token); $tokenProvider->expects($this->once()) ->method('setPassword') ->with($token, $sessionId, $password) @@ -1254,7 +1254,7 @@ class SessionTest extends \Test\TestCase { $mapper->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $mapper->expects($this->once()) ->method('update'); $request @@ -1273,7 +1273,7 @@ class SessionTest extends \Test\TestCase { $this->timeFactory ->expects($this->any()) ->method('getTime') - ->will($this->returnValue(100)); + ->willReturn(100); $manager->method('getByEmail') ->with('john') @@ -1308,7 +1308,7 @@ class SessionTest extends \Test\TestCase { $mapper->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $mapper->expects($this->never()) ->method('update'); $request @@ -1327,7 +1327,7 @@ class SessionTest extends \Test\TestCase { $this->timeFactory ->expects($this->any()) ->method('getTime') - ->will($this->returnValue(100)); + ->willReturn(100); $manager->method('getByEmail') ->with('john') @@ -1375,7 +1375,7 @@ class SessionTest extends \Test\TestCase { $this->session ->method('set') - ->will($this->returnCallback(function($k, $v) use (&$davAuthenticatedSet, &$lastPasswordConfirmSet) { + ->willReturnCallback(function($k, $v) use (&$davAuthenticatedSet, &$lastPasswordConfirmSet) { switch ($k) { case Auth::DAV_AUTHENTICATED: $davAuthenticatedSet = $v; @@ -1386,7 +1386,7 @@ class SessionTest extends \Test\TestCase { default: throw new \Exception(); } - })); + }); $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([ |