use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class PipelineTemplateConfigViewModelTest method shouldSetConfigAttributesBasedOnExistingPipeline.
@Test
public void shouldSetConfigAttributesBasedOnExistingPipeline() {
StageConfig stage1 = StageConfigMother.custom("stage_foo", "foo1", "foo2");
StageConfig stage2 = StageConfigMother.custom("stage_bar", "bar1", "bar2");
PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("pipeline", stage1, stage2);
PipelineTemplateConfigViewModel viewModel = new PipelineTemplateConfigViewModel(new PipelineTemplateConfig(), "", Arrays.asList(PipelineConfigMother.pipelineConfig("foo_bar"), pipeline));
Map m = m("template", m(PipelineTemplateConfig.NAME, "template_name"), PipelineTemplateConfigViewModel.USE_EXISTING_PIPELINE, "1", PipelineTemplateConfigViewModel.SELECTED_PIPELINE_NAME, pipeline.name().toString());
viewModel.setConfigAttributes(m);
assertThat(viewModel.useExistingPipeline(), is(true));
assertThat(viewModel.selectedPipelineName(), is(pipeline.name().toString()));
PipelineTemplateConfig template = viewModel.templateConfig();
assertThat(template.name(), is(new CaseInsensitiveString("template_name")));
assertThat(template.size(), is(2));
assertThat(template.get(0), is(stage1));
assertThat(template.get(1), is(stage2));
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class BuildRepositoryServiceIntegrationTest method shouldCancelAllJobs.
@Test
public void shouldCancelAllJobs() throws Exception {
mingle = PipelineMother.twoBuildPlansWithResourcesAndSvnMaterialsAtUrl(PIPELINE_NAME, DEV_STAGE, svnTestRepo.projectRepositoryUrl());
StageConfig devStage = mingle.get(0);
schedulePipeline(mingle);
final Stage stage = stageDao.mostRecentWithBuilds(CaseInsensitiveString.str(mingle.name()), devStage);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
public void doInTransactionWithoutResult(TransactionStatus status) {
stageService.cancelStage(stage);
}
});
final Stage cancelled = stageService.stageById(stage.getId());
assertThat(cancelled.stageState(), is(StageState.Cancelled));
final JobInstances builds = cancelled.getJobInstances();
for (JobInstance job : builds) {
assertThat(job.currentStatus(), is(JobState.Completed));
assertThat(job.getResult(), is(JobResult.Cancelled));
assertThat(job.displayStatusWithResult(), is("cancelled"));
}
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class StageApprovalAuthorizationTest method shouldAuthorizeIfRoleIsInApprovalList.
@Test
public void shouldAuthorizeIfRoleIsInApprovalList() throws Exception {
CONFIG_HELPER.addSecurityWithAdminConfig();
CONFIG_HELPER.addRole(new RoleConfig(new CaseInsensitiveString("adminRole"), new RoleUser(new CaseInsensitiveString("tester"))));
StageConfig stage = StageConfigMother.custom("test", authConfigWithAdminRole);
PipelineConfig pipeline = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, stage);
assertThat("User tester should have permission on test stage", securityService.hasOperatePermissionForStage(CaseInsensitiveString.str(pipeline.name()), CaseInsensitiveString.str(stage.name()), "tester"), is(true));
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class StageApprovalAuthorizationTest method shouldAuthorizeUserCruiseIfUserIsAuthorisedToOperateAutoStage.
@Test
public void shouldAuthorizeUserCruiseIfUserIsAuthorisedToOperateAutoStage() throws Exception {
CONFIG_HELPER.addSecurityWithAdminConfig();
CONFIG_HELPER.setOperatePermissionForStage(PIPELINE_NAME, STAGE_NAME, "cruise");
StageConfig stage = StageConfigMother.custom("ft", new Approval(new AuthConfig(new AdminUser(new CaseInsensitiveString("cruise")))));
PipelineConfig pipeline = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, stage);
assertThat(securityService.hasOperatePermissionForStage(CaseInsensitiveString.str(pipeline.name()), CaseInsensitiveString.str(stage.name()), "cruise"), is(true));
assertThat(securityService.hasOperatePermissionForStage(PIPELINE_NAME, STAGE_NAME, "anyone"), is(false));
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class PipelineSchedulerIntegrationTest method shouldThrowExceptionIfOtherStageIsRunningInTheSamePipeline.
@Test
public void shouldThrowExceptionIfOtherStageIsRunningInTheSamePipeline() throws Exception {
Pipeline pipeline = makeCompletedPipeline();
StageConfig ftStage = goConfigService.stageConfigNamed(PIPELINE_MINGLE, FT_STAGE);
scheduleService.rerunStage(PIPELINE_MINGLE, pipeline.getCounter().toString(), FT_STAGE);
try {
scheduleService.rerunStage(PIPELINE_MINGLE, pipeline.getCounter().toString(), FT_STAGE);
Assert.fail("Should throw exception if fails to re-run stage");
} catch (Exception ignored) {
assertThat(ignored.getMessage(), matches("Cannot schedule: Pipeline.+is still in progress"));
}
}
Aggregations