Search in sources :

Example 46 with OperateOnDeployment

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

the class SAML2KerberosAuthenticationTestCase method testNegotiateHttpHeader.

/**
     * Test for SPNEGO working.
     *
     * @throws Exception
     */
@Test
@OperateOnDeployment(SERVICE_PROVIDER_NAME)
public void testNegotiateHttpHeader(@ArquillianResource URL webAppURL, @ArquillianResource @OperateOnDeployment(IDENTITY_PROVIDER_NAME) URL idpURL) throws Exception {
    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
        final HttpGet httpGet = new HttpGet(webAppURL.toURI());
        final HttpResponse response = httpClient.execute(httpGet);
        assertThat("Unexpected status code.", response.getStatusLine().getStatusCode(), equalTo(HttpServletResponse.SC_UNAUTHORIZED));
        final Header[] authnHeaders = response.getHeaders("WWW-Authenticate");
        assertThat("WWW-Authenticate header is present", authnHeaders, notNullValue());
        assertThat("WWW-Authenticate header is non-empty", authnHeaders.length, not(equalTo(0)));
        final Set<? super String> authnHeaderValues = new HashSet<String>();
        for (final Header header : authnHeaders) {
            authnHeaderValues.add(header.getValue());
        }
        Matcher<String> matcherContainsString = containsString("Negotiate");
        Matcher<Iterable<? super String>> matcherAnyContainsNegotiate = hasItem(matcherContainsString);
        assertThat("WWW-Authenticate [Negotiate] header is missing", authnHeaderValues, matcherAnyContainsNegotiate);
        consumeResponse(response);
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Header(org.apache.http.Header) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) HashSet(java.util.HashSet) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 47 with OperateOnDeployment

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

the class SPNEGOLoginModuleTestCase method testUnsuccessfulAuthz.

/**
     * Correct login, but without permissions.
     *
     * @throws Exception
     */
@Test
@OperateOnDeployment("WEB")
public void testUnsuccessfulAuthz(@ArquillianResource URL webAppURL) throws Exception {
    final URI servletUri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
    LOGGER.trace("Testing correct authentication, but failed authorization " + servletUri);
    Utils.makeCallWithKerberosAuthn(servletUri, "hnelson", "secret", HttpServletResponse.SC_FORBIDDEN);
}
Also used : URI(java.net.URI) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 48 with OperateOnDeployment

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

the class SPNEGOLoginModuleTestCase method testContInvalidKerberosSpnegoWorkflow.

/**
     * SPNEGO continuation scenario - more mechanismTypes is provided and the Kerberos mechanism is not the most preferable one.
     * Client provides invalid token in the second round.
     */
@Test
@OperateOnDeployment("WEB")
public void testContInvalidKerberosSpnegoWorkflow(@ArquillianResource URL webAppURL) throws Exception {
    URI uri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
    final String[] mechTypes = new String[] { OID_DUMMY, OID_KERBEROS_V5 };
    assertSpnegoWorkflow(uri, mechTypes, DUMMY_TOKEN, DUMMY_TOKEN, true, false);
}
Also used : URI(java.net.URI) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 49 with OperateOnDeployment

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

the class ServletRunAsTestCase method runServletWithIncorrectRole.

/**
     * Access Servlet which uses RunAs with different role than in needed for secured EJB invocation.
     * <p>
     * This method will run init() and doGet() method and stores results.
     *
     * @param url
     * @throws Exception
     */
@Test
@InSequence(4)
@OperateOnDeployment(DEPLOYMENT)
public void runServletWithIncorrectRole(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + RunAsUserServlet.SERVLET_PATH.substring(1) + "?" + Utils.encodeQueryParam(CallProtectedEjbServlet.FILE_PARAM, INCORRECT_ROLE_AND_UNDEPLOY.getAbsolutePath()));
    incorrectRoleResult = Utils.makeCall(servletUrl.toURI(), HTTP_OK);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 50 with OperateOnDeployment

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

the class XercesUsageInWebServiceTestCase method testXercesUsageInWebService.

/**
     * Test that the webservice invocation works fine
     *
     * @throws Exception
     */
@OperateOnDeployment("webservice-app-with-xerces")
@Test
public void testXercesUsageInWebService() throws Exception {
    final QName serviceName = new QName("org.jboss.as.test.integration.xerces.ws", "XercesUsageWebService");
    final URL wsdlURL = new URL(url.toExternalForm() + "XercesUsageWebService?wsdl");
    final Service service = Service.create(wsdlURL, serviceName);
    final XercesUsageWSEndpoint port = service.getPort(XercesUsageWSEndpoint.class);
    final String xml = "dummy.xml";
    final String result = port.parseUsingXerces(xml);
    Assert.assertEquals("Unexpected return message from webservice", XercesUsageWebService.SUCCESS_MESSAGE, result);
}
Also used : QName(javax.xml.namespace.QName) XercesUsageWebService(org.jboss.as.test.integration.xerces.ws.XercesUsageWebService) Service(javax.xml.ws.Service) XercesUsageWSEndpoint(org.jboss.as.test.integration.xerces.ws.XercesUsageWSEndpoint) 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