use of com.thoughtworks.go.plugin.access.scm.SCMProperty 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;
}
use of com.thoughtworks.go.plugin.access.scm.SCMProperty in project gocd by gocd.
the class SCMsTest method shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound.
@Test
void shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound() {
String pluginId = "plugin-id";
SCMPropertyConfiguration scmConfiguration = new SCMPropertyConfiguration();
scmConfiguration.add(new SCMProperty("k1"));
scmConfiguration.add(new SCMProperty("k2").with(REQUIRED, false).with(PART_OF_IDENTITY, false));
SCMMetadataStore.getInstance().addMetadataFor(pluginId, new SCMConfigurations(scmConfiguration), null);
SCM scm1 = SCMMother.create("1", "scm1", pluginId, "1.0", new Configuration(create("k1", false, "v1")));
SCM scm2 = SCMMother.create("2", "scm2", pluginId, "1.0", new Configuration(create("k1", false, "v2")));
SCM scm3 = SCMMother.create("3", "scm3", pluginId, "1.0", new Configuration(create("k1", false, "v1")));
SCM scm4 = SCMMother.create("4", "scm4", pluginId, "1.0", new Configuration(create("k1", false, "V1")));
SCM scm5 = SCMMother.create("5", "scm5", pluginId, "1.0", new Configuration(create("k1", false, "v1"), create("k2", false, "v2")));
SCMs scms = new SCMs(scm1, scm2, scm3, scm4, scm5);
scms.validate(null);
assertThat(scm2.getFingerprint().equals(scm1.getFingerprint())).isFalse();
assertThat(scm3.getFingerprint().equals(scm1.getFingerprint())).isTrue();
assertThat(scm4.getFingerprint().equals(scm1.getFingerprint())).isFalse();
assertThat(scm5.getFingerprint().equals(scm1.getFingerprint())).isTrue();
String expectedErrorMessage = "Cannot save SCM, found duplicate SCMs. scm1, scm3, scm5";
assertThat(scm1.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
assertThat(scm2.errors().getAllOn(SCM.SCM_ID)).isEmpty();
assertThat(scm3.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
assertThat(scm4.errors().getAllOn(SCM.SCM_ID)).isEmpty();
assertThat(scm5.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
}
Aggregations