Search in sources :

Example 6 with Configuration

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

the class SCMConfigXmlLoaderTest method shouldBeAbleToResolveSecureConfigPropertiesForSCMs.

@Test
public void shouldBeAbleToResolveSecureConfigPropertiesForSCMs() throws Exception {
    String encryptedValue = new GoCipher().encrypt("secure-two");
    String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'>\n" + "<scms>\n" + "    <scm id='scm-id' name='name'>\n" + "		<pluginConfiguration id='plugin-id' version='1.0'/>\n" + "      <configuration>\n" + "        <property>\n" + "          <key>plain</key>\n" + "          <value>value</value>\n" + "        </property>\n" + "        <property>\n" + "          <key>secure-one</key>\n" + "          <value>secure-value</value>\n" + "        </property>\n" + "        <property>\n" + "          <key>secure-two</key>\n" + "          <encryptedValue>" + encryptedValue + "</encryptedValue>\n" + "        </property>\n" + "      </configuration>\n" + "    </scm>\n" + "  </scms>" + "<pipelines group=\"group_name\">\n" + "  <pipeline name=\"new_name\">\n" + "    <materials>\n" + "      <scm ref='scm-id' />\n" + "    </materials>\n" + "    <stage name=\"stage_name\">\n" + "      <jobs>\n" + "        <job name=\"job_name\" />\n" + "      </jobs>\n" + "    </stage>\n" + "  </pipeline>\n" + "</pipelines></cruise>";
    //meta data of scm
    SCMPropertyConfiguration scmConfiguration = new SCMPropertyConfiguration();
    scmConfiguration.add(new SCMProperty("plain"));
    scmConfiguration.add(new SCMProperty("secure-one").with(SCMConfiguration.SECURE, true));
    scmConfiguration.add(new SCMProperty("secure-two").with(SCMConfiguration.SECURE, true));
    SCMMetadataStore.getInstance().addMetadataFor("plugin-id", new SCMConfigurations(scmConfiguration), null);
    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(xml);
    SCM scmConfig = goConfigHolder.config.getSCMs().first();
    PipelineConfig pipelineConfig = goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("new_name"));
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) pipelineConfig.materialConfigs().get(0);
    assertThat(pluggableSCMMaterialConfig.getSCMConfig(), is(scmConfig));
    Configuration configuration = pluggableSCMMaterialConfig.getSCMConfig().getConfiguration();
    assertThat(configuration.get(0).getConfigurationValue().getValue(), is("value"));
    assertThat(configuration.get(1).getEncryptedValue(), is(new GoCipher().encrypt("secure-value")));
    assertThat(configuration.get(2).getEncryptedValue(), is(encryptedValue));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) Configuration(com.thoughtworks.go.domain.config.Configuration) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 7 with Configuration

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

the class PackageDefinitionTest method shouldNotDisplayEmptyValuesInGetConfigForDisplay.

@Test
public void shouldNotDisplayEmptyValuesInGetConfigForDisplay() throws Exception {
    RepositoryMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "some-plugin", "version", new Configuration(create("rk1", false, "rv1")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pk1", false, ""), create("pk2", false, "pack_value_2"), create("pk3", false, null)), repository);
    packageDefinition.setRepository(repository);
    assertThat(packageDefinition.getConfigForDisplay(), is("Repository: [rk1=rv1] - Package: [pk2=pack_value_2]"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 8 with Configuration

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

the class PackageDefinitionTest method shouldCheckForEqualityOfPackageDefinition.

@Test
public void shouldCheckForEqualityOfPackageDefinition() {
    Configuration configuration = new Configuration();
    PackageDefinition packageDefinition = new PackageDefinition("id", "name", configuration);
    assertThat(packageDefinition, is(new PackageDefinition("id", "name", configuration)));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) Test(org.junit.Test)

Example 9 with Configuration

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

the class PackageDefinitionTest method shouldConvertKeysToLowercaseInGetConfigForDisplay.

@Test
public void shouldConvertKeysToLowercaseInGetConfigForDisplay() throws Exception {
    RepositoryMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "some-plugin", "version", new Configuration(create("rk1", false, "rv1")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pack_key_1", false, "pack_value_1"), create("PACK_KEY_2", false, "PACK_VALUE_2"), create("pacK_KeY3", false, "pacKValue_3")), repository);
    packageDefinition.setRepository(repository);
    assertThat(packageDefinition.getConfigForDisplay(), is("Repository: [rk1=rv1] - Package: [pack_key_1=pack_value_1, pack_key_2=PACK_VALUE_2, pack_key3=pacKValue_3]"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 10 with Configuration

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

the class PackageDefinitionTest method shouldValidateUniqueKeysInConfiguration.

@Test
public void shouldValidateUniqueKeysInConfiguration() {
    ConfigurationProperty one = new ConfigurationProperty(new ConfigurationKey("one"), new ConfigurationValue("value1"));
    ConfigurationProperty duplicate1 = new ConfigurationProperty(new ConfigurationKey("ONE"), new ConfigurationValue("value2"));
    ConfigurationProperty duplicate2 = new ConfigurationProperty(new ConfigurationKey("ONE"), new ConfigurationValue("value3"));
    ConfigurationProperty two = new ConfigurationProperty(new ConfigurationKey("two"), new ConfigurationValue());
    PackageDefinition packageDefinition = new PackageDefinition();
    packageDefinition.setConfiguration(new Configuration(one, duplicate1, duplicate2, two));
    packageDefinition.setName("go-server");
    packageDefinition.validate(null);
    assertThat(one.errors().isEmpty(), is(false));
    assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for Package 'go-server'"), is(true));
    assertThat(duplicate1.errors().isEmpty(), is(false));
    assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for Package 'go-server'"), is(true));
    assertThat(duplicate2.errors().isEmpty(), is(false));
    assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for Package 'go-server'"), is(true));
    assertThat(two.errors().isEmpty(), is(true));
}
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) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) Test(org.junit.Test)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)134 Test (org.junit.Test)116 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)95 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)28 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