Search in sources :

Example 31 with OperateOnDeployment

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

the class LoggingDeploymentResourceTestCase method testEarDeploymentConfigurationResource.

@OperateOnDeployment(EAR_DEPLOYMENT_NAME)
@Test
public void testEarDeploymentConfigurationResource() throws Exception {
    ModelNode loggingConfiguration = readDeploymentResource(EAR_DEPLOYMENT_NAME, EAR_DEPLOYMENT_NAME + "/META-INF/logging.properties");
    // The address should have logging.properties
    Deque<Property> resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
    Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
    ModelNode handler = loggingConfiguration.get("handler", "FILE");
    Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
    Assert.assertTrue(handler.hasDefined("properties"));
    String fileName = null;
    // Find the fileName property
    for (Property property : handler.get("properties").asPropertyList()) {
        if ("fileName".equals(property.getName())) {
            fileName = property.getValue().asString();
            break;
        }
    }
    Assert.assertNotNull("fileName property not found", fileName);
    Assert.assertTrue(fileName.endsWith("test-logging-ear.log"));
    // Check the WAR which should inherit the EAR's logging.properties
    loggingConfiguration = readSubDeploymentResource(EAR_DEPLOYMENT_NAME, EAR_WAR_DEPLOYMENT_NAME, EAR_DEPLOYMENT_NAME + "/META-INF/logging.properties");
    // The address should have logging.properties
    resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
    Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
    handler = loggingConfiguration.get("handler", "FILE");
    Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
    Assert.assertTrue(handler.hasDefined("properties"));
    fileName = null;
    // Find the fileName property
    for (Property property : handler.get("properties").asPropertyList()) {
        if ("fileName".equals(property.getName())) {
            fileName = property.getValue().asString();
            break;
        }
    }
    Assert.assertNotNull("fileName property not found", fileName);
    Assert.assertTrue(fileName.endsWith("test-logging-ear.log"));
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) ArrayDeque(java.util.ArrayDeque) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 32 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 33 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 34 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 35 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)

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