Search in sources :

Example 36 with ConfigurationProperty

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

the class ConfigurationPropertyBuilderTest method shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForUnSecuredProperty.

@Test
public void shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForUnSecuredProperty() {
    Property key = new Property("key");
    key.with(Property.SECURE, false);
    ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", "enc_value", false);
    assertThat(property.errors().get("configurationValue").get(0), is("You may only specify `value` or `encrypted_value`, not both!"));
    assertThat(property.errors().get("encryptedValue").get(0), is("You may only specify `value` or `encrypted_value`, not both!"));
    assertThat(property.getConfigurationValue().getValue(), is("value"));
    assertThat(property.getEncryptedValue(), is("enc_value"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Property(com.thoughtworks.go.plugin.api.config.Property) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Test(org.junit.Test)

Example 37 with ConfigurationProperty

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

the class ElasticProfileTest method postConstruct_shouldEncryptSecureConfigurations.

@Test
public void postConstruct_shouldEncryptSecureConfigurations() {
    PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true))));
    ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), profileSettings, null, null, null);
    store.setPluginInfo(pluginInfo);
    ElasticProfile profile = new ElasticProfile("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
    profile.encryptSecureConfigurations();
    assertThat(profile.size(), is(1));
    assertTrue(profile.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) ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.Test)

Example 38 with ConfigurationProperty

use of com.thoughtworks.go.domain.config.ConfigurationProperty 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", "plugin_id");
    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.Test)

Example 39 with ConfigurationProperty

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

the class ElasticProfileTest method postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined.

@Test
public void postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined() {
    ElasticProfile profile = new ElasticProfile("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
    profile.encryptSecureConfigurations();
    assertThat(profile.size(), is(1));
    assertFalse(profile.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.Test)

Example 40 with ConfigurationProperty

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

the class ElasticProfileTest method shouldValidateConfigPropertyNameUniqueness.

@Test
public void shouldValidateConfigPropertyNameUniqueness() throws Exception {
    ConfigurationProperty prop1 = ConfigurationPropertyMother.create("USERNAME");
    ConfigurationProperty prop2 = ConfigurationPropertyMother.create("USERNAME");
    ElasticProfile profile = new ElasticProfile("docker.unit-test", "cd.go.elastic-agent.docker", prop1, prop2);
    profile.validate(null);
    assertThat(profile.errors().size(), is(0));
    assertThat(prop1.errors().size(), is(1));
    assertThat(prop2.errors().size(), is(1));
    assertThat(prop1.errors().on(ConfigurationProperty.CONFIGURATION_KEY), is("Duplicate key 'USERNAME' found for Elastic agent profile 'docker.unit-test'"));
    assertThat(prop2.errors().on(ConfigurationProperty.CONFIGURATION_KEY), is("Duplicate key 'USERNAME' found for Elastic agent profile 'docker.unit-test'"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Test(org.junit.Test)

Aggregations

ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)113 Test (org.junit.Test)71 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)51 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)49 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)30 Configuration (com.thoughtworks.go.domain.config.Configuration)29 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)21 Property (com.thoughtworks.go.plugin.api.config.Property)13 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)11 GoCipher (com.thoughtworks.go.security.GoCipher)11 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)10 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)8 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)8 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)7 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)7 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)7 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)6 ArrayList (java.util.ArrayList)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5