- $this->assertFalse(isset($this->globals['IPBANS']['FAILURES'][$this->ipAddr]));
- }
-
- /**
- * Record a failed login attempt and ban the IP after too many failures
- */
- public function testHandleFailedLoginBanIp()
- {
- $this->loginManager->handleFailedLogin($this->server);
- $this->assertEquals(1, $this->globals['IPBANS']['FAILURES'][$this->ipAddr]);
- $this->assertTrue($this->loginManager->canLogin($this->server));
-
- $this->loginManager->handleFailedLogin($this->server);
- $this->assertEquals(2, $this->globals['IPBANS']['FAILURES'][$this->ipAddr]);
- $this->assertTrue($this->loginManager->canLogin($this->server));
-
- $this->loginManager->handleFailedLogin($this->server);
- $this->assertEquals(3, $this->globals['IPBANS']['FAILURES'][$this->ipAddr]);
- $this->assertTrue($this->loginManager->canLogin($this->server));
-
- $this->loginManager->handleFailedLogin($this->server);
- $this->assertEquals(4, $this->globals['IPBANS']['FAILURES'][$this->ipAddr]);
- $this->assertFalse($this->loginManager->canLogin($this->server));
-
- // handleFailedLogin is not supposed to be called at this point:
- // - no login form should be displayed once an IP has been banned
- // - yet this could happen when using custom templates / scripts
- $this->loginManager->handleFailedLogin($this->server);
- $this->assertEquals(5, $this->globals['IPBANS']['FAILURES'][$this->ipAddr]);
- $this->assertFalse($this->loginManager->canLogin($this->server));