use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class BuildCauseProducerServiceWithFlipModificationTest method setUpPipelineWithTwoMaterials.
private SvnMaterialConfig setUpPipelineWithTwoMaterials() throws Exception {
SvnMaterialConfig svnMaterialConfig = svn(repository.getUrl().originalArgument(), repository.getUserName(), repository.getPassword(), repository.isCheckExternals());
svnMaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "svnDir"));
MaterialConfigs materialConfigs = new MaterialConfigs(svnMaterialConfig, hgTestRepo.createMaterialConfig("hgDir"));
mingleConfig = configHelper.addPipeline(PIPELINE_NAME, STAGE_NAME, materialConfigs, "unit", "functional");
return svnMaterialConfig;
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MaterialExpansionServiceCachingTest method shouldCacheSvnMaterialCheckExternalCommand.
@Test
public void shouldCacheSvnMaterialCheckExternalCommand() {
SvnMaterialConfig svnMaterialConfig = svnMaterialConfig(svnRepo.projectRepositoryUrl(), "mainRepo");
MaterialConfigs materialConfigs = new MaterialConfigs();
String cacheKey = materialExpansionService.cacheKeyForSubversionMaterialCommand(svnMaterialConfig.getFingerprint());
Subversion svn = (SvnCommand) goCache.get(cacheKey);
assertNull(svn);
materialExpansionService.expandForScheduling(svnMaterialConfig, materialConfigs);
svn = (SvnCommand) goCache.get(cacheKey);
assertNotNull(svn);
assertThat(svn.getUrl().originalArgument(), is(svnMaterialConfig.getUrl()));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class SvnMaterialTest method shouldReturnEqualsWhenEverythingIsSameForSvnMaterialConfigs.
/* TODO: *SBD* Move this test into SvnMaterialConfig test after mothers are moved. */
@Test
void shouldReturnEqualsWhenEverythingIsSameForSvnMaterialConfigs() {
SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
svnMaterialConfig.setConfigAttributes(Collections.singletonMap(SvnMaterialConfig.CHECK_EXTERNALS, String.valueOf(true)));
svnMaterialConfig.setConfigAttributes(Collections.singletonMap(SvnMaterialConfig.USERNAME, "userName"));
svnMaterialConfig.setPassword("password");
svnMaterialConfig.setConfigAttributes(Collections.singletonMap(SvnMaterialConfig.URL, "URL"));
SvnMaterialConfig other = MaterialConfigsMother.svnMaterialConfig();
other.setConfigAttributes(Collections.singletonMap(SvnMaterialConfig.CHECK_EXTERNALS, String.valueOf(true)));
other.setConfigAttributes(Collections.singletonMap(SvnMaterialConfig.USERNAME, "userName"));
other.setPassword("password");
other.setConfigAttributes(Collections.singletonMap(SvnMaterialConfig.URL, "URL"));
assertThat(other).isEqualTo(svnMaterialConfig);
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class ConfigCipherUpdaterTest method shouldMigrateEncryptedPasswordsThatWereEncryptedWithFlawedCipher.
@Test
public void shouldMigrateEncryptedPasswordsThatWereEncryptedWithFlawedCipher() throws Exception {
String originalConfig = readFileToString(originalConfigFile, UTF_8);
assertThat(originalConfig, containsString("encryptedPassword=\"" + passwordEncryptedWithFlawedCipher + "\""));
updater.migrate();
writeStringToFile(new File(systemEnvironment.getCruiseConfigFile()), ConfigMigrator.migrate(readFileToString(new File(systemEnvironment.getCruiseConfigFile()), UTF_8)), UTF_8);
File copyOfOldConfig = new File(systemEnvironment.getConfigDir(), "cipher.original." + timestamp);
assertThat(copyOfOldConfig.exists(), is(true));
assertThat(readFileToString(copyOfOldConfig, UTF_8).equals(FLAWED_VALUE), is(true));
String newCipher = readFileToString(systemEnvironment.getDESCipherFile(), UTF_8);
assertThat(newCipher.equals(FLAWED_VALUE), is(false));
File editedConfigFile = new File(systemEnvironment.getCruiseConfigFile());
String editedConfig = readFileToString(editedConfigFile, UTF_8);
assertThat(editedConfig.contains("encryptedPassword=\"" + passwordEncryptedWithFlawedCipher + "\""), is(false));
CruiseConfig config = magicalGoConfigXmlLoader.loadConfigHolder(editedConfig).config;
MaterialConfigs materialConfigs = config.getAllPipelineConfigs().get(0).materialConfigs();
SvnMaterialConfig svnMaterial = materialConfigs.getSvnMaterial();
assertThat(svnMaterial.getPassword(), is(password));
assertThat(svnMaterial.getEncryptedPassword(), startsWith("AES:"));
assertThat(new GoCipher().decrypt(svnMaterial.getEncryptedPassword()), is("password"));
P4MaterialConfig p4Material = materialConfigs.getP4Material();
assertThat(p4Material.getPassword(), is(password));
assertThat(p4Material.getEncryptedPassword(), startsWith("AES:"));
assertThat(new GoCipher().decrypt(p4Material.getEncryptedPassword()), is("password"));
TfsMaterialConfig tfsMaterial = materialConfigs.getTfsMaterial();
assertThat(tfsMaterial.getPassword(), is(password));
assertThat(tfsMaterial.getEncryptedPassword(), startsWith("AES:"));
assertThat(new GoCipher().decrypt(tfsMaterial.getEncryptedPassword()), is("password"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertMinimalPipeline.
@Test
void shouldConvertMinimalPipeline() {
CRPipeline crPipeline = new CRPipeline();
crPipeline.setName("p1");
List<CRStage> min_stages = new ArrayList<>();
CRStage min_stage = new CRStage();
min_stage.setName("build");
Collection<CRJob> min_jobs = new ArrayList<>();
CRJob job = new CRJob();
job.setName("buildjob");
List<CRTask> min_tasks = new ArrayList<>();
min_tasks.add(new CRBuildTask(CRBuildFramework.rake));
job.setTasks(min_tasks);
min_jobs.add(job);
min_stage.setJobs(min_jobs);
min_stages.add(min_stage);
crPipeline.setStages(min_stages);
Collection<CRMaterial> min_materials = new ArrayList<>();
CRSvnMaterial crSvnMaterial = new CRSvnMaterial();
crSvnMaterial.setUrl("url");
min_materials.add(crSvnMaterial);
crPipeline.setMaterials(min_materials);
PipelineConfig pipelineConfig = configConverter.toPipelineConfig(crPipeline, context, new SCMs());
assertThat(pipelineConfig.name().toLower()).isEqualTo("p1");
assertThat(pipelineConfig.materialConfigs().first() instanceof SvnMaterialConfig).isTrue();
assertThat(pipelineConfig.first().name().toLower()).isEqualTo("build");
assertThat(pipelineConfig.getLabelTemplate()).isEqualTo(PipelineLabel.COUNT_TEMPLATE);
}
Aggregations