use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class PackageRepositoryService method populateConfiguration.
private RepositoryConfiguration populateConfiguration(Configuration configuration) {
RepositoryConfiguration repositoryConfiguration = new RepositoryConfiguration();
for (ConfigurationProperty configurationProperty : configuration) {
String value = configurationProperty.getValue();
repositoryConfiguration.add(new PackageMaterialProperty(configurationProperty.getConfigurationKey().getName(), value));
}
return repositoryConfiguration;
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class PackageRepositoryService method addErrorsToConfiguration.
private void addErrorsToConfiguration(ValidationResult validationResult, PackageRepository packageRepository) {
for (ValidationError validationError : validationResult.getErrors()) {
ConfigurationProperty property = packageRepository.getConfiguration().getProperty(validationError.getKey());
if (property != null) {
property.addError(validationError.getKey(), validationError.getMessage());
} else {
String validationErrorKey = StringUtils.isBlank(validationError.getKey()) ? PackageRepository.CONFIGURATION : validationError.getKey();
packageRepository.addError(validationErrorKey, validationError.getMessage());
}
}
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class DeletePackageConfigCommandTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
packageUuid = "random-uuid";
configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey("PACKAGE_ID"), new ConfigurationValue("prettyjson")));
packageDefinition = new PackageDefinition(packageUuid, "prettyjson", configuration);
result = new HttpLocalizedOperationResult();
PackageRepositories repositories = cruiseConfig.getPackageRepositories();
PackageRepository repository = new PackageRepository();
repository.addPackage(packageDefinition);
repositories.add(repository);
cruiseConfig.setPackageRepositories(repositories);
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class SecurityAuthConfigCreateCommandTest method shouldInvokePluginValidationsBeforeSave.
@Test
public void shouldInvokePluginValidationsBeforeSave() throws Exception {
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("key", "error"));
when(extension.validateAuthConfig(eq("aws"), Matchers.<Map<String, String>>any())).thenReturn(validationResult);
SecurityAuthConfig newProfile = new SecurityAuthConfig("foo", "aws", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("val")));
PluginProfileCommand command = new SecurityAuthConfigCreateCommand(mock(GoConfigService.class), newProfile, extension, null, new HttpLocalizedOperationResult());
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
thrown.expect(PluginProfileNotFoundException.class);
thrown.expectMessage("Security auth config `foo` does not exist.");
command.isValid(cruiseConfig);
command.update(cruiseConfig);
assertThat(newProfile.first().errors().size(), is(1));
assertThat(newProfile.first().errors().asString(), is("error"));
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class PackageDefinitionTest method shouldMakeConfigurationSecureBasedOnMetadata.
@Test
public void shouldMakeConfigurationSecureBasedOnMetadata() throws Exception {
/*secure property is set based on metadata*/
ConfigurationProperty secureProperty = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, new GoCipher());
ConfigurationProperty nonSecureProperty = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, new GoCipher());
PackageDefinition packageDefinition = new PackageDefinition("go", "name", new Configuration(secureProperty, nonSecureProperty));
PackageRepository packageRepository = new PackageRepository();
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-id", "1.0"));
packageDefinition.setRepository(packageRepository);
PackageConfigurations packageConfigurations = new PackageConfigurations();
packageConfigurations.addConfiguration(new PackageConfiguration("key1").with(PackageConfiguration.SECURE, true));
packageConfigurations.addConfiguration(new PackageConfiguration("key2").with(PackageConfiguration.SECURE, false));
PackageMetadataStore.getInstance().addMetadataFor("plugin-id", packageConfigurations);
packageDefinition.applyPackagePluginMetadata("plugin-id");
assertThat(secureProperty.isSecure(), is(true));
assertThat(nonSecureProperty.isSecure(), is(false));
}
Aggregations