Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@owncloud.com>2016-05-18 12:33:56 +0300
committerChristoph Wurst <christoph@owncloud.com>2016-05-18 19:25:37 +0300
commit062657873911bd1c1c633a5b4944ebc6f4781ea8 (patch)
treee92d6db32caf0265f8085e62aee2037d016da425 /tests
parentdc0e3617dc1c5a3d4c4fbc67e6bae957e5afff8e (diff)
add method to query all user auth tokens
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/authentication/token/defaulttokenmappertest.php18
-rw-r--r--tests/lib/authentication/token/defaulttokenprovidertest.php10
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';