Search in sources :

Example 36 with OperateOnDeployment

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

the class SPNEGOLoginModuleTestCase method testAuthn.

/**
     * Correct login.
     *
     * @throws Exception
     */
@Test
@OperateOnDeployment("WEB")
public void testAuthn(@ArquillianResource URL webAppURL) throws Exception {
    final URI servletUri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
    LOGGER.trace("Testing successful authentication " + servletUri);
    final String responseBody = Utils.makeCallWithKerberosAuthn(servletUri, "jduke", "theduke", HttpServletResponse.SC_OK);
    assertEquals("Unexpected response body", SimpleSecuredServlet.RESPONSE_BODY, responseBody);
}
Also used : URI(java.net.URI) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 37 with OperateOnDeployment

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

the class SPNEGOLoginModuleTestCase method testUnsecured.

/**
     * Unsecured request.
     *
     * @throws Exception
     */
@Test
@OperateOnDeployment("WEB")
public void testUnsecured(@ArquillianResource URL webAppURL) throws Exception {
    final URI servletUri = getServletURI(webAppURL, SimpleServlet.SERVLET_PATH);
    LOGGER.trace("Testing access to unprotected resource " + servletUri);
    final String responseBody = Utils.makeCallWithKerberosAuthn(servletUri, null, null, HttpServletResponse.SC_OK);
    assertEquals("Unexpected response body.", SimpleServlet.RESPONSE_BODY, responseBody);
}
Also used : URI(java.net.URI) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 38 with OperateOnDeployment

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

the class SPNEGOLoginModuleTestCase method testNoKerberosSpnegoWorkflow.

/**
     * SPNEGO simple scenario - more mechanismTypes is provided but the Kerberos mechanism is not listed as the supported one.
     */
@Test
@OperateOnDeployment("WEB")
public void testNoKerberosSpnegoWorkflow(@ArquillianResource URL webAppURL) throws Exception {
    final URI uri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
    final String[] mechTypes = new String[] { OID_DUMMY, OID_NTLM };
    assertSpnegoWorkflow(uri, mechTypes, DUMMY_TOKEN, null, false, false);
}
Also used : URI(java.net.URI) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 39 with OperateOnDeployment

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

the class SPNEGOLoginModuleTestCase method testMoreMechTypesSpnegoWorkflow.

/**
     * SPNEGO simple scenario - more mechanismTypes is provided but the Kerberos mechanism is most preferable one and it has a
     * valid token.
     */
@Test
@OperateOnDeployment("WEB")
public void testMoreMechTypesSpnegoWorkflow(@ArquillianResource URL webAppURL) throws Exception {
    KerberosTestUtils.assumeKerberosAuthenticationSupported();
    final URI uri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
    final String[] mechTypes = new String[] { OID_KERBEROS_V5, OID_DUMMY, OID_KERBEROS_V5_LEGACY };
    assertSpnegoWorkflow(uri, mechTypes, createNewKerberosTicketForHttp(uri), null, false, true);
}
Also used : URI(java.net.URI) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 40 with OperateOnDeployment

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

the class SPNEGOLoginModuleTestCase method testUnsuccessfulAuthn.

/**
     * Incorrect login.
     *
     * @throws Exception
     */
@Test
@OperateOnDeployment("WEB")
public void testUnsuccessfulAuthn(@ArquillianResource URL webAppURL) throws Exception {
    final URI servletUri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
    LOGGER.trace("Testing failed authentication " + servletUri);
    try {
        Utils.makeCallWithKerberosAuthn(servletUri, "jduke", "the%", HttpServletResponse.SC_OK);
        fail();
    } catch (LoginException e) {
    // OK
    }
    try {
        Utils.makeCallWithKerberosAuthn(servletUri, "jd%", "theduke", HttpServletResponse.SC_OK);
        fail();
    } catch (LoginException e) {
    // OK
    }
}
Also used : LoginException(javax.security.auth.login.LoginException) URI(java.net.URI) 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