Search in sources :

Example 56 with ConfigurationKey

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

the class SecurityAuthConfigTest method postConstruct_shouldEncryptSecureConfigurations.

@Test
public void postConstruct_shouldEncryptSecureConfigurations() 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", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
    authConfig.encryptSecureConfigurations();
    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 57 with ConfigurationKey

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

the class SecurityAuthConfigTest method addConfigurations_shouldAddConfigurationsWithEncryptedValue.

@Test
public void addConfigurations_shouldAddConfigurationsWithEncryptedValue() throws Exception {
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new EncryptedConfigurationValue("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 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 58 with ConfigurationKey

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

the class SecurityAuthConfigTest method postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined.

@Test
public void postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined() throws Exception {
    SecurityAuthConfig authConfig = new SecurityAuthConfig("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
    authConfig.encryptSecureConfigurations();
    assertThat(authConfig.size(), is(1));
    assertFalse(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) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.jupiter.api.Test)

Example 59 with ConfigurationKey

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

the class ElasticProfileTest method addConfiguration_shouldIgnoreEncryptionInAbsenceOfCorrespondingConfigurationInStore.

@Test
public void addConfiguration_shouldIgnoreEncryptionInAbsenceOfCorrespondingConfigurationInStore() throws Exception {
    ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), new PluggableInstanceSettings(new ArrayList<>()), null, null, null, null);
    store.setPluginInfo(pluginInfo);
    ElasticProfile profile = new ElasticProfile("id", "prod-cluster");
    profile.addConfigurations(Arrays.asList(new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass"))));
    assertThat(profile.size(), is(1));
    assertFalse(profile.first().isSecure());
    assertThat(profile, 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) ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 60 with ConfigurationKey

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

the class ConfigurationPropertyMother method create.

public static ConfigurationProperty create(String key, boolean isSecure, String value) {
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(value), null, new GoCipher());
    property.handleSecureValueConfiguration(isSecure);
    return property;
}
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) GoCipher(com.thoughtworks.go.security.GoCipher)

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