diff options
Diffstat (limited to 'tests/Settings/Controller/AuthSettingsControllerTest.php')
-rw-r--r-- | tests/Settings/Controller/AuthSettingsControllerTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/Settings/Controller/AuthSettingsControllerTest.php b/tests/Settings/Controller/AuthSettingsControllerTest.php index d335abc98a3..113d24089ec 100644 --- a/tests/Settings/Controller/AuthSettingsControllerTest.php +++ b/tests/Settings/Controller/AuthSettingsControllerTest.php @@ -23,6 +23,7 @@ namespace Test\Settings\Controller; use OC\AppFramework\Http; use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\ExpiredTokenException; use OC\Authentication\Token\DefaultToken; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; @@ -183,6 +184,30 @@ class AuthSettingsControllerTest extends TestCase { $this->assertEquals([], $this->controller->destroy($tokenId)); } + public function testDestroyExpired() { + $tokenId = 124; + $token = $this->createMock(DefaultToken::class); + + $token->expects($this->exactly(2)) + ->method('getId') + ->willReturn($tokenId); + + $token->expects($this->once()) + ->method('getUID') + ->willReturn($this->uid); + + $this->tokenProvider->expects($this->once()) + ->method('getTokenById') + ->with($this->equalTo($tokenId)) + ->willThrowException(new ExpiredTokenException($token)); + + $this->tokenProvider->expects($this->once()) + ->method('invalidateTokenById') + ->with($this->uid, $tokenId); + + $this->assertSame([], $this->controller->destroy($tokenId)); + } + public function testDestroyWrongUser() { $tokenId = 124; $token = $this->createMock(DefaultToken::class); @@ -315,6 +340,26 @@ class AuthSettingsControllerTest extends TestCase { $this->assertSame([], $this->controller->update($tokenId, ['filesystem' => true], 'App password')); } + public function testUpdateExpired() { + $tokenId = 42; + $token = $this->createMock(DefaultToken::class); + + $token->expects($this->once()) + ->method('getUID') + ->willReturn($this->uid); + + $this->tokenProvider->expects($this->once()) + ->method('getTokenById') + ->with($this->equalTo($tokenId)) + ->willThrowException(new ExpiredTokenException($token)); + + $this->tokenProvider->expects($this->once()) + ->method('updateToken') + ->with($this->equalTo($token)); + + $this->assertSame([], $this->controller->update($tokenId, ['filesystem' => true], 'App password')); + } + public function testUpdateTokenWrongUser() { $tokenId = 42; $token = $this->createMock(DefaultToken::class); |