3636use OC \Authentication \Token \DefaultToken ;
3737use OC \Authentication \Token \IProvider ;
3838use OC \Authentication \Token \IToken ;
39+ use OC \Authentication \Token \IWipeableToken ;
3940use OC \Authentication \Token \RemoteWipe ;
4041use OCA \Settings \Controller \AuthSettingsController ;
4142use OCP \Activity \IEvent ;
@@ -428,9 +429,15 @@ private function mockGetTokenById(int $tokenId, $token): void {
428429 }
429430
430431 public function testRemoteWipeNotSuccessful (): void {
432+ $ token = $ this ->createMock (IToken::class);
433+ $ token ->expects ($ this ->once ())
434+ ->method ('getUID ' )
435+ ->willReturn ($ this ->uid );
436+ $ this ->mockGetTokenById (123 , $ token );
437+
431438 $ this ->remoteWipe ->expects ($ this ->once ())
432439 ->method ('markTokenForWipe ' )
433- ->with (123 )
440+ ->with ($ token )
434441 ->willReturn (false );
435442
436443 $ response = $ this ->controller ->wipe (123 );
@@ -439,10 +446,32 @@ public function testRemoteWipeNotSuccessful(): void {
439446 $ this ->assertEquals ($ expected , $ response );
440447 }
441448
449+ public function testRemoteWipeWrongUser (): void {
450+ $ token = $ this ->createMock (IToken::class);
451+ $ token ->expects ($ this ->once ())
452+ ->method ('getUID ' )
453+ ->willReturn ('definetly-not- ' . $ this ->uid );
454+ $ this ->mockGetTokenById (123 , $ token );
455+
456+ $ this ->remoteWipe ->expects ($ this ->never ())
457+ ->method ('markTokenForWipe ' );
458+
459+ $ response = $ this ->controller ->wipe (123 );
460+
461+ $ expected = new JSONResponse ([], Http::STATUS_NOT_FOUND );
462+ $ this ->assertEquals ($ expected , $ response );
463+ }
464+
442465 public function testRemoteWipeSuccessful (): void {
466+ $ token = $ this ->createMock (IWipeableToken::class);
467+ $ token ->expects ($ this ->once ())
468+ ->method ('getUID ' )
469+ ->willReturn ($ this ->uid );
470+ $ this ->mockGetTokenById (123 , $ token );
471+
443472 $ this ->remoteWipe ->expects ($ this ->once ())
444473 ->method ('markTokenForWipe ' )
445- ->with (123 )
474+ ->with ($ token )
446475 ->willReturn (true );
447476
448477 $ response = $ this ->controller ->wipe (123 );
0 commit comments