Skip to content

Commit

Permalink
Test-Fix of chromdriver129 issue (#3062)
Browse files Browse the repository at this point in the history
* Fix issue on chrome 129

- issue and discussion SeleniumHQ/selenium#14514
- https://issues.chromium.org/issues/367755364

* Revert "Fix error in integration tests"

This reverts commit 66940b0.

* refactor ChromeDriver setup

* reset DefaultIntegrationTestConfig timeout changes

* test on timeout

* another test on timeout

* another test on timeout

* another test on timeout

* another test on timeout

* another test on timeout

* do not use hard coded Url
  • Loading branch information
strehle authored Sep 24, 2024
1 parent de61a50 commit 86d7d74
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private String startCreateUserFlow(String secret) {
public void testEmailDomainRegisteredWithIDPDoesNotAllowAccountCreation() throws Exception {
String adminToken = IntegrationTestUtils.getClientCredentialsToken(baseUrl, "admin", "adminsecret");
IdentityProvider<OIDCIdentityProviderDefinition> oidcProvider = new IdentityProvider().setName("oidc_provider").setActive(true).setType(OriginKeys.OIDC10).setOriginKey(OriginKeys.OIDC10).setConfig(new OIDCIdentityProviderDefinition());
oidcProvider.getConfig().setAuthUrl(new URL("https://example.com"));
oidcProvider.getConfig().setAuthUrl(new URL("http://example.com"));
oidcProvider.getConfig().setShowLinkText(false);
oidcProvider.getConfig().setTokenUrl(new URL("http://localhost:8080/uaa/idp_login"));
oidcProvider.getConfig().setTokenKeyUrl(new URL("http://localhost:8080/uaa/idp_login"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public ChromeDriver webDriver() {
ChromeOptions options = new ChromeOptions();
options.addArguments(
"--verbose",
"--headless",
"--headless=old",
"--window-position=-2400,-2400",
"--window-size=1024,768",
"--disable-web-security",
"--ignore-certificate-errors",
"--allow-running-insecure-content",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.cloudfoundry.identity.uaa.account.UserInfoResponse;
import org.cloudfoundry.identity.uaa.constants.OriginKeys;
import org.cloudfoundry.identity.uaa.integration.endpoints.SamlLogoutAuthSourceEndpoint;
import org.cloudfoundry.identity.uaa.integration.pageObjects.Page;
import org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils;
import org.cloudfoundry.identity.uaa.integration.util.ScreenshotOnFail;
import org.cloudfoundry.identity.uaa.oauth.client.test.TestAccounts;
Expand Down Expand Up @@ -486,6 +487,7 @@ public void successfulLoginWithOIDC_and_SAML_Provider_PlusRefreshRotation() thro
webDriver.findElement(By.name("password")).sendKeys("saml6");
webDriver.findElement(By.id("submit_button")).click();

Page.validateUrlStartsWithWait(webDriver, zoneUrl);
assertThat(webDriver.getCurrentUrl(), containsString(zoneUrl));
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void testNotAutoLoginAfterResetPassword() {
webDriver.findElement(By.name("password")).sendKeys("new_password");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();

assertThat(webDriver.getCurrentUrl(), startsWith("https://example.redirect.com/?code="));
assertThat(webDriver.getCurrentUrl(), startsWith("http://example.redirect.com/?code="));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
Expand Down Expand Up @@ -636,7 +635,7 @@ public void perform_SamlInvitation_Automatic_Redirect_In_Zone2(String username,
}

@Test
public void test_RelayState_redirect_from_idp() {
public void test_RelayState_redirect_from_idp() throws InterruptedException {
//ensure we are able to resolve DNS for hostname testzone1.localhost
String zoneId = "testzone1";

Expand Down Expand Up @@ -692,7 +691,7 @@ public void test_RelayState_redirect_from_idp() {
webDriver.findElement(By.xpath(SIMPLESAMLPHP_LOGIN_PROMPT_XPATH_EXPR));
sendCredentials(testAccounts.getUserName(), "koala");

assertThat(webDriver.getCurrentUrl(), startsWith("https://www.google.com"));
Page.validateUrlStartsWithWait(webDriver, "https://www.google.com");
webDriver.get(baseUrl + "/logout.do");
webDriver.get(zoneUrl + "/logout.do");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.cloudfoundry.identity.uaa.integration.pageObjects;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

import org.hamcrest.Matcher;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;

public class Page {
Expand Down Expand Up @@ -49,4 +51,11 @@ private void clickLogout() {
public void clearCookies() {
driver.manage().deleteAllCookies();
}

public static void validateUrlStartsWithWait(WebDriver driver, String currentUrlStart) throws InterruptedException {
if (!driver.getCurrentUrl().startsWith(currentUrlStart)) {
TimeUnit.SECONDS.sleep(5);
}
assertThat(driver.getCurrentUrl(), startsWith(currentUrlStart));
}
}

0 comments on commit 86d7d74

Please sign in to comment.