aboutsummaryrefslogtreecommitdiffstats
path: root/tests/regex/password_complexity_test.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-04-01 15:11:10 +0200
committerAndreas Fischer <bantu@phpbb.com>2011-04-01 15:11:10 +0200
commitf392f55d9b82cf6e387cf71bd3895d52469c8991 (patch)
treea4d504c6a11fa948d15e245972381b64fc9315c1 /tests/regex/password_complexity_test.php
parent564ce6c7f680090c606a6be4d2598dd04b88aab4 (diff)
parent4dce53628c97062b1085eb714892f6d81ae07699 (diff)
downloadforums-f392f55d9b82cf6e387cf71bd3895d52469c8991.tar
forums-f392f55d9b82cf6e387cf71bd3895d52469c8991.tar.gz
forums-f392f55d9b82cf6e387cf71bd3895d52469c8991.tar.bz2
forums-f392f55d9b82cf6e387cf71bd3895d52469c8991.tar.xz
forums-f392f55d9b82cf6e387cf71bd3895d52469c8991.zip
Merge branch 'ticket/bantu/9751' into develop-olympus
* ticket/bantu/9751: [ticket/9751] Add shortcut logic for pass_complex == PASS_TYPE_ANY. [ticket/9751] Compare $password with empty string instead of casting it to bool [ticket/9751] Use a switch/case block without break for password complexity. [ticket/9751] Password requirement "Must contain letters and numbers" fails
Diffstat (limited to 'tests/regex/password_complexity_test.php')
-rw-r--r--tests/regex/password_complexity_test.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php
new file mode 100644
index 0000000000..21e8d12a0a
--- /dev/null
+++ b/tests/regex/password_complexity_test.php
@@ -0,0 +1,81 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
+
+class phpbb_password_complexity_test extends phpbb_test_case
+{
+ public function password_complexity_test_data_positive()
+ {
+ return array(
+ array('12345', 'PASS_TYPE_ANY'),
+ array('qwerty', 'PASS_TYPE_ANY'),
+ array('QWERTY', 'PASS_TYPE_ANY'),
+ array('QwerTY', 'PASS_TYPE_ANY'),
+ array('q$erty', 'PASS_TYPE_ANY'),
+ array('qW$rty', 'PASS_TYPE_ANY'),
+
+ array('QwerTY', 'PASS_TYPE_CASE'),
+ array('QwerTY123', 'PASS_TYPE_ALPHA'),
+ array('QwerTY123$&', 'PASS_TYPE_SYMBOL'),
+
+ array('', 'PASS_TYPE_ANY'),
+ );
+ }
+
+ public function password_complexity_test_data_negative()
+ {
+ return array(
+ array('qwerty', 'PASS_TYPE_CASE'),
+ array('QWERTY', 'PASS_TYPE_CASE'),
+ array('123456', 'PASS_TYPE_CASE'),
+ array('#$&', 'PASS_TYPE_CASE'),
+ array('QTY123$', 'PASS_TYPE_CASE'),
+
+ array('qwerty', 'PASS_TYPE_ALPHA'),
+ array('QWERTY', 'PASS_TYPE_ALPHA'),
+ array('123456', 'PASS_TYPE_ALPHA'),
+ array('QwertY', 'PASS_TYPE_ALPHA'),
+ array('qwerty123', 'PASS_TYPE_ALPHA'),
+ array('QWERTY123', 'PASS_TYPE_ALPHA'),
+ array('#$&', 'PASS_TYPE_ALPHA'),
+ array('QTY123$', 'PASS_TYPE_ALPHA'),
+
+ array('qwerty', 'PASS_TYPE_SYMBOL'),
+ array('QWERTY', 'PASS_TYPE_SYMBOL'),
+ array('123456', 'PASS_TYPE_SYMBOL'),
+ array('QwertY', 'PASS_TYPE_SYMBOL'),
+ array('qwerty123', 'PASS_TYPE_SYMBOL'),
+ array('QWERTY123', 'PASS_TYPE_SYMBOL'),
+ array('#$&', 'PASS_TYPE_SYMBOL'),
+ array('qwerty123$', 'PASS_TYPE_SYMBOL'),
+ array('QWERTY123$', 'PASS_TYPE_SYMBOL'),
+ );
+ }
+
+ /**
+ * @dataProvider password_complexity_test_data_positive
+ */
+ public function test_password_complexity_positive($password, $mode)
+ {
+ global $config;
+ $config['pass_complex'] = $mode;
+ $this->assertFalse(validate_password($password));
+ }
+
+ /**
+ * @dataProvider password_complexity_test_data_negative
+ */
+ public function test_password_complexity_negative($password, $mode)
+ {
+ global $config;
+ $config['pass_complex'] = $mode;
+ $this->assertEquals('INVALID_CHARS', validate_password($password));
+ }
+}