diff options
author | sualko <klaus@jsxc.org> | 2017-08-18 18:34:15 +0300 |
---|---|---|
committer | sualko <klaus@jsxc.org> | 2017-08-18 18:34:15 +0300 |
commit | dbd3c714ca66fc06310c152a3d04b5eebb446788 (patch) | |
tree | a803fdd8e1270f04d48567406a9a14bcf498acbc /tests/unit | |
parent | 93bf6260b958037090e611561d64a166fddc0b30 (diff) |
reduce number of login attempts for external api
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/controller/ExternalApiControllerTest.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/controller/ExternalApiControllerTest.php b/tests/unit/controller/ExternalApiControllerTest.php index d4f3d44..751249f 100644 --- a/tests/unit/controller/ExternalApiControllerTest.php +++ b/tests/unit/controller/ExternalApiControllerTest.php @@ -151,6 +151,11 @@ class ExternalApiControllerTest extends TestCase public function testCheckPasswordWithInvalidParams() { + $this->userManager + ->expects($this->once()) + ->method('userExists') + ->with('foo') + ->willReturn(true); $this->userSession ->expects($this->once()) ->method('login') @@ -164,6 +169,14 @@ class ExternalApiControllerTest extends TestCase public function testCheckPasswordWithInvalidParamsAndDomain() { + $this->userManager + ->expects($this->exactly(2)) + ->method('userExists') + ->will($this->returnValueMap([ + ['foo@localhost', true], + ['foo', true] + ])); + $this->userSession ->expects($this->exactly(2)) ->method('login') @@ -180,6 +193,11 @@ class ExternalApiControllerTest extends TestCase public function testCheckPasswordWithValidParams() { $uid = 'foo'; + $this->userManager + ->expects($this->once()) + ->method('userExists') + ->with($uid) + ->willReturn(true); $this->user ->expects($this->once()) ->method('getUID') @@ -203,6 +221,11 @@ class ExternalApiControllerTest extends TestCase public function testCheckPasswordWithValidParamsAndDomain() { $uid = 'foo'; + $this->userManager + ->expects($this->once()) + ->method('userExists') + ->with('foo@localhost') + ->willReturn(true); $this->user ->expects($this->once()) ->method('getUID') @@ -295,6 +318,12 @@ class ExternalApiControllerTest extends TestCase $this->userManager ->expects($this->once()) + ->method('userExists') + ->with($user->getUID()) + ->willReturn(true); + + $this->userManager + ->expects($this->once()) ->method('get') ->with($user->getUID()) ->willReturn($user); @@ -317,6 +346,12 @@ class ExternalApiControllerTest extends TestCase $this->userManager ->expects($this->once()) + ->method('userExists') + ->with($user->getUID()) + ->willReturn(true); + + $this->userManager + ->expects($this->once()) ->method('get') ->with($user->getUID()) ->willReturn($user); @@ -372,6 +407,12 @@ class ExternalApiControllerTest extends TestCase $this->userManager ->expects($this->once()) + ->method('userExists') + ->with($user->getUID()) + ->willReturn(true); + + $this->userManager + ->expects($this->once()) ->method('get') ->with($user->getUID()) ->willReturn($user); |