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"));
}
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());
}
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"))));
}
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());
}
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'"));
}
Aggregations