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));
}
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));
}
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));
}
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));
}
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"))));
}
Aggregations