use of com.gargoylesoftware.htmlunit.WebClient in project testcases by coheigea.
the class OIDCTest method loginToClientsPage.
// Runs as BeforeClass: Login to the OIDC Clients page + create a new client
private static void loginToClientsPage(String rpPort, String oidcPort, String idpPort) throws Exception {
String url = "https://localhost:" + oidcPort + "/fediz-oidc/console/clients";
String user = "alice";
String password = "ecila";
// Login to the client page successfully
WebClient webClient = setupWebClient(user, password, idpPort);
HtmlPage loginPage = login(url, webClient);
final String bodyTextContent = loginPage.getBody().getTextContent();
Assert.assertTrue(bodyTextContent.contains("Registered Clients"));
String clientUrl = "https://localhost:" + rpPort + "/fedizdoubleit/auth/rp/complete";
// Now try to register a new client
HtmlPage registeredClientPage = registerNewClient(webClient, url, "consumer-id", clientUrl, clientUrl);
String registeredClientPageBody = registeredClientPage.getBody().getTextContent();
Assert.assertTrue(registeredClientPageBody.contains("Registered Clients"));
Assert.assertTrue(registeredClientPageBody.contains("consumer-id"));
HtmlTable table = registeredClientPage.getHtmlElementById("registered_clients");
storedClientId = table.getCellAt(1, 1).asText().trim();
Assert.assertNotNull(storedClientId);
// Now get the Client Secret
final HtmlPage clientPage = webClient.getPage(url + "/" + storedClientId);
HtmlTable clientPageTable = clientPage.getHtmlElementById("client");
storedClientSecret = clientPageTable.getCellAt(1, 2).asText().trim();
Assert.assertNotNull(storedClientSecret);
webClient.close();
}
use of com.gargoylesoftware.htmlunit.WebClient 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();
}
use of com.gargoylesoftware.htmlunit.WebClient in project spring-security by spring-projects.
the class S101Configurer method installBuildTool.
private String installBuildTool(File installationDirectory, File configurationDirectory) {
String source = "https://structure101.com/binaries/v6";
try (final WebClient webClient = new WebClient()) {
HtmlPage page = webClient.getPage(source);
Matcher matcher = null;
for (HtmlAnchor anchor : page.getAnchors()) {
Matcher candidate = Pattern.compile("(structure101-build-java-all-)(.*).zip").matcher(anchor.getHrefAttribute());
if (candidate.find()) {
matcher = candidate;
}
}
if (matcher == null) {
return null;
}
copyZipToFilesystem(source, installationDirectory, matcher.group(1) + matcher.group(2));
return matcher.group(2);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of com.gargoylesoftware.htmlunit.WebClient in project javaee7-samples by javaee-samples.
the class MyBeanTest method setup.
@Before
public void setup() throws IOException {
webClient = new WebClient();
page = webClient.getPage(base + "/faces/index.xhtml");
nameInputText = (HtmlTextInput) page.getElementById("nameInputText");
ageInputText = (HtmlTextInput) page.getElementById("ageInputText");
zipInputText = (HtmlTextInput) page.getElementById("zipInputText");
button = (HtmlSubmitInput) page.getElementById("submitButton");
}
use of com.gargoylesoftware.htmlunit.WebClient in project javaee7-samples by javaee-samples.
the class SecureServletTest method setup.
@Before
public void setup() {
correctCreds.addCredentials("u1", "p1");
incorrectCreds.addCredentials("random", "random");
webClient = new WebClient();
}
Aggregations