Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
14.29% |
6 / 42 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_password_complexity_test | |
14.29% |
6 / 42 |
|
50.00% |
2 / 4 |
14.08 | |
0.00% |
0 / 1 |
| password_complexity_test_data_positive | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| password_complexity_test_data_negative | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
2 | |||
| test_password_complexity_positive | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_password_complexity_negative | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/../../phpBB/includes/functions_user.php'; |
| 15 | |
| 16 | class phpbb_password_complexity_test extends phpbb_test_case |
| 17 | { |
| 18 | public static function password_complexity_test_data_positive() |
| 19 | { |
| 20 | return array( |
| 21 | array('12345', 'PASS_TYPE_ANY'), |
| 22 | array('qwerty', 'PASS_TYPE_ANY'), |
| 23 | array('QWERTY', 'PASS_TYPE_ANY'), |
| 24 | array('QwerTY', 'PASS_TYPE_ANY'), |
| 25 | array('q$erty', 'PASS_TYPE_ANY'), |
| 26 | array('qW$rty', 'PASS_TYPE_ANY'), |
| 27 | |
| 28 | array('QwerTY', 'PASS_TYPE_CASE'), |
| 29 | array('QwerTY123', 'PASS_TYPE_ALPHA'), |
| 30 | array('QwerTY123$&', 'PASS_TYPE_SYMBOL'), |
| 31 | |
| 32 | array('', 'PASS_TYPE_ANY'), |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | public static function password_complexity_test_data_negative() |
| 37 | { |
| 38 | return array( |
| 39 | array('qwerty', 'PASS_TYPE_CASE'), |
| 40 | array('QWERTY', 'PASS_TYPE_CASE'), |
| 41 | array('123456', 'PASS_TYPE_CASE'), |
| 42 | array('#$&', 'PASS_TYPE_CASE'), |
| 43 | array('QTY123$', 'PASS_TYPE_CASE'), |
| 44 | |
| 45 | array('qwerty', 'PASS_TYPE_ALPHA'), |
| 46 | array('QWERTY', 'PASS_TYPE_ALPHA'), |
| 47 | array('123456', 'PASS_TYPE_ALPHA'), |
| 48 | array('QwertY', 'PASS_TYPE_ALPHA'), |
| 49 | array('qwerty123', 'PASS_TYPE_ALPHA'), |
| 50 | array('QWERTY123', 'PASS_TYPE_ALPHA'), |
| 51 | array('#$&', 'PASS_TYPE_ALPHA'), |
| 52 | array('QTY123$', 'PASS_TYPE_ALPHA'), |
| 53 | |
| 54 | array('qwerty', 'PASS_TYPE_SYMBOL'), |
| 55 | array('QWERTY', 'PASS_TYPE_SYMBOL'), |
| 56 | array('123456', 'PASS_TYPE_SYMBOL'), |
| 57 | array('QwertY', 'PASS_TYPE_SYMBOL'), |
| 58 | array('qwerty123', 'PASS_TYPE_SYMBOL'), |
| 59 | array('QWERTY123', 'PASS_TYPE_SYMBOL'), |
| 60 | array('#$&', 'PASS_TYPE_SYMBOL'), |
| 61 | array('qwerty123$', 'PASS_TYPE_SYMBOL'), |
| 62 | array('QWERTY123$', 'PASS_TYPE_SYMBOL'), |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @dataProvider password_complexity_test_data_positive |
| 68 | */ |
| 69 | public function test_password_complexity_positive($password, $mode) |
| 70 | { |
| 71 | global $config; |
| 72 | $config['pass_complex'] = $mode; |
| 73 | $this->assertFalse(validate_password($password)); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @dataProvider password_complexity_test_data_negative |
| 78 | */ |
| 79 | public function test_password_complexity_negative($password, $mode) |
| 80 | { |
| 81 | global $config; |
| 82 | $config['pass_complex'] = $mode; |
| 83 | $this->assertEquals('INVALID_CHARS', validate_password($password)); |
| 84 | } |
| 85 | } |