Search in sources :

Example 21 with ConfigurationKey

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"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) VerifyConnectionResponse(com.thoughtworks.go.plugin.domain.common.VerifyConnectionResponse) SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ValidationError(com.thoughtworks.go.plugin.domain.common.ValidationError) ValidationResult(com.thoughtworks.go.plugin.domain.common.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 22 with ConfigurationKey

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());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) Test(org.junit.jupiter.api.Test)

Example 23 with ConfigurationKey

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;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey)

Example 24 with ConfigurationKey

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"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) GoCipher(com.thoughtworks.go.security.GoCipher) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) ConfigParamPreprocessor(com.thoughtworks.go.config.preprocessor.ConfigParamPreprocessor) Test(org.junit.jupiter.api.Test)

Example 25 with ConfigurationKey

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);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Aggregations

ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)71 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)71 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)65 Test (org.junit.jupiter.api.Test)49 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)29 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)13 GoCipher (com.thoughtworks.go.security.GoCipher)13 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)12 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)12 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)11 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 ArrayList (java.util.ArrayList)9 Configuration (com.thoughtworks.go.domain.config.Configuration)8 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)8 Test (org.junit.Test)7 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)5 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)4