diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-08-01 12:14:22 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-08-01 12:14:22 -0400 |
commit | db88a00d48d1dce48b8700e460c06ff7fb344f0a (patch) | |
tree | cdb089f5aadcbd22aa63612d4d50bbe63fcbe112 /tests/units/AuthenticationTest.php | |
parent | db69d5c429cf747e72c4ded26f3821e7f688bc13 (diff) |
Add bruteforce protection
Diffstat (limited to 'tests/units/AuthenticationTest.php')
-rw-r--r-- | tests/units/AuthenticationTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
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 @@ +<?php + +require_once __DIR__.'/Base.php'; + +use Model\User; +use Model\Authentication; + +class AuthenticationTest extends Base +{ + public function testHasCaptcha() + { + $u = new User($this->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')); + } +} |