Search in sources :

Example 1 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class EnvironmentsConfigTest method shouldRemoveAgentFromAllEnvironments.

@Test
public void shouldRemoveAgentFromAllEnvironments() throws Exception {
    BasicEnvironmentConfig env2 = new BasicEnvironmentConfig(new CaseInsensitiveString("prod"));
    env2.addPipeline(new CaseInsensitiveString("test"));
    env2.addAgent("agent-one");
    env2.addAgent("agent-two");
    configs.add(env2);
    BasicEnvironmentConfig env3 = new BasicEnvironmentConfig(new CaseInsensitiveString("dev"));
    env3.addPipeline(new CaseInsensitiveString("build"));
    env3.addAgent("agent-two");
    env3.addAgent("agent-three");
    configs.add(env3);
    assertThat(configs.get(0).getAgents().size(), is(1));
    assertThat(configs.get(1).getAgents().size(), is(2));
    assertThat(configs.environmentsForAgent("agent-one").size(), is(2));
    configs.removeAgentFromAllEnvironments("agent-one");
    assertThat(configs.get(0).getAgents().size(), is(0));
    assertThat(configs.get(1).getAgents().size(), is(1));
    assertThat(configs.get(2).getAgents().size(), is(2));
    assertThat(configs.environmentsForAgent("agent-one").size(), is(0));
    assertThat(configs.environmentsForAgent("agent-two").size(), is(2));
    assertThat(configs.environmentsForAgent("agent-three").size(), is(1));
}
Also used : BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 2 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class EnvironmentsConfigTest method shouldGetLocalPartsWhenOriginIsMixed.

@Test
public void shouldGetLocalPartsWhenOriginIsMixed() {
    env.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig prodLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
    prodLocalPart.addAgent("1235");
    prodLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig prodRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
    prodRemotePart.setOrigins(new RepoConfigOrigin());
    MergeEnvironmentConfig pairEnvironmentConfig = new MergeEnvironmentConfig(prodLocalPart, prodRemotePart);
    configs.add(pairEnvironmentConfig);
    assertThat(configs.getLocal().size(), is(2));
    assertThat(configs.getLocal(), hasItem(env));
    assertThat(configs.getLocal(), hasItem(prodLocalPart));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 3 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class BuildPlansTest method shouldFindBuildPlanByName.

@Test
public void shouldFindBuildPlanByName() {
    JobConfigs jobConfigs = new JobConfigs();
    jobConfigs.add(jobConfig("Test"));
    assertThat(jobConfigs.containsName(new CaseInsensitiveString("Poo")), is(false));
}
Also used : JobConfigs(com.thoughtworks.go.config.JobConfigs) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 4 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldMarkEnvironmentContextCreatedForAdditionalDataAsSecureIfTheValueContainsAnySpecialCharacters.

@Test
public void shouldMarkEnvironmentContextCreatedForAdditionalDataAsSecureIfTheValueContainsAnySpecialCharacters() throws UnsupportedEncodingException {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", true, "!secure_value:with_special_chars");
    SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1, k2));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
    HashMap<String, String> map = new HashMap<>();
    map.put("ADDITIONAL_DATA_ONE", "foobar:!secure_value:with_special_chars");
    map.put("ADDITIONAL_DATA_URL_ENCODED", "something:%21secure_value%3Awith_special_chars");
    map.put("ADDITIONAL_DATA_TWO", "foobar:secure_value_with_regular_chars");
    Modification modification = new Modification("loser", "comment", "email", new Date(), "revision-123", JsonHelper.toJsonString(map));
    Modifications modifications = new Modifications(modification);
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K2"), is("!secure_value:with_special_chars"));
    assertThat(environmentVariableContext.getPropertyForDisplay("GO_SCM_TW_DEV_GO_AGENT_K2"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_ADDITIONAL_DATA_ONE"), is("foobar:!secure_value:with_special_chars"));
    assertThat(environmentVariableContext.getPropertyForDisplay("GO_SCM_TW_DEV_GO_AGENT_ADDITIONAL_DATA_ONE"), is("foobar:!secure_value:with_special_chars"));
    assertThat(environmentVariableContext.getPropertyForDisplay("GO_SCM_TW_DEV_GO_AGENT_ADDITIONAL_DATA_TWO"), is("foobar:secure_value_with_regular_chars"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_ADDITIONAL_DATA_URL_ENCODED"), is("something:%21secure_value%3Awith_special_chars"));
    assertThat(environmentVariableContext.getPropertyForDisplay("GO_SCM_TW_DEV_GO_AGENT_ADDITIONAL_DATA_URL_ENCODED"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Modifications(com.thoughtworks.go.domain.materials.Modifications) SCM(com.thoughtworks.go.domain.scm.SCM) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 5 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class TfsMaterialConfigUpdateTest method shouldSetConfigAttributes.

@Test
public void shouldSetConfigAttributes() {
    TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "some_domain", "passwd", "walk_this_path");
    Map<String, String> map = new HashMap<>();
    map.put(ScmMaterialConfig.URL, "http://foo:8080/tfs/HelloWorld");
    map.put(ScmMaterialConfig.USERNAME, "boozer");
    map.put(ScmMaterialConfig.PASSWORD, "secret");
    map.put(ScmMaterialConfig.FOLDER, "folder");
    map.put(ScmMaterialConfig.AUTO_UPDATE, "0");
    map.put(ScmMaterialConfig.FILTER, "/root,/**/*.help");
    map.put(AbstractMaterialConfig.MATERIAL_NAME, "my-tfs-material-name");
    map.put(TfsMaterialConfig.PROJECT_PATH, "/useless/project");
    map.put(TfsMaterialConfig.DOMAIN, "CORPORATE");
    tfsMaterialConfig.setConfigAttributes(map);
    TfsMaterialConfig newTfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://foo:8080/tfs/HelloWorld"), "boozer", "CORPORATE", "secret", "/useless/project");
    newTfsMaterialConfig.setName(new CaseInsensitiveString("my-tfs-material-name"));
    newTfsMaterialConfig.setFolder("folder");
    assertThat(tfsMaterialConfig, is(newTfsMaterialConfig));
    assertThat(tfsMaterialConfig.getPassword(), is("passwd"));
    assertThat(tfsMaterialConfig.isAutoUpdate(), is(false));
    assertThat(tfsMaterialConfig.getDomain(), is("CORPORATE"));
    assertThat(tfsMaterialConfig.getName(), is(new CaseInsensitiveString("my-tfs-material-name")));
    assertThat(tfsMaterialConfig.filter(), is(new Filter(new IgnoredFiles("/root"), new IgnoredFiles("/**/*.help"))));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) HashMap(java.util.HashMap) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)373 Test (org.junit.Test)276 Username (com.thoughtworks.go.server.domain.Username)84 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)69 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)58 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)55 Modification (com.thoughtworks.go.domain.materials.Modification)46 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HashMap (java.util.HashMap)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)29 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 Before (org.junit.Before)25 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 Pipeline (com.thoughtworks.go.domain.Pipeline)23 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)21 ArrayList (java.util.ArrayList)21 Stage (com.thoughtworks.go.domain.Stage)20