Search in sources :

Example 16 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ElasticProfileTest method addConfigurations_shouldAddConfigurationsWithEncryptedValue.

@Test
public void addConfigurations_shouldAddConfigurationsWithEncryptedValue() throws Exception {
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new EncryptedConfigurationValue("some_name"));
    ElasticProfile profile = new ElasticProfile("id", "prod-cluster");
    profile.addConfigurations(Arrays.asList(property));
    assertThat(profile.size(), is(1));
    assertThat(profile, contains(new ConfigurationProperty(new ConfigurationKey("username"), new EncryptedConfigurationValue("some_name"))));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.jupiter.api.Test)

Example 17 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class SecurityAuthConfigTest method addConfiguration_shouldIgnoreEncryptionInAbsenceOfCorrespondingConfigurationInStore.

@Test
public void addConfiguration_shouldIgnoreEncryptionInAbsenceOfCorrespondingConfigurationInStore() throws Exception {
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(pluginDescriptor("plugin_id"), new PluggableInstanceSettings(new ArrayList<>()), null, null, null);
    store.setPluginInfo(pluginInfo);
    SecurityAuthConfig authConfig = new SecurityAuthConfig("id", "plugin_id");
    authConfig.addConfigurations(Arrays.asList(new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass"))));
    assertThat(authConfig.size(), is(1));
    assertFalse(authConfig.first().isSecure());
    assertThat(authConfig, contains(new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass"))));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 18 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class SecurityAuthConfigTest method addConfiguration_shouldEncryptASecureVariable.

@Test
public void addConfiguration_shouldEncryptASecureVariable() throws Exception {
    PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true))));
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(pluginDescriptor("plugin_id"), profileSettings, null, null, null);
    store.setPluginInfo(pluginInfo);
    SecurityAuthConfig authConfig = new SecurityAuthConfig("id", "plugin_id");
    authConfig.addConfigurations(Arrays.asList(new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass"))));
    assertThat(authConfig.size(), is(1));
    assertTrue(authConfig.first().isSecure());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 19 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class SecurityAuthConfigTest method addConfigurations_shouldAddConfigurationsWithValue.

@Test
public void addConfigurations_shouldAddConfigurationsWithValue() throws Exception {
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("some_name"));
    SecurityAuthConfig authConfig = new SecurityAuthConfig("id", "plugin_id");
    authConfig.addConfigurations(Arrays.asList(property));
    assertThat(authConfig.size(), is(1));
    assertThat(authConfig, contains(new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("some_name"))));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.jupiter.api.Test)

Example 20 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ElasticAgentProfileCreateCommandTest method shouldInvokePluginValidationsBeforeSave.

@Test
public void shouldInvokePluginValidationsBeforeSave() throws Exception {
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("key", "error"));
    when(extension.validate(eq("aws"), anyMap())).thenReturn(validationResult);
    ElasticProfile newProfile = new ElasticProfile("foo", "prod-cluster", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("val")));
    EntityConfigUpdateCommand command = new ElasticAgentProfileCreateCommand(mock(GoConfigService.class), newProfile, extension, null, new HttpLocalizedOperationResult());
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    assertThatThrownBy(() -> command.isValid(cruiseConfig)).isInstanceOf(RecordNotFoundException.class).hasMessageContaining(EntityType.ElasticProfile.notFoundMessage(newProfile.getId()));
    command.update(cruiseConfig);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) EntityConfigUpdateCommand(com.thoughtworks.go.config.commands.EntityConfigUpdateCommand) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)71 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)71 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)65 Test (org.junit.jupiter.api.Test)49 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)29 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)13 GoCipher (com.thoughtworks.go.security.GoCipher)13 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)12 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)12 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)11 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 ArrayList (java.util.ArrayList)9 Configuration (com.thoughtworks.go.domain.config.Configuration)8 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)8 Test (org.junit.Test)7 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)5 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)4