use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class GoFileConfigDataSourceIntegrationTest method shouldEncryptSvnPasswordWhenConfigIsChangedViaFileSystem.
@Test
public void shouldEncryptSvnPasswordWhenConfigIsChangedViaFileSystem() throws Exception {
String configContent = ConfigFileFixture.configWithPipeline(String.format("<pipeline name='pipeline1'>" + " <materials>" + " <svn url='svnurl' username='admin' password='%s'/>" + " </materials>" + " <stage name='mingle'>" + " <jobs>" + " <job name='do-something'>" + " <tasks><ant /></tasks>" + " </job>" + " </jobs>" + " </stage>" + "</pipeline>", "hello"), GoConstants.CONFIG_SCHEMA_VERSION);
FileUtils.writeStringToFile(dataSource.fileLocation(), configContent, UTF_8);
GoConfigHolder configHolder = dataSource.load();
PipelineConfig pipelineConfig = configHolder.config.pipelineConfigByName(new CaseInsensitiveString("pipeline1"));
SvnMaterialConfig svnMaterialConfig = (SvnMaterialConfig) pipelineConfig.materialConfigs().get(0);
assertThat(svnMaterialConfig.getEncryptedPassword(), is(not(nullValue())));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MaterialRepresenter method toJSON.
public static void toJSON(OutputWriter jsonWriter, MaterialConfig materialConfig) {
if (!materialConfig.errors().isEmpty()) {
jsonWriter.addChild("errors", errorWriter -> {
HashMap<String, String> errorMapping = new HashMap<>();
errorMapping.put("materialName", "name");
errorMapping.put("folder", "destination");
errorMapping.put("autoUpdate", "auto_update");
errorMapping.put("filterAsString", "filter");
errorMapping.put("checkexternals", "check_externals");
errorMapping.put("serverAndPort", "port");
errorMapping.put("useTickets", "use_tickets");
errorMapping.put("pipelineName", "pipeline");
errorMapping.put("stageName", "stage");
errorMapping.put("pipelineStageName", "pipeline");
errorMapping.put("packageId", "ref");
errorMapping.put("scmId", "ref");
errorMapping.put("encryptedPassword", "encrypted_password");
new ErrorGetter(errorMapping).toJSON(errorWriter, materialConfig);
});
}
jsonWriter.add("type", classToTypeMap.get(materialConfig.getClass()));
switch(classToTypeMap.get(materialConfig.getClass())) {
case "git":
jsonWriter.addChild("attributes", attributeWriter -> GitMaterialRepresenter.toJSON(attributeWriter, (GitMaterialConfig) materialConfig));
break;
case "hg":
jsonWriter.addChild("attributes", attributeWriter -> HgMaterialRepresenter.toJSON(attributeWriter, (HgMaterialConfig) materialConfig));
break;
case "svn":
jsonWriter.addChild("attributes", attributeWriter -> SvnMaterialRepresenter.toJSON(attributeWriter, (SvnMaterialConfig) materialConfig));
break;
case "p4":
jsonWriter.addChild("attributes", attributeWriter -> PerforceMaterialRepresenter.toJSON(attributeWriter, (P4MaterialConfig) materialConfig));
break;
case "tfs":
jsonWriter.addChild("attributes", attributeWriter -> TfsMaterialRepresenter.toJSON(attributeWriter, (TfsMaterialConfig) materialConfig));
break;
case "dependency":
jsonWriter.addChild("attributes", attributeWriter -> DependencyMaterialRepresenter.toJSON(attributeWriter, (DependencyMaterialConfig) materialConfig));
break;
case "package":
jsonWriter.addChild("attributes", attributeWriter -> PackageMaterialRepresenter.toJSON(attributeWriter, (PackageMaterialConfig) materialConfig));
break;
case "plugin":
jsonWriter.addChild("attributes", attributeWriter -> PluggableScmMaterialRepresenter.toJSON(attributeWriter, (PluggableSCMMaterialConfig) materialConfig));
break;
}
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldSavePipelineMaterialRevisions.
@Test
public void shouldSavePipelineMaterialRevisions() throws Exception {
SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig("gitUrl", "folder", "user", "pass", true, "*.doc");
assertCanLoadAndSaveMaterialRevisionsFor(svnMaterialConfig);
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MaterialUpdateServiceIntegrationTest method shouldClearServerHealthLogsForMaterialWhereAutoUpdateChanged.
@Test
public void shouldClearServerHealthLogsForMaterialWhereAutoUpdateChanged() throws Exception {
SvnMaterialConfig material = svn("non-existent-url!", "user", "pwd2", false);
HealthStateScope scope = HealthStateScope.forMaterialConfig(material);
serverHealthService.update(ServerHealthState.error("where's the material!", "fubar", HealthStateType.general(scope)));
material.setAutoUpdate(false);
MaterialUpdateService materialUpdateService = new MaterialUpdateService(null, null, mock(MaterialUpdateCompletedTopic.class), mock(GoConfigWatchList.class), mock(GoConfigService.class), systemEnvironment, serverHealthService, null, mock(MDUPerformanceLogger.class), materialConfigConverter, null, maintenanceModeService, null, null);
materialUpdateService.onConfigChange(configWithMaterial(material));
assertThat(serverHealthService, ServerHealthMatcher.doesNotContainState(HealthStateType.general(scope)));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class PipelineWithRunOnAllJob method addToSetup.
public void addToSetup() throws Exception {
TestRepo svnTestRepo = new SvnTestRepo("testsvnrepo");
svnClient = new SvnCommand(null, svnTestRepo.projectRepositoryUrl());
MaterialConfigs materialConfigs = MaterialConfigsMother.mockMaterialConfigs(svnTestRepo.projectRepositoryUrl());
SvnMaterialConfig svnMaterialConfig = (SvnMaterialConfig) materialConfigs.first();
svnMaterialConfig.setName(new CaseInsensitiveString(DEFAULT_MATERIAL));
svnMaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "default-folder"));
configHelper.addPipelineWithGroup(groupName, pipelineName, materialConfigs, devStage, jobsOfDevStage);
configHelper.addStageToPipeline(pipelineName, ftStage, JOB_FOR_FT_STAGE);
configHelper.setPipelineLabelTemplate(pipelineName, "label-${COUNT}");
dbHelper.onSetUp();
}
Aggregations