summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Jack <cuonic@cuonic.com>2015-11-06 16:08:22 +0100
committerLiam Jack <cuonic@cuonic.com>2015-11-06 16:08:22 +0100
commit0db7815d21a4ba73c092e37b67d927943803aef5 (patch)
treedff3f8312de6f4cac1831c6ff7573e8ce79fff36
parent01e7c685a5705d39190e123a1461ff29f1d62603 (diff)
downloadPHPAuth-1.1.zip
PHPAuth-1.1.tar.gz
PHPAuth-1.1.tar.bz2
Should fix PHPUnit testsv1.1
-rwxr-xr-xAuth.php4
-rw-r--r--tests/AuthTest.php32
2 files changed, 18 insertions, 18 deletions
diff --git a/Auth.php b/Auth.php
index 7ab525d..76a63be 100755
--- a/Auth.php
+++ b/Auth.php
@@ -177,7 +177,7 @@ class Auth
$zxcvbn = new Zxcvbn();
- if($zxcvbn->passwordStrength($password)['score'] < $this->config->password_min_score) {
+ if($zxcvbn->passwordStrength($password)['score'] < intval($this->config->password_min_score)) {
$return['message'] = $this->lang['password_weak'];
return $return;
}
@@ -1108,7 +1108,7 @@ class Auth
$zxcvbn = new Zxcvbn();
- if($zxcvbn->passwordStrength($newpass)['score'] < $this->config->password_min_score) {
+ if($zxcvbn->passwordStrength($newpass)['score'] < intval($this->config->password_min_score)) {
$return['message'] = $this->lang['password_weak'];
return $return;
}
diff --git a/tests/AuthTest.php b/tests/AuthTest.php
index 4114ee9..b6b3b2d 100644
--- a/tests/AuthTest.php
+++ b/tests/AuthTest.php
@@ -29,16 +29,16 @@ class AuthTest extends PHPUnit_Framework_TestCase
public function testRegister()
{
// Successful registration
- $this->assertFalse($this->auth->register("test@email.com", "TestPassword1", "TestPassword1", array(), NULL, false)['error']);
+ $this->assertFalse($this->auth->register('test@email.com', 'T3H-1337-P@$$', 'T3H-1337-P@$$')['error']);
// Failed registration: same email
- $this->assertTrue($this->auth->register("test@email.com", "TestPassword1", "TestPassword1", array(), NULL, false)['error']);
+ $this->assertTrue($this->auth->register('test@email.com', 'T3H-1337-P@$$', 'T3H-1337-P@$$')['error']);
// Failed registration: invalid email address
- $this->assertTrue($this->auth->register("InvalidEmail", "TestPassword1", "TestPassword1", array(), NULL, false)['error']);
+ $this->assertTrue($this->auth->register('InvalidEmail', 'T3H-1337-P@$$', 'T3H-1337-P@$$')['error']);
// Failed registration: invalid password
- $this->assertTrue($this->auth->register("test2@email.com", "lamepass", "lamepass", array(), NULL, false)['error']);
+ $this->assertTrue($this->auth->register('test2@email.com', 'lamepass', 'lamepass')['error']);
}
/**
@@ -51,7 +51,7 @@ class AuthTest extends PHPUnit_Framework_TestCase
$this->dbh->exec("DELETE FROM attempts;");
// Successful login
- $this->assertFalse($this->auth->login("test@email.com", "TestPassword1")['error']);
+ $this->assertFalse($this->auth->login("test@email.com", 'T3H-1337-P@$$')['error']);
// Failed login: incorrect email
$this->assertTrue($this->auth->login("incorrect@email.com", "IncorrectPassword1")['error']);
@@ -135,22 +135,22 @@ class AuthTest extends PHPUnit_Framework_TestCase
$uid = $this->dbh->query("SELECT id FROM users WHERE email = 'test@email.com';", PDO::FETCH_ASSOC)->fetch()['id'];
// Successful changePassword
- $this->assertFalse($this->auth->changePassword($uid, "TestPassword1", "TestPassword2", "TestPassword2")['error']);
+ $this->assertFalse($this->auth->changePassword($uid, 'T3H-1337-P@$$', 'T3H-1337-P@$$2', 'T3H-1337-P@$$2')['error']);
// Failed changePassword: invalid current password
- $this->assertTrue($this->auth->changePassword($uid, "lamepass", "TestPassword2", "TestPassword2")['error']);
+ $this->assertTrue($this->auth->changePassword($uid, "invalid", 'T3H-1337-P@$$2', 'T3H-1337-P@$$2')['error']);
// Failed changePassword: incorrect current password
- $this->assertTrue($this->auth->changePassword($uid, "IncorrectPassword1", "TestPassword2", "TestPassword2")['error']);
+ $this->assertTrue($this->auth->changePassword($uid, "IncorrectPassword1", 'T3H-1337-P@$$2', 'T3H-1337-P@$$2')['error']);
// Failed changePassword: invalid new password
- $this->assertTrue($this->auth->changePassword($uid, "TestPassword2", "lamepass", "lamepass")['error']);
+ $this->assertTrue($this->auth->changePassword($uid, 'T3H-1337-P@$$2', "lamepass", "lamepass")['error']);
// Failed changePassword: new password and confirmation do not match
- $this->assertTrue($this->auth->changePassword($uid, "TestPassword2", "TestPassword3", "TestPassword4")['error']);
+ $this->assertTrue($this->auth->changePassword($uid, 'T3H-1337-P@$$2', 'T3H-1337-P@$$3', 'T3H-1337-P@$$4')['error']);
// Failed changePassword: incorrect UID
- $this->assertTrue($this->auth->changePassword(9999999, "TestPassword2", "TestPassword3", "TestPassword3")['error']);
+ $this->assertTrue($this->auth->changePassword(9999999, 'T3H-1337-P@$$2', 'T3H-1337-P@$$3', 'T3H-1337-P@$$3')['error']);
}
/**
@@ -162,16 +162,16 @@ class AuthTest extends PHPUnit_Framework_TestCase
$uid = $this->dbh->query("SELECT id FROM users WHERE email = 'test@email.com';", PDO::FETCH_ASSOC)->fetch()['id'];
// Successful changeEmail
- $this->assertFalse($this->auth->changeEmail($uid, "test2@email.com", "TestPassword2")['error']);
+ $this->assertFalse($this->auth->changeEmail($uid, "test2@email.com", 'T3H-1337-P@$$2')['error']);
// Failed changeEmail: invalid email
- $this->assertTrue($this->auth->changeEmail($uid, "invalid.email", "TestPassword2")['error']);
+ $this->assertTrue($this->auth->changeEmail($uid, "invalid.email", 'T3H-1337-P@$$2')['error']);
// Failed changeEmail: new email is the same as current email
- $this->assertTrue($this->auth->changeEmail($uid, "test2@email.com", "TestPassword2")['error']);
+ $this->assertTrue($this->auth->changeEmail($uid, "test2@email.com", 'T3H-1337-P@$$2')['error']);
// Failed changeEmail: password is invalid
- $this->assertTrue($this->auth->changeEmail($uid, "test3@email.com", "lamepass")['error']);
+ $this->assertTrue($this->auth->changeEmail($uid, "test3@email.com", "invalid")['error']);
// Failed changeEmail: password is incorrect
$this->assertTrue($this->auth->changeEmail($uid, "test3@email.com", "IncorrectPassword1")['error']);
@@ -219,7 +219,7 @@ class AuthTest extends PHPUnit_Framework_TestCase
$this->assertTrue($this->auth->deleteUser($uid, "IncorrectPassword1")['error']);
// Successful deleteUser
- $this->assertFalse($this->auth->deleteUser($uid, "TestPassword2")['error']);
+ $this->assertFalse($this->auth->deleteUser($uid, 'T3H-1337-P@$$2')['error']);
// Failed deleteUser: incorrect UID
$this->assertTrue($this->auth->deleteUser(9999999, "IncorrectPassword1")['error']);