Search in sources :

Example 76 with ConfigurationProperty

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());
}
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 77 with ConfigurationProperty

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"));
}
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 78 with ConfigurationProperty

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());
}
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 79 with ConfigurationProperty

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"))));
}
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.Test)

Example 80 with ConfigurationProperty

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;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ArrayList(java.util.ArrayList)

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