Search in sources :

Example 6 with OperateOnDeployment

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

the class ReuseAuthenticatedSubjectTestCase method testEjbInDifferentSecurityDomain.

/**
     * Test whether if web app and EJB belong to the different security domain then the user is authenticated for both web app
     * and EJB invoked from that app.
     *
     * @param url
     * @throws Exception
     */
@OperateOnDeployment(DEPLOYMENT_NAME)
@Test
public void testEjbInDifferentSecurityDomain(@ArquillianResource URL url) throws Exception {
    resetCounter(url);
    final URL servletUrl = new URL(url.toExternalForm() + ReuseAuthenticatedSubjectServlet.SERVLET_PATH.substring(1) + "?" + ReuseAuthenticatedSubjectServlet.SAME_SECURITY_DOMAIN_PARAM + "=false");
    String servletOutput = Utils.makeCallWithBasicAuthn(servletUrl, USER, PASSWORD, 200);
    Assert.assertEquals("Unexpected servlet output after EJB call", EjbOwnSecurityDomainImpl.SAY_HELLO, servletOutput);
    Assert.assertEquals("Authenticated subject was reused for EJB from the different security domain", "2", getCounter(url));
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 7 with OperateOnDeployment

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

the class JACCForEarModulesTestCase method testWebPermissions.

/**
     * Tests web permissions (war directly and war in ear).
     *
     * @param webAppURL
     * @throws Exception
     */
@Test
@OperateOnDeployment("war")
public void testWebPermissions(@ArquillianResource URL webAppURL) throws Exception {
    final Document doc = getPermissionDocument(webAppURL);
    testJACCWebPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT + "/ActiveContextPolicies/ContextPolicy[@contextID='jacc-test.war']"));
    testJACCWebPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT + "/ActiveContextPolicies/ContextPolicy[@contextID='ear-jacc-test.ear!ear-jacc-test.war']"));
}
Also used : Document(org.dom4j.Document) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 8 with OperateOnDeployment

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

the class UsersRolesLoginModuleTestCase method testExternalFiles.

/**
     * testExternalFiles
     *
     * @throws Exception
     * @see #USERS_EXT
     * @see #ROLES_EXT
     */
@OperateOnDeployment(DEP1)
@Test
public void testExternalFiles(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + SimpleSecuredServlet.SERVLET_PATH.substring(1));
    //successful authentication and authorization
    assertEquals("Response body is not correct.", SimpleSecuredServlet.RESPONSE_BODY, Utils.makeCallWithBasicAuthn(servletUrl, MARCUS, ANIL_PWD, 200));
    //successful authentication and unsuccessful authorization
    Utils.makeCallWithBasicAuthn(servletUrl, ANIL, MARCUS_PWD, 403);
    //tests related to case insensitiveness
    Utils.makeCallWithBasicAuthn(servletUrl, ANIL, MARCUS_PWD.toUpperCase(Locale.ENGLISH), 401);
    Utils.makeCallWithBasicAuthn(servletUrl, MARCUS, ANIL_PWD.toLowerCase(Locale.ENGLISH), 401);
    //unsuccessful authentication
    Utils.makeCallWithBasicAuthn(servletUrl, MARCUS, MARCUS_PWD, 401);
    Utils.makeCallWithBasicAuthn(servletUrl, ANIL, MARCUS, 401);
    Utils.makeCallWithBasicAuthn(servletUrl, ANIL_PWD, MARCUS_PWD, 401);
    Utils.makeCallWithBasicAuthn(servletUrl, ANIL, Utils.hashMD5(MARCUS_PWD, Coding.BASE_64), 401);
    Utils.makeCallWithBasicAuthn(servletUrl, ANIL, Utils.hashMD5(MARCUS_PWD, Coding.HEX), 401);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 9 with OperateOnDeployment

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

the class UsersRolesLoginModuleTestCase method testHashOnlyStorePassword.

/**
     * testHashOnlyStorePassword
     *
     * @throws Exception
     */
@OperateOnDeployment(DEP6a)
@Test
public void testHashOnlyStorePassword(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + SimpleSecuredServlet.SERVLET_PATH.substring(1));
    //successful authentication and authorization
    assertEquals("Response body is not correct.", SimpleSecuredServlet.RESPONSE_BODY, Utils.makeCallWithBasicAuthn(servletUrl, ANIL, Utils.hashMD5(ANIL_PWD, Coding.BASE_64), 200));
    //successful authentication and unsuccessful authorization
    Utils.makeCallWithBasicAuthn(servletUrl, MARCUS, Utils.hashMD5(MARCUS_PWD, Coding.BASE_64), 403);
    //unsuccessful authentication
    Utils.makeCallWithBasicAuthn(servletUrl, ANIL, ANIL_PWD, 401);
    Utils.makeCallWithBasicAuthn(servletUrl, MARCUS, MARCUS_PWD, 401);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 10 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)

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