use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class StageApprovalAuthorizationTest method shouldNotAuthorizeIfUserIsNotDefinedInApprovalList.
@Test
public void shouldNotAuthorizeIfUserIsNotDefinedInApprovalList() throws Exception {
CONFIG_HELPER.addSecurityWithAdminConfig();
StageConfig stage = StageConfigMother.custom("ft", authConfigWithUserJez);
PipelineConfig pipeline = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, stage);
assertThat("User hacker should not have permission on ft stage", securityService.hasOperatePermissionForStage(CaseInsensitiveString.str(pipeline.name()), CaseInsensitiveString.str(stage.name()), "hacker"), is(false));
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class StageApprovalAuthorizationTest method shouldAuthorizeAnyUserIfNoAuthorizationDefinedForAutoApproval.
@Test
public void shouldAuthorizeAnyUserIfNoAuthorizationDefinedForAutoApproval() throws Exception {
CONFIG_HELPER.addSecurityWithAdminConfig();
StageConfig stage = StageConfigMother.custom("ft", Approval.automaticApproval());
PipelineConfig pipeline = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, stage);
assertThat("Cruise should not have permission on ft stage unless configured with permission", securityService.hasOperatePermissionForStage(CaseInsensitiveString.str(pipeline.name()), CaseInsensitiveString.str(stage.name()), "cruise"), is(true));
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class StageApprovalAuthorizationTest method shouldAuthorizeIfUserIsInApprovalList.
@Test
public void shouldAuthorizeIfUserIsInApprovalList() throws Exception {
CONFIG_HELPER.addSecurityWithAdminConfig();
StageConfig stage = StageConfigMother.custom("ft", authConfigWithUserJez);
PipelineConfig pipeline = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, stage);
assertThat("User jez should have permission on ft stage", securityService.hasOperatePermissionForStage(CaseInsensitiveString.str(pipeline.name()), CaseInsensitiveString.str(stage.name()), "jez"), is(true));
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class DatabaseAccessHelper method newPipelineWithAllStagesPassed.
public Pipeline newPipelineWithAllStagesPassed(PipelineConfig config) throws SQLException {
Pipeline pipeline = newPipelineWithFirstStagePassed(config);
for (StageConfig stageConfig : config) {
if (config.first().equals(stageConfig)) {
continue;
}
Stage instance = instanceFactory.createStageInstance(stageConfig, new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
stageDao.saveWithJobs(pipeline, instance);
passStage(instance);
}
return pipelineDao.loadPipeline(pipeline.getId());
}
use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.
the class DatabaseAccessHelper method configurePipeline.
private PipelineConfig configurePipeline(String pipelineName, String stageName, String... jobConfigNames) {
final String[] defaultBuildPlanNames = { "functional", "unit" };
jobConfigNames = jobConfigNames.length == 0 ? defaultBuildPlanNames : jobConfigNames;
StageConfig stageConfig = StageConfigMother.stageConfig(stageName, BuildPlanMother.withBuildPlans(jobConfigNames));
MaterialConfigs materialConfigs = MaterialConfigsMother.multipleMaterialConfigs();
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString(pipelineName), materialConfigs, stageConfig);
return pipelineConfig;
}
Aggregations