Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unit tests for Manager::invalidateTokensOfUser
Signed-off-by: Artur Neumann <[email protected]>
  • Loading branch information
individual-it committed Jan 6, 2023
commit 0f9e597b3e9a90ad6493ddca943da9110aa212dd
44 changes: 44 additions & 0 deletions tests/lib/Authentication/Token/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,48 @@ public function testUpdatePasswords() {

$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');
}
}