Skip to content

Commit

Permalink
[WFCORE-6933] Add the required permissions for the Log4j2ServiceActiv…
Browse files Browse the repository at this point in the history
…ator 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 <jperkins@redhat.com>
  • Loading branch information
jamezp committed Jul 23, 2024
1 parent 235aa52 commit 6a55195
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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) {

}
}
}

0 comments on commit 6a55195

Please sign in to comment.