Skip to content

Commit

Permalink
Increases the Access Token and Refresh Token's Lifespan for tests (#591)
Browse files Browse the repository at this point in the history
* Improves token manager's refresh token handling

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

* Adds relevant test

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

* Removes unnecessary class

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

* Addresses review remarks

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

* Re-adjusts the review remarks

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

* Refactors the code

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

* Adjusts the wait time in token retrieval tests

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

* Increases the Access Token and Refresh Token's Lifespan for tests

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>

---------

Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>
  • Loading branch information
mdanish98 authored Jan 17, 2025
1 parent 6029a9b commit 92c2869
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void retrieveNewAccessTokenWhenExpired() throws IOException, InterruptedE
String initialAccessToken = tokenManager.getAccessToken();
assertNotNull(initialAccessToken);

long tokenLifetime = 1000;
long tokenLifetime = 2000;
Thread.sleep(tokenLifetime + 5);

String newAccessToken = tokenManager.getAccessToken();
Expand All @@ -69,7 +69,7 @@ public void provideSameAccessTokenWhenNotExpired() throws IOException, Interrupt
String initialAccessToken = tokenManager.getAccessToken();
assertNotNull(initialAccessToken);

long tokenLifetime = 350;
long tokenLifetime = 800;
Thread.sleep(tokenLifetime);

String newAccessToken = tokenManager.getAccessToken();
Expand All @@ -83,7 +83,7 @@ public void retrieveNewAccessTokenUsingRefreshTokenWhenAccessTokenIsExpired() th
String initialAccessToken = tokenManager.getAccessToken();
assertNotNull(initialAccessToken);

long tokenLifetime = 1000;
long tokenLifetime = 2000;
Thread.sleep(tokenLifetime + 15);

String newAccessToken = tokenManager.getAccessToken();
Expand All @@ -97,7 +97,7 @@ public void retrieveNewAccessTokenUsingRefreshTokenWhenExpired() throws IOExcept
String initialAccessToken = tokenManager.getAccessToken();
assertNotNull(initialAccessToken);

long tokenLifetime = 3000;
long tokenLifetime = 4000;
Thread.sleep(tokenLifetime + 5);

String newAccessToken = tokenManager.getAccessToken();
Expand All @@ -112,7 +112,7 @@ public void retrieveNewAccessTokenWhenSSOMaxReached() throws IOException, Interr
String initialAccessToken = tokenManager.getAccessToken();
assertNotNull(initialAccessToken);

long timeLimit = 4000;
long timeLimit = 6000;
String intermediateAccessToken = null;

while (timeLimit > 0) {
Expand Down
4 changes: 2 additions & 2 deletions ci/keycloak/realm/BaSyx-realm.json
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@
"frontchannelLogout" : true,
"protocol" : "openid-connect",
"attributes" : {
"access.token.lifespan" : "1",
"access.token.lifespan" : "2",
"client.secret.creation.time" : "1734780525",
"post.logout.redirect.uris" : "+",
"oauth2.device.authorization.grant.enabled" : "false",
Expand All @@ -1764,7 +1764,7 @@
"require.pushed.authorization.requests" : "false",
"acr.loa.map" : "{}",
"display.on.consent.screen" : "false",
"client.session.max.lifespan" : "3",
"client.session.max.lifespan" : "4",
"token.response.type.bearer.lower-case" : "false"
},
"authenticationFlowBindingOverrides" : { },
Expand Down

0 comments on commit 92c2869

Please sign in to comment.