use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PackageRepositoryTest method shouldNotUpdateSecurePropertyWhenPluginIsMissing.
@Test
public void shouldNotUpdateSecurePropertyWhenPluginIsMissing() {
GoCipher goCipher = new GoCipher();
ConfigurationProperty secureProperty = new ConfigurationProperty(new ConfigurationKey("key1"), null, new EncryptedConfigurationValue("value"), goCipher);
ConfigurationProperty nonSecureProperty = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, goCipher);
PackageDefinition packageDefinition = new PackageDefinition("go", "name", new Configuration(secureProperty, nonSecureProperty));
ConfigurationProperty nonSecureRepoProperty = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, goCipher);
ConfigurationProperty secureRepoProperty = new ConfigurationProperty(new ConfigurationKey("key2"), null, new EncryptedConfigurationValue("value"), goCipher);
PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name", new Configuration(secureRepoProperty, nonSecureRepoProperty), new Packages(packageDefinition));
packageRepository.applyPackagePluginMetadata();
assertThat(secureProperty.getEncryptedConfigurationValue(), is(notNullValue()));
assertThat(secureProperty.getConfigurationValue(), is(nullValue()));
assertThat(nonSecureProperty.getConfigurationValue(), is(notNullValue()));
assertThat(nonSecureProperty.getEncryptedConfigurationValue(), is(nullValue()));
assertThat(secureRepoProperty.getEncryptedConfigurationValue(), is(notNullValue()));
assertThat(secureRepoProperty.getConfigurationValue(), is(nullValue()));
assertThat(nonSecureRepoProperty.getConfigurationValue(), is(notNullValue()));
assertThat(nonSecureRepoProperty.getEncryptedConfigurationValue(), is(nullValue()));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PackageRepositoryTest method shouldClearConfigurationsWhichAreEmptyAndNoErrors.
@Test
public void shouldClearConfigurationsWhichAreEmptyAndNoErrors() throws Exception {
PackageRepository packageRepository = new PackageRepository();
packageRepository.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-one"), new ConfigurationValue()));
packageRepository.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-two"), new EncryptedConfigurationValue()));
packageRepository.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-three"), null, new EncryptedConfigurationValue(), null));
ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("name-four"), null, new EncryptedConfigurationValue(), null);
configurationProperty.addErrorAgainstConfigurationValue("error");
packageRepository.getConfiguration().add(configurationProperty);
packageRepository.clearEmptyConfigurations();
assertThat(packageRepository.getConfiguration().size(), is(1));
assertThat(packageRepository.getConfiguration().get(0).getConfigurationKey().getName(), is("name-four"));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PackageRepositoryTest method shouldValidateUniqueKeysInConfiguration.
@Test
public void shouldValidateUniqueKeysInConfiguration() {
ConfigurationProperty one = new ConfigurationProperty(new ConfigurationKey("one"), new ConfigurationValue("value1"));
ConfigurationProperty duplicate1 = new ConfigurationProperty(new ConfigurationKey("ONE"), new ConfigurationValue("value2"));
ConfigurationProperty duplicate2 = new ConfigurationProperty(new ConfigurationKey("ONE"), new ConfigurationValue("value3"));
ConfigurationProperty two = new ConfigurationProperty(new ConfigurationKey("two"), new ConfigurationValue());
PackageRepository repository = new PackageRepository();
repository.setConfiguration(new Configuration(one, duplicate1, duplicate2, two));
repository.setName("yum");
repository.validate(null);
assertThat(one.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for Repository 'yum'"), is(true));
assertThat(duplicate1.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for Repository 'yum'"), is(true));
assertThat(duplicate2.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for Repository 'yum'"), is(true));
assertThat(two.errors().isEmpty(), is(true));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PluginSettings method populateSettingsMap.
public PluginSettings populateSettingsMap(PluginSettingsConfiguration configuration) {
for (Property property : configuration.list()) {
String settingsKey = property.getKey();
settingsMap.add(new ConfigurationProperty(new ConfigurationKey(settingsKey), new ConfigurationValue("")));
}
return this;
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class JobAgentMetadata method elasticProfile.
public ElasticProfile elasticProfile() {
Gson gson = new Gson();
Map map = gson.fromJson(metadata, LinkedHashMap.class);
String pluginId = (String) map.get("pluginId");
String id = (String) map.get("id");
Map<String, String> properties = (Map<String, String>) map.get("properties");
Collection<ConfigurationProperty> configProperties = properties.entrySet().stream().map(new Function<Map.Entry<String, String>, ConfigurationProperty>() {
@Override
public ConfigurationProperty apply(Map.Entry<String, String> entry) {
return new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()));
}
}).collect(Collectors.toList());
return new ElasticProfile(id, pluginId, configProperties);
}
Aggregations