diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-10 14:20:27 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-09-10 14:20:27 +0200 |
commit | c25063dc0766f86aadcfa0ef87c1dfe1f758dc2b (patch) | |
tree | b52779ab965630a8b4192c78231bb6a201144279 /tests/lib | |
parent | b056b5b7fcca028b57a38026de11890886bc4de1 (diff) | |
download | nextcloud-server-c25063dc0766f86aadcfa0ef87c1dfe1f758dc2b.tar.gz nextcloud-server-c25063dc0766f86aadcfa0ef87c1dfe1f758dc2b.zip |
Don't break when the IP is empty
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Security/Bruteforce/CapabilitiesTest.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/lib/Security/Bruteforce/CapabilitiesTest.php b/tests/lib/Security/Bruteforce/CapabilitiesTest.php index 16c2b2caf15..cd43d94f8cb 100644 --- a/tests/lib/Security/Bruteforce/CapabilitiesTest.php +++ b/tests/lib/Security/Bruteforce/CapabilitiesTest.php @@ -40,8 +40,6 @@ class CapabilitiesTest extends TestCase { parent::setUp(); $this->request = $this->createMock(IRequest::class); - $this->request->method('getRemoteAddress') - ->willReturn('10.10.10.10'); $this->throttler = $this->createMock(Throttler::class); @@ -57,6 +55,9 @@ class CapabilitiesTest extends TestCase { ->with('10.10.10.10') ->willReturn(42); + $this->request->method('getRemoteAddress') + ->willReturn('10.10.10.10'); + $expected = [ 'bruteforce' => [ 'delay' => 42 @@ -66,4 +67,23 @@ class CapabilitiesTest extends TestCase { $this->assertEquals($expected, $result); } + + public function testGetCapabilitiesOnCli() { + $this->throttler->expects($this->atLeastOnce()) + ->method('getDelay') + ->with('') + ->willReturn(0); + + $this->request->method('getRemoteAddress') + ->willReturn(''); + + $expected = [ + 'bruteforce' => [ + 'delay' => 0 + ] + ]; + $result = $this->capabilities->getCapabilities(); + + $this->assertEquals($expected, $result); + } } |