Search in sources :

Example 11 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment 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."));
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebConversation(com.meterware.httpunit.WebConversation) WebForm(com.meterware.httpunit.WebForm) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 12 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment 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"));
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebConversation(com.meterware.httpunit.WebConversation) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebForm(com.meterware.httpunit.WebForm) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebLink(com.meterware.httpunit.WebLink) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment 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."));
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) WebConversation(com.meterware.httpunit.WebConversation) WebForm(com.meterware.httpunit.WebForm) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 14 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class WebSecurityDIGESTTestCase method testUserWithoutNeededRole.

/**
     * Check whether user with correct credentials but without needed role has not access to secured page.
     *
     * @param url
     * @throws Exception
     */
@OperateOnDeployment(DEPLOYMENT)
@Test
public void testUserWithoutNeededRole(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + SimpleSecuredServlet.SERVLET_PATH.substring(1));
    Utils.makeCallWithBasicAuthn(servletUrl, USER_WITHOUT_NEEDED_ROLE, USER_WITHOUT_NEEDED_ROLE_PASSWORD, HTTP_FORBIDDEN);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 15 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class WebSecurityDIGESTTestCase method testCorrectUser.

/**
     * Check whether user with correct credentials has access to secured page.
     *
     * @param url
     * @throws Exception
     */
@OperateOnDeployment(DEPLOYMENT)
@Test
public void testCorrectUser(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + SimpleSecuredServlet.SERVLET_PATH.substring(1));
    String responseBody = Utils.makeCallWithBasicAuthn(servletUrl, GOOD_USER, GOOD_USER_PASSWORD, HTTP_OK);
    assertEquals("Response body is not correct.", SimpleSecuredServlet.RESPONSE_BODY, responseBody);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Aggregations

OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)94 Test (org.junit.Test)93 URL (java.net.URL)31 URI (java.net.URI)22 HttpGet (org.apache.http.client.methods.HttpGet)20 HttpResponse (org.apache.http.HttpResponse)17 InitialContext (javax.naming.InitialContext)15 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)13 QName (javax.xml.namespace.QName)11 Service (javax.xml.ws.Service)11 HttpEntity (org.apache.http.HttpEntity)10 Bus (org.apache.cxf.Bus)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 ActAsServiceIface (org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface)6 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)5 WebConversation (com.meterware.httpunit.WebConversation)5 WebForm (com.meterware.httpunit.WebForm)5 WebRequest (com.meterware.httpunit.WebRequest)5