Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/validator/AuthTokenAlgorithmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,26 @@

namespace web_eid\web_eid_authtoken_validation_php\validator;

use DateTime;
use web_eid\web_eid_authtoken_validation_php\testutil\AbstractTestWithValidator;
use web_eid\web_eid_authtoken_validation_php\exceptions\AuthTokenParseException;
use web_eid\web_eid_authtoken_validation_php\testutil\Dates;

class AuthTokenAlgorithmTest extends AbstractTestWithValidator
{

protected function setUp(): void
{
parent::setUp();
// Ensure that the certificates do not expire.
Dates::setMockedCertificateValidatorDate(new DateTime("2021-07-23"));
}

protected function tearDown(): void
{
Dates::resetMockedCertificateValidatorDate();
}

public function testWhenAlgorithmNoneThenValidationFails(): void
{
$authToken = $this->replaceTokenField(self::VALID_AUTH_TOKEN, "algorithm", "NONE");
Expand Down
8 changes: 7 additions & 1 deletion tests/validator/AuthTokenSignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class AuthTokenSignatureTest extends AbstractTestWithValidator
'"signature":"arx164xRiwhIQDINe0J+ZxJWZFOQTx0PBtOaWaxAe7gofEIHRIbV1w0sOCYBJnvmvMem9hU4nc2+iJx2x8poYck4Z6eI3GwtiksIec3XQ9ZIk1n/XchXnmPn3GYV+HzJ",' .
'"format":"web-eid:1.0"}';

protected function setUp(): void
{
parent::setUp();
// Ensure that the certificates do not expire.
Dates::setMockedCertificateValidatorDate(new DateTime("2021-07-23"));
}

protected function tearDown(): void
{
Dates::resetMockedCertificateValidatorDate();
Expand Down Expand Up @@ -75,7 +82,6 @@ public function testWhenValidTokenAndWrongOriginThenValidationFails(): void

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

Expand Down