Search in sources :

Example 41 with DisabledOnOs

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"));
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 42 with DisabledOnOs

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("=> ******"));
    }
}
Also used : LogFixture(com.thoughtworks.go.util.LogFixture) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 43 with DisabledOnOs

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"));
}
Also used : File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 44 with DisabledOnOs

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'");
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 45 with DisabledOnOs

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");
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)85 Test (org.junit.jupiter.api.Test)78 Path (java.nio.file.Path)38 File (java.io.File)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 PathsBaseTest (org.assertj.core.internal.PathsBaseTest)12 AssertionsUtil.expectAssertionError (org.assertj.core.util.AssertionsUtil.expectAssertionError)11 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)6 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)6 PageSwapperTest (org.neo4j.io.pagecache.PageSwapperTest)6 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)5 DelegatingStoreChannel (org.neo4j.io.fs.DelegatingStoreChannel)5 StoreChannel (org.neo4j.io.fs.StoreChannel)5 DisabledForRoot (org.neo4j.test.extension.DisabledForRoot)5 Closeable (java.io.Closeable)4 URI (java.net.URI)4 FileUtils.writeByteArrayToFile (org.apache.commons.io.FileUtils.writeByteArrayToFile)4 ShouldBeFile.shouldBeFile (org.assertj.core.error.ShouldBeFile.shouldBeFile)4 FilesBaseTest (org.assertj.core.internal.FilesBaseTest)4 Files.newFile (org.assertj.core.util.Files.newFile)4