use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.
the class CommandLineTest method shouldLogPasswordsOnEnvironmentAsStarsUnderLinux.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldLogPasswordsOnEnvironmentAsStarsUnderLinux() {
CommandLine line = CommandLine.createCommandLine("echo").withArg("My Password is:").withArg("secret").withArg(new PasswordArgument("secret")).withEncoding("utf-8");
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
environmentVariableContext.setProperty("ENV_PASSWORD", "secret", false);
InMemoryStreamConsumer output = new InMemoryStreamConsumer();
InMemoryStreamConsumer forDisplay = InMemoryStreamConsumer.inMemoryConsumer();
ProcessWrapper processWrapper = line.execute(output, environmentVariableContext, null);
processWrapper.waitForExit();
assertThat(forDisplay.getAllOutput(), not(containsString("secret")));
assertThat(output.getAllOutput(), containsString("secret"));
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.
the class CommandLineTest method shouldNotLogPasswordsFromStream.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldNotLogPasswordsFromStream() {
try (LogFixture logFixture = logFixtureFor(CommandLine.class, Level.DEBUG)) {
CommandLine line = CommandLine.createCommandLine("/bin/echo").withArg("=>").withArg(new PasswordArgument("secret")).withEncoding("utf-8");
line.runOrBomb(null);
assertThat(logFixture.getLog(), not(containsString("secret")));
assertThat(logFixture.getLog(), containsString("=> ******"));
}
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.
the class CommandLineTest method shouldBeAbleToRunCommandsInSubdirectories.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldBeAbleToRunCommandsInSubdirectories() throws IOException {
File shellScript = createScriptInSubFolder("hello-world.sh", "echo ${PWD}");
assertThat(shellScript.setExecutable(true), is(true));
CommandLine line = CommandLine.createCommandLine("./hello-world.sh").withWorkingDir(subFolder).withEncoding("utf-8");
InMemoryStreamConsumer out = new InMemoryStreamConsumer();
line.execute(out, new EnvironmentVariableContext(), null).waitForExit();
assertThat(out.getAllOutput().trim(), endsWith("subFolder"));
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.
the class BuilderTest method shouldReportErrorWhenCancelCommandDoesNotExist.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldReportErrorWhenCancelCommandDoesNotExist() {
StubBuilder stubBuilder = new StubBuilder();
CommandBuilder cancelBuilder = new CommandBuilder("echo2", "cancel task", new File("."), new RunIfConfigs(FAILED), stubBuilder, "");
CommandBuilder builder = new CommandBuilder("echo", "normal task", new File("."), new RunIfConfigs(FAILED), cancelBuilder, "");
builder.cancel(goPublisher, new EnvironmentVariableContext(), null, null, "utf-8");
assertThat(goPublisher.getMessage()).contains("Error happened while attempting to execute 'echo2 cancel task'");
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.
the class ExecTaskBuilderTest method shouldNormalizeWorkingDirectory.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldNormalizeWorkingDirectory() {
ExecTask execTask = new ExecTask("ant", "", "folder\\child");
CommandBuilder builder = (CommandBuilder) execTaskBuilder.createBuilder(builderFactory, execTask, pipelineStub("label", "."), resolver);
assertThat(builder.getWorkingDir().getPath()).isEqualTo("./folder/child");
}
Aggregations