summaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication/Token/RemoteWipeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Authentication/Token/RemoteWipeTest.php')
-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())