diff options
author | Maat <maat-pub@mageia.biz> | 2012-06-03 21:23:14 +0200 |
---|---|---|
committer | Maat <maat-pub@mageia.biz> | 2012-06-03 21:23:14 +0200 |
commit | a06a38ae692551dc1c0416b835ce9924b3d9f7f5 (patch) | |
tree | 1bb2c2b3d8d56668585513890afc1d641cead0b1 /tests/regex/password_complexity_test.php | |
parent | 2db884ac2e5122be1db0582b76bf7204783a0c0d (diff) | |
parent | 19a47dfbbc4265e33c14d6679b5693d80120db4b (diff) | |
download | forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.gz forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.bz2 forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.xz forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.zip |
Merging with upstream 3.0.11
Diffstat (limited to 'tests/regex/password_complexity_test.php')
-rw-r--r-- | tests/regex/password_complexity_test.php | 81 |
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..07453555ee --- /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-2.0.php GNU General Public License v2 +* +*/ + +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)); + } +} |