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 geode by apache.
the class TestSessionsTomcat8Base method testSessionPersists1.
/**
* Check that our session persists. The values we pass in as query params are used to set
* attributes on the session.
*/
@Test
public void testSessionPersists1() throws Exception {
String key = "value_testSessionPersists1";
String value = "Foo";
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
req.setParameter("cmd", QueryCommand.SET.name());
req.setParameter("param", key);
req.setParameter("value", value);
WebResponse response = wc.getResponse(req);
String sessionId = response.getNewCookieValue("JSESSIONID");
assertNotNull("No apparent session cookie", sessionId);
// The request retains the cookie from the prior response...
req.setParameter("cmd", QueryCommand.GET.name());
req.setParameter("param", key);
req.removeParameter("value");
response = wc.getResponse(req);
assertEquals(value, response.getText());
}
use of com.meterware.httpunit.WebConversation in project geode by apache.
the class TestSessionsTomcat8Base method testBasicRegion.
/**
* Test that a session attribute gets set into the region too.
*/
@Test
public void testBasicRegion() throws Exception {
String key = "value_testBasicRegion";
String value = "Foo";
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
// Set an attribute
req.setParameter("cmd", QueryCommand.SET.name());
req.setParameter("param", key);
req.setParameter("value", value);
WebResponse response = wc.getResponse(req);
String sessionId = response.getNewCookieValue("JSESSIONID");
assertEquals(value, region.get(sessionId).getAttribute(key));
}
use of com.meterware.httpunit.WebConversation in project geode by apache.
the class TestSessionsTomcat8Base method testCommitSessionValveInvalidSession.
/*
* Test for issue #38 CommitSessionValve throws exception on invalidated sessions
*/
@Test
public void testCommitSessionValveInvalidSession() throws Exception {
Callback c = new Callback() {
@Override
public void call(HttpServletRequest request, HttpServletResponse response) throws IOException {
HttpSession session = request.getSession();
session.invalidate();
response.getWriter().write("done");
}
};
servlet.getServletContext().setAttribute("callback", c);
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
// Execute the callback
req.setParameter("cmd", QueryCommand.CALLBACK.name());
req.setParameter("param", "callback");
WebResponse response = wc.getResponse(req);
assertEquals("done", response.getText());
}
Aggregations