Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Sep 5, 2023
1 parent 398f143 commit 1b73d31
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/php/admin-bundle/Tests/AbstractAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function doTestAllPages(): void
}

$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('https://keycloak.phrasea.local/realms/master/protocol/openid-connect/auth?client_id=test&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fadmin%2Foauth%2Fcheck&state=cj1odHRwJTNBJTJGJTJGbG9jYWxob3N0JTJGYWRtaW4%3D', $response->getTargetUrl());
$this->assertEquals(getenv('KEYCLOAK_URL').'/realms/master/protocol/openid-connect/auth?client_id=test&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fadmin%2Foauth%2Fcheck&state=cj1odHRwJTNBJTJGJTJGbG9jYWxob3N0JTJGYWRtaW4%3D', $response->getTargetUrl());

$this->logIn($this->client);
$crawler = $this->client->request('GET', '/admin');
Expand Down
29 changes: 1 addition & 28 deletions lib/php/auth-bundle/Tests/Client/OAuthClientTestMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function getJwtFor(string $userId): string
$now = new DateTimeImmutable();
$token = $configuration
->builder()
->issuedBy('https://keycloak.phrasea.local/realms/master')
->issuedBy(getenv('KEYCLOAK_URL').'/realms/master')
// Configures the time that the token was issue (iat claim)
->issuedAt($now)
// Configures the time that the token can be used (nbf claim)
Expand All @@ -67,33 +67,6 @@ public static function getJwtFor(string $userId): string
return $token->toString();
}

public static function generateExpiresJwt(string $userId): string
{
$configuration = Configuration::forAsymmetricSigner(
new Sha256(),
InMemory::file(__DIR__ . '/key.pem'),
InMemory::file(__DIR__ . '/key.pub'),
);

$now = new DateTimeImmutable();
$token = $configuration
->builder()
->issuedBy('https://keycloak.phrasea.local/realms/master')
// Configures the time that the token was issue (iat claim)
->issuedAt($now)
// Configures the time that the token can be used (nbf claim)
->canOnlyBeUsedAfter($now->modify('+1 minute'))
->expiresAt($now->modify('-1 hour'))
->relatedTo($userId)
->withClaim('azp', 'test')
->withClaim('preferred_username', self::USERS[$userId]['username'])
->withClaim('roles', self::USERS[$userId]['roles'] ?? [])
->withClaim('groups', self::USERS[$userId]['groups'] ?? [])
->getToken(new Sha256(), InMemory::file(__DIR__.'/key.pem'));

return $token->toString();
}

public function request(string $method, string $url, array $options = []): ResponseInterface
{
$args = [$method, $url, $options];
Expand Down

0 comments on commit 1b73d31

Please sign in to comment.