Skip to content

Commit 72f7061

Browse files
aarmammrts
authored andcommitted
Update mock dates in tests
1 parent 8744547 commit 72f7061

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

tests/validator/AuthTokenAlgorithmTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,26 @@
2424

2525
namespace web_eid\web_eid_authtoken_validation_php\validator;
2626

27+
use DateTime;
2728
use web_eid\web_eid_authtoken_validation_php\testutil\AbstractTestWithValidator;
2829
use web_eid\web_eid_authtoken_validation_php\exceptions\AuthTokenParseException;
30+
use web_eid\web_eid_authtoken_validation_php\testutil\Dates;
2931

3032
class AuthTokenAlgorithmTest extends AbstractTestWithValidator
3133
{
3234

35+
protected function setUp(): void
36+
{
37+
parent::setUp();
38+
// Ensure that the certificates do not expire.
39+
Dates::setMockedCertificateValidatorDate(new DateTime("2021-07-23"));
40+
}
41+
42+
protected function tearDown(): void
43+
{
44+
Dates::resetMockedCertificateValidatorDate();
45+
}
46+
3347
public function testWhenAlgorithmNoneThenValidationFails(): void
3448
{
3549
$authToken = $this->replaceTokenField(self::VALID_AUTH_TOKEN, "algorithm", "NONE");

tests/validator/AuthTokenSignatureTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ class AuthTokenSignatureTest extends AbstractTestWithValidator
4242
'"signature":"arx164xRiwhIQDINe0J+ZxJWZFOQTx0PBtOaWaxAe7gofEIHRIbV1w0sOCYBJnvmvMem9hU4nc2+iJx2x8poYck4Z6eI3GwtiksIec3XQ9ZIk1n/XchXnmPn3GYV+HzJ",' .
4343
'"format":"web-eid:1.0"}';
4444

45+
protected function setUp(): void
46+
{
47+
parent::setUp();
48+
// Ensure that the certificates do not expire.
49+
Dates::setMockedCertificateValidatorDate(new DateTime("2021-07-23"));
50+
}
51+
4552
protected function tearDown(): void
4653
{
4754
Dates::resetMockedCertificateValidatorDate();
@@ -75,7 +82,6 @@ public function testWhenValidTokenAndWrongOriginThenValidationFails(): void
7582

7683
public function testWhenTokenWithWrongCertThenValidationFails(): void
7784
{
78-
Dates::setMockedCertificateValidatorDate(new DateTime('2024-08-01 10:13:43.000'));
7985
$authTokenValidator = AuthTokenValidators::getAuthTokenValidator();
8086
$authTokenWithWrongCert = $authTokenValidator->parse(self::AUTH_TOKEN_WRONG_CERT);
8187

0 commit comments

Comments
 (0)