Skip to content

Commit

Permalink
Test empty string in guessable data
Browse files Browse the repository at this point in the history
  • Loading branch information
Stadly committed Jan 31, 2019
1 parent efd4800 commit a38ab6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
- Nothing

### Fixed
- Nothing
- Error emitted for empty string in guessable data.

### Deprecated
- Nothing
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/GuessableDataRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function contains(string $password, $data): bool
}

foreach ($strings as $string) {
if ('' !== $string && mb_stripos($password, $string) !== false) {
if ($string !== '' && mb_stripos($password, $string) !== false) {
return true;
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/Rule/GuessableDataRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ public function testPasswordCanContainGuessableDateInRule(): void
self::assertFalse($rule->test($password));
}

/**
* @covers ::test
*/
public function testPasswordDoesNotContainEmptyString(): void
{
$rule = new GuessableDataRule(['']);
$password = new Password('foobar');

self::assertTrue($rule->test($password));
}

/**
* @covers ::test
*/
Expand Down

0 comments on commit a38ab6d

Please sign in to comment.