use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class SvnMaterialRepresenter method fromJSON.
@Override
public SvnMaterialConfig fromJSON(JsonReader jsonReader, ConfigHelperOptions options) {
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig();
super.fromJSON(jsonReader, svnMaterialConfig, options);
jsonReader.readStringIfPresent("url", svnMaterialConfig::setUrl);
jsonReader.optBoolean("check_externals").ifPresent(svnMaterialConfig::setCheckExternals);
return svnMaterialConfig;
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method shouldErrorOutWhenThreePipelinesFormACycle.
@Test
public void shouldErrorOutWhenThreePipelinesFormACycle() throws Exception {
CruiseConfig cruiseConfig = createCruiseConfig();
PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
SvnMaterialConfig material = (SvnMaterialConfig) pipeline1.materialConfigs().get(0);
material.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "svn_dir"));
P4MaterialConfig p4MaterialConfig = p4("localhost:1999", "view");
p4MaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "p4_folder"));
pipeline1.addMaterialConfig(p4MaterialConfig);
PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline3", "stage", "build");
PipelineConfig pipeline3 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
goConfigMother.setDependencyOn(cruiseConfig, pipeline3, "pipeline3", "stage");
goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
goConfigMother.setDependencyOn(cruiseConfig, pipeline1, "pipeline2", "stage");
cruiseConfig.validate(null);
assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(false));
assertThat(pipeline2.materialConfigs().errors().isEmpty(), is(false));
assertThat(pipeline3.materialConfigs().errors().isEmpty(), is(false));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.
@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
final MaterialConfig svnMaterialConfig = svn("http://svn_url_1", "username", "password", false);
svnMaterialConfig.setAutoUpdate(false);
final MaterialConfig svnMaterialConfigWithAutoUpdate = svn("http://svn_url_2", "username", "password", false);
svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
final MaterialConfig hgMaterialConfig = hg("http://hg_url", null);
hgMaterialConfig.setAutoUpdate(false);
final MaterialConfig gitMaterialConfig = git("http://git_url");
gitMaterialConfig.setAutoUpdate(false);
final MaterialConfig tfsMaterialConfig = tfs(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
tfsMaterialConfig.setAutoUpdate(false);
final MaterialConfig p4MaterialConfig = p4("http://p4_url", "view", "username");
p4MaterialConfig.setAutoUpdate(false);
final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(6));
assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldUnderstandEncryptedPasswordAttributeForSvnMaterial.
@Test
void shouldUnderstandEncryptedPasswordAttributeForSvnMaterial() throws Exception {
String password = "abc";
String encryptedPassword = new GoCipher().encrypt(password);
String content = configWithPipeline(format("<pipeline name='pipeline1'>" + " <materials>" + " <svn url='svnurl' username='admin' encryptedPassword='%s'/>" + " </materials>" + " <stage name='mingle'>" + " <jobs>" + " <job name='do-something'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + " </job>" + " </jobs>" + " </stage>" + "</pipeline>", encryptedPassword), CONFIG_SCHEMA_VERSION);
GoConfigHolder configHolder = ConfigMigrator.loadWithMigration(content);
CruiseConfig cruiseConfig = configHolder.config;
SvnMaterialConfig svnMaterialConfig = (SvnMaterialConfig) cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("pipeline1")).materialConfigs().get(0);
assertThat(svnMaterialConfig.getEncryptedPassword()).isEqualTo(encryptedPassword);
assertThat(svnMaterialConfig.getPassword()).isEqualTo(password);
CruiseConfig configForEdit = configHolder.configForEdit;
svnMaterialConfig = (SvnMaterialConfig) configForEdit.pipelineConfigByName(new CaseInsensitiveString("pipeline1")).materialConfigs().get(0);
assertThat(svnMaterialConfig.getEncryptedPassword()).isEqualTo(encryptedPassword);
assertThat(svnMaterialConfig.getPassword()).isEqualTo("abc");
assertThat(ReflectionUtil.getField(svnMaterialConfig, "password")).isNull();
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldMigrateEncryptedMaterialPasswordWithNewlineAndSpaces_XslMigrationFrom88To90.
@Test
void shouldMigrateEncryptedMaterialPasswordWithNewlineAndSpaces_XslMigrationFrom88To90(ResetCipher resetCipher) throws Exception {
resetCipher.setupDESCipherFile();
String plainText = "user-password!";
// "user-password!" encrypted using the above key
String encryptedValue = "mvcX9yrQsM4iPgm1tDxN1A==";
String encryptedValueWithWhitespaceAndNewline = new StringBuilder(encryptedValue).insert(2, "\r\n" + " ").toString();
String content = configWithPipeline("<pipeline name='some_pipeline'>" + " <materials>" + " <svn url='asdsa' username='user' encryptedPassword='" + encryptedValueWithWhitespaceAndNewline + "' dest='svn'>" + "<filter>\n" + " <ignore pattern='**/*' />\n" + " </filter>" + "</svn>" + "<tfs url='tfsurl' username='user' domain='domain' encryptedPassword='" + encryptedValueWithWhitespaceAndNewline + "' projectPath='path' dest='tfs' />" + "<p4 port='host:9999' username='user' encryptedPassword='" + encryptedValueWithWhitespaceAndNewline + "' dest='perforce'>\n" + " <view><![CDATA[view]]></view>\n" + " </p4>" + " </materials>" + " <stage name='some_stage'>" + " <jobs>" + " <job name=\"some_job\">\n" + " <tasks>\n" + " <exec command=\"echo\">\n" + " <runif status=\"passed\" />\n" + " </exec>\n" + " </tasks>" + " </job>\n" + " </jobs>" + " </stage>" + "</pipeline>", 88);
CruiseConfig config = ConfigMigrator.loadWithMigration(content).config;
MaterialConfigs materialConfigs = config.allPipelines().get(0).materialConfigs();
SvnMaterialConfig svnMaterialConfig = (SvnMaterialConfig) materialConfigs.get(0);
assertThat(svnMaterialConfig.getPassword()).isEqualTo(plainText);
assertThat(svnMaterialConfig.getEncryptedPassword()).startsWith("AES:");
assertThat(svnMaterialConfig.getFilterAsString()).isEqualTo("**/*");
TfsMaterialConfig tfs = (TfsMaterialConfig) materialConfigs.get(1);
assertThat(tfs.getPassword()).isEqualTo(plainText);
assertThat(tfs.getEncryptedPassword()).startsWith("AES:");
assertThat(tfs.getUrl()).isEqualTo("tfsurl");
P4MaterialConfig p4 = (P4MaterialConfig) materialConfigs.get(2);
assertThat(p4.getPassword()).isEqualTo(plainText);
assertThat(p4.getEncryptedPassword()).startsWith("AES:");
assertThat(p4.getServerAndPort()).isEqualTo("host:9999");
}
Aggregations