use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class DependencyMaterialConfigTest method shouldBeAbleToHaveADependencyAndOneOtherMaterial.
@Test
public void shouldBeAbleToHaveADependencyAndOneOtherMaterial() throws Exception {
NewGoConfigMother mother = new NewGoConfigMother();
mother.addPipeline("pipeline-name", "stage-name", "job-name");
PipelineConfig pipelineConfig = mother.addPipeline("dependent", "stage-name", "job-name", new DependencyMaterialConfig(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name")));
pipelineConfig.addMaterialConfig(new P4MaterialConfig("localhost:1666", "foo"));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
CruiseConfig cruiseConfig = mother.cruiseConfig();
writer.write(cruiseConfig, buffer, false);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer.toByteArray());
CruiseConfig config = loader.loadConfigHolder(FileUtil.readToEnd(inputStream)).config;
MaterialConfigs materialConfigs = config.pipelineConfigByName(new CaseInsensitiveString("dependent")).materialConfigs();
assertThat(materialConfigs.get(0), is(instanceOf(DependencyMaterialConfig.class)));
assertThat(materialConfigs.get(1), is(instanceOf(P4MaterialConfig.class)));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class ConfigCipherUpdaterTest method shouldMigrateEncryptedPasswordsThatWereEncryptedWithFlawedCipher.
@Test
public void shouldMigrateEncryptedPasswordsThatWereEncryptedWithFlawedCipher() throws Exception {
String originalConfig = FileUtil.readContentFromFile(originalConfigFile);
assertThat(originalConfig.contains("encryptedPassword=\"" + passwordEncryptedWithFlawedCipher + "\""), is(true));
updater.migrate();
File copyOfOldConfig = new File(systemEnvironment.getConfigDir(), "cipher.original." + timestamp);
assertThat(copyOfOldConfig.exists(), is(true));
assertThat(FileUtil.readContentFromFile(copyOfOldConfig).equals(ConfigCipherUpdater.FLAWED_VALUE), is(true));
String newCipher = FileUtil.readContentFromFile(systemEnvironment.getCipherFile());
assertThat(newCipher.equals(ConfigCipherUpdater.FLAWED_VALUE), is(false));
File editedConfigFile = new File(systemEnvironment.getCruiseConfigFile());
String editedConfig = FileUtil.readContentFromFile(editedConfigFile);
assertThat(editedConfig.contains("encryptedPassword=\"" + passwordEncryptedWithFlawedCipher + "\""), is(false));
String passwordEncryptedWithNewCipher = new GoCipher().encrypt(password);
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(), is(passwordEncryptedWithNewCipher));
P4MaterialConfig p4Material = materialConfigs.getP4Material();
assertThat(p4Material.getPassword(), is(password));
assertThat(p4Material.getEncryptedPassword(), is(passwordEncryptedWithNewCipher));
TfsMaterialConfig tfsMaterial = materialConfigs.getTfsMaterial();
assertThat(tfsMaterial.getPassword(), is(password));
assertThat(tfsMaterial.getEncryptedPassword(), is(passwordEncryptedWithNewCipher));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class ScheduleTestUtil method saveConfigWithTimer.
public AddedPipeline saveConfigWithTimer(String pipelineName, TimerConfig timer, MaterialDeclaration... materialDeclaration) {
String stageName = AutoTriggerDependencyResolutionTest.STAGE_NAME;
MaterialConfigs materialConfigs = new MaterialConfigs();
for (MaterialDeclaration mDecl : materialDeclaration) {
MaterialConfig materialConfig = AutoTriggerDependencyResolutionTest.CLONER.deepClone(mDecl.material.config());
materialConfigs.add(materialConfig);
}
PipelineConfig cfg = configHelper.addPipelineWithGroupAndTimer(DEFAULT_GROUP, pipelineName, materialConfigs, stageName, timer, "job1");
return new AddedPipeline(cfg, new DependencyMaterial(str(pipelineName), str(stageName)));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldForceStagePlanWithModificationsSinceLast.
@Test
public void shouldForceStagePlanWithModificationsSinceLast() throws Exception {
Pipeline completedMingle = scheduleAndCompleteInitialPipelines();
pipelineDao.loadPipeline(completedMingle.getId());
TestingMaterial testingMaterial = new TestingMaterial();
mingleConfig.setMaterialConfigs(new MaterialConfigs(testingMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(testingMaterial, testingMaterial.modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createManualForced(revisions, Username.ANONYMOUS);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline forcedPipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineService.save(forcedPipeline);
verifyMingleScheduledWithModifications();
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldScheduleMultipleJobsWhenToBeRunMultipleInstance.
@Test
public void shouldScheduleMultipleJobsWhenToBeRunMultipleInstance() throws Exception {
configHelper.setRunMultipleInstance(CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", 2);
Material stubMaterial = new TestingMaterial();
evolveConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY, environmentConfigService.agentsForPipeline(evolveConfig.name())), md5, new TimeProvider());
pipelineService.save(pipeline);
Stage instance = scheduleService.scheduleStage(pipeline, STAGE_NAME, "anyone", new ScheduleService.NewStageInstanceCreator(goConfigService), new ScheduleService.ExceptioningErrorHandler());
JobInstances scheduledJobs = instance.getJobInstances();
assertThat(scheduledJobs.size(), is(2));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
}
Aggregations