use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.
the class SPNEGOLoginModuleTestCase method testPlainKerberosWorkflow.
/**
* Kerberos simple scenario. Client provides a valid Kerberos token (without SPNEGO envelope) in the first round. See
* <a href="https://tools.ietf.org/html/rfc4121">RFC-4121</a>.
*/
@Test
@OperateOnDeployment("WEB")
public void testPlainKerberosWorkflow(@ArquillianResource URL webAppURL) throws Exception {
final URI uri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
final byte[] kerberosToken = createNewKerberosTicketForHttp(uri);
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
final HttpGet httpGet = new HttpGet(uri);
HttpResponse response = httpClient.execute(httpGet);
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
assertHttpHeader(response, HEADER_WWW_AUTHENTICATE, "Negotiate");
EntityUtils.consume(response.getEntity());
httpGet.setHeader(HEADER_AUTHORIZATION, "Negotiate " + Base64.getEncoder().encodeToString(kerberosToken));
response = httpClient.execute(httpGet);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Negotiate response in HTTP header:\n" + KerberosTestUtils.dumpNegotiateHeader(response));
}
assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode());
assertEquals("Unexpected response body", SimpleSecuredServlet.RESPONSE_BODY, EntityUtils.toString(response.getEntity()));
}
}
use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.
the class JACCForEarModulesTestCase method testEJBPermissions.
/**
* Tests EJB permissions (jar directly and jar in ear).
*
* @param webAppURL
* @throws Exception
*/
@Test
@OperateOnDeployment("war")
public void testEJBPermissions(@ArquillianResource URL webAppURL) throws Exception {
final Document doc = getPermissionDocument(webAppURL);
testJACCEjbPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT + "/ActiveContextPolicies/ContextPolicy[@contextID='jar-jacc-test.jar']"));
testJACCEjbPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT + "/ActiveContextPolicies/ContextPolicy[@contextID='ear-jacc-test.ear!ear-jacc-test.jar']"));
}
use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.
the class SPNEGOLoginModuleTestCase method testContSpnegoWorkflow.
/**
* SPNEGO continuation scenario - more mechanismTypes is provided and the Kerberos mechanism is not the most preferable one.
* Client provides valid token in the second round.
*/
@Test
@OperateOnDeployment("WEB")
public void testContSpnegoWorkflow(@ArquillianResource URL webAppURL) throws Exception {
final URI uri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
final String[] mechTypes = new String[] { OID_DUMMY, OID_KERBEROS_V5_LEGACY, OID_KERBEROS_V5 };
assertSpnegoWorkflow(uri, mechTypes, DUMMY_TOKEN, createNewKerberosTicketForHttp(uri), true, true);
}
use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.
the class SPNEGOLoginModuleTestCase method testLegacyKerberosSpnegoWorkflow.
/**
* SPNEGO continuation scenario - Kerberos mechanisms are provided as mechanismTypes. The Legacy (aka Microsoft) mechanism
* is provided as the first one and we expect the server will not accept it and it'll ask the token for the standard
* Kerberos mechanism OID. Client provides valid token in both rounds.
*/
@Test
@OperateOnDeployment("WEB")
public void testLegacyKerberosSpnegoWorkflow(@ArquillianResource URL webAppURL) throws Exception {
final URI uri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
final String[] mechTypes = new String[] { OID_KERBEROS_V5_LEGACY, OID_KERBEROS_V5 };
final byte[] kerberosToken = createNewKerberosTicketForHttp(uri);
assertSpnegoWorkflow(uri, mechTypes, kerberosToken, kerberosToken, true, true);
}
use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.
the class SPNEGOLoginModuleTestCase method testFormFallback.
/**
* Tests web SPNEGO authentication with FORM method fallback.
*
* @throws Exception
*/
@Test
@OperateOnDeployment("WEB-FORM")
public void testFormFallback(@ArquillianResource URL webAppURL) throws Exception {
KerberosTestUtils.assumeKerberosAuthenticationSupported();
final URI servletUri = getServletURI(webAppURL, SimpleSecuredServlet.SERVLET_PATH);
LOGGER.trace("Testing fallback to FORM authentication. " + servletUri);
LOGGER.trace("Testing successful SPNEGO authentication");
String responseBody = Utils.makeCallWithKerberosAuthn(servletUri, "jduke", "theduke", HttpServletResponse.SC_OK);
assertEquals("Unexpected response body", SimpleSecuredServlet.RESPONSE_BODY, responseBody);
LOGGER.trace("Testing successful FORM authentication");
responseBody = Utils.makeHttpCallWoSPNEGO(webAppURL.toExternalForm(), SimpleSecuredServlet.SERVLET_PATH, "jduke@JBOSS.ORG", "fallback", HttpServletResponse.SC_OK);
assertEquals("Unexpected response body", SimpleSecuredServlet.RESPONSE_BODY, responseBody);
LOGGER.trace("Testing FORM fallback");
responseBody = Utils.makeHttpCallWithFallback(webAppURL.toExternalForm(), SimpleSecuredServlet.SERVLET_PATH, "jduke@JBOSS.ORG", "fallback", HttpServletResponse.SC_OK);
assertEquals("Unexpected response body", SimpleSecuredServlet.RESPONSE_BODY, responseBody);
}
Aggregations