diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-11-02 13:37:39 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-02 13:39:17 +0100 |
commit | 9d6e01ef40f7f4d2acab653b33e1af026bcde6c7 (patch) | |
tree | 45c98681e5fd2671bba975a56bc75185b08d0f9a /tests/lib/User | |
parent | 271f2a4cfff2be6f25d4bc546040613fdb2e70bf (diff) | |
download | nextcloud-server-9d6e01ef40f7f4d2acab653b33e1af026bcde6c7.tar.gz nextcloud-server-9d6e01ef40f7f4d2acab653b33e1af026bcde6c7.zip |
Add missing tests and fix PHPDoc
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests/lib/User')
-rw-r--r-- | tests/lib/User/SessionTest.php | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index f4237e94cde..ee9ed737cf5 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> * This file is licensed under the Affero General Public License version 3 or @@ -43,6 +42,12 @@ class SessionTest extends \Test\TestCase { private $throttler; /** @var ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */ private $random; + /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ + private $manager; + /** @var ISession|\PHPUnit_Framework_MockObject_MockObject */ + private $session; + /** @var Session|\PHPUnit_Framework_MockObject_MockObject */ + private $userSession; protected function setUp() { parent::setUp(); @@ -55,6 +60,21 @@ class SessionTest extends \Test\TestCase { $this->config = $this->createMock(IConfig::class); $this->throttler = $this->createMock(Throttler::class); $this->random = $this->createMock(ISecureRandom::class); + $this->manager = $this->createMock(IUserManager::class); + $this->session = $this->createMock(ISession::class); + $this->userSession = $this->getMockBuilder(Session::class) + ->setConstructorArgs([ + $this->manager, + $this->session, + $this->timeFactory, + $this->tokenProvider, + $this->config, + $this->random, + ]) + ->setMethods([ + 'setMagicInCookie', + ]) + ->getMock(); \OC_User::setIncognitoMode(false); } @@ -1136,4 +1156,27 @@ class SessionTest extends \Test\TestCase { $userSession->logClientIn('john', 'doe', $request, $this->throttler); } + + public function testCreateRememberMeToken() { + $user = $this->createMock(IUser::class); + $user + ->expects($this->exactly(2)) + ->method('getUID') + ->willReturn('UserUid'); + $this->random + ->expects($this->once()) + ->method('generate') + ->with(32) + ->willReturn('LongRandomToken'); + $this->config + ->expects($this->once()) + ->method('setUserValue') + ->with('UserUid', 'login_token', 'LongRandomToken', 10000); + $this->userSession + ->expects($this->once()) + ->method('setMagicInCookie') + ->with('UserUid', 'LongRandomToken'); + + $this->userSession->createRememberMeToken($user); + } } |