-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFCORE-6532] Add security manager to script tests
- Loading branch information
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,11 @@ | |
package org.wildfly.scripts.test; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.TimeoutException; | ||
import java.util.function.Function; | ||
|
@@ -15,22 +20,42 @@ | |
import org.jboss.as.test.shared.TestSuiteEnvironment; | ||
import org.jboss.dmr.ModelNode; | ||
import org.junit.Assert; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.wildfly.common.test.ServerHelper; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class DomainScriptTestCase extends ScriptTestCase { | ||
|
||
private static final Function<ModelControllerClient, Boolean> HOST_CONTROLLER_CHECK = ServerHelper::isDomainRunning; | ||
|
||
@Parameterized.Parameter | ||
public Map<String, String> env; | ||
public DomainScriptTestCase() { | ||
super("domain"); | ||
} | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object> data() { | ||
final Collection<Object> result = new ArrayList<>(2); | ||
result.add(Collections.emptyMap()); | ||
result.add(Collections.singletonMap("SECMGR", "true")); | ||
return result; | ||
} | ||
|
||
@Override | ||
void testScript(final ScriptProcess script) throws InterruptedException, TimeoutException, IOException { | ||
script.start(HOST_CONTROLLER_CHECK, ServerHelper.DEFAULT_SERVER_JAVA_OPTS); | ||
boolean isSecurityManagerEnabled = Boolean.parseBoolean(System.getProperty("security.manager")); | ||
|
||
String[] modifiedJavaOpts = Arrays.copyOf(ServerHelper.DEFAULT_SERVER_JAVA_OPTS, ServerHelper.DEFAULT_SERVER_JAVA_OPTS.length + 1); | ||
modifiedJavaOpts[modifiedJavaOpts.length - 1] = "-secmgr"; | ||
|
||
String[] javaOptsToUse = isSecurityManagerEnabled ? modifiedJavaOpts : ServerHelper.DEFAULT_SERVER_JAVA_OPTS; | ||
|
||
script.start(HOST_CONTROLLER_CHECK, env, javaOptsToUse); | ||
|
||
Assert.assertNotNull("The process is null and may have failed to start.", script); | ||
Assert.assertTrue("The process is not running and should be", script.isAlive()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters