File: ValidatePasswordTest.php

package info (click to toggle)
postfixadmin 3.3.15%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,816 kB
  • sloc: php: 10,120; perl: 1,069; sh: 643; python: 169; xml: 62; sql: 3; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 877 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

class ValidatePasswordTest extends \PHPUnit\Framework\TestCase {
    public function testBasic() {
        $config = Config::getInstance();

        // Set to the defaults, just to make sure.
        Config::write('password_validation', array(
#    '/regular expression/' => '$PALANG key (optional: + parameter)',
            '/.{5}/' => 'password_too_short 5',      # minimum length 5 characters
            '/([a-zA-Z].*){3}/' => 'password_no_characters 3',  # must contain at least 3 characters
            '/([0-9].*){2}/' => 'password_no_digits 2',      # must contain at least 2 digits
        ));

        $this->assertEmpty(validate_password('fishSheep01'));
        $this->assertEmpty(validate_password('Password01'));
        $this->assertNotEmpty(validate_password('pas')); // notEmpty == fail
        $this->assertNotEmpty(validate_password('pa1'));
    }
}