Search in sources :

Example 46 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class MergeEnvironmentConfigTest method shouldAddEnvironmentVariablesToEnvironmentVariableContextFrom2Parts.

@Test
public void shouldAddEnvironmentVariablesToEnvironmentVariableContextFrom2Parts() throws Exception {
    pairEnvironmentConfig.get(0).addEnvironmentVariable("variable-name1", "variable-value1");
    pairEnvironmentConfig.get(1).addEnvironmentVariable("variable-name2", "variable-value2");
    EnvironmentVariableContext context = pairEnvironmentConfig.createEnvironmentContext();
    assertThat(context.getProperty("variable-name1"), is("variable-value1"));
    assertThat(context.getProperty("variable-name2"), is("variable-value2"));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 47 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class EnvironmentVariableConfigTest method shouldAddPlainTextEnvironmentVariableToContext.

@Test
public void shouldAddPlainTextEnvironmentVariableToContext() {
    String key = "key";
    String plainText = "plainText";
    EnvironmentVariableConfig environmentVariableConfig = new EnvironmentVariableConfig(goCipher, key, plainText, false);
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    environmentVariableConfig.addTo(context);
    assertThat(context.getProperty(key), is(plainText));
    assertThat(context.getPropertyForDisplay(key), is(plainText));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 48 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class EnvironmentVariableConfigTest method shouldAddSecureEnvironmentVariableToContext.

@Test
public void shouldAddSecureEnvironmentVariableToContext() throws InvalidCipherTextException {
    String key = "key";
    String plainText = "plainText";
    String cipherText = "encrypted";
    when(goCipher.encrypt(plainText)).thenReturn(cipherText);
    when(goCipher.decrypt(cipherText)).thenReturn(plainText);
    EnvironmentVariableConfig environmentVariableConfig = new EnvironmentVariableConfig(goCipher, key, plainText, true);
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    environmentVariableConfig.addTo(context);
    assertThat(context.getProperty(key), is(plainText));
    assertThat(context.getPropertyForDisplay(key), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 49 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class MergeEnvironmentConfig method createEnvironmentContext.

@Override
public EnvironmentVariableContext createEnvironmentContext() {
    EnvironmentVariableContext context = new EnvironmentVariableContext(EnvironmentVariableContext.GO_ENVIRONMENT_NAME, CaseInsensitiveString.str(this.name()));
    this.getVariables().addTo(context);
    return context;
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext)

Example 50 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class BuildWorkTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
    environmentVariableContext = new EnvironmentVariableContext();
    artifactManipulator = new GoArtifactsManipulatorStub();
    new SystemEnvironment().setProperty("serviceUrl", SERVER_URL);
    buildRepository = new com.thoughtworks.go.remote.work.BuildRepositoryRemoteStub();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Before(org.junit.Before)

Aggregations

EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)94 Test (org.junit.Test)74 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)19 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)16 File (java.io.File)14 Date (java.util.Date)13 Modification (com.thoughtworks.go.domain.materials.Modification)12 Modifications (com.thoughtworks.go.domain.materials.Modifications)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)9 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)9 Before (org.junit.Before)8 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)6 Materials (com.thoughtworks.go.config.materials.Materials)6 Builder (com.thoughtworks.go.domain.builder.Builder)6 HashMap (java.util.HashMap)6 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)5 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)5 PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)5 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)5