Skip to content

Commit

Permalink
Update TOTP creation in tests
Browse files Browse the repository at this point in the history
The Time-Based One-Time Password (TOTP) creation in our tests has been updated to include a clock mock. This change ensures that the TOTP verification can be tested in a predictable and controlled manner, regardless of the actual system time.
  • Loading branch information
Spomky committed Apr 15, 2024
1 parent 5493259 commit 0d35971
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/TOTPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function verifyOtpWithEpochInWindow(
): void {
$clock = new ClockMock();
$clock->setDateTime(DateTimeImmutable::createFromFormat('U', (string) $timestamp));
$otp = self::createTOTP(6, 'sha1', 30, 'JDDK4U6G3BJLEZ7Y', '[email protected]', 'My Project', 100);
$otp = self::createTOTP(6, 'sha1', 30, 'JDDK4U6G3BJLEZ7Y', '[email protected]', 'My Project', 100, $clock);

static::assertSame($expectedResult, $otp->verify($input, null, $leeway));
}
Expand Down

0 comments on commit 0d35971

Please sign in to comment.