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");
}
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");
}
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]");
}
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();
}
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;
}
Aggregations