use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class PluginProfileCommand method isValidForCreateOrUpdate.
protected boolean isValidForCreateOrUpdate(CruiseConfig preprocessedConfig) {
preprocessedProfile = findExistingProfile(preprocessedConfig);
preprocessedProfile.validate(null);
ValidationResult result = validateUsingExtension(preprocessedProfile.getPluginId(), profile.getConfigurationAsMap(true));
if (!result.isSuccessful()) {
for (ValidationError validationError : result.getErrors()) {
ConfigurationProperty property = preprocessedProfile.getProperty(validationError.getKey());
if (property == null) {
profile.addNewConfiguration(validationError.getKey(), false);
preprocessedProfile.addNewConfiguration(validationError.getKey(), false);
property = preprocessedProfile.getProperty(validationError.getKey());
}
property.addError(validationError.getKey(), validationError.getMessage());
}
}
if (preprocessedProfile.errors().isEmpty()) {
getPluginProfiles(preprocessedConfig).validate(null);
BasicCruiseConfig.copyErrors(preprocessedProfile, profile);
return preprocessedProfile.getAllErrors().isEmpty() && profile.errors().isEmpty();
}
BasicCruiseConfig.copyErrors(preprocessedProfile, profile);
return false;
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class ConfigRepoPlugin method getCrConfigurations.
public static List<CRConfigurationProperty> getCrConfigurations(Configuration configuration) {
List<CRConfigurationProperty> config = new ArrayList<>();
for (ConfigurationProperty prop : configuration) {
String configKeyName = prop.getConfigKeyName();
if (!prop.isSecure())
config.add(new CRConfigurationProperty(configKeyName, prop.getValue(), null));
else {
CRConfigurationProperty crProp = new CRConfigurationProperty(configKeyName, null, prop.getEncryptedValue());
config.add(crProp);
}
}
return config;
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class PluggableSCMMaterialPollerTest method assertConfiguration.
private void assertConfiguration(com.thoughtworks.go.plugin.api.config.Configuration configurationsSentToPlugin, Configuration configurationInMaterial) {
assertThat(configurationsSentToPlugin.size(), is(configurationInMaterial.size()));
for (ConfigurationProperty property : configurationInMaterial) {
Property configuration = configurationsSentToPlugin.get(property.getConfigurationKey().getName());
assertThat(configuration.getValue(), is(property.getValue()));
}
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class CruiseConfigTestBase method shouldAddPackageDefinitionToGivenRepository.
@Test
public void shouldAddPackageDefinitionToGivenRepository() throws Exception {
String repoId = "repo-id";
PackageRepository packageRepository = PackageRepositoryMother.create(repoId, "repo-name", "plugin-id", "1.0", new Configuration());
PackageDefinition existing = PackageDefinitionMother.create("pkg-1", "pkg1-name", new Configuration(), packageRepository);
packageRepository.setPackages(new Packages(existing));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
Configuration configuration = new Configuration();
configuration.add(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
configuration.add(new ConfigurationProperty(new ConfigurationKey("key-with-no-value"), new ConfigurationValue("")));
PackageDefinition packageDefinition = PackageDefinitionMother.create(null, "pkg2-name", configuration, packageRepository);
cruiseConfig.savePackageDefinition(packageDefinition);
assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
assertThat(cruiseConfig.getPackageRepositories().get(0).getId(), is(repoId));
assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().size(), is(2));
assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().get(0).getId(), is(existing.getId()));
PackageDefinition createdPkgDef = cruiseConfig.getPackageRepositories().get(0).getPackages().get(1);
assertThat(createdPkgDef.getId(), is(notNullValue()));
assertThat(createdPkgDef.getConfiguration().getProperty("key"), is(Matchers.notNullValue()));
assertThat(createdPkgDef.getConfiguration().getProperty("key-with-no-value"), is(nullValue()));
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class ConfigurationPropertyBuilderTest method shouldCreateWithErrorsInPresenceOfEncryptedTextInputForUnSecuredProperty.
@Test
public void shouldCreateWithErrorsInPresenceOfEncryptedTextInputForUnSecuredProperty() {
Property key = new Property("key");
key.with(Property.SECURE, false);
ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", null, "enc_value", false);
assertThat(property.errors().get("encryptedValue").get(0), is("encrypted_value cannot be specified to a unsecured property."));
assertThat(property.getEncryptedValue(), is("enc_value"));
}
Aggregations