8000 Upgrade Selenium and Arquillian dependencies in testsuite by mabartos · Pull Request #29779 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/actions/build-keycloak/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ runs:
with:
create-cache-if-it-doesnt-exist: true

- id: phantomjs-cache
name: PhantomJS cache
uses: ./.github/actions/phantomjs-cache

- id: frontend-plugin-cache
name: Frontend Plugin Cache
uses: ./.github/actions/frontend-plugin-cache
Expand Down
4 changes: 0 additions & 4 deletions .github/actions/integration-test-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ runs:
name: Maven cache
uses: ./.github/actions/maven-cache

- id: phantomjs-cache
name: PhantomJS cache
uses: ./.github/actions/phantomjs-cache

- id: frontend-plugin-cache
name: Frontend Plugin Cache
uses: ./.github/actions/frontend-plugin-cache
Expand Down
26 changes: 0 additions & 26 deletions .github/actions/phantomjs-cache/action.yml

This file was deleted.

2 changes: 1 addition & 1 deletion testsuite/integration-arquillian/HOW-TO-RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ the same time both hosts must use different domains to be considered cross-origi
Also, those new cookies policies are currently not yet enabled by default (which will change in the near future). To test
those policies, you need the latest stable Firefox together with `firefox-strict-cookies` profile. This profile sets the
browser to Firefox, configures the proper cookies behavior and makes Firefox to run in the headless mode (which is ok
because this is not UI testing). For debugging purposes you can override the headless mode with `-DfirefoxHeadless=false`.
because this is not UI testing). For debugging purposes you can override the headless mode with `-DfirefoxArguments=''`.

**Broker tests:**

Expand Down
48 changes: 20 additions & 28 deletions testsuite/integration-arquillian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@
<arquillian-core.version>1.8.0.Final</arquillian-core.version>
<!--the version of shrinkwrap_resolver should align with the version in arquillian-bom-->
<shrinkwrap-resolver.version>3.2.1</shrinkwrap-resolver.version>
<selenium.version>3.14.0</selenium.version>
<arquillian-drone.version>2.5.5</arquillian-drone.version>
<arquillian-graphene.version>3.0.0-alpha.3</arquillian-graphene.version>
<selenium.version>4.21.0</selenium.version>
<arquillian-drone.version>3.0.0-alpha.8</arquillian-drone.version>
<arquillian-graphene.version>3.0.0-alpha.4</arquillian-graphene.version>
<arquillian-wildfly-container.version>3.0.1.Final</arquillian-wildfly-container.version>
<arquillian-wls-container.version>1.0.1.Final</arquillian-wls-container.version>
<arquillian-infinispan-container.version>1.2.0.Beta3</arquillian-infinispan-container.version>
<undertow.version>${undertow-jakarta.version}</undertow.version>
<undertow-embedded.version>1.0.0.Final</undertow-embedded.version>
<version.org.wildfly.extras.creaper>1.6.1</version.org.wildfly.extras.creaper>
<appium.client.version>6.1.0</appium.client.version>
<appium.client.version>9.2.2</appium.client.version>
<jakarta.persistence-legacy.version>2.2.3</jakarta.persistence-legacy.version>
<smallrye.jandex.version>3.0.5</smallrye.jandex.version>
<commons.validator.version>1.8.0</commons.validator.version>

<!--migration properties-->
<migration.70.version>1.9.8.Final</migration.70.version>
Expand Down Expand Up @@ -122,6 +123,11 @@
<artifactId>lift</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-manager</artifactId>
<version>${selenium.version}</version>
</dependency>

<!-- Drivers -->
<dependency>
Expand Down Expand Up @@ -154,6 +160,16 @@
<artifactId>selenium-remote-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit3-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons.validator.version}</version>
</dependency>

<dependency>
<groupId>org.jboss.arquillian</groupId>
Expand Down Expand Up @@ -610,30 +626,6 @@
<dballocator.skip>false</dballocator.skip>
</properties>
</profile>

<!-- Workaround for issues related to PhantomJS in some newer linux environment. See for example here for more details https://github.com/nodejs/node/issues/43132 -->
<profile>
<id>phantomjs-openssl-workaround</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<OPENSSL_CONF>/dev/null</OPENSSL_CONF>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

</project>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${auth.server.home}</outputDirectory>
<outputDirectory>${auth.server.home}/conf</outputDirectory>
<resources>
<resource>
<directory>${common.resources}/keystore</directory>
<includes>
<include>ca.crt</include>
<include>client.crt</include>
<include>client.key</include>
<include>client.p12</include>
<include>client-ca.crt</include>
<include>client-ca.key</include>
<include>*.crl</include>
Expand All @@ -80,7 +81,9 @@
<directory>${common.resources}/pki/root/ca</directory>
<includes>
<include>certs/clients/test-user-san@localhost.cert.pem</include>
<include>certs/clients/test-user-san@localhost.p12</include>
<include>certs/clients/test-user@localhost.key.pem</include>
<include>certs/clients/test-user-san-cert-test-user-key@localhost.p12</include>
</includes>
</resource>
</resources>
Expand Down
13 changes: 9 additions & 4 deletions testsuite/integration-arquillian/tests/base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
<!--exclude cluster tests by default, enabled by 'auth-server-*-cluster' profiles in tests/pom.xml-->
<exclude.cluster>**/cluster/**/*Test.java</exclude.cluster>
<exclude.crossdc>**/crossdc/**/*Test.java</exclude.crossdc>
<mvel.version>2.4.0.Final</mvel.version>
<mvel.version>2.5.2.Final</mvel.version>
<systemrules.version>1.19.0</systemrules.version>
<common.resources>${basedir}/../../servers/auth-server/common</common.resources>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>

<dependencies>
Expand Down Expand Up @@ -208,6 +208,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.io.File;
import java.net.MalformedURLException;

/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
public class KeycloakDronePostSetup {
public static final String HTML_UNIT_SSL_KEYSTORE_PROP = "htmlunit-ssl-keystore";
public static final String HTML_UNIT_SSL_KEYSTORE_PASSWORD_PROP = "htmlunit-ssl-keystore-password";
public static final String HTML_UNIT_SSL_KEYSTORE_TYPE_PROP = "htmlunit-ssl-keystore-type";

@Inject
@ClassScoped // needed in BrowserDriverIgnoreDecider
Expand All @@ -54,22 +60,19 @@ public void configureWebDriver(@Observes AfterDroneEnhanced event, DroneContext
DronePoint<?> dronePoint = event.getDronePoint();
Object drone = droneContext.get(dronePoint).getInstance();

if (drone instanceof RemoteWebDriver) {
RemoteWebDriver remoteWebDriver = (RemoteWebDriver) drone;
log.infof("Detected browser: %s %s", remoteWebDriver.getCapabilities().getBrowserName(), remoteWebDriver.getCapabilities().getVersion());
if (drone instanceof RemoteWebDriver remoteWebDriver) {
log.infof("Detected browser: %s %s", remoteWebDriver.getCapabilities().getBrowserName(), remoteWebDriver.getCapabilities().getBrowserVersion());
webDriverProducer.set(remoteWebDriver);
}

if (drone instanceof WebDriver && !(drone instanceof AppiumDriver)) {
WebDriver webDriver = (WebDriver) drone;
if (drone instanceof WebDriver webDriver && !(drone instanceof AppiumDriver)) {
configureDriverSettings(webDriver);
webDriverProducer.set(webDriver);
} else {
log.warn("Drone is not instanceof WebDriver for a desktop browser! Drone is " + drone);
}

if (drone instanceof GrapheneProxyInstance) {
GrapheneProxyInstance droneProxy = (GrapheneProxyInstance) drone;
if (drone instanceof GrapheneProxyInstance droneProxy) {
if (drone instanceof HtmlUnitDriver) {
droneProxy.registerInterceptor(new HtmlUnitInterceptor());
}
Expand All @@ -89,11 +92,11 @@ private void configureDriverSettings(WebDriver driver) {
driver.manage().window().maximize();

configureFirefoxDriver(driver);
configureHtmlUnitDriver(driver);
}

private void configureFirefoxDriver(WebDriver driver) {
if (driver instanceof FirefoxDriver) {
FirefoxDriver firefoxDriver = (FirefoxDriver) driver;
if (driver instanceof FirefoxDriver firefoxDriver) {
Capabilities capabilities = firefoxDriver.getCapabilities();
FirefoxOptions options = new FirefoxOptions(capabilities);
// disables extension automatic updates as we don't need it when running the test suite
Expand All @@ -102,6 +105,28 @@ private void configureFirefoxDriver(WebDriver driver) {
}
}

private void configureHtmlUnitDriver(WebDriver driver) {
if (driver instanceof HtmlUnitDriver htmlUnitDriver) {
final var keystore = System.getProperty(HTML_UNIT_SSL_KEYSTORE_PROP);
final var keystorePassword = System.getProperty(HTML_UNIT_SSL_KEYSTORE_PASSWORD_PROP);
final var keystoreType = System.getProperty(HTML_UNIT_SSL_KEYSTORE_TYPE_PROP);

log.info("Check HtmlUnit driver TLS settings");

if (keystore != null && keystorePassword != null && keystoreType != null) {
Comment thread
mabartos marked this conversation as resolved.
Resolved
log.infof("Keystore '%s', password '%s', type '%s'", keystore, keystorePassword, keystoreType);

var options = htmlUnitDriver.getWebClient().getOptions();
options.setUseInsecureSSL(true);
try {
options.setSSLClientCertificateKeyStore(new File(keystore).toURI().toURL(), keystorePassword, keystoreType);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
}

public static class HtmlUnitInterceptor implements Interceptor {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.jboss.arquillian.drone.webdriver.spi.BrowserCapabilitiesRegistry;
import org.jboss.logging.Logger;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

Expand All @@ -53,33 +52,16 @@ public void createConfiguration(@Observes BeforeDroneInstantiated event, DroneCo
DesiredCapabilities capabilitiesToAdd = new DesiredCapabilities();
updateCapabilityKeys("htmlUnit", webDriverCfg, capabilitiesToAdd);
updateCapabilityKeys("appium", webDriverCfg, capabilitiesToAdd);
configurePhantomJSDriver(webDriverCfg, capabilitiesToAdd);
acceptAllSSLCerts(webDriverCfg, capabilitiesToAdd);

BrowserCapabilities browserCap = registryInstance.get().getEntryFor(webDriverCfg.getBrowser());
webDriverCfg.setBrowserInternal(new KcBrowserCapabilities(capabilitiesToAdd, browserCap));
}

private void acceptAllSSLCerts(WebDriverConfiguration webDriverCfg, DesiredCapabilities capabilitiesToAdd) {
capabilitiesToAdd.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilitiesToAdd.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
}

private void configurePhantomJSDriver(WebDriverConfiguration webDriverCfg, DesiredCapabilities capabilitiesToAdd) {
if (!webDriverCfg.getBrowser().equals("phantomjs")) {
return;
}

String cliArgs = System.getProperty("keycloak.phantomjs.cli.args");

if (cliArgs == null) {
cliArgs = "--ignore-ssl-errors=true --web-security=false";
}

capabilitiesToAdd.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgs);
}


// This is to ensure that default value of capabilities like "version" will be used just for the HtmlUnitDriver, but not for other drivers.
// Hence in configs we have "htmlUnit.version" instead of "version"
private void updateCapabilityKeys(String browser, WebDriverConfiguration webDriverCfg, DesiredCapabilities capabilitiesToAdd, String... exclude) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -66,7 +68,7 @@ public static void waitUntilHidden() {
private static void waitUntilDisplayedOrHidden(boolean displayed) {
ExpectedCondition condition = ExpectedConditions.visibilityOfElementLocated(By.className(ALERT_CLASS_NAME));
condition = displayed ? condition : ExpectedConditions.not(condition);
new WebDriverWait(getCurrentDriver(), PAGELOAD_TIMEOUT_MILLIS / 1000).until(condition);
new WebDriverWait(getCurrentDriver(), Duration.ofMillis(PAGELOAD_TIMEOUT_MILLIS)).until(condition);
}

public String getText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.keycloak.testsuite.util;

import com.gargoylesoftware.htmlunit.WebClient;
import org.htmlunit.WebClient;
import org.jboss.arquillian.drone.webdriver.htmlunit.DroneHtmlUnitDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Qualifier
public @interface PhantomJSBrowser {
public @interface HtmlUnitBrowser {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;
import java.util.Optional;
import java.util.function.Supplier;

Expand Down Expand Up @@ -45,7 +46,7 @@ public static boolean selectContainsOption(Select select, String optionText) {

public static boolean currentTitleEquals(String url) {
try {
(new WebDriverWait(getCurrentDriver(), 5)).until(ExpectedConditions.titleIs(url));
(new WebDriverWait(getCurrentDriver(), Duration.ofSeconds(5))).until(ExpectedConditions.titleIs(url));
}
catch (TimeoutException e) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openqa.selenium.support.ui.WebDriverWait;

import java.net.URI;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -90,7 +91,7 @@ private static boolean urlCheck(ExpectedCondition condition) {
WebDriver driver = getCurrentDriver();

try {
(new WebDriverWait(driver, 5, 100)).until(condition);
(new WebDriverWait(driver, Duration.ofSeconds(5), Duration.ofMillis(100))).until(condition);
} catch (TimeoutException e) {
return false;
}
Expand Down
Loading
0