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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations