Skip to content

Commit

Permalink
Add an assertion to test where one was missing
Browse files Browse the repository at this point in the history
This change adds an assertion to
testCanDecryptResponseReturnsResponseWhenEncryptionIsUsed to complete
the test and avoid it being risky; ensuring that it does something
meaningful.
  • Loading branch information
settermjd authored and mstefan21 committed Jul 4, 2023
1 parent a0ae99b commit a6441cc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/src/Provider/KeycloakTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,17 @@ public function testCanDecryptResponseThrowsExceptionIfResponseIsNotAStringAndEn

public function testCanDecryptResponseReturnsResponseWhenEncryptionIsUsed()
{

$jwt = JWT::encode(
json_decode(
sprintf(
$this->jwtTemplate,
(new DateTimeImmutable())->add(new DateInterval('PT1H'))->getTimestamp(),
(new DateTimeImmutable())->sub(new DateInterval('P1D'))->getTimestamp(),
(new DateTimeImmutable())->sub(new DateInterval('P1D'))->getTimestamp()
),
true
$jwtPayload = json_decode(
sprintf(
$this->jwtTemplate,
(new DateTimeImmutable())->add(new DateInterval('PT1H'))->getTimestamp(),
(new DateTimeImmutable())->sub(new DateInterval('P1D'))->getTimestamp(),
(new DateTimeImmutable())->sub(new DateInterval('P1D'))->getTimestamp()
),
true
);
$jwt = JWT::encode(
$jwtPayload,
self::ENCRYPTION_KEY,
self::ENCRYPTION_ALGORITHM
);
Expand All @@ -515,6 +515,8 @@ public function testCanDecryptResponseReturnsResponseWhenEncryptionIsUsed()
->setEncryptionKey(self::ENCRYPTION_KEY);

$response = $this->provider->decryptResponse($jwt);

$this->assertSame($jwtPayload, $response);
}
}
}

0 comments on commit a6441cc

Please sign in to comment.