Search in sources :

Example 1 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration.

@Test
void shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration() {
    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)).isEqualTo("value1");
    assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY)).isEqualTo("value2");
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 2 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldPopulateItselfFromConfigAttributesMap.

@Test
void shouldPopulateItselfFromConfigAttributesMap() {
    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)).isEqualTo("value1");
    assertThat(scm.getConfigAsMap().get("Key2").get(SCM.VALUE_KEY)).isEqualTo("value2");
}
Also used : SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.jupiter.api.Test)

Example 3 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldOnlyDisplayFieldsWhichAreNonSecureAndPartOfIdentityInGetConfigForDisplayWhenPluginExists.

@Test
void shouldOnlyDisplayFieldsWhichAreNonSecureAndPartOfIdentityInGetConfigForDisplayWhenPluginExists() {
    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()).isEqualTo("[key1=value1, key5=value5]");
}
Also used : 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.jupiter.api.Test)

Example 4 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class SCMTest method shouldSetConfigAttributesAsAvailable.

@Test
void shouldSetConfigAttributesAsAvailable() {
    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()).isEqualTo("scm-id");
    assertThat(scm.getName()).isEqualTo("scm-name");
    assertThat(scm.isAutoUpdate()).isFalse();
    assertThat(scm.getPluginConfiguration().getId()).isEqualTo("plugin-id");
    assertThat(scm.getConfigAsMap().get("url").get(SCM.VALUE_KEY)).isEqualTo("http://localhost");
    assertThat(scm.getConfigAsMap().get("username").get(SCM.VALUE_KEY)).isEqualTo("user");
    assertThat(scm.getConfigAsMap().get("password").get(SCM.VALUE_KEY)).isEqualTo("pass");
    assertThat(scm.getConfiguration().getProperty("password").getConfigurationValue()).isNull();
    assertThat(scm.getConfiguration().getProperty("password").getEncryptedConfigurationValue()).isNotNull();
}
Also used : 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.jupiter.api.Test)

Example 5 with SCMConfigurations

use of com.thoughtworks.go.plugin.access.scm.SCMConfigurations in project gocd by gocd.

the class ScheduledPipelineLoaderIntegrationTest method setupPipelineWithScmMaterial.

private PipelineConfig setupPipelineWithScmMaterial(String pipelineName, String stageName, String jobName) {
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfigWithConfigProperties("url", "password");
    SCMPropertyConfiguration configuration = new SCMPropertyConfiguration();
    configuration.add(new SCMProperty("url", null).with(PackageConfiguration.PART_OF_IDENTITY, true));
    configuration.add(new SCMProperty("password", null).with(PackageConfiguration.PART_OF_IDENTITY, false));
    SCMMetadataStore.getInstance().addMetadataFor(pluggableSCMMaterialConfig.getPluginId(), new SCMConfigurations(configuration), null);
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig(pipelineName, stageName, new MaterialConfigs(pluggableSCMMaterialConfig), jobName);
    configHelper.addSCMConfig(pluggableSCMMaterialConfig.getSCMConfig());
    configHelper.addPipeline(pipelineConfig);
    return pipelineConfig;
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) SCMProperty(com.thoughtworks.go.plugin.access.scm.SCMProperty)

Aggregations

SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)16 Test (org.junit.jupiter.api.Test)12 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)11 SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)6 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)2 SCMProperty (com.thoughtworks.go.plugin.access.scm.SCMProperty)2 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 Before (org.junit.Before)2 Configuration (com.thoughtworks.go.domain.config.Configuration)1 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)1 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)1 SCM (com.thoughtworks.go.domain.scm.SCM)1 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)1 JsonBasedPluggableTask (com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask)1 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)1 SCMView (com.thoughtworks.go.plugin.access.scm.SCMView)1 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)1 GoCipher (com.thoughtworks.go.security.GoCipher)1