aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-05-31 10:29:30 +0200
committerGitHub <noreply@github.com>2022-05-31 10:29:30 +0200
commit279e06a80fa4488e9afc823d517918abb502fecc (patch)
treecf1a3a530d8f579fbf0cad5bafbaf8999ccf328c /tests
parentf855b73aa5045fa3c9dc350240c01a84e32f787e (diff)
parentf9efc410fa6d7cbe01b01ae9cdc7ea31cf0de48e (diff)
downloadnextcloud-server-279e06a80fa4488e9afc823d517918abb502fecc.tar.gz
nextcloud-server-279e06a80fa4488e9afc823d517918abb502fecc.zip
Merge pull request #32587 from nextcloud/bugfix/noid/improve-jsconfighelper
Improve JSConfigHelper code quality a bit
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php124
1 files changed, 52 insertions, 72 deletions
diff --git a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
index aa713b99156..38d01950f6a 100644
--- a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
@@ -66,25 +66,20 @@ class RateLimitingMiddlewareTest extends TestCase {
public function testBeforeControllerWithoutAnnotation() {
$this->reflector
- ->expects($this->at(0))
+ ->expects($this->exactly(4))
->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'limit')
- ->willReturn('');
- $this->reflector
- ->expects($this->at(1))
- ->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'period')
- ->willReturn('');
- $this->reflector
- ->expects($this->at(2))
- ->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'limit')
- ->willReturn('');
- $this->reflector
- ->expects($this->at(3))
- ->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'period')
- ->willReturn('');
+ ->withConsecutive(
+ ['AnonRateThrottle', 'limit'],
+ ['AnonRateThrottle', 'period'],
+ ['UserRateThrottle', 'limit'],
+ ['UserRateThrottle', 'period']
+ )
+ ->willReturnMap([
+ ['AnonRateThrottle', 'limit', ''],
+ ['AnonRateThrottle', 'period', ''],
+ ['UserRateThrottle', 'limit', ''],
+ ['UserRateThrottle', 'period', ''],
+ ]);
$this->limiter
->expects($this->never())
@@ -107,25 +102,20 @@ class RateLimitingMiddlewareTest extends TestCase {
->willReturn('127.0.0.1');
$this->reflector
- ->expects($this->at(0))
- ->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'limit')
- ->willReturn('100');
- $this->reflector
- ->expects($this->at(1))
- ->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'period')
- ->willReturn('10');
- $this->reflector
- ->expects($this->at(2))
- ->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'limit')
- ->willReturn('');
- $this->reflector
- ->expects($this->at(3))
+ ->expects($this->exactly(4))
->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'period')
- ->willReturn('');
+ ->withConsecutive(
+ ['AnonRateThrottle', 'limit'],
+ ['AnonRateThrottle', 'period'],
+ ['UserRateThrottle', 'limit'],
+ ['UserRateThrottle', 'period']
+ )
+ ->willReturnMap([
+ ['AnonRateThrottle', 'limit', '100'],
+ ['AnonRateThrottle', 'period', '10'],
+ ['UserRateThrottle', 'limit', ''],
+ ['UserRateThrottle', 'period', ''],
+ ]);
$this->limiter
->expects($this->never())
@@ -155,25 +145,20 @@ class RateLimitingMiddlewareTest extends TestCase {
->willReturn($user);
$this->reflector
- ->expects($this->at(0))
+ ->expects($this->exactly(4))
->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'limit')
- ->willReturn('');
- $this->reflector
- ->expects($this->at(1))
- ->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'period')
- ->willReturn('');
- $this->reflector
- ->expects($this->at(2))
- ->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'limit')
- ->willReturn('100');
- $this->reflector
- ->expects($this->at(3))
- ->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'period')
- ->willReturn('10');
+ ->withConsecutive(
+ ['AnonRateThrottle', 'limit'],
+ ['AnonRateThrottle', 'period'],
+ ['UserRateThrottle', 'limit'],
+ ['UserRateThrottle', 'period']
+ )
+ ->willReturnMap([
+ ['AnonRateThrottle', 'limit', ''],
+ ['AnonRateThrottle', 'period', ''],
+ ['UserRateThrottle', 'limit', '100'],
+ ['UserRateThrottle', 'period', '10'],
+ ]);
$this->limiter
->expects($this->never())
@@ -201,25 +186,20 @@ class RateLimitingMiddlewareTest extends TestCase {
->willReturn(false);
$this->reflector
- ->expects($this->at(0))
- ->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'limit')
- ->willReturn('200');
- $this->reflector
- ->expects($this->at(1))
- ->method('getAnnotationParameter')
- ->with('AnonRateThrottle', 'period')
- ->willReturn('20');
- $this->reflector
- ->expects($this->at(2))
- ->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'limit')
- ->willReturn('100');
- $this->reflector
- ->expects($this->at(3))
+ ->expects($this->exactly(4))
->method('getAnnotationParameter')
- ->with('UserRateThrottle', 'period')
- ->willReturn('10');
+ ->withConsecutive(
+ ['AnonRateThrottle', 'limit'],
+ ['AnonRateThrottle', 'period'],
+ ['UserRateThrottle', 'limit'],
+ ['UserRateThrottle', 'period']
+ )
+ ->willReturnMap([
+ ['AnonRateThrottle', 'limit', '200'],
+ ['AnonRateThrottle', 'period', '20'],
+ ['UserRateThrottle', 'limit', '100'],
+ ['UserRateThrottle', 'period', '10'],
+ ]);
$this->limiter
->expects($this->never())