public void testLogInWithOpenIDAndSignUp() throws Exception {
    openid = createServer();

    realm = new HudsonPrivateSecurityRealm(true);
    hudson.setSecurityRealm(realm);

    WebClient wc = new WebClient();
    // Workaround failing ajax requests to build queue
    wc.setThrowExceptionOnFailingAjax(false);

    // Login with OpenID as an unregistered user
    HtmlPage login = wc.goTo("federatedLoginService/openid/login?from=/");
    login
        .getDocumentElement()
        .getOneHtmlElementByAttribute("a", "title", "log in with OpenID")
        .click();
    HtmlForm loginForm = getFormById(login, "openid_form");
    loginForm.getInputByName("openid").setValueAttribute(openid.url);
    HtmlPage signUp = (HtmlPage) loginForm.submit();

    // Sign up user
    HtmlForm signUpForm =
        getFormByAction(signUp, "/securityRealm/createAccountWithFederatedIdentity");
    signUpForm.getInputByName("password1").setValueAttribute("x");
    signUpForm.getInputByName("password2").setValueAttribute("x");
    HtmlPage loggedIn = submit(signUpForm);

    assertNotNull(loggedIn.getAnchorByHref("/logout"));
    assertNotNull(loggedIn.getAnchorByHref("/user/aliceW"));

    wc.goTo("logout");

    // Re-login
    login(wc);
  }
  private void login(WebClient wc) throws Exception {
    HtmlPage login = wc.goTo("federatedLoginService/openid/login?from=/");
    login
        .getDocumentElement()
        .getOneHtmlElementByAttribute("a", "title", "log in with OpenID")
        .click();
    HtmlForm loginForm = getFormById(login, "openid_form");
    loginForm.getInputByName("openid").setValueAttribute(openid.url);
    HtmlPage loggedIn = (HtmlPage) loginForm.submit();

    assertNotNull(loggedIn.getAnchorByHref("/logout"));
    assertNotNull(loggedIn.getAnchorByHref("/user/aliceW"));
  }
Пример #3
0
  public void testPreview() throws Exception {
    String name = uniqueWikiPageName("PreviewPageTest");
    HtmlPage editPage = clickEditLink(getWikiPage(name));
    HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    HtmlInput minorEdit = form.getInputByName("minorEdit");
    assertFalse(minorEdit.isChecked());
    minorEdit.setChecked(true);
    HtmlInput description = form.getInputByName("description");
    String expectedDescription = "My test change";
    description.setValueAttribute(expectedDescription);
    HtmlTextArea content = form.getTextAreaByName("content");
    String expectedContent = "http://www.example.com";
    content.setText(expectedContent);

    // Now if we preview we should get the previewed text rendered, and in
    // the edit area.  The other options should be preserved too.
    editPage = (HtmlPage) form.getInputByValue("Preview").click();
    form = editPage.getFormByName(ID_EDIT_FORM);
    minorEdit = form.getInputByName("minorEdit");
    description = form.getInputByName("description");
    content = form.getTextAreaByName("content");
    assertEquals(expectedDescription, description.getValueAttribute());
    assertTrue(minorEdit.isChecked());
    assertEquals(expectedContent + NEWLINE_TEXTAREA, content.getText());
    // This checks for the rendering...
    assertNotNull(editPage.getAnchorByHref(expectedContent));
  }
  private void testSetDescription(String url, TestObject object) throws Exception {
    object.doSubmitDescription("description");

    // test the roundtrip
    HtmlPage page = j.new WebClient().goTo(url);
    page.getAnchorByHref("editDescription").click();
    HtmlForm form = findForm(page, "submitDescription");
    j.submit(form);

    assertEquals("description", object.getDescription());
  }
Пример #5
0
  public List<HtmlTableRow> getcources() {
    String eteraz = "eteraz_nomreh.aspx";
    try {
      page3 = web.getPage(url + "/" + eteraz);
      List<HtmlAnchor> anch = page3.getAnchors();

      page4 = page3.getAnchorByHref(anch.get(anch.size() - 1).getHrefAttribute()).click();

      HtmlTable tbl = page4.getHtmlElementById("ctl00_ContentPlaceHolder1_grdWorkBook");

      return tbl.getRows();
    } catch (FailingHttpStatusCodeException | IOException e) {

      e.printStackTrace();
    }
    return null;
  }