diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-05-18 11:33:56 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-05-18 18:25:37 +0200 |
commit | 062657873911bd1c1c633a5b4944ebc6f4781ea8 (patch) | |
tree | e92d6db32caf0265f8085e62aee2037d016da425 /tests | |
parent | dc0e3617dc1c5a3d4c4fbc67e6bae957e5afff8e (diff) | |
download | nextcloud-server-062657873911bd1c1c633a5b4944ebc6f4781ea8.tar.gz nextcloud-server-062657873911bd1c1c633a5b4944ebc6f4781ea8.zip |
add method to query all user auth tokens
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/authentication/token/defaulttokenmappertest.php | 18 | ||||
-rw-r--r-- | tests/lib/authentication/token/defaulttokenprovidertest.php | 10 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/lib/authentication/token/defaulttokenmappertest.php b/tests/lib/authentication/token/defaulttokenmappertest.php index 9a21e143fb4..e17149a5c1b 100644 --- a/tests/lib/authentication/token/defaulttokenmappertest.php +++ b/tests/lib/authentication/token/defaulttokenmappertest.php @@ -141,4 +141,22 @@ class DefaultTokenMapperTest extends TestCase { $this->mapper->getToken($token); } + public function testGetTokenByUser() { + $user = $this->getMock('\OCP\IUser'); + $user->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('user1')); + + $this->assertCount(2, $this->mapper->getTokenByUser($user)); + } + + public function testGetTokenByUserNotFound() { + $user = $this->getMock('\OCP\IUser'); + $user->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('user1000')); + + $this->assertCount(0, $this->mapper->getTokenByUser($user)); + } + } diff --git a/tests/lib/authentication/token/defaulttokenprovidertest.php b/tests/lib/authentication/token/defaulttokenprovidertest.php index 1902227a4fa..eeb249cfa8a 100644 --- a/tests/lib/authentication/token/defaulttokenprovidertest.php +++ b/tests/lib/authentication/token/defaulttokenprovidertest.php @@ -103,6 +103,16 @@ class DefaultTokenProviderTest extends TestCase { $this->assertEquals($this->time, $tk->getLastActivity()); } + + public function testGetTokenByUser() { + $user = $this->getMock('\OCP\IUser'); + $this->mapper->expects($this->once()) + ->method('getTokenByUser') + ->with($user) + ->will($this->returnValue(['token'])); + + $this->assertEquals(['token'], $this->tokenProvider->getTokenByUser($user)); + } public function testGetPassword() { $token = 'token1234'; |