Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use page objects for favicon test #2498

Merged
merged 3 commits into from
Oct 4, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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."));
}
}