Upgrade Selenium and Arquillian dependencies in testsuite

Closes #29778

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
Martin Bartoš 2024-05-22 13:15:08 +02:00 committed by Marek Posolda
parent 711a8f5447
commit b1a90972b6
20 changed files with 79 additions and 115 deletions

View file

@ -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:**

View file

@ -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>
@ -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>
@ -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>

View file

@ -42,7 +42,7 @@
<!--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>
@ -208,6 +208,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

View file

@ -56,7 +56,7 @@ public class KeycloakDronePostSetup {
if (drone instanceof RemoteWebDriver) {
RemoteWebDriver remoteWebDriver = (RemoteWebDriver) drone;
log.infof("Detected browser: %s %s", remoteWebDriver.getCapabilities().getBrowserName(), remoteWebDriver.getCapabilities().getVersion());
log.infof("Detected browser: %s %s", remoteWebDriver.getCapabilities().getBrowserName(), remoteWebDriver.getCapabilities().getBrowserVersion());
webDriverProducer.set(remoteWebDriver);
}

View file

@ -61,7 +61,6 @@ public class KeycloakWebDriverConfigurator {
}
private void acceptAllSSLCerts(WebDriverConfiguration webDriverCfg, DesiredCapabilities capabilitiesToAdd) {
capabilitiesToAdd.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilitiesToAdd.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
}

View file

@ -27,6 +27,8 @@ import org.openqa.selenium.support.ui.ExpectedCondition;
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;
@ -66,7 +68,7 @@ public abstract class AbstractPatternFlyAlert {
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() {

View file

@ -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;

View file

@ -17,6 +17,7 @@ import org.openqa.selenium.support.ui.ExpectedConditions;
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;
@ -45,7 +46,7 @@ public final class UIUtils {
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;

View file

@ -9,6 +9,7 @@ import org.openqa.selenium.support.ui.ExpectedCondition;
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;
@ -90,7 +91,7 @@ public final class URLUtils {
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;
}

View file

@ -78,7 +78,7 @@ public final class WaitUtils {
}
public static void waitUntilElementClassContains(WebElement element, String value) {
new WebDriverWait(getCurrentDriver(), 1).until(
new WebDriverWait(getCurrentDriver(), Duration.ofSeconds(1)).until(
ExpectedConditions.attributeContains(element, "class", value)
);
}
@ -105,7 +105,7 @@ public final class WaitUtils {
return; // not needed
}
WebDriverWait wait = new WebDriverWait(driver, PAGELOAD_TIMEOUT_MILLIS / 1000);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofMillis(PAGELOAD_TIMEOUT_MILLIS));
try {
wait

View file

@ -369,11 +369,6 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
// Click browser 'back' on review profile page
idpConfirmLinkPage.clickReviewProfile();
// Need to confirm again with htmlUnit due the JS not working correctly
if (driver instanceof HtmlUnitDriver) {
idpConfirmLinkPage.assertCurrent();
idpConfirmLinkPage.clickReviewProfile();
}
waitForPage(driver, "update account information", false);
updateAccountInformationPage.assertCurrent();
driver.navigate().back();

View file

@ -14,6 +14,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -62,7 +63,7 @@ public class BrokerTestTools {
public static void waitForPage(final WebDriver driver, final String title, final boolean isHtmlTitle) {
waitForPageToLoad();
WebDriverWait wait = new WebDriverWait(driver, 5);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
ExpectedCondition<Boolean> condition = new ExpectedCondition<Boolean>() {
private String actualTitle = null;
@ -89,7 +90,7 @@ public class BrokerTestTools {
}
public static void waitForElementEnabled(WebDriver driver, final String elementName) {
WebDriverWait wait = new WebDriverWait(driver, 5);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
ExpectedCondition<Boolean> condition = (WebDriver input) -> {
List<WebElement> elements = input.findElements(By.name(elementName));

View file

@ -39,6 +39,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -190,7 +191,7 @@ public class KcSamlIdPInitiatedSsoTest extends AbstractKeycloakTest {
}
private void waitForPage(final String title, final boolean htmlTitle) {
WebDriverWait wait = new WebDriverWait(driver, 5);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
ExpectedCondition<Boolean> condition = (WebDriver input) -> htmlTitle ? input.getTitle().toLowerCase().contains(title) : PageUtils.getPageTitle(input).toLowerCase().contains(title);

View file

@ -17,7 +17,7 @@
package org.keycloak.testsuite.oauth;
import com.fasterxml.jackson.databind.JsonNode;
import com.gargoylesoftware.htmlunit.WebClient;
import org.htmlunit.WebClient;
import java.io.Closeable;
import org.hamcrest.CoreMatchers;
import org.jboss.arquillian.drone.webdriver.htmlunit.DroneHtmlUnitDriver;

View file

@ -65,6 +65,7 @@ import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.util.PhantomJSBrowser;
import org.keycloak.testsuite.util.RealmBuilder;
import org.keycloak.testsuite.util.UserBuilder;
import org.keycloak.testsuite.util.WaitUtils;
import org.keycloak.userprofile.UserProfileConstants;
import org.openqa.selenium.WebDriver;
@ -573,6 +574,8 @@ public abstract class AbstractX509AuthenticationTest extends AbstractTestRealmKe
loginConfirmationPage.open();
WaitUtils.waitForPageToLoad();
Assert.assertTrue(loginConfirmationPage.getSubjectDistinguishedNameText().startsWith("EMAILADDRESS=test-user@localhost"));
Assert.assertEquals(username, loginConfirmationPage.getUsernameText());

View file

@ -36,7 +36,7 @@
<property name="firefoxLegacy">${firefoxLegacyDriver}</property>
<property name="firefoxDriverVersion">${firefoxDriverVersion}</property>
<property name="firefoxUserPreferences">${firefoxUserPreferences}</property>
<property name="firefoxHeadless">${firefoxHeadless}</property>
<property name="firefoxArguments">${firefoxArguments}</property>
<!-- chrome -->
<property name="chromeBinary">${chromeBinary}</property>
@ -83,7 +83,7 @@
<property name="firefoxLegacy">${firefoxLegacyDriver}</property>
<property name="firefoxDriverVersion">${firefoxDriverVersion}</property>
<property name="firefoxUserPreferences">${firefoxUserPreferences}</property>
<property name="firefoxHeadless">${firefoxHeadless}</property>
<property name="firefoxArguments">${firefoxArguments}</property>
<!-- chrome -->
<property name="chromeBinary">${chromeBinary}</property>

View file

@ -13,38 +13,17 @@
<name>WebAuthn tests</name>
<properties>
<selenium.version>4.1.0</selenium.version>
<graphene.webdriver.version>3.0.0-alpha.3</graphene.webdriver.version>
<htmlunit.driver.version>3.58.0</htmlunit.driver.version>
<arquillian.drone.version>3.0.0-alpha.4</arquillian.drone.version>
<firefoxUserPreferences>${project.build.directory}/dependency/firefox-user-preferences.js
</firefoxUserPreferences>
<selenium.firefox.driver.version>4.1.2</selenium.firefox.driver.version>
<firefoxUserPreferences>${project.build.directory}/dependency/firefox-user-preferences.js</firefoxUserPreferences>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-bom</artifactId>
<version>${arquillian.drone.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-webdriver</artifactId>
<version>${arquillian.drone.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver</artifactId>
<version>${graphene.webdriver.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>${htmlunit.driver.version}</version>
<artifactId>htmlunit3-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
@ -68,13 +47,6 @@
<value>firefox</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${selenium.firefox.driver.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View file

@ -17,7 +17,6 @@
package org.keycloak.testsuite.webauthn.pages.fragments;
import org.jboss.arquillian.graphene.fragment.Root;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.TimeoutException;
@ -32,17 +31,25 @@ import static org.keycloak.testsuite.util.WaitUtils.waitUntilElementIsNotPresent
/**
* @author Vaclav Muzikar <vmuzikar@redhat.com>
*
* Page fragments seem not to be working after migration from CGlib to ByteBuddy in Graphene
*/
public class ContentAlert {
private static final String ROOT_ID = "//ul[@data-testid='alerts']/li[1]";
private static final String ROOT_ID = "//ul[@data-testid='alerts']/li[1]//div";
//The first alert from the alert group is what we are interested in.
@FindBy(xpath = ROOT_ID + "//div")
private AlertElement alertElement;
@FindBy(xpath = ROOT_ID)
private WebElement alertElementRoot;
@FindBy(className = ROOT_ID + "[@class='pf-v5-c-alert__title']")
private WebElement messageElement;
@FindBy(className = ROOT_ID + "[@class='pf-v5-c-alert__action']")
private WebElement closeBtn;
public boolean isDisplayed() {
try {
return alertElement.getRoot().isDisplayed();
return alertElementRoot.isDisplayed();
}
catch (NoSuchElementException e) {
return false;
@ -62,16 +69,16 @@ public class ContentAlert {
}
public String getMessage() {
return getTextFromElement(alertElement.getMessageElement());
return getTextFromElement(messageElement);
}
public void close() {
alertElement.getCloseBtn().click();
closeBtn.click();
assertIsNotDisplayed();
}
protected void assertAlertType(String type) {
assertTrue("Alert is not " + type, doesElementClassContain(alertElement.getRoot(), type));
assertTrue("Alert is not " + type, doesElementClassContain(alertElementRoot, type));
}
protected void assertMessage(String expectedMessage) {
@ -113,31 +120,4 @@ public class ContentAlert {
assertInfo();
assertMessage(expectedMessage);
}
/**
* Elements are placed into a separate class to leverage Page Fragment functionality so that all elements are found
* under the Root element.
*/
private class AlertElement {
@Root
private WebElement root;
@FindBy(className = "pf-v5-c-alert__title")
private WebElement messageElement;
@FindBy(className = "pf-v5-c-alert__action")
private WebElement closeBtn;
public WebElement getRoot() {
return root;
}
public WebElement getMessageElement() {
return messageElement;
}
public WebElement getCloseBtn() {
return closeBtn;
}
}
}
}

View file

@ -16,7 +16,6 @@
*/
package org.keycloak.testsuite.webauthn.registration;
import com.beust.jcommander.internal.Lists;
import com.webauthn4j.data.attestation.authenticator.COSEKey;
import com.webauthn4j.data.attestation.statement.COSEAlgorithmIdentifier;
import org.junit.Test;
@ -46,12 +45,12 @@ public class PubKeySignRegisterTest extends AbstractWebAuthnVirtualTest {
@Test
public void publicKeySignaturesWrong() {
assertPublicKeyAlgorithms(false, null, Lists.newArrayList(RS512, ES512));
assertPublicKeyAlgorithms(false, null, List.of(RS512, ES512));
}
@Test
public void publicKeySignaturesAlternatives() {
assertPublicKeyAlgorithms(true, COSEAlgorithmIdentifier.ES256, Lists.newArrayList(ES256, ES512));
assertPublicKeyAlgorithms(true, COSEAlgorithmIdentifier.ES256, List.of(ES256, ES512));
}
@Test
@ -61,7 +60,7 @@ public class PubKeySignRegisterTest extends AbstractWebAuthnVirtualTest {
@Test
public void publicKeySignaturesRSA() {
assertPublicKeyAlgorithms(false, null, Lists.newArrayList(RS384, ES512));
assertPublicKeyAlgorithms(false, null, List.of(RS384, ES512));
}
@Test

View file

@ -215,15 +215,15 @@
<ieDriverArch>Win32</ieDriverArch>
<ieDriverVersion/>
<js.browser>chrome</js.browser>
<js.chromeArguments>--headless</js.chromeArguments>
<js.chromeArguments>--headless --ignore-ssl-errors=yes --ignore-certificate-errors</js.chromeArguments>
<htmlUnitBrowserVersion>chrome</htmlUnitBrowserVersion>
<firefox_binary/> <!-- the path is set automatically based on the OS -->
<firefoxLegacyDriver>false</firefoxLegacyDriver>
<firefoxDriverVersion/>
<firefoxUserPreferences/>
<firefoxHeadless>true</firefoxHeadless>
<firefoxArguments>-headless</firefoxArguments>
<chromeBinary/>
<chromeArguments>--headless --window-size=1920,1080 --remote-allow-origins=*</chromeArguments>
<chromeArguments>--headless --window-size=1920,1080 --remote-allow-origins=* --ignore-ssl-errors=yes --ignore-certificate-errors</chromeArguments>
<chromeDriverVersion/>
<appium.platformName/>
@ -600,7 +600,7 @@
<firefoxLegacyDriver>${firefoxLegacyDriver}</firefoxLegacyDriver>
<firefoxDriverVersion>${firefoxDriverVersion}</firefoxDriverVersion>
<firefoxUserPreferences>${firefoxUserPreferences}</firefoxUserPreferences>
<firefoxHeadless>${firefoxHeadless}</firefoxHeadless>
<firefoxArguments>${firefoxArguments}</firefoxArguments>
<appium.platformName>${appium.platformName}</appium.platformName>
<appium.deviceName>${appium.deviceName}</appium.deviceName>
@ -1862,17 +1862,6 @@
</dependencies>
<dependencyManagement>
<dependencies>
<!-- we need to specify the correct version because of conflict in arquillian-drone-webdriver-depchain -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.27</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
@ -2077,7 +2066,7 @@
<browser>firefox</browser>
<js.browser>firefox</js.browser>
<firefoxUserPreferences>${project.build.directory}/dependency/firefox-cookies-prefs.js</firefoxUserPreferences>
<firefoxHeadless>true</firefoxHeadless>
<firefoxArguments>-headless</firefoxArguments>
<browser.strict.cookies>true</browser.strict.cookies>
</properties>
</profile>