-
Notifications
You must be signed in to change notification settings - Fork 4
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
2 changed files
with
32 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
use App\Exception\GoneException; | ||
use App\Exception\NotFoundException; | ||
use App\Exception\UnauthorizedException; | ||
use App\Service\Log\Output\Email; | ||
use App\Service\User\UserService; | ||
use DateTime; | ||
use Exception; | ||
|
@@ -189,6 +190,36 @@ public function cannot_add_existing_user_as_email_used_in_reset() | |
$us->add($userData); | ||
} | ||
|
||
/** @test */ | ||
public function logsNoticeWhenPasswordResetIsRequestedForNonExistentAccount(): void | ||
{ | ||
$email = '[email protected]'; | ||
$hashed_email = hash('sha256', $email); | ||
|
||
$repoProphecy = $this->prophesize(ActorUsersInterface::class); | ||
$loggerProphecy = $this->prophesize(LoggerInterface::class); | ||
|
||
$repoProphecy | ||
->recordPasswordResetRequest(Argument::cetera()) | ||
->willThrow(Exception::class); | ||
|
||
$loggerProphecy | ||
->notice( | ||
'Attempt made to reset password for non-existent account', | ||
Argument::that(function ($arg) use ($hashed_email) { | ||
return $arg['email'] instanceof Email && (string)($arg['email']) == $hashed_email; | ||
}) | ||
) | ||
->shouldBeCalled(); | ||
|
||
$userService = new UserService($repoProphecy->reveal(), $loggerProphecy->reveal()); | ||
|
||
try { | ||
$userService->requestPasswordReset($email); | ||
} catch (Exception) { | ||
} | ||
} | ||
|
||
/** @test */ | ||
public function can_get_a_user_from_storage(): void | ||
{ | ||
|