diff --git a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/CreateAccountIT.java b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/CreateAccountIT.java index cc2e8bd63a9..4e63c95dfd7 100644 --- a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/CreateAccountIT.java +++ b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/CreateAccountIT.java @@ -183,7 +183,7 @@ private String startCreateUserFlow(String secret) { public void testEmailDomainRegisteredWithIDPDoesNotAllowAccountCreation() throws Exception { String adminToken = IntegrationTestUtils.getClientCredentialsToken(baseUrl, "admin", "adminsecret"); IdentityProvider 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")); diff --git a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/DefaultIntegrationTestConfig.java b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/DefaultIntegrationTestConfig.java index 98bdfeb671b..329ac8fad18 100644 --- a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/DefaultIntegrationTestConfig.java +++ b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/DefaultIntegrationTestConfig.java @@ -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", diff --git a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/OIDCLoginIT.java b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/OIDCLoginIT.java index e55d73ce24d..20a7a7debe7 100644 --- a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/OIDCLoginIT.java +++ b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/OIDCLoginIT.java @@ -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; @@ -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?")); diff --git a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/ResetPasswordIT.java b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/ResetPasswordIT.java index 39e14bdf627..12fbd547d5a 100644 --- a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/ResetPasswordIT.java +++ b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/ResetPasswordIT.java @@ -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 diff --git a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/SamlLoginIT.java b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/SamlLoginIT.java index 43ad9986d4c..2c01bf1f5c4 100644 --- a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/SamlLoginIT.java +++ b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/SamlLoginIT.java @@ -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; @@ -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"; @@ -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"); } diff --git a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/Page.java b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/Page.java index 6a5e2d63968..7373c8fd5db 100644 --- a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/Page.java +++ b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/Page.java @@ -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 { @@ -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)); + } }