diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-05-19 10:28:00 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-05-19 10:28:00 +0200 |
commit | e1a9a26bf550eed08666a761221bb290b8d5e01b (patch) | |
tree | 3c8dad14571d6a3f262aefff14638056efea7f52 /tests | |
parent | 7ca5b35379144d868a36f10c237c78de56f4ed5a (diff) | |
parent | 062657873911bd1c1c633a5b4944ebc6f4781ea8 (diff) | |
download | nextcloud-server-e1a9a26bf550eed08666a761221bb290b8d5e01b.tar.gz nextcloud-server-e1a9a26bf550eed08666a761221bb290b8d5e01b.zip |
Merge pull request #24686 from owncloud/query-user-authtokens
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'; |