diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-04-12 20:32:48 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2017-04-13 12:00:16 +0200 |
commit | 66835476b59b8be7593d4cfa03a51c4f265d7e26 (patch) | |
tree | 91770c8fe403da25af50e6336727ab55fe57cd27 /tests/lib/Security/Bruteforce/ThrottlerTest.php | |
parent | 5505faa3d7b6f5a95f18fe5027355d700d69f396 (diff) | |
download | nextcloud-server-66835476b59b8be7593d4cfa03a51c4f265d7e26.tar.gz nextcloud-server-66835476b59b8be7593d4cfa03a51c4f265d7e26.zip |
Add support for ratelimiting via annotations
This allows adding rate limiting via annotations to controllers, as one example:
```
@UserRateThrottle(limit=5, period=100)
@AnonRateThrottle(limit=1, period=100)
```
Would mean that logged-in users can access the page 5 times within 100 seconds, and anonymous users 1 time within 100 seconds. If only an AnonRateThrottle is specified that one will also be applied to logged-in users.
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests/lib/Security/Bruteforce/ThrottlerTest.php')
-rw-r--r-- | tests/lib/Security/Bruteforce/ThrottlerTest.php | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/tests/lib/Security/Bruteforce/ThrottlerTest.php b/tests/lib/Security/Bruteforce/ThrottlerTest.php index 02d5b701679..9679d0c1759 100644 --- a/tests/lib/Security/Bruteforce/ThrottlerTest.php +++ b/tests/lib/Security/Bruteforce/ThrottlerTest.php @@ -76,51 +76,6 @@ class ThrottlerTest extends TestCase { $this->assertLessThan(2, $cutoff->s); } - public function testSubnet() { - // IPv4 - $this->assertSame( - '64.233.191.254/32', - $this->invokePrivate($this->throttler, 'getIPv4Subnet', ['64.233.191.254', 32]) - ); - $this->assertSame( - '64.233.191.252/30', - $this->invokePrivate($this->throttler, 'getIPv4Subnet', ['64.233.191.254', 30]) - ); - $this->assertSame( - '64.233.191.240/28', - $this->invokePrivate($this->throttler, 'getIPv4Subnet', ['64.233.191.254', 28]) - ); - $this->assertSame( - '64.233.191.0/24', - $this->invokePrivate($this->throttler, 'getIPv4Subnet', ['64.233.191.254', 24]) - ); - $this->assertSame( - '64.233.188.0/22', - $this->invokePrivate($this->throttler, 'getIPv4Subnet', ['64.233.191.254', 22]) - ); - // IPv6 - $this->assertSame( - '2001:db8:85a3::8a2e:370:7334/127', - $this->invokePrivate($this->throttler, 'getIPv6Subnet', ['2001:0db8:85a3:0000:0000:8a2e:0370:7334', 127]) - ); - $this->assertSame( - '2001:db8:85a3::8a2e:370:7300/120', - $this->invokePrivate($this->throttler, 'getIPv6Subnet', ['2001:0db8:85a3:0000:0000:8a2e:0370:7300', 120]) - ); - $this->assertSame( - '2001:db8:85a3::/64', - $this->invokePrivate($this->throttler, 'getIPv6Subnet', ['2001:0db8:85a3:0000:0000:8a2e:0370:7334', 64]) - ); - $this->assertSame( - '2001:db8:85a3::/48', - $this->invokePrivate($this->throttler, 'getIPv6Subnet', ['2001:0db8:85a3:0000:0000:8a2e:0370:7334', 48]) - ); - $this->assertSame( - '2001:db8:8500::/40', - $this->invokePrivate($this->throttler, 'getIPv6Subnet', ['2001:0db8:85a3:0000:0000:8a2e:0370:7334', 40]) - ); - } - public function dataIsIPWhitelisted() { return [ [ |