Search in sources :

Example 1 with SCMProperty

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;
}
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)

Example 2 with SCMProperty

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));
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) SCMProperty(com.thoughtworks.go.plugin.access.scm.SCMProperty) Test(org.junit.jupiter.api.Test)

Aggregations

SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)2 SCMProperty (com.thoughtworks.go.plugin.access.scm.SCMProperty)2 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)2 Configuration (com.thoughtworks.go.domain.config.Configuration)1 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)1 Test (org.junit.jupiter.api.Test)1