From 6a55195f999747678458c05f62e2674583b8337b Mon Sep 17 00:00:00 2001 From: "James R. Perkins" Date: Tue, 23 Jul 2024 16:25:16 -0700 Subject: [PATCH] [WFCORE-6933] Add the required permissions for the Log4j2ServiceActivator when deploying. Update the test to only fail if the ServerDeploymentException is not thrown when expected. https://issues.redhat.com/browse/WFCORE-6933 Signed-off-by: James R. Perkins --- .../logging/LoggingDependenciesTestCase.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/logging/LoggingDependenciesTestCase.java b/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/logging/LoggingDependenciesTestCase.java index 61b3b0be3b3..dfd839300f0 100644 --- a/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/logging/LoggingDependenciesTestCase.java +++ b/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/logging/LoggingDependenciesTestCase.java @@ -14,6 +14,7 @@ import org.jboss.logging.Logger; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -57,9 +58,15 @@ public void stopContainer() throws Exception { container.stop(); } - @Test(expected = ServerDeploymentException.class) + @Test public void disableLoggingDependencies() throws Exception { final JavaArchive archive = createDeployment(Log4j2ServiceActivator.class, Log4j2ServiceActivator.DEPENDENCIES); + // Required permissions for log4j2 + addPermissions(archive, + new RuntimePermission("getClassLoader"), + new RuntimePermission("accessDeclaredMembers"), + new RuntimePermission("getenv.*") + ); // Ensure the log4j deployment can be deployed deploy(archive); undeploy(); @@ -69,6 +76,11 @@ public void disableLoggingDependencies() throws Exception { // Restart the container, expect the exception during deployment container.stop(); container.start(); - deploy(archive); + try { + deploy(archive); + Assert.fail("Expected a ServerDeploymentException to be thrown."); + } catch (ServerDeploymentException expected) { + + } } } \ No newline at end of file