aboutsummaryrefslogtreecommitdiffstats
path: root/tests/regex/password_complexity_test.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-04-01 15:11:55 +0200
committerAndreas Fischer <bantu@phpbb.com>2011-04-01 15:11:55 +0200
commitebc338b9f3b75b758f55dc5a9a2300e8c154c74f (patch)
tree5a58664b9e7f146a9a3e6afec83af134088fe9a4 /tests/regex/password_complexity_test.php
parenta40bc114c0f658b62c14a00eda59d57a27fff680 (diff)
parentf392f55d9b82cf6e387cf71bd3895d52469c8991 (diff)
downloadforums-ebc338b9f3b75b758f55dc5a9a2300e8c154c74f.tar
forums-ebc338b9f3b75b758f55dc5a9a2300e8c154c74f.tar.gz
forums-ebc338b9f3b75b758f55dc5a9a2300e8c154c74f.tar.bz2
forums-ebc338b9f3b75b758f55dc5a9a2300e8c154c74f.tar.xz
forums-ebc338b9f3b75b758f55dc5a9a2300e8c154c74f.zip
Merge branch 'develop-olympus' into develop
* develop-olympus: [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));
+ }
+}