Search in sources :

Example 51 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class EntityHashingServiceTest method pluginSettings.

private PluginSettings pluginSettings(String id, String key, String secret) {
    final PluginSettings p = new PluginSettings(id);
    final ConfigurationProperty cp = new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(secret));
    cp.handleSecureValueConfiguration(true);
    p.getPluginSettingsProperties().add(cp);
    return p;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) PluginSettings(com.thoughtworks.go.server.domain.PluginSettings)

Example 52 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class BasicCruiseConfigTest method shouldEncryptSecurePluggableArtifactConfigPropertiesOfAllTemplatesInConfig.

@Test
public void shouldEncryptSecurePluggableArtifactConfigPropertiesOfAllTemplatesInConfig(ResetCipher resetCipher) throws IOException, CryptoException {
    setArtifactPluginInfo();
    resetCipher.setupAESCipherFile();
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.getArtifactStores().add(new ArtifactStore("store1", "cd.go.s3"));
    PipelineConfig pipelineConfig = new GoConfigMother().addPipelineWithTemplate(cruiseConfig, "p1", "t1", "s1", "j1");
    cruiseConfig.addPipeline("first", pipelineConfig);
    PipelineTemplateConfig templateConfig = cruiseConfig.getTemplates().first();
    JobConfig jobConfig = templateConfig.getStages().get(0).getJobs().get(0);
    PluggableArtifactConfig artifactConfig = new PluggableArtifactConfig("foo", "store1");
    artifactConfig.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"))));
    jobConfig.artifactTypeConfigs().add(artifactConfig);
    BasicCruiseConfig preprocessed = GoConfigMother.deepClone(cruiseConfig);
    new ConfigParamPreprocessor().process(preprocessed);
    cruiseConfig.encryptSecureProperties(preprocessed);
    Configuration properties = ((PluggableArtifactConfig) cruiseConfig.getTemplates().get(0).getStages().get(0).getJobs().get(0).artifactTypeConfigs().get(0)).getConfiguration();
    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) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigParamPreprocessor(com.thoughtworks.go.config.preprocessor.ConfigParamPreprocessor) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.jupiter.api.Test)

Example 53 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class BasicCruiseConfigTest method shouldEncryptSecureRoleConfigProperties.

@Test
public void shouldEncryptSecureRoleConfigProperties(ResetCipher resetCipher) throws IOException, CryptoException {
    setAuthorizationPluginInfo();
    resetCipher.setupAESCipherFile();
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.server().security().securityAuthConfigs().add(new SecurityAuthConfig("auth1", "cd.go.github"));
    PluginRoleConfig pluginRole = new PluginRoleConfig("role1", "auth1");
    pluginRole.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.server().security().getRoles().add(pluginRole);
    BasicCruiseConfig preprocessed = GoConfigMother.deepClone(cruiseConfig);
    new ConfigParamPreprocessor().process(preprocessed);
    cruiseConfig.encryptSecureProperties(preprocessed);
    Configuration properties = cruiseConfig.server().security().getRoles().getPluginRoleConfigs().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) ConfigParamPreprocessor(com.thoughtworks.go.config.preprocessor.ConfigParamPreprocessor) Test(org.junit.jupiter.api.Test)

Example 54 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ArtifactStoreTest method postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined.

@Test
public void postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined() {
    ArtifactStore artifactStore = new ArtifactStore("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
    artifactStore.encryptSecureConfigurations();
    assertThat(artifactStore.size(), is(1));
    assertFalse(artifactStore.first().isSecure());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.jupiter.api.Test)

Example 55 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class PluginRoleConfigTest method shouldEncryptSecurePluginProperties.

@Test
public void shouldEncryptSecurePluginProperties() throws CryptoException {
    setAuthorizationPluginInfo();
    String authConfigId = "auth_config_id";
    String pluginId = "cd.go.github";
    BasicCruiseConfig basicCruiseConfig = new BasicCruiseConfig();
    basicCruiseConfig.server().security().securityAuthConfigs().add(new SecurityAuthConfig(authConfigId, pluginId));
    PluginRoleConfig role = new PluginRoleConfig("admin", authConfigId);
    role.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"))));
    GoCipher goCipher = new GoCipher();
    assertThat(role.getProperty("k1").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k1").getConfigValue(), is("pub_v1"));
    assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
    assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
    assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
    assertThat(role.getProperty("k3").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k3").getConfigValue(), is("pub_v3"));
    assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
    role.encryptSecureProperties(basicCruiseConfig);
    assertThat(role.getProperty("k1").getEncryptedValue(), is(goCipher.encrypt("pub_v1")));
    assertThat(role.getProperty("k1").getConfigValue(), is(nullValue()));
    assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
    assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
    assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
    assertThat(role.getProperty("k3").getEncryptedValue(), is(goCipher.encrypt("pub_v3")));
    assertThat(role.getProperty("k3").getConfigValue(), is(nullValue()));
    assertThat(role.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) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.jupiter.api.Test)

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