/** * @see By#linkText(java.lang.String) * @since 3.1 */ public static By byLinkText(String linkText) { return By.linkText(linkText); }
public WebElement findClientRegistrationByName(String clientName) { return DefaultLoginPage.this.driver.findElement(By.linkText(clientName)); }
private void logout() { webDriver.findElement(By.cssSelector(".dropdown-trigger")).click(); webDriver.findElement(By.linkText("Sign Out")).click(); }
private void signOut() { webDriver.findElement(By.xpath("//*[text()='"+userEmail+"']")).click(); webDriver.findElement(By.linkText("Sign Out")).click(); }
private void changePassword(String originalPassword, String newPassword, String confirmPassword) { webDriver.findElement(By.xpath("//*[text()='"+userEmail+"']")).click(); webDriver.findElement(By.linkText("Account Settings")).click(); webDriver.findElement(By.linkText("Change Password")).click(); webDriver.findElement(By.name("current_password")).sendKeys(originalPassword); webDriver.findElement(By.name("new_password")).sendKeys(newPassword); webDriver.findElement(By.name("confirm_password")).sendKeys(confirmPassword); webDriver.findElement(By.xpath("//input[@value='Change password']")).click(); }
private void validateSuccessfulOIDCLogin(String zoneUrl, String userName, String password) { login(zoneUrl, userName, password); webDriver.findElement(By.cssSelector(".dropdown-trigger")).click(); webDriver.findElement(By.linkText("Sign Out")).click(); IntegrationTestUtils.validateAccountChooserCookie(zoneUrl, webDriver); }
private void beginPasswordReset(String username) { webDriver.get(baseUrl + "/login"); Assert.assertEquals("Cloud Foundry", webDriver.getTitle()); webDriver.findElement(By.linkText("Reset password")).click(); Assert.assertEquals("Reset Password", webDriver.findElement(By.tagName("h1")).getText()); // Enter email address webDriver.findElement(By.name("username")).sendKeys(username); webDriver.findElement(By.xpath("//input[@value='Send reset password link']")).click(); Assert.assertEquals("Instructions Sent", webDriver.findElement(By.tagName("h1")).getText()); }
@Test public void testQRCodeScreen_ClickManualAndReturn() throws Exception{ performLogin(username); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); webDriver.findElement(By.linkText("manual setup instructions")).click(); assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl()); webDriver.findElement(By.id("Back")).click(); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); String imageSrc = webDriver.findElement(By.id("qr")).getAttribute("src"); String secretKey = getSecretFromQrImageString(imageSrc); webDriver.findElement(By.id("Next")).click(); verifyCodeOnRegistration(secretKey, "/"); }
@Test public void testManualMfaRegistrationFlow() { performLogin(username); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); webDriver.findElement(By.linkText("manual setup instructions")).click(); assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl()); String key = webDriver.findElement(By.id("key")).getText(); String account = webDriver.findElement(By.id("account")).getText(); assertFalse("secret not found", key.isEmpty()); assertFalse("account not found", account.isEmpty()); webDriver.findElement(By.id("Next")).click(); assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl()); verifyCodeOnRegistration(key, "/"); }
@Test public void testManualMfaRegistrationFlow_ClickBackAndManual() { performLogin(username); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); webDriver.findElement(By.linkText("manual setup instructions")).click(); assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl()); webDriver.findElement(By.id("Back")).click(); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); webDriver.findElement(By.linkText("manual setup instructions")).click(); assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl()); String key = webDriver.findElement(By.id("key")).getText(); String account = webDriver.findElement(By.id("account")).getText(); assertFalse("secret not found", key.isEmpty()); assertFalse("account not found", account.isEmpty()); webDriver.findElement(By.id("Next")).click(); assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl()); verifyCodeOnRegistration(key, "/"); }
@Test public void testQRCodeScreen_ClickManualClickNextClickBack() throws Exception{ performLogin(username); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); webDriver.findElement(By.linkText("manual setup instructions")).click(); assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl()); webDriver.findElement(By.id("Next")).click(); assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl()); webDriver.findElement(By.id("Back")).click(); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); String imageSrc = webDriver.findElement(By.id("qr")).getAttribute("src"); String secretKey = getSecretFromQrImageString(imageSrc); assertFalse("secret not found", secretKey.isEmpty()); webDriver.findElement(By.id("Next")).click(); verifyCodeOnRegistration(secretKey, "/"); }
@Test public void login_with_wrong_keys() throws Exception { identityProvider.getConfig().setTokenKeyUrl(new URL("https://login.microsoftonline.com/9bc40aaf-e150-4c30-bb3c-a8b3b677266e/discovery/v2.0/keys")); updateProvider(); webDriver.get(zoneUrl + "/login"); webDriver.findElement(By.linkText("My OIDC Provider")).click(); Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl)); webDriver.findElement(By.name("username")).sendKeys("marissa"); webDriver.findElement(By.name("password")).sendKeys("koala"); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); Assert.assertThat(webDriver.getCurrentUrl(), containsString(zoneUrl + "/oauth_error?error=There+was+an+error+when+authenticating+against+the+external+identity+provider")); List<String> cookies = IntegrationTestUtils.getAccountChooserCookies(zoneUrl, webDriver); assertThat(cookies, not(Matchers.hasItem(startsWith("Saved-Account-")))); }
public String testChangeEmail(boolean logout) throws Exception { signIn(userEmail, "secr3T"); int receivedEmailSize = simpleSmtpServer.getReceivedEmailSize(); webDriver.get(baseUrl + "/profile"); Assert.assertEquals(userEmail, webDriver.findElement(By.cssSelector(".profile .email")).getText()); webDriver.findElement(By.linkText("Change Email")).click(); Assert.assertEquals("Current Email Address: " + userEmail, webDriver.findElement(By.cssSelector(".email-display")).getText()); String newEmail = userEmail.replace("user", "new"); webDriver.findElement(By.name("newEmail")).sendKeys(newEmail); webDriver.findElement(By.xpath("//input[@value='Send Verification Link']")).click(); assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Instructions Sent")); assertEquals(receivedEmailSize + 1, simpleSmtpServer.getReceivedEmailSize()); Iterator receivedEmail = simpleSmtpServer.getReceivedEmail(); SmtpMessage message = (SmtpMessage) receivedEmail.next(); receivedEmail.remove(); assertEquals(newEmail, message.getHeaderValue("To")); assertThat(message.getBody(), containsString("Verify your email")); String link = testClient.extractLink(message.getBody()); assertFalse(contains(link, "@")); assertFalse(contains(link, "%40")); if (logout) { webDriver.get(baseUrl + "/logout.do"); } webDriver.get(link); return newEmail; }
private void login(String zoneUrl, String userName, String password) { webDriver.get(zoneUrl + "/logout.do"); webDriver.get(zoneUrl + "/"); Cookie beforeLogin = webDriver.manage().getCookieNamed("JSESSIONID"); assertNotNull(beforeLogin); assertNotNull(beforeLogin.getValue()); webDriver.findElement(By.linkText("My OIDC Provider")).click(); Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl)); webDriver.findElement(By.name("username")).sendKeys(userName); webDriver.findElement(By.name("password")).sendKeys(password); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); Assert.assertThat(webDriver.getCurrentUrl(), containsString(zoneUrl)); assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?")); Cookie afterLogin = webDriver.manage().getCookieNamed("JSESSIONID"); assertNotNull(afterLogin); assertNotNull(afterLogin.getValue()); assertNotEquals(beforeLogin.getValue(), afterLogin.getValue()); }
webDriver.get(baseUrl + "/oauth/authorize?client_id=" + authCodeClientId + "&redirect_uri=http://example.redirect.com&grant_type=authorization_code&response_type=code"); webDriver.findElement(By.linkText("Reset password")).click(); Assert.assertEquals("Reset Password", webDriver.findElement(By.tagName("h1")).getText());
@Test public void testSingleLogoutWithNoLogoutUrlOnIDP() throws Exception { SamlIdentityProviderDefinition providerDefinition = createIDPWithNoSLOSConfigured(SAML_ORIGIN); IdentityProvider<SamlIdentityProviderDefinition> provider = new IdentityProvider(); provider.setIdentityZoneId(OriginKeys.UAA); provider.setType(OriginKeys.SAML); provider.setActive(true); provider.setConfig(providerDefinition); provider.setOriginKey(providerDefinition.getIdpEntityAlias()); provider.setName("simplesamlphp for uaa"); String zoneAdminToken = getZoneAdminToken(baseUrl, serverRunning); 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("//h2[contains(text(), 'Enter your username and password')]")); 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")); }
webDriver.findElement(By.linkText("My OIDC Provider")).click(); Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl)); webDriver.findElement(By.linkText("SAML Login")).click(); webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]")); webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.linkText("Login with Simple SAML PHP(simplesamlphp)")).click(); webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]")); webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.linkText("My OIDC Provider")).click();