summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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';