Using a valid URI when deleting cookies before/after running tests
Closes #22691 Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
This commit is contained in:
parent
c2112b9edd
commit
d540584449
3 changed files with 23 additions and 5 deletions
|
@ -68,7 +68,6 @@ import org.keycloak.services.ErrorResponse;
|
|||
import org.keycloak.services.managers.AuthenticationManager;
|
||||
import org.keycloak.services.resource.RealmResourceProvider;
|
||||
import org.keycloak.services.scheduled.ClearExpiredUserSessions;
|
||||
import org.keycloak.services.util.CacheControlUtil;
|
||||
import org.keycloak.services.util.CookieHelper;
|
||||
import org.keycloak.sessions.RootAuthenticationSessionModel;
|
||||
import org.keycloak.storage.UserStorageProvider;
|
||||
|
@ -1177,4 +1176,10 @@ public class TestingResourceProvider implements RealmResourceProvider {
|
|||
return Response.noContent().cacheControl(cacheControl).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/blank")
|
||||
@Produces(MediaType.TEXT_HTML_UTF_8)
|
||||
public Response getBlankPage() {
|
||||
return Response.ok("<html><body></body></html>").build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,10 @@ import org.jboss.arquillian.graphene.proxy.InvocationContext;
|
|||
import org.jboss.arquillian.test.spi.annotation.ClassScoped;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.testsuite.util.WaitUtils;
|
||||
import org.openqa.selenium.Capabilities;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxOptions;
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||
|
||||
|
@ -84,8 +87,20 @@ public class KeycloakDronePostSetup {
|
|||
driver.manage().timeouts().implicitlyWait(implicitWaitMillis, TimeUnit.MILLISECONDS);
|
||||
driver.manage().timeouts().pageLoadTimeout(pageLoadTimeoutMillis, TimeUnit.MILLISECONDS);
|
||||
driver.manage().window().maximize();
|
||||
|
||||
configureFirefoxDriver(driver);
|
||||
}
|
||||
|
||||
private void configureFirefoxDriver(WebDriver driver) {
|
||||
if (driver instanceof FirefoxDriver) {
|
||||
FirefoxDriver firefoxDriver = (FirefoxDriver) driver;
|
||||
Capabilities capabilities = firefoxDriver.getCapabilities();
|
||||
FirefoxOptions options = new FirefoxOptions(capabilities);
|
||||
// disables extension automatic updates as we don't need it when running the test suite
|
||||
options.addPreference("extensions.update.enabled", "false");
|
||||
firefoxDriver.getCapabilities().merge(options);
|
||||
}
|
||||
}
|
||||
|
||||
public static class HtmlUnitInterceptor implements Interceptor {
|
||||
|
||||
|
@ -133,6 +148,6 @@ public class KeycloakDronePostSetup {
|
|||
public int getPrecedence() {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,9 +283,7 @@ public abstract class AbstractKeycloakTest {
|
|||
}
|
||||
|
||||
protected void deleteAllCookiesForRealm(String realmName) {
|
||||
// we can't use /auth/realms/{realmName} because some browsers (e.g. Chrome) apparently don't send cookies
|
||||
// to JSON pages and therefore can't delete realms cookies there; a non existing page will do just fine
|
||||
navigateToUri(oauth.SERVER_ROOT + "/auth/realms/" + realmName + "/super-random-page");
|
||||
navigateToUri(oauth.SERVER_ROOT + "/auth/realms/" + realmName + "/testing/blank");
|
||||
log.info("deleting cookies in '" + realmName + "' realm");
|
||||
driver.manage().deleteAllCookies();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue