Search in sources :

Example 26 with StageConfig

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));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) StageConfig(com.thoughtworks.go.config.StageConfig) Test(org.junit.Test)

Example 27 with StageConfig

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));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) StageConfig(com.thoughtworks.go.config.StageConfig) Test(org.junit.Test)

Example 28 with StageConfig

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));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) StageConfig(com.thoughtworks.go.config.StageConfig) Test(org.junit.Test)

Example 29 with StageConfig

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());
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) StageConfig(com.thoughtworks.go.config.StageConfig)

Example 30 with StageConfig

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;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

StageConfig (com.thoughtworks.go.config.StageConfig)31 Test (org.junit.Test)12 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)3 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 Agents (com.thoughtworks.go.config.Agents)2 JobConfigs (com.thoughtworks.go.config.JobConfigs)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)2 NullStage (com.thoughtworks.go.domain.NullStage)2 Stage (com.thoughtworks.go.domain.Stage)2 InstanceFactory (com.thoughtworks.go.server.service.InstanceFactory)2 Map (java.util.Map)2 Gson (com.google.gson.Gson)1 AdminUser (com.thoughtworks.go.config.AdminUser)1 Approval (com.thoughtworks.go.config.Approval)1 AuthConfig (com.thoughtworks.go.config.AuthConfig)1