mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
unit tests for Manager::invalidateTokensOfUser
Signed-off-by: Artur Neumann <artur@jankaritech.com>
This commit is contained in:
parent
fdfde4e6cc
commit
37c017ccad
1 changed files with 44 additions and 0 deletions
|
|
@ -355,4 +355,48 @@ class ManagerTest extends TestCase {
|
|||
|
||||
$this->manager->updatePasswords('uid', 'pass');
|
||||
}
|
||||
|
||||
public function testInvalidateTokensOfUserNoClientName() {
|
||||
$t1 = new PublicKeyToken();
|
||||
$t2 = new PublicKeyToken();
|
||||
$t1->setId(123);
|
||||
$t2->setId(456);
|
||||
|
||||
$this->publicKeyTokenProvider
|
||||
->expects($this->once())
|
||||
->method('getTokenByUser')
|
||||
->with('theUser')
|
||||
->willReturn([$t1, $t2]);
|
||||
$this->publicKeyTokenProvider
|
||||
->expects($this->exactly(2))
|
||||
->method('invalidateTokenById')
|
||||
->withConsecutive(
|
||||
['theUser', 123],
|
||||
['theUser', 456],
|
||||
);
|
||||
$this->manager->invalidateTokensOfUser('theUser', null);
|
||||
}
|
||||
|
||||
public function testInvalidateTokensOfUserClientNameGiven() {
|
||||
$t1 = new PublicKeyToken();
|
||||
$t2 = new PublicKeyToken();
|
||||
$t3 = new PublicKeyToken();
|
||||
$t1->setId(123);
|
||||
$t1->setName('Firefox session');
|
||||
$t2->setId(456);
|
||||
$t2->setName('My Client Name');
|
||||
$t3->setId(789);
|
||||
$t3->setName('mobile client');
|
||||
|
||||
$this->publicKeyTokenProvider
|
||||
->expects($this->once())
|
||||
->method('getTokenByUser')
|
||||
->with('theUser')
|
||||
->willReturn([$t1, $t2, $t3]);
|
||||
$this->publicKeyTokenProvider
|
||||
->expects($this->once())
|
||||
->method('invalidateTokenById')
|
||||
->with('theUser', 456);
|
||||
$this->manager->invalidateTokensOfUser('theUser', 'My Client Name');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue