Search in sources :

Example 41 with Configuration

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

the class SCMTest method shouldNotUpdateSecurePropertyWhenPluginIsMissing.

@Test
public void shouldNotUpdateSecurePropertyWhenPluginIsMissing() {
    GoCipher goCipher = new GoCipher();
    ConfigurationProperty secureProperty = new ConfigurationProperty(new ConfigurationKey("key1"), null, new EncryptedConfigurationValue("value"), goCipher);
    ConfigurationProperty nonSecureProperty = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value1"), null, goCipher);
    SCM scm = SCMMother.create("scm-id", "scm-name", "plugin-id", "version", new Configuration(secureProperty, nonSecureProperty));
    scm.applyPluginMetadata();
    assertThat(secureProperty.getEncryptedConfigurationValue(), is(notNullValue()));
    assertThat(secureProperty.getConfigurationValue(), is(nullValue()));
    assertThat(nonSecureProperty.getConfigurationValue(), is(notNullValue()));
    assertThat(nonSecureProperty.getEncryptedConfigurationValue(), is(nullValue()));
}
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) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) 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 42 with Configuration

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

the class SCMTest method shouldOnlyDisplayFieldsWhichAreNonSecureAndPartOfIdentityInGetConfigForDisplayWhenPluginExists.

@Test
public void shouldOnlyDisplayFieldsWhichAreNonSecureAndPartOfIdentityInGetConfigForDisplayWhenPluginExists() throws Exception {
    SCMConfigurations scmConfiguration = new SCMConfigurations();
    scmConfiguration.add(new SCMConfiguration("key1").with(PART_OF_IDENTITY, true).with(SECURE, false));
    scmConfiguration.add(new SCMConfiguration("key2").with(PART_OF_IDENTITY, false).with(SECURE, false));
    scmConfiguration.add(new SCMConfiguration("key3").with(PART_OF_IDENTITY, true).with(SECURE, true));
    scmConfiguration.add(new SCMConfiguration("key4").with(PART_OF_IDENTITY, false).with(SECURE, true));
    scmConfiguration.add(new SCMConfiguration("key5").with(PART_OF_IDENTITY, true).with(SECURE, false));
    SCMMetadataStore.getInstance().addMetadataFor("plugin-id", scmConfiguration, null);
    Configuration configuration = new Configuration(create("key1", false, "value1"), create("key2", false, "value2"), create("key3", true, "value3"), create("key4", true, "value4"), create("key5", false, "value5"));
    SCM scm = SCMMother.create("scm", "scm-name", "plugin-id", "1.0", configuration);
    assertThat(scm.getConfigForDisplay(), is("[key1=value1, key5=value5]"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.Test)

Example 43 with Configuration

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

the class SCMTest method shouldPopulateItselfFromConfigAttributesMap.

@Test
public void shouldPopulateItselfFromConfigAttributesMap() throws Exception {
    SCMConfigurations scmConfigurations = new SCMConfigurations();
    scmConfigurations.add(new SCMConfiguration("KEY1"));
    scmConfigurations.add(new SCMConfiguration("Key2"));
    SCMPreference scmPreference = mock(SCMPreference.class);
    when(scmPreference.getScmConfigurations()).thenReturn(scmConfigurations);
    SCMMetadataStore.getInstance().setPreferenceFor("plugin-id", scmPreference);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
    SCM scm = new SCM("scm-id", new PluginConfiguration("plugin-id", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    scm.setConfigAttributes(attributeMap);
    assertThat(scm.getConfigAsMap().get("KEY1").get(SCM.VALUE_KEY), is("value1"));
    assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY), is("value2"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.Test)

Example 44 with Configuration

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

the class SCMTest method shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration.

@Test
public void shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration() throws Exception {
    SCMConfigurations scmConfigurations = new SCMConfigurations();
    scmConfigurations.add(new SCMConfiguration("KEY1"));
    scmConfigurations.add(new SCMConfiguration("Key2"));
    SCMPreference scmPreference = mock(SCMPreference.class);
    when(scmPreference.getScmConfigurations()).thenReturn(scmConfigurations);
    SCMMetadataStore.getInstance().setPreferenceFor("plugin-id", scmPreference);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    SCM scm = new SCM("scm-id", new PluginConfiguration("plugin-id", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    scm.setConfigAttributes(attributeMap);
    assertThat(scm.getConfigAsMap().get("KEY1").get(SCM.VALUE_KEY), is("value1"));
    assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY), is("value2"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.Test)

Example 45 with Configuration

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

the class SCMTest method shouldSetConfigAttributesAsAvailable.

@Test
public void shouldSetConfigAttributesAsAvailable() throws Exception {
    SCMConfigurations scmConfigurations = new SCMConfigurations();
    scmConfigurations.add(new SCMConfiguration("url"));
    scmConfigurations.add(new SCMConfiguration("username"));
    scmConfigurations.add(new SCMConfiguration("password").with(SECURE, true));
    SCMMetadataStore.getInstance().addMetadataFor("plugin-id", scmConfigurations, null);
    Map<String, String> attributeMap = DataStructureUtils.m(SCM.SCM_ID, "scm-id", SCM.NAME, "scm-name", SCM.AUTO_UPDATE, "false", "url", "http://localhost", "username", "user", "password", "pass");
    SCM scm = new SCM(null, new PluginConfiguration("plugin-id", "1"), new Configuration());
    scm.setConfigAttributes(attributeMap);
    assertThat(scm.getId(), is("scm-id"));
    assertThat(scm.getName(), is("scm-name"));
    assertThat(scm.isAutoUpdate(), is(false));
    assertThat(scm.getPluginConfiguration().getId(), is("plugin-id"));
    assertThat(scm.getConfigAsMap().get("url").get(SCM.VALUE_KEY), is("http://localhost"));
    assertThat(scm.getConfigAsMap().get("username").get(SCM.VALUE_KEY), is("user"));
    assertThat(scm.getConfigAsMap().get("password").get(SCM.VALUE_KEY), is("pass"));
    assertThat(scm.getConfiguration().getProperty("password").getConfigurationValue(), is(nullValue()));
    assertThat(scm.getConfiguration().getProperty("password").getEncryptedConfigurationValue(), is(not(nullValue())));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.Test)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)136 Test (org.junit.Test)114 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)97 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)29 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)20 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)17 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)17 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)15 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)14 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)12 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)12 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)11 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)11 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)10 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)9