Refine search
@Test public void testFrameReportsChangedWhenSameUser_whenLoggedOut() throws UnsupportedEncodingException, InterruptedException { webDriver.get(testPage); webDriver.findElement(By.id("sameUser")).click(); assertMessage("unchanged"); }
@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-")))); }
private String startCreateUserFlow(String secret) { String userEmail = "user" + new SecureRandom().nextInt() + "@example.com"; webDriver.get(baseUrl + "/"); webDriver.findElement(By.xpath("//*[text()='Create account']")).click(); assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText()); webDriver.findElement(By.name("email")).sendKeys(userEmail); webDriver.findElement(By.name("password")).sendKeys(secret); webDriver.findElement(By.name("password_confirmation")).sendKeys(secret); webDriver.findElement(By.xpath("//input[@value='Send activation link']")).click(); return userEmail; }
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 loginThroughDiscovery(String userEmail, String password) { webDriver.findElement(By.id("email")).sendKeys(userEmail); webDriver.findElement(By.cssSelector(".form-group input[value='Next']")).click(); webDriver.findElement(By.id("password")).sendKeys(password); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); } }
public void advanced() { this.form.findElement(By.cssSelector(".tofullversion")) .findElement(By.tagName("a")).click(); }
@Test @RunAsClient public void test() throws Exception { driver.get(applicationURL().toString()); System.out.println(driver.getPageSource()); WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html[@bar]"))); WebElement elt = driver.findElement(By.tagName("html")); assertEquals("<bar>foo_value</bar>", elt.getAttribute("bar")); } }
@Test public void testEmailDomainRegisteredWithIDPDoesNotAllowAccountCreation() throws Exception { String adminToken = IntegrationTestUtils.getClientCredentialsToken(baseUrl, "admin", "adminsecret"); IdentityProvider<OIDCIdentityProviderDefinition> oidcProvider = new IdentityProvider().setName("oidc_provider").setActive(true).setType(OriginKeys.OIDC10).setOriginKey(OriginKeys.OIDC10).setConfig(new OIDCIdentityProviderDefinition()); 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")); oidcProvider.getConfig().setEmailDomain(Collections.singletonList("example.com")); oidcProvider.getConfig().setRelyingPartyId("client_id"); oidcProvider.getConfig().setRelyingPartySecret("client_secret"); IntegrationTestUtils.createOrUpdateProvider(adminToken, baseUrl, oidcProvider); try { startCreateUserFlow("test"); assertEquals("Account sign-up is not required for this email domain. Please login with the identity provider", webDriver.findElement(By.cssSelector(".alert-error")).getText()); webDriver.findElement(By.xpath("//input[@value='Login with provider']")).click(); assertThat(webDriver.getCurrentUrl(), startsWith(oidcProvider.getConfig().getAuthUrl().toString())); } finally { IntegrationTestUtils.deleteProvider(adminToken, baseUrl, OriginKeys.UAA, OriginKeys.OIDC10); } } }
URL inviteLink = response.getBody().getNewInvites().get(0).getInviteLink(); webDriver.get(inviteLink.toString()); webDriver.findElement(By.xpath("//h1[contains(text(), 'Welcome')]")); webDriver.findElement(By.name("username")).clear(); webDriver.findElement(By.name("username")).sendKeys("marissa"); webDriver.findElement(By.name("password")).sendKeys("koala"); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
@Test public void testAccountChooserFlow() throws Exception { String zoneUrl = createDiscoveryZone(); String userEmail = createAnotherUser(zoneUrl); webDriver.get(zoneUrl + "/logout.do"); webDriver.get(zoneUrl); loginThroughDiscovery(userEmail, USER_PASSWORD); webDriver.get(zoneUrl + "/logout.do"); webDriver.get(zoneUrl); assertEquals(userEmail, webDriver.findElement(By.className("email-address")).getText()); webDriver.findElement(By.className("email-address")).click(); assertEquals(userEmail, webDriver.findElement(By.id("username")).getAttribute("value")); webDriver.findElement(By.id("password")).sendKeys(USER_PASSWORD); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); assertEquals("Where to?", webDriver.findElement(By.cssSelector(".island 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, "/"); }
public void clickVisibilityOptionForResponseCommentAndSave(String idString, int numOfTheCheckbox) { String idSuffix = idString.substring(18); WebElement commentRow = browser.driver.findElement(By.id(idString)); click(commentRow.findElements(By.tagName("a")).get(1)); WebElement commentEditForm = browser.driver.findElement(By.id("responseCommentEditForm" + idSuffix)); click(commentRow.findElement(By.id("frComment-visibility-options-trigger" + idSuffix))); click(commentRow.findElements(By.cssSelector("input[type='checkbox']")).get(numOfTheCheckbox)); click(commentEditForm.findElement(By.className("col-sm-offset-5")).findElement(By.tagName("a"))); ThreadHelper.waitFor(1000); }
@Test public void testInvalidAppRedirectDisplaysError() throws Exception { ScimUser user = createUnapprovedUser(serverRunning); // given we vist the app (specifying an invalid redirect - incorrect protocol https) webDriver.get(appUrl + "?redirect_uri=https://localhost:8080/app/"); // Sign in to login server webDriver.findElement(By.name("username")).sendKeys(user.getUserName()); webDriver.findElement(By.name("password")).sendKeys(user.getPassword()); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); // Authorize the app for some scopes assertThat(webDriver.findElement(By.className("alert-error")).getText(), IntegrationTestUtils.RegexMatcher.matchesRegex("^Invalid redirect (.*) did not match one of the registered values")); }
@Test public void testQRCodeValidation() { performLogin(username); assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl()); webDriver.findElement(By.id("Next")).click(); assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl()); webDriver.findElement(By.name("code")).sendKeys("1111111111111111112222"); webDriver.findElement(By.id("verify_code_btn")).click(); assertEquals("Incorrect code, please try again.", webDriver.findElement(By.cssSelector("form .error-color")).getText()); }
@Test public void testDisplayIdentityZoneNameOnVerifyPage() { performLogin(username); webDriver.findElement(By.id("Next")).click(); assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl()); assertEquals(webDriver.findElement(By.id("mfa-identity-zone")).getText(), mfaZone.getName()); webDriver.findElement(By.id("verify_code_btn")).click(); assertEquals(webDriver.findElement(By.id("mfa-identity-zone")).getText(), mfaZone.getName()); }
@Test public void testMethodNotAllowedRoutedToErrorPage() throws Exception { webDriver.get(baseUrl + "/authenticate"); Assert.assertTrue("Check if on the error page", webDriver.findElement(By.tagName("h2")).getText().contains("Uh oh.")); Assert.assertTrue("Check if on the error page", webDriver.findElement(By.tagName("h2")).getText().contains("Something went amiss.")); } }
@Test public void displaysErrorWhenPasswordContravenesPolicy() { //the only policy we can contravene by default is the length String newPassword = new RandomValueStringGenerator(260).generate(); webDriver.get(baseUrl + "/change_password"); signIn(userEmail, PASSWORD); changePassword(PASSWORD, newPassword, newPassword); WebElement errorMessage = webDriver.findElement(By.className("error-message")); assertTrue(errorMessage.isDisplayed()); assertEquals("Password must be no more than 255 characters in length.", errorMessage.getText()); }
@Test public void testLoginHint() throws Exception { String newUserEmail = createAnotherUser(); webDriver.get(baseUrl + "/logout.do"); String ldapLoginHint = URLEncoder.encode("{\"origin\":\"ldap\"}", "UTF-8"); webDriver.get(baseUrl + "/login?login_hint=" + ldapLoginHint); assertEquals("Cloud Foundry", webDriver.getTitle()); attemptLogin(newUserEmail, USER_PASSWORD); assertThat(webDriver.findElement(By.className("alert-error")).getText(), containsString("Unable to verify email or password. Please try again.")); String uaaLoginHint = URLEncoder.encode("{\"origin\":\"uaa\"}", "UTF-8"); webDriver.get(baseUrl + "/login?login_hint=" + uaaLoginHint); assertEquals("Cloud Foundry", webDriver.getTitle()); attemptLogin(newUserEmail, USER_PASSWORD); assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to?")); webDriver.get(baseUrl + "/logout.do"); }
private void login() { WebElement userNameElement = waitForElementById("user_name", 60); WebElement passwordElement = waitForElementById("user_password"); userNameElement.sendKeys(username); passwordElement.sendKeys(password); passwordElement.submit(); driver.get(getPulseURL() + "clusterDetail.html"); WebElement userNameOnPulsePage = (new WebDriverWait(driver, 30, 1000)).until( (ExpectedCondition<WebElement>) d -> d.findElement(By.id("userName"))); assertNotNull(userNameOnPulsePage); }
public boolean isVisibilityDropdownOptionHidden(String optionValue, int qnNumber) { return browser.driver.findElement(By.id("questionTable-" + qnNumber)) .findElement(By.className("visibility-options-dropdown-option")) .findElement(By.xpath("//a[@data-option-name='" + optionValue + "']/..")) .getAttribute("class").contains("hidden"); }