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:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-03-24 22:26:52 +0300
committerGitHub <noreply@github.com>2020-03-24 22:26:52 +0300
commit3b26bfe879e7ebd3eeef1ef767cbacc8acd20293 (patch)
tree01711f01b31ea08d01372c4ef7dba97ef1623f60 /apps/settings/tests
parent3e338c907533dd77599b576ecfadd44b3d1a9855 (diff)
parent9935c71ec310b45a7cfcf0bad286eace4192ebb4 (diff)
Merge pull request #20127 from nextcloud/bugfix/noid/check-user-on-remote-wipe
Check the user on remote wipe
Diffstat (limited to 'apps/settings/tests')
-rw-r--r--apps/settings/tests/Controller/AuthSettingsControllerTest.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/apps/settings/tests/Controller/AuthSettingsControllerTest.php b/apps/settings/tests/Controller/AuthSettingsControllerTest.php
index 923a63d706c..1d24a90794f 100644
--- a/apps/settings/tests/Controller/AuthSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AuthSettingsControllerTest.php
@@ -36,6 +36,7 @@ use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
+use OC\Authentication\Token\IWipeableToken;
use OC\Authentication\Token\RemoteWipe;
use OCA\Settings\Controller\AuthSettingsController;
use OCP\Activity\IEvent;
@@ -428,9 +429,15 @@ class AuthSettingsControllerTest extends TestCase {
}
public function testRemoteWipeNotSuccessful(): void {
+ $token = $this->createMock(IToken::class);
+ $token->expects($this->once())
+ ->method('getUID')
+ ->willReturn($this->uid);
+ $this->mockGetTokenById(123, $token);
+
$this->remoteWipe->expects($this->once())
->method('markTokenForWipe')
- ->with(123)
+ ->with($token)
->willReturn(false);
$response = $this->controller->wipe(123);
@@ -439,10 +446,32 @@ class AuthSettingsControllerTest extends TestCase {
$this->assertEquals($expected, $response);
}
+ public function testRemoteWipeWrongUser(): void {
+ $token = $this->createMock(IToken::class);
+ $token->expects($this->once())
+ ->method('getUID')
+ ->willReturn('definetly-not-' . $this->uid);
+ $this->mockGetTokenById(123, $token);
+
+ $this->remoteWipe->expects($this->never())
+ ->method('markTokenForWipe');
+
+ $response = $this->controller->wipe(123);
+
+ $expected = new JSONResponse([], Http::STATUS_NOT_FOUND);
+ $this->assertEquals($expected, $response);
+ }
+
public function testRemoteWipeSuccessful(): void {
+ $token = $this->createMock(IWipeableToken::class);
+ $token->expects($this->once())
+ ->method('getUID')
+ ->willReturn($this->uid);
+ $this->mockGetTokenById(123, $token);
+
$this->remoteWipe->expects($this->once())
->method('markTokenForWipe')
- ->with(123)
+ ->with($token)
->willReturn(true);
$response = $this->controller->wipe(123);