Search in sources :

Example 1 with XmlPage

use of com.gargoylesoftware.htmlunit.xml.XmlPage in project testcases by coheigea.

the class SAMLSSOTest method login.

private static String login(String url, String user, String password, String idpPort) throws IOException {
    final WebClient webClient = new WebClient();
    webClient.getOptions().setUseInsecureSSL(true);
    webClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", Integer.parseInt(idpPort)), new UsernamePasswordCredentials(user, password));
    webClient.getOptions().setJavaScriptEnabled(false);
    final HtmlPage idpPage = webClient.getPage(url);
    webClient.getOptions().setJavaScriptEnabled(true);
    Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText());
    final HtmlForm form = idpPage.getFormByName("samlsigninresponseform");
    final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
    final XmlPage rpPage = button.click();
    return rpPage.asXml();
}
Also used : HtmlForm(com.gargoylesoftware.htmlunit.html.HtmlForm) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlSubmitInput(com.gargoylesoftware.htmlunit.html.HtmlSubmitInput) AuthScope(org.apache.http.auth.AuthScope) XmlPage(com.gargoylesoftware.htmlunit.xml.XmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Example 2 with XmlPage

use of com.gargoylesoftware.htmlunit.xml.XmlPage in project testcases by coheigea.

the class FederationTest method login.

private static String login(String url, String user, String password, String idpPort) throws IOException {
    final WebClient webClient = new WebClient();
    webClient.getOptions().setUseInsecureSSL(true);
    webClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", Integer.parseInt(idpPort)), new UsernamePasswordCredentials(user, password));
    webClient.getOptions().setJavaScriptEnabled(false);
    final HtmlPage idpPage = webClient.getPage(url);
    webClient.getOptions().setJavaScriptEnabled(true);
    Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText());
    final HtmlForm form = idpPage.getFormByName("signinresponseform");
    final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
    final XmlPage rpPage = button.click();
    return rpPage.asXml();
}
Also used : HtmlForm(com.gargoylesoftware.htmlunit.html.HtmlForm) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlSubmitInput(com.gargoylesoftware.htmlunit.html.HtmlSubmitInput) AuthScope(org.apache.http.auth.AuthScope) XmlPage(com.gargoylesoftware.htmlunit.xml.XmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Aggregations

WebClient (com.gargoylesoftware.htmlunit.WebClient)2 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)2 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 HtmlSubmitInput (com.gargoylesoftware.htmlunit.html.HtmlSubmitInput)2 XmlPage (com.gargoylesoftware.htmlunit.xml.XmlPage)2 AuthScope (org.apache.http.auth.AuthScope)2 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)2