Skip to content

Commit

Permalink
password validator / password hash generator
Browse files Browse the repository at this point in the history
  • Loading branch information
teodoroleckie committed May 8, 2021
1 parent 6795a10 commit aa5c969
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
24 changes: 1 addition & 23 deletions infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,7 @@
"text": ".\/infection-report"
},
"mutators": {
"@default": true,
"IncrementInteger": {
"ignore": [
"Tleckie\\Password\\Requirements::__construct",
"Tleckie\\Password\\Hash::__construct"
]
},
"DecrementInteger": {
"ignore": [
"Tleckie\\Password\\Requirements::__construct",
"Tleckie\\Password\\Hash::__construct"
]
},
"TrueValue": {
"ignore": [
"Tleckie\\Password\\Requirements::__construct"
]
},
"ProtectedVisibility": {
"ignore": [
"Tleckie\\Password\\Requirements::pattern"
]
}
"@default": true
},
"testFramework":"phpunit",
"bootstrap": "./vendor/autoload.php"
Expand Down
32 changes: 21 additions & 11 deletions tests/RequirementsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,37 @@ public function isValid(
bool $sameLowerChar,
string $password,
bool $expected
): void {
): void
{
$requirements = new Requirements($minSize, $sameUpperChar, $sameNumber, $sameSpecialChar, $sameLowerChar);
static::assertEquals($expected, $requirements->isValid($password));
}

/**
* @test
*/
public function standalone(): void
{
$requirements = new Requirements();
static::assertTrue( $requirements->isValid('tes.T123'));
}

/**
* @return array[]
*/
public function validatorDataProvider(): array
{
return [
[8,true,true,true,true, 'tes.T123', true],
[10,true,true,true,true, 'tes.T123', false],
[9,true,true,true,true, 'tes.T123', false],
[9,true,true,true,true, 'tes.t123', false],
[9,true,true,true,true, 'tes.Taaaa', false],
[12,true,true,true,true, '4444.T111111', false],
[8,false,true,true,true, 'tes.T123', true],
[8,false,false,true,true, 'tes.T123', true],
[8,false,false,false,true, 'tes.T123', true],
[8,false,false,false,false, 'tes.T123', true],
[8, true, true, true, true, 'tes.T123', true],
[10, true, true, true, true, 'tes.T123', false],
[9, true, true, true, true, 'tes.T123', false],
[9, true, true, true, true, 'tes.t123', false],
[9, true, true, true, true, 'tes.Taaaa', false],
[12, true, true, true, true, '4444.T111111', false],
[8, false, true, true, true, 'tes.T123', true],
[8, false, false, true, true, 'tes.T123', true],
[8, false, false, false, true, 'tes.T123', true],
[8, false, false, false, false, 'tes.T123', true],
];
}
}

0 comments on commit aa5c969

Please sign in to comment.