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 38128136799..057b17a9c8e 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 @@ -16,6 +16,7 @@ import org.cloudfoundry.identity.uaa.ServerRunning; import org.cloudfoundry.identity.uaa.account.UserInfoResponse; import org.cloudfoundry.identity.uaa.constants.OriginKeys; +import org.cloudfoundry.identity.uaa.integration.pageObjects.FaviconElement; import org.cloudfoundry.identity.uaa.integration.pageObjects.LoginPage; import org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils; import org.cloudfoundry.identity.uaa.integration.util.ScreenshotOnFail; @@ -465,8 +466,11 @@ public void testGroupIntegration() throws Exception { @Test public void testFavicon_Should_Not_Save() throws Exception { - webDriver.get(baseUrl + "/favicon.ico"); - testSimpleSamlLogin("/login", "Where to?", MARISSA4_USERNAME, MARISSA4_PASSWORD); + createIdentityProvider(SAML_ORIGIN); + FaviconElement.getDefaultIcon(webDriver, baseUrl); + LoginPage.go(webDriver, baseUrl) + .clickSamlLink_goToSamlLoginPage() + .login_goToHomePage(MARISSA4_USERNAME, MARISSA4_PASSWORD); } diff --git a/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/FaviconElement.java b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/FaviconElement.java new file mode 100644 index 00000000000..8de2b522a2a --- /dev/null +++ b/uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/FaviconElement.java @@ -0,0 +1,24 @@ +package org.cloudfoundry.identity.uaa.integration.pageObjects; + +import org.openqa.selenium.WebDriver; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.endsWith; +import static org.junit.Assert.assertThat; + +public class FaviconElement extends Page { + + // The favicon.ico image is not present on the server because we specify a custom icon URL + // in the headers, but browsers try to hit it and tests need to hit this default URL. + static public FaviconElement getDefaultIcon(WebDriver driver, String baseUrl) { + driver.get(baseUrl + "/favicon.ico"); + return new FaviconElement(driver); + } + + // Expect a 404 error when landing on the favicon URL. + public FaviconElement(WebDriver driver) { + super(driver); + assertThat("Should be on the favicon image", driver.getCurrentUrl(), endsWith("/favicon.ico")); + assertThat(driver.getPageSource(), containsString("Something went amiss.")); + } +} \ No newline at end of file