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
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2019-07-03 11:10:56 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2019-07-09 14:57:04 +0300
commitd058ef2b6c6b3faf354fd8abeecb4cd71949d5a6 (patch)
tree34275b1f142f429f8c8982f7a79cc2327ee1c0b7 /tests/lib/Authentication
parent1c261675ad3da9804bd9a8c88326103eb2f56bd3 (diff)
Make it possible to wipe all tokens/devices of a user
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Authentication')
-rw-r--r--tests/lib/Authentication/Token/RemoteWipeTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/lib/Authentication/Token/RemoteWipeTest.php b/tests/lib/Authentication/Token/RemoteWipeTest.php
index d5d63b2fb40..7193bee5389 100644
--- a/tests/lib/Authentication/Token/RemoteWipeTest.php
+++ b/tests/lib/Authentication/Token/RemoteWipeTest.php
@@ -33,6 +33,7 @@ use OC\Authentication\Token\IWipeableToken;
use OC\Authentication\Token\RemoteWipe;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
+use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -93,6 +94,43 @@ class RemoteWipeTest extends TestCase {
$this->assertTrue($result);
}
+ public function testMarkAllTokensForWipeNoWipeableToken(): void {
+ /** @var IUser|MockObject $user */
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')->willReturn('user123');
+ $token1 = $this->createMock(IToken::class);
+ $token2 = $this->createMock(IToken::class);
+ $this->tokenProvider->expects($this->once())
+ ->method('getTokenByUser')
+ ->with('user123')
+ ->willReturn([$token1, $token2]);
+
+ $result = $this->remoteWipe->markAllTokensForWipe($user);
+
+ $this->assertFalse($result);
+ }
+
+ public function testMarkAllTokensForWipe(): void {
+ /** @var IUser|MockObject $user */
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')->willReturn('user123');
+ $token1 = $this->createMock(IToken::class);
+ $token2 = $this->createMock(IWipeableToken::class);
+ $this->tokenProvider->expects($this->once())
+ ->method('getTokenByUser')
+ ->with('user123')
+ ->willReturn([$token1, $token2]);
+ $token2->expects($this->once())
+ ->method('wipe');
+ $this->tokenProvider->expects($this->once())
+ ->method('updateToken')
+ ->with($token2);
+
+ $result = $this->remoteWipe->markAllTokensForWipe($user);
+
+ $this->assertTrue($result);
+ }
+
public function testStartWipingNotAWipeToken() {
$token = $this->createMock(IToken::class);
$this->tokenProvider->expects($this->once())