diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-05-19 11:20:22 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-05-23 09:11:12 +0200 |
commit | 74277c25be2f3231e52a73a684bd14452a9ff2aa (patch) | |
tree | ca68eac57db357563e64e9f323df667fcc28f8f6 /tests/lib/Authentication/Token/DefaultTokenMapperTest.php | |
parent | 6495534bcdbbda8aa2748cc9f5d94dcb2bc7a04a (diff) | |
download | nextcloud-server-74277c25be2f3231e52a73a684bd14452a9ff2aa.tar.gz nextcloud-server-74277c25be2f3231e52a73a684bd14452a9ff2aa.zip |
add button to invalidate browser sessions/device tokens
Diffstat (limited to 'tests/lib/Authentication/Token/DefaultTokenMapperTest.php')
-rw-r--r-- | tests/lib/Authentication/Token/DefaultTokenMapperTest.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php index e17149a5c1b..9179e23bfb2 100644 --- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php @@ -159,4 +159,31 @@ class DefaultTokenMapperTest extends TestCase { $this->assertCount(0, $this->mapper->getTokenByUser($user)); } + public function testDeleteById() { + $user = $this->getMock('\OCP\IUser'); + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('id') + ->from('authtoken') + ->where($qb->expr()->eq('token', $qb->createNamedParameter('9c5a2e661482b65597408a6bb6c4a3d1af36337381872ac56e445a06cdb7fea2b1039db707545c11027a4966919918b19d875a8b774840b18c6cbb7ae56fe206'))); + $result = $qb->execute(); + $id = $result->fetch()['id']; + $user->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('user1')); + + $this->mapper->deleteById($user, $id); + $this->assertEquals(2, $this->getNumberOfTokens()); + } + + public function testDeleteByIdWrongUser() { + $user = $this->getMock('\OCP\IUser'); + $id = 33; + $user->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('user10000')); + + $this->mapper->deleteById($user, $id); + $this->assertEquals(3, $this->getNumberOfTokens()); + } + } |