Search in sources :

Example 66 with ConfigurationProperty

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

the class SCMTest method shouldValidateUniqueKeysInConfiguration.

@Test
public void shouldValidateUniqueKeysInConfiguration() {
    ConfigurationProperty one = create("one", false, "value1");
    ConfigurationProperty duplicate1 = create("ONE", false, "value2");
    ConfigurationProperty duplicate2 = create("ONE", false, "value3");
    ConfigurationProperty two = create("two", false, null);
    SCM scm = new SCM();
    scm.setConfiguration(new Configuration(one, duplicate1, duplicate2, two));
    scm.setName("git");
    scm.validate(null);
    assertThat(one.errors().isEmpty(), is(false));
    assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
    assertThat(duplicate1.errors().isEmpty(), is(false));
    assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
    assertThat(duplicate2.errors().isEmpty(), is(false));
    assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
    assertThat(two.errors().isEmpty(), is(true));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) Test(org.junit.Test)

Example 67 with ConfigurationProperty

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

the class SCMTest method shouldGetConfigAsMap.

@Test
public void shouldGetConfigAsMap() throws Exception {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("test-plugin-id", "13.4");
    GoCipher cipher = new GoCipher();
    List<String> keys = Arrays.asList("Avengers 1", "Avengers 2", "Avengers 3", "Avengers 4");
    List<String> values = Arrays.asList("Iron man", "Hulk", "Thor", "Captain America");
    Configuration configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey(keys.get(0)), new ConfigurationValue(values.get(0))), new ConfigurationProperty(new ConfigurationKey(keys.get(1)), new ConfigurationValue(values.get(1))), new ConfigurationProperty(new ConfigurationKey(keys.get(2)), new ConfigurationValue(values.get(2))), new ConfigurationProperty(new ConfigurationKey(keys.get(3)), new ConfigurationValue(values.get(3)), new EncryptedConfigurationValue(cipher.encrypt(values.get(3))), cipher));
    SCM scm = new SCM("scm-id", pluginConfiguration, configuration);
    Map<String, Map<String, String>> configMap = scm.getConfigAsMap();
    assertThat(configMap.keySet().size(), is(keys.size()));
    assertThat(configMap.values().size(), is(values.size()));
    assertThat(configMap.keySet().containsAll(keys), is(true));
    for (int i = 0; i < keys.size(); i++) {
        assertThat(configMap.get(keys.get(i)).get(SCM.VALUE_KEY), is(values.get(i)));
    }
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) GoCipher(com.thoughtworks.go.security.GoCipher) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 68 with ConfigurationProperty

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

the class SCMTest method shouldAddConfigurationPropertiesForAnyPlugin.

@Test
public void shouldAddConfigurationPropertiesForAnyPlugin() {
    List<ConfigurationProperty> configurationProperties = Arrays.asList(ConfigurationPropertyMother.create("key", "value", "encValue"));
    Configuration configuration = new Configuration();
    SCM scm = SCMMother.create("id", "name", "does_not_exist", "1.1", configuration);
    assertThat(configuration.size(), is(0));
    scm.addConfigurations(configurationProperties);
    assertThat(configuration.size(), is(1));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) Test(org.junit.Test)

Example 69 with ConfigurationProperty

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

the class SCMTest method shouldClearConfigurationsWhichAreEmptyAndNoErrors.

@Test
public void shouldClearConfigurationsWhichAreEmptyAndNoErrors() throws Exception {
    SCM scm = new SCM();
    scm.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-one"), new ConfigurationValue()));
    scm.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-two"), new EncryptedConfigurationValue()));
    scm.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-three"), null, new EncryptedConfigurationValue(), null));
    ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("name-four"), null, new EncryptedConfigurationValue(), null);
    configurationProperty.addErrorAgainstConfigurationValue("error");
    scm.getConfiguration().add(configurationProperty);
    scm.clearEmptyConfigurations();
    assertThat(scm.getConfiguration().size(), is(1));
    assertThat(scm.getConfiguration().get(0).getConfigurationKey().getName(), is("name-four"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) 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 70 with ConfigurationProperty

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

the class MaterialConfigsMother method pluggableSCMMaterialConfigWithConfigProperties.

public static PluggableSCMMaterialConfig pluggableSCMMaterialConfigWithConfigProperties(String... properties) {
    SCM scmConfig = SCMMother.create("scm-id");
    Configuration configuration = new Configuration();
    for (String property : properties) {
        ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey(property), new ConfigurationValue(property + "-value"));
        configuration.add(configurationProperty);
    }
    scmConfig.setConfiguration(configuration);
    return new PluggableSCMMaterialConfig(null, scmConfig, "des-folder", null);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) SCM(com.thoughtworks.go.domain.scm.SCM)

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