From db88a00d48d1dce48b8700e460c06ff7fb344f0a Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 1 Aug 2015 12:14:22 -0400 Subject: Add bruteforce protection --- tests/units/AuthenticationTest.php | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/units/AuthenticationTest.php (limited to 'tests/units/AuthenticationTest.php') diff --git a/tests/units/AuthenticationTest.php b/tests/units/AuthenticationTest.php new file mode 100644 index 00000000..75b55ece --- /dev/null +++ b/tests/units/AuthenticationTest.php @@ -0,0 +1,39 @@ +container); + $a = new Authentication($this->container); + + $this->assertFalse($a->hasCaptcha('not_found')); + $this->assertFalse($a->hasCaptcha('admin')); + + $this->assertTrue($u->incrementFailedLogin('admin')); + $this->assertTrue($u->incrementFailedLogin('admin')); + $this->assertTrue($u->incrementFailedLogin('admin')); + + $this->assertFalse($a->hasCaptcha('not_found')); + $this->assertTrue($a->hasCaptcha('admin')); + } + + public function testHandleFailedLogin() + { + $u = new User($this->container); + $a = new Authentication($this->container); + + $this->assertFalse($u->isLocked('admin')); + + for ($i = 0; $i <= 6; $i++) { + $a->handleFailedLogin('admin'); + } + + $this->assertTrue($u->isLocked('admin')); + } +} -- cgit v1.2.3