diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-07-27 14:14:20 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2017-07-27 14:17:45 +0200 |
commit | f22ab3e665124e79427f51049fea0f937b66cdbb (patch) | |
tree | a2f4b3260853d0252b76d3ce452512a3f6a47ee6 /tests | |
parent | 63aa12e38c2e819b54c4b9e9632264a0e59dc6f2 (diff) | |
download | nextcloud-server-f22ab3e665124e79427f51049fea0f937b66cdbb.tar.gz nextcloud-server-f22ab3e665124e79427f51049fea0f937b66cdbb.zip |
Add metadata to \OCP\AppFramework\Http\Response::throttle
Fixes https://github.com/nextcloud/server/issues/5891
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/LoginControllerTest.php | 4 | ||||
-rw-r--r-- | tests/lib/AppFramework/Http/ResponseTest.php | 5 | ||||
-rw-r--r-- | tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php | 4 |
3 files changed, 11 insertions, 2 deletions
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index bd2d0143caf..493bade9dd8 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -307,7 +307,7 @@ class LoginControllerTest extends TestCase { ->method('deleteUserValue'); $expected = new \OCP\AppFramework\Http\RedirectResponse($loginPageUrl); - $expected->throttle(); + $expected->throttle(['user' => 'MyUserName']); $this->assertEquals($expected, $this->loginController->tryLogin($user, $password, '/apps/files')); } @@ -634,7 +634,7 @@ class LoginControllerTest extends TestCase { ->method('createRememberMeToken'); $expected = new RedirectResponse(''); - $expected->throttle(); + $expected->throttle(['user' => 'john']); $this->assertEquals($expected, $this->loginController->tryLogin('john@doe.com', 'just wrong', null)); } } diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php index d8959face89..9267d862600 100644 --- a/tests/lib/AppFramework/Http/ResponseTest.php +++ b/tests/lib/AppFramework/Http/ResponseTest.php @@ -269,4 +269,9 @@ class ResponseTest extends \Test\TestCase { $this->childResponse->throttle(); $this->assertTrue($this->childResponse->isThrottled()); } + + public function testGetThrottleMetadata() { + $this->childResponse->throttle(['foo' => 'bar']); + $this->assertSame(['foo' => 'bar'], $this->childResponse->getThrottleMetadata()); + } } diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php index 14d3b796846..ae2345764ff 100644 --- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php @@ -112,6 +112,10 @@ class BruteForceMiddlewareTest extends TestCase { ->expects($this->once()) ->method('isThrottled') ->willReturn(true); + $response + ->expects($this->once()) + ->method('getThrottleMetadata') + ->willReturn([]); $this->reflector ->expects($this->once()) ->method('getAnnotationParameter') |