use of com.meterware.httpunit.WebConversation in project wildfly by wildfly.
the class AbstractBasicFederationTestCase method testFederationWithGlobalLogout.
@Test
public void testFederationWithGlobalLogout() throws Exception {
WebConversation conversation = new WebConversation();
HttpUnitOptions.setLoggingHttpHeaders(true);
LOGGER.trace("REQEST: " + formatUrl(this.serviceProvider1) + "/index.jsp");
WebRequest request = new GetMethodWebRequest(formatUrl(this.serviceProvider1) + "/index.jsp");
WebResponse response = conversation.getResponse(request);
LOGGER.trace("RESPONSE: " + response.getText());
assertTrue(response.getURL().getPath().startsWith("/idp"));
assertEquals(1, response.getForms().length);
WebForm webForm = response.getForms()[0];
webForm.setParameter("j_username", "tomcat");
webForm.setParameter("j_password", "tomcat");
webForm.getSubmitButtons()[0].click();
response = conversation.getCurrentPage();
assertTrue("cannot reach protected content at " + formatUrl(this.serviceProvider1), response.getText().contains("Welcome to " + formatContextPath(this.serviceProvider1)));
LOGGER.trace("REQEST: " + formatUrl(this.serviceProvider2));
request = new GetMethodWebRequest(formatUrl(this.serviceProvider2));
response = conversation.getResponse(request);
LOGGER.trace("RESPONSE: " + response.getText());
assertTrue("cannot reach protected content at " + formatUrl(this.serviceProvider2), response.getText().contains("Welcome to " + formatContextPath(this.serviceProvider2)));
if (performGlobalLogout()) {
// global logout from serviceProvider2
LOGGER.trace("REQEST: " + formatUrl(this.serviceProvider2) + GLOBAL_LOGOUT_URL_PARAM);
response = conversation.getResponse(formatUrl(this.serviceProvider2) + GLOBAL_LOGOUT_URL_PARAM);
LOGGER.trace("GLO response(" + this.serviceProvider2 + "):" + response.getText());
assertTrue("cannot reach logged out page", response.getText().contains("Logout"));
// check if GLO was successful, so serviceProvider1 is requesting IDP login form
LOGGER.trace("REQEST: " + formatUrl(this.serviceProvider1));
request = new GetMethodWebRequest(formatUrl(this.serviceProvider1));
response = conversation.getResponse(request);
LOGGER.trace("RESPONSE: " + response.getText());
assertTrue("cannot reach IDP", response.getURL().getPath().startsWith("/idp"));
assertEquals("no form present on supposed IDP login page", 1, response.getForms().length);
}
}
use of com.meterware.httpunit.WebConversation in project wildfly by wildfly.
the class RestoreOriginalRequestTestCase method testPostOriginalRequest.
@Test
@OperateOnDeployment("service-provider-2")
public void testPostOriginalRequest(@ArquillianResource URL serviceProvider2) throws Exception {
WebRequest request = new GetMethodWebRequest(formatUrl(serviceProvider2) + "/savedRequest/savedRequest.html");
WebConversation conversation = new WebConversation();
WebResponse response = conversation.getResponse(request);
WebForm webForm = response.getForms()[0];
webForm.setParameter("j_username", "tomcat");
webForm.setParameter("j_password", "tomcat");
webForm.getSubmitButtons()[0].click();
response = conversation.getCurrentPage();
assertTrue(response.getText().contains("Back to the original requested resource."));
}
use of com.meterware.httpunit.WebConversation in project wildfly by wildfly.
the class SAMLIDPInitiatedTestCase method testAuthentication.
@Ignore("wait for PL > 2.6.0.CR2")
@Test
@OperateOnDeployment("identity-provider")
public void testAuthentication(@ArquillianResource URL url) throws Exception {
WebConversation conversation = new WebConversation();
HttpUnitOptions.setLoggingHttpHeaders(true);
WebRequest request = new GetMethodWebRequest(url.toString());
WebResponse response = conversation.getResponse(request);
assertEquals(1, response.getForms().length);
WebForm webForm = response.getForms()[0];
webForm.setParameter("j_username", "tomcat");
webForm.setParameter("j_password", "tomcat");
webForm.getSubmitButtons()[0].click();
response = conversation.getCurrentPage();
LOGGER.debug("Response from IDP: " + response.getText());
LOGGER.debug("SP1-URL: " + serviceProviderPostURL);
LOGGER.debug("webURI: " + webURI);
WebLink link = response.getLinkWithID("service-provider-1-id");
assertNotNull("Cannot reach link with id: service-provider-1-id", link);
response = link.click();
assertTrue("Not properly redirected to sp-post1.war", response.getText().contains("Welcome to sp-post1.war"));
}
use of com.meterware.httpunit.WebConversation in project wildfly by wildfly.
the class SAMLIDPInitiatedTestCase method testPostOriginalRequest.
@Test
@OperateOnDeployment("identity-provider")
public void testPostOriginalRequest(@ArquillianResource URL url) throws Exception {
WebRequest request = new GetMethodWebRequest(url.toString());
WebConversation conversation = new WebConversation();
WebResponse response = conversation.getResponse(request);
WebForm webForm = response.getForms()[0];
webForm.setParameter("j_username", "tomcat");
webForm.setParameter("j_password", "tomcat");
webForm.getSubmitButtons()[0].click();
request = new GetMethodWebRequest(url + "?SAML_VERSION=2.0&TARGET=" + this.serviceProviderPostURL + "/savedRequest/savedRequest.jsp");
response = conversation.getResponse(request);
assertTrue(response.getText().contains("Back to the original requested resource."));
}
use of com.meterware.httpunit.WebConversation in project javaee7-samples by javaee-samples.
the class ScopedBeanTest method checkRenderedPage.
@Test
public void checkRenderedPage() throws Exception {
WebConversation conv = new WebConversation();
GetMethodWebRequest getRequest = new GetMethodWebRequest(base + "/faces/index.xhtml");
String responseText = conv.getResponse(getRequest).getText();
assert (responseText.contains("Hello there!"));
}
Aggregations