use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class MaterialConfigsMother method pluggableSCMMaterialConfigWithConfigProperties.
public static PluggableSCMMaterialConfig pluggableSCMMaterialConfigWithConfigProperties(String... properties) {
SCM scmConfig = SCMMother.create("scm-id");
Configuration configuration = new Configuration();
for (String property : properties) {
ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey(property), new ConfigurationValue(property + "-value"));
configuration.add(configurationProperty);
}
scmConfig.setConfiguration(configuration);
return new PluggableSCMMaterialConfig(null, scmConfig, "des-folder", null, false);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class SecretConfigCreateCommandTest method shouldInvokePluginValidations.
@Test
public void shouldInvokePluginValidations() throws Exception {
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("key", "error"));
SecretConfig newSecretConfig = new SecretConfig("foo", "file", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("val")));
RuleAwarePluginProfileCommand command = new SecretConfigCreateCommand(mock(GoConfigService.class), newSecretConfig, extension, null, new HttpLocalizedOperationResult());
when(extension.validateSecretsConfig(eq("file"), anyMap())).thenReturn(validationResult);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
assertThatThrownBy(() -> command.isValid(cruiseConfig)).isInstanceOf(RecordNotFoundException.class).hasMessageContaining(EntityType.SecretConfig.notFoundMessage(newSecretConfig.getId()));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey 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"), anyMap())).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();
assertThatThrownBy(() -> command.isValid(cruiseConfig)).isInstanceOf(RecordNotFoundException.class).hasMessageContaining(EntityType.SecurityAuthConfig.notFoundMessage(newProfile.getId()));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class RuleAwarePluginProfileCommandTest method shouldValidateIfSecretConfigIdIsNull.
@Test
public void shouldValidateIfSecretConfigIdIsNull() {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
SecretConfig securityAuthConfig = new SecretConfig(null, "some-plugin", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
cruiseConfig.getSecretConfigs().add(securityAuthConfig);
RuleAwarePluginProfileCommand command = new StubSecretConfigCommand(goConfigService, securityAuthConfig, currentUser, result);
assertThatThrownBy(() -> command.isValid(cruiseConfig)).hasMessageContaining(EntityType.ElasticProfile.idCannotBeBlank());
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class CreateAgentMessageTest method shouldGetPluginId.
@Test
void shouldGetPluginId() {
List<ConfigurationProperty> properties = singletonList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
ElasticProfile elasticProfile = new ElasticProfile("foo", "prod-cluster", properties);
ClusterProfile clusterProfile = new ClusterProfile("foo", "plugin-id", properties);
Map<String, String> clusterProfileConfigurations = clusterProfile.getConfigurationAsMap(true);
Map<String, String> configurationAsMap = elasticProfile.getConfigurationAsMap(true);
CreateAgentMessage message = new CreateAgentMessage("key", "env", elasticProfile, clusterProfile, null);
assertThat(message.pluginId()).isEqualTo(clusterProfile.getPluginId());
assertThat(message.getClusterProfileConfiguration()).isEqualTo(clusterProfileConfigurations);
assertThat(message.configuration()).isEqualTo(configurationAsMap);
}
Aggregations