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:
authorJoas Schilling <coding@schilljs.com>2020-03-16 10:52:46 +0300
committerJoas Schilling <coding@schilljs.com>2020-03-16 11:29:28 +0300
commit9935c71ec310b45a7cfcf0bad286eace4192ebb4 (patch)
treeb40257e93a8d559053c096378515c1594ffe5632 /apps/settings/tests
parentf85747f74c54c0bc973e0cd6338239dccf32a3f5 (diff)
Check the user on remote wipe
Signed-off-by: Joas Schilling <coding@schilljs.com>
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);