use of com.thoughtworks.go.domain.config.ConfigurationProperty 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());
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class ConfigurationPropertyBuilderTest method shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForSecureProperty.
@Test
public void shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForSecureProperty() {
Property key = new Property("key");
key.with(Property.SECURE, true);
ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", "enc_value", true);
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 ConfigurationPropertyBuilderTest method shouldCreateWithValueForAUnsecuredProperty.
@Test
public void shouldCreateWithValueForAUnsecuredProperty() {
Property key = new Property("key");
key.with(Property.SECURE, false);
ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", null, false);
assertThat(property.getConfigurationValue().getValue(), is("value"));
assertNull(property.getEncryptedConfigurationValue());
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty 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);
store.setPluginInfo(pluginInfo);
ElasticProfile profile = new ElasticProfile("id", "plugin_id");
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"))));
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class ConfigurationDisplayUtil method getConfigurationPropertiesToBeUsedForDisplay.
public static List<ConfigurationProperty> getConfigurationPropertiesToBeUsedForDisplay(PluginPreferenceStore metadataStore, String pluginId, final Configuration configuration) {
List<ConfigurationProperty> keysForDisplay = new ArrayList<>();
boolean pluginDoesNotExist = !metadataStore.hasPreferenceFor(pluginId);
for (ConfigurationProperty property : configuration) {
boolean isNotASecureProperty = !property.isSecure();
boolean isPartOfIdentity = metadataStore.hasOption(pluginId, property.getConfigurationKey().getName(), PackageConfiguration.PART_OF_IDENTITY);
if (isNotASecureProperty && !StringUtils.isBlank(property.getValue()) && (pluginDoesNotExist || isPartOfIdentity)) {
keysForDisplay.add(property);
}
}
return keysForDisplay;
}
Aggregations