Skip to content

Commit

Permalink
Output more information when OfflineServletAdapterTest fails
Browse files Browse the repository at this point in the history
Closes keycloak#25714

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
  • Loading branch information
ahus1 committed Dec 20, 2023
1 parent 8d7b0cc commit e36aba2
Showing 1 changed file with 22 additions and 3 deletions.
Expand Up @@ -34,6 +34,7 @@
import java.io.Closeable;
import java.io.IOException;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
Expand Down Expand Up @@ -268,14 +269,32 @@ private void resetTimeOffsetAuthenticated(String username, String password) {
}
super.setAdapterServletTimeOffset(0, offlineTokenPage.toString());

// action on the filter is only executed after the user has been authenticated
if (loginPage.isCurrent()) {
loginPage.login(username, password);
waitForPageToLoad();
AccountHelper.logout(adminClient.realm(TEST), DEFAULT_USERNAME);
}
setTimeOffset(0);
// Improve stability of the cleanup and have more time for synchronizing auth and app server living in different JVMs
pause(400);
}


@Override
protected void afterAbstractKeycloakTestRealmImport() {
// after each re-import, ensure that the information stored in JWKPublicKeyLocator is reset
String resetDeploymentUri = UriBuilder.fromUri(offlineTokenPage.toString())
.queryParam(AdapterActionsFilter.RESET_DEPLOYMENT_PARAM, "true")
.build().toString();
driver.navigate().to(resetDeploymentUri);
waitForPageToLoad();

// action on the filter is only executed after the user has been authenticated
if (loginPage.isCurrent()) {
loginPage.login(DEFAULT_USERNAME, DEFAULT_PASSWORD);
waitForPageToLoad();
AccountHelper.logout(adminClient.realm(TEST), DEFAULT_USERNAME);
}
assertThat(driver.getPageSource(), containsString("Restarted PublicKeyLocator"));
super.afterAbstractKeycloakTestRealmImport();
}

}

0 comments on commit e36aba2

Please sign in to comment.