Skip to content

Commit 4f38bfb

Browse files
authored
Merge pull request #51726 from sberyozkin/flaky_code_flow_test
Add assert messages to flaky CodeFlowAuthorizationTest#testCodeFlowUserInfoCachedInIdToken
2 parents 3b08439 + 236fcd4 commit 4f38bfb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

integration-tests/oidc-wiremock/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
<artifactId>rest-assured</artifactId>
5252
<scope>test</scope>
5353
</dependency>
54+
<dependency>
55+
<groupId>org.assertj</groupId>
56+
<artifactId>assertj-core</artifactId>
57+
<scope>test</scope>
58+
</dependency>
5459
<dependency>
5560
<groupId>io.smallrye.certs</groupId>
5661
<artifactId>smallrye-certificate-generator</artifactId>

integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
1111
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
1212
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
13+
import static org.assertj.core.api.Assertions.assertThat;
1314
import static org.awaitility.Awaitility.given;
1415
import static org.junit.jupiter.api.Assertions.assertEquals;
1516
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -381,7 +382,9 @@ public void testCodeFlowUserInfoCachedInIdToken() throws Exception {
381382
final long nowInSecs = nowInSecs();
382383
final long sessionCookieLifespan = stateCookieDate.toInstant().getEpochSecond() - nowInSecs;
383384
// 5 mins is default
384-
assertTrue(sessionCookieLifespan >= 299 && sessionCookieLifespan <= 304);
385+
assertThat(sessionCookieLifespan).isGreaterThanOrEqualTo(299);
386+
387+
assertThat(sessionCookieLifespan).isLessThanOrEqualTo(304);
385388

386389
TextPage textPage = form.getInputByValue("login").click();
387390

@@ -399,11 +402,11 @@ public void testCodeFlowUserInfoCachedInIdToken() throws Exception {
399402

400403
Cookie sessionCookie = getSessionCookie(webClient, "code-flow-user-info-github-cached-in-idtoken");
401404
Date date = sessionCookie.getExpires();
402-
assertTrue(date.toInstant().getEpochSecond() - issuedAt >= 299 + 300);
405+
assertThat(date.toInstant().getEpochSecond() - issuedAt).isGreaterThanOrEqualTo(299 + 300);
403406
// This test enables the token refresh, in this case the cookie age is extended by additional 5 mins
404407
// to minimize the risk of the browser losing immediately after it has expired, for this cookie
405408
// be returned to Quarkus, analyzed and refreshed
406-
assertTrue(date.toInstant().getEpochSecond() - issuedAt <= 299 + 300 + 3);
409+
assertThat(date.toInstant().getEpochSecond() - issuedAt).isLessThanOrEqualTo(299 + 300 + 3);
407410

408411
assertEquals(299, decryptAccessTokenExpiryTime(webClient, "code-flow-user-info-github-cached-in-idtoken"));
409412

@@ -427,8 +430,8 @@ public void testCodeFlowUserInfoCachedInIdToken() throws Exception {
427430

428431
sessionCookie = getSessionCookie(webClient, "code-flow-user-info-github-cached-in-idtoken");
429432
date = sessionCookie.getExpires();
430-
assertTrue(date.toInstant().getEpochSecond() - issuedAt >= 299 + 300);
431-
assertTrue(date.toInstant().getEpochSecond() - issuedAt <= 299 + 300 + 3);
433+
assertThat(date.toInstant().getEpochSecond() - issuedAt).isGreaterThanOrEqualTo(299 + 300);
434+
assertThat(date.toInstant().getEpochSecond() - issuedAt).isLessThanOrEqualTo(299 + 300 + 3);
432435

433436
assertEquals(305, decryptAccessTokenExpiryTime(webClient, "code-flow-user-info-github-cached-in-idtoken"));
434437

0 commit comments

Comments
 (0)