diff --git a/app/Libraries/Aauth.php b/app/Libraries/Aauth.php index 4135751..2cd0ab6 100644 --- a/app/Libraries/Aauth.php +++ b/app/Libraries/Aauth.php @@ -857,9 +857,11 @@ class Aauth if ($userModel->transStatus() === false) { + // @codeCoverageIgnoreStart $userModel->transRollback(); return false; + // @codeCoverageIgnoreEnd } else { @@ -1709,9 +1711,11 @@ class Aauth if ($groupModel->transStatus() === false) { + // @codeCoverageIgnoreStart $groupModel->transRollback(); return false; + // @codeCoverageIgnoreEnd } else { @@ -2360,9 +2364,11 @@ class Aauth if ($permModel->transStatus() === false) { + // @codeCoverageIgnoreStart $permModel->transRollback(); return false; + // @codeCoverageIgnoreEnd } else { @@ -2977,6 +2983,6 @@ class Aauth } } - trigger_error('Call to undefined method ' . __CLASS__ . '::' . $name . '()', E_USER_ERROR); + return trigger_error('Call to undefined method ' . __CLASS__ . '::' . $name . '()', E_USER_ERROR); } } diff --git a/tests/Aauth/Database/LoginAttemptModelTest.php b/tests/Aauth/Database/LoginAttemptModelTest.php index b6e2cd6..4b721b0 100644 --- a/tests/Aauth/Database/LoginAttemptModelTest.php +++ b/tests/Aauth/Database/LoginAttemptModelTest.php @@ -62,8 +62,10 @@ class LoginAttemptModelTest extends CIDatabaseTestCase $config = new \Config\Aauth(); $config->loginAttemptCookie = true; $this->model = new LoginAttemptModel($this->db, $config); - $loginAttempt = $this->model->find(); - $this->assertEquals(0, $loginAttempt); + $this->assertEquals(0, $this->model->find()); + + $this->model->save(); + $this->assertEquals(1, $this->model->find()); } public function testSaveCookie() @@ -76,6 +78,11 @@ class LoginAttemptModelTest extends CIDatabaseTestCase $this->assertEquals(1, $this->model->find()); $this->assertTrue($this->model->save()); + + $this->response = new \CodeIgniter\HTTP\Response(new App()); + $this->response->setCookie('logins', 10, 4000); + $this->model = new LoginAttemptModel($this->db, $config, $this->response); + $this->assertFalse($this->model->save()); } public function testDeleteCookie() diff --git a/tests/Aauth/Libraries/Aauth/CallTest.php b/tests/Aauth/Libraries/Aauth/CallTest.php new file mode 100644 index 0000000..ab89c01 --- /dev/null +++ b/tests/Aauth/Libraries/Aauth/CallTest.php @@ -0,0 +1,21 @@ +library = new Aauth(); + } + + //-------------------------------------------------------------------- + + public function testFailCall() + { + $this->expectException('ErrorException'); // Or whichever exception it is + $this->library->getNotExistingFunc(); + } +} diff --git a/tests/Aauth/Libraries/Aauth/PermTest.php b/tests/Aauth/Libraries/Aauth/PermTest.php index be876b6..c6a612a 100644 --- a/tests/Aauth/Libraries/Aauth/PermTest.php +++ b/tests/Aauth/Libraries/Aauth/PermTest.php @@ -517,5 +517,7 @@ class PermTest extends CIDatabaseTestCase $groupPermsOrderBy = $this->library->listGroupPermsPaginated(2, 10, 'id DESC'); $this->assertEquals('testPerm2', $groupPermsOrderBy['perms'][0]['name']); $this->assertEquals('testPerm1', $groupPermsOrderBy['perms'][1]['name']); + + $this->assertFalse($this->library->listGroupPermsPaginated(99)); } } diff --git a/tests/Aauth/Libraries/Aauth/TOTPTest.php b/tests/Aauth/Libraries/Aauth/TOTPTest.php index c29380a..53e5d79 100644 --- a/tests/Aauth/Libraries/Aauth/TOTPTest.php +++ b/tests/Aauth/Libraries/Aauth/TOTPTest.php @@ -94,7 +94,6 @@ class TOTPTest extends CIDatabaseTestCase $totp = TOTP::create('JBSWY3DPEHPK3PXP'); $totpCode = $totp->now(); - usleep(1000); $this->assertTrue($this->library->login('admin@example.com', 'password123456', null, $totpCode)); $userModel = new UserModel(); @@ -110,6 +109,8 @@ class TOTPTest extends CIDatabaseTestCase $this->library = new Aauth($config, $session); $this->library = new Aauth($config, $session); + $totp = TOTP::create('JBSWY3DPEHPK3PXP'); + $totpCode = $totp->now(); $this->assertTrue($this->library->login('admin@example.com', 'password123456', null, $totpCode)); $userModel->protect(false)->update(1, ['last_ip_address' => '99.99.99.99']); @@ -202,7 +203,6 @@ class TOTPTest extends CIDatabaseTestCase $totp = TOTP::create('JBSWY3DPEHPK3PXP'); $totpCode = $totp->now(); - usleep(1000); $this->assertTrue($this->library->verifyUserTotpCode($totpCode)); $this->assertTrue($this->library->verifyUserTotpCode($totpCode, 1));