-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -376,4 +376,30 @@ public function it_can_validate_credentials() | |
$this->assertTrue($success); | ||
$this->assertFalse($fail); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_rehash_password_if_required() | ||
{ | ||
if (! method_exists($this->hasher, 'needsRehash')) { | ||
$this->markTestSkipped('Password rehash is not supported in this version.'); | ||
} | ||
|
||
$connection = $this->newConnectionMock(); | ||
$connection->shouldReceive('putItem')->andReturn($this->sampleAwsResult()); | ||
$this->setConnectionResolver($connection); | ||
|
||
$originalHash = '$2y$10$ouGGlM0C/YKgk8MbQHxVHOblxztk/PlXZbKw7w2wfA8FlXsB0Po9G'; | ||
$user = new UserA([ | ||
'partition' => '[email protected]', | ||
'password' => $originalHash, | ||
]); | ||
$provider = new AuthUserProvider($this->hasher, UserA::class); | ||
$provider->rehashPasswordIfRequired($user, ['password' => 'foo'], true); | ||
$this->assertNotSame($originalHash, $user->password); | ||
$this->assertTrue($this->hasher->check('foo', $user->password)); | ||
|
||
$rehashedHash = $user->password; | ||
$provider->rehashPasswordIfRequired($user, ['password' => 'foo']); | ||
$this->assertSame($rehashedHash, $user->password); | ||
} | ||
} |