use of hudson.EnvVars in project workflow-cps-plugin by jenkinsci.
the class ArgumentsActionImplTest method testArraySanitization.
@Test
public void testArraySanitization() {
EnvVars env = new EnvVars();
String secretUsername = "IAmA";
// assume secretuser is a bound credential
env.put("USERVARIABLE", secretUsername);
Set<String> sensitiveVariables = new HashSet<>();
sensitiveVariables.add("USERVARIABLE");
HashMap<String, Object> args = new HashMap<>();
args.put("ints", new int[] { 1, 2, 3 });
args.put("strings", new String[] { "heh", secretUsername, "lumberjack" });
ArgumentsActionImpl filtered = new ArgumentsActionImpl(args, env, sensitiveVariables);
Map<String, Object> filteredArgs = filtered.getArguments();
Assert.assertEquals(2, filteredArgs.size());
Assert.assertThat(filteredArgs, IsMapContaining.hasEntry("ints", ArgumentsAction.NotStoredReason.UNSERIALIZABLE));
Assert.assertThat(filteredArgs, IsMapContaining.hasKey("strings"));
Object[] contents = (Object[]) (filteredArgs.get("strings"));
Assert.assertArrayEquals(new Object[] { "heh", "${USERVARIABLE}", "lumberjack" }, (Object[]) (filteredArgs.get("strings")));
}
use of hudson.EnvVars in project phabricator-jenkins-plugin by uber.
the class TestUtils method setEnvironmentVariables.
public static void setEnvironmentVariables(JenkinsRule j, Map<String, String> params) throws IOException {
EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty();
EnvVars envVars = prop.getEnvVars();
envVars.putAll(params);
j.jenkins.getGlobalNodeProperties().add(prop);
}
Aggregations