aboutsummaryrefslogtreecommitdiffstats
path: root/tests/regex/password_complexity_test.php
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-05-08 03:21:19 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-05-08 03:21:19 -0400
commitab44fe5e394fe7b69c57266e2934200a3ee9bbc5 (patch)
treee6021c19fa15800787b1a7459fb8ad40cf2d8391 /tests/regex/password_complexity_test.php
parent9c6660a2253149baff0094b943823de6758b35a6 (diff)
parentc0336988155736583c6fc4398980bd2a4e4036b6 (diff)
downloadforums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.gz
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.bz2
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.xz
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.zip
Merge branch 'develop' into feature/prune-users
* develop: (170 commits) [ticket/10145] Always recompile all templates when DEBUG_EXTRA is defined. [feature/attachment-management-no-reassignment] Handle privacy and some more. [ticket/10148] Turn TEMPLATE_BITFIELD into an instance variable. [ticket/10147] Corrected a typo in includes/functions_template.php. [ticket/10141] Save a hash lookup when value is not in cache. [ticket/10143] Added tests for storing a previously deleted value in db cache. [ticket/10105] Update AIM express link. [ticket/10105] Update AIM application download link. [ticket/10137] Remove unintended space at end of PHP_URL_FOPEN_SUPPORT_EXPLAIN. [ticket/10141] Split double-assignment into conditional and unconditional part. [ticket/10141] Use a cache in $auth->_fill_acl() for better performance. [ticket/9961] Create log entries when users are activated. [ticket/10139] Make signatures of set_atomic() consistent by using $new_value. [ticket/10139] Rename $cache to $use_cache to avoid confusion with cache object [ticket/10006] Remove unneeded if statements [ticket/10006] Remove return values [ticket/10006] More testing [ticket/10006] Tweak the tests a bit [ticket/10006] Add phpbb_config::delete [ticket/7941] Added @return to generate_board_url docstring. ...
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));
+ }
+}