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

Page object refactoring for two additional tests #2490

Merged
merged 5 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -38,7 +38,6 @@
import org.cloudfoundry.identity.uaa.util.RetryRule;
import org.cloudfoundry.identity.uaa.zone.IdentityZone;
import org.cloudfoundry.identity.uaa.zone.IdentityZoneConfiguration;
import org.cloudfoundry.identity.uaa.zone.IdentityZoneHolder;
import org.flywaydb.core.internal.util.StringUtils;
import org.hamcrest.Matchers;
import org.junit.After;
Expand Down Expand Up @@ -445,21 +444,11 @@ public void testSingleLogoutWithNoLogoutUrlOnIDP() throws Exception {

provider = IntegrationTestUtils.createOrUpdateProvider(zoneAdminToken, baseUrl, provider);

webDriver.get(baseUrl + "/login");
Assert.assertEquals("Cloud Foundry", webDriver.getTitle());
webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
webDriver.findElement(By.xpath(SIMPLESAMLPHP_LOGIN_PROMPT_XPATH_EXPR));
webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName());
webDriver.findElement(By.name("password")).sendKeys(testAccounts.getPassword());
webDriver.findElement(By.xpath("//input[@value='Login']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to"));

webDriver.findElement(By.cssSelector(".dropdown-trigger")).click();
webDriver.findElement(By.linkText("Sign Out")).click();
webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();

assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to"));
LoginPage.go(webDriver, baseUrl)
.startSamlLogin()
.login(testAccounts.getUserName(), testAccounts.getPassword())
.logout()
.automaticSamlLogin();
swalchemist marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ public LoginPage(WebDriver driver) {
// When there is a SAML integration, there is a link to go to a SAML login page instead. This assumes there is
// only one SAML link.
public SamlLoginPage startSamlLogin() {
driver.findElement(By.className("saml-login-link")).click();
clickFirstSamlLoginLink();
return new SamlLoginPage(driver);
}

// If the SAML IDP has no logout URL in the metadata, logging out of UAA will leave
// the IDP still logged in, and when going back to the SAML login page, it will log
// the app back in automatically and immediately redirect to the post-login page.
public HomePage automaticSamlLogin() {
clickFirstSamlLoginLink();
return new HomePage(driver);
}

private void clickFirstSamlLoginLink() {
driver.findElement(By.className("saml-login-link")).click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public LoginPage begin(String baseUrl) {
}

public LoginPage logout() {
clickLogout();
return new LoginPage(driver);
}

private void clickLogout() {
driver.findElement(By.cssSelector(".dropdown-trigger")).click();
driver.findElement(By.linkText("Sign Out")).click();
return new LoginPage(driver);
}
}