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