use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class SecurityAuthConfigServiceTest method verifyConnection_shouldFailForAInvalidAuthConfig.
@Test
public void verifyConnection_shouldFailForAInvalidAuthConfig() throws Exception {
SecurityAuthConfig ldap = new SecurityAuthConfig("ldap", "cd.go.ldap", new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue()));
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("password", "Password cannot be blank"));
validationResult.addError(new ValidationError("username", "Username cannot be blank"));
VerifyConnectionResponse validationFailed = new VerifyConnectionResponse("validation-failed", "Connection check passed", validationResult);
when(extension.verifyConnection("cd.go.ldap", ldap.getConfigurationAsMap(true))).thenReturn(validationFailed);
VerifyConnectionResponse response = securityAuthConfigService.verifyConnection(ldap);
assertThat(response, is(validationFailed));
assertThat(ldap.getProperty("username").errors().get("username").get(0), is("Username cannot be blank"));
assertThat(ldap.getProperty("password").errors().get("password").get(0), is("Password cannot be blank"));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ArtifactStoreTest method postConstruct_shouldEncryptSecureConfigurations.
@Test
public void postConstruct_shouldEncryptSecureConfigurations() {
final PluggableInstanceSettings storeConfig = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true))));
final ArtifactPluginInfo pluginInfo = new ArtifactPluginInfo(pluginDescriptor("plugin_id"), storeConfig, null, null, null, null);
store.setPluginInfo(pluginInfo);
ArtifactStore artifactStore = new ArtifactStore("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
artifactStore.encryptSecureConfigurations();
assertThat(artifactStore.size(), is(1));
assertTrue(artifactStore.first().isSecure());
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class BasicCruiseConfigTest method setupPipelines.
private BasicCruiseConfig setupPipelines() {
BasicCruiseConfig config = GoConfigMother.configWithPipelines("ancestor", "parent", "child");
config.getArtifactStores().add(new ArtifactStore("cd.go.s3", "cd.go.s3"));
PipelineConfig ancestor = config.pipelineConfigByName(new CaseInsensitiveString("ancestor"));
ancestor.add(StageConfigMother.stageConfig("stage1", new JobConfigs(new JobConfig("job1"))));
PluggableArtifactConfig pluggableArtifactConfig = new PluggableArtifactConfig("art_1", "cd.go.s3", new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("pub_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("pub_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("pub_v3")));
ancestor.getStage("stage1").getJobs().first().artifactTypeConfigs().add(pluggableArtifactConfig);
PipelineConfig parent = config.pipelineConfigByName(new CaseInsensitiveString("parent"));
parent.add(StageConfigMother.stageConfig("stage1", new JobConfigs(new JobConfig("job1"))));
parent.getStage("stage1").jobConfigByConfigName("job1").artifactTypeConfigs().add(new PluggableArtifactConfig("art_2", "cd.go.s3"));
PipelineConfig child = config.pipelineConfigByName(new CaseInsensitiveString("child"));
child.addParam(new ParamConfig("UPSTREAM_PIPELINE", "ancestor/parent"));
child.addParam(new ParamConfig("UPSTREAM_STAGE", "stage1"));
child.addParam(new ParamConfig("UPSTREAM_JOB", "job1"));
child.addParam(new ParamConfig("ARTIFACT_ID", "art_1"));
child.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("parent", "stage1")));
child.add(StageConfigMother.stageConfig("stage1", new JobConfigs(new JobConfig("job1"))));
FetchPluggableArtifactTask fetchFromAncestor = new FetchPluggableArtifactTask(new CaseInsensitiveString("#{UPSTREAM_PIPELINE}"), new CaseInsensitiveString("#{UPSTREAM_STAGE}"), new CaseInsensitiveString("#{UPSTREAM_JOB}"), "#{ARTIFACT_ID}");
fetchFromAncestor.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("fetch_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("fetch_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("fetch_v3"))));
child.getStage("stage1").getJobs().get(0).addTask(fetchFromAncestor);
FetchPluggableArtifactTask fetchFromParent = new FetchPluggableArtifactTask(new CaseInsensitiveString("parent"), new CaseInsensitiveString("stage1"), new CaseInsensitiveString("job1"), "art_2");
fetchFromParent.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("fetch_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("fetch_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("fetch_v3"))));
child.getStage("stage1").getJobs().get(0).addTask(fetchFromParent);
setArtifactPluginInfo();
return config;
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class BasicCruiseConfigTest method shouldEncryptElasticAgentProfileConfigProperties.
@Test
public void shouldEncryptElasticAgentProfileConfigProperties(ResetCipher resetCipher) throws IOException, CryptoException {
setEAPluginInfo();
resetCipher.setupAESCipherFile();
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.getElasticConfig().getClusterProfiles().add(new ClusterProfile("prod-cluster", "ecs"));
ElasticProfile elasticProfile = new ElasticProfile("profile1", "prod-cluster");
elasticProfile.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("pub_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("pub_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("pub_v3"))));
cruiseConfig.getElasticConfig().getProfiles().add(elasticProfile);
BasicCruiseConfig preprocessed = GoConfigMother.deepClone(cruiseConfig);
new ConfigParamPreprocessor().process(preprocessed);
cruiseConfig.encryptSecureProperties(preprocessed);
Configuration properties = cruiseConfig.getElasticConfig().getProfiles().get(0);
GoCipher goCipher = new GoCipher();
assertThat(properties.getProperty("k1").getEncryptedValue(), is(goCipher.encrypt("pub_v1")));
assertThat(properties.getProperty("k1").getConfigValue(), is(nullValue()));
assertThat(properties.getProperty("k1").getValue(), is("pub_v1"));
assertThat(properties.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(properties.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(properties.getProperty("k2").getValue(), is("pub_v2"));
assertThat(properties.getProperty("k3").getEncryptedValue(), is(goCipher.encrypt("pub_v3")));
assertThat(properties.getProperty("k3").getConfigValue(), is(nullValue()));
assertThat(properties.getProperty("k3").getValue(), is("pub_v3"));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class JobInstanceMother method jobPlanWithAssociatedEntities.
public static JobPlan jobPlanWithAssociatedEntities(String jobName, long id, List<ArtifactPlan> artifactPlans) {
ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("image"), new ConfigurationValue("elastic-agent"));
ConfigurationProperty clusterconfigurationProperty = new ConfigurationProperty(new ConfigurationKey("Url"), new ConfigurationValue("aws.com"));
ElasticProfile elasticProfile = new ElasticProfile("elastic", "clusterId", configurationProperty);
ClusterProfile clusterProfile = new ClusterProfile("clusterId", "plugin", clusterconfigurationProperty);
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("some_var", "blah");
return new DefaultJobPlan(new Resources(new Resource("foo"), new Resource("bar")), artifactPlans, id, defaultJobIdentifier(jobName), null, variables, new EnvironmentVariables(), elasticProfile, clusterProfile);
}
Aggregations