Search in sources :

Example 61 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class ScheduleServiceSecurityTest method shouldReturnAppropriateHttpResultIfUserDoesNotHaveOperatePermission.

@Test
public void shouldReturnAppropriateHttpResultIfUserDoesNotHaveOperatePermission() throws Exception {
    configHelper.enableSecurity();
    configHelper.addAdmins("admin");
    configHelper.setOperatePermissionForGroup("defaultGroup", "jez");
    Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
    Username anonymous = new Username(new CaseInsensitiveString("anonymous"));
    HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    Stage resultStage = scheduleService.cancelAndTriggerRelevantStages(pipeline.getStages().byName(fixture.ftStage).getId(), anonymous, operationResult);
    assertThat(resultStage, is(nullValue()));
    assertThat(operationResult.isSuccessful(), is(false));
    assertThat(operationResult.httpCode(), is(SC_UNAUTHORIZED));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Stage(com.thoughtworks.go.domain.Stage) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 62 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class ScheduleServiceSecurityTest method shouldNotThrowExceptionIfUserHasOperatePermission.

@Test
public void shouldNotThrowExceptionIfUserHasOperatePermission() throws Exception {
    configHelper.enableSecurity();
    Username user = UserHelper.getUserName();
    configHelper.setOperatePermissionForGroup("defaultGroup", user.getUsername().toString());
    Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
    HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    Stage stageForCancellation = pipeline.getStages().byName(fixture.ftStage);
    Stage resultStage = scheduleService.cancelAndTriggerRelevantStages(stageForCancellation.getId(), user, operationResult);
    assertThat(resultStage, is(not(nullValue())));
    assertThat(operationResult.isSuccessful(), is(true));
    assertThat(operationResult.httpCode(), is(SC_OK));
// TODO: Check why stage result is not persisted after stage is cancelled
// Stage mostRecent = stageDao.mostRecentStage(new StageConfigIdentifier(fixture.pipelineName, fixture.ftStage));
// assertThat(mostRecent.getResult(), is(StageResult.Cancelled));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Stage(com.thoughtworks.go.domain.Stage) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 63 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class ScheduleServiceSecurityTest method shouldCancelStageGivenValidPipelineAndStageName.

@Test
public void shouldCancelStageGivenValidPipelineAndStageName() throws Exception {
    configHelper.enableSecurity();
    Username user = UserHelper.getUserName();
    configHelper.setOperatePermissionForGroup("defaultGroup", user.getUsername().toString());
    Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
    HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    Stage stageForCancellation = pipeline.getStages().byName(fixture.ftStage);
    Stage resultStage = scheduleService.cancelAndTriggerRelevantStages(pipeline.getName(), stageForCancellation.getName(), user, operationResult);
    assertThat(resultStage, is(not(nullValue())));
    assertThat(operationResult.isSuccessful(), is(true));
    assertThat(operationResult.httpCode(), is(SC_OK));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Stage(com.thoughtworks.go.domain.Stage) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 64 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class SchedulingCheckerServiceIntegrationTest method shouldNotScheduleStageInLockedPipelineIfAnyStageIsActiveInAnyPipeline.

@Test
public void shouldNotScheduleStageInLockedPipelineIfAnyStageIsActiveInAnyPipeline() throws Exception {
    Pipeline completed = pipelineFixture.createdPipelineWithAllStagesPassed();
    Pipeline pipeline = pipelineFixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
    configFileHelper.lockPipeline(pipeline.getName());
    // to ensure locking happens(fixture uses the dao to directly save it to the db, hence lock is not taken)
    pipelineService.save(pipeline);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    schedulingChecker.canScheduleStage(completed.getIdentifier(), pipelineFixture.stageName(1), APPROVED_USER, result);
    assertThat(result.getServerHealthState().isSuccess(), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString("is locked"));
    assertThat(result.getServerHealthState().getDescription(), containsString(pipeline.getName()));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Pipeline(com.thoughtworks.go.domain.Pipeline)

Example 65 with Pipeline

use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.

the class SchedulingCheckerServiceIntegrationTest method shouldNotPassCheckingIfPipelineIsPausedForManualTrigger.

@Test
public void shouldNotPassCheckingIfPipelineIsPausedForManualTrigger() throws Exception {
    Pipeline pipeline = pipelineFixture.createdPipelineWithAllStagesPassed();
    Username userName = new Username(new CaseInsensitiveString("A humble developer"));
    pipelinePauseService.pause(pipeline.getName(), "Upgrade scheduled", userName);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    assertThat(schedulingChecker.canManuallyTrigger(pipelineFixture.pipelineConfig(), APPROVED_USER, result), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString(pipeline.getName() + " is paused"));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline)

Aggregations

Pipeline (com.thoughtworks.go.domain.Pipeline)184 Test (org.junit.Test)122 Stage (com.thoughtworks.go.domain.Stage)33 Username (com.thoughtworks.go.server.domain.Username)30 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)24 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)24 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)21 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)20 JobInstance (com.thoughtworks.go.domain.JobInstance)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)13 Date (java.util.Date)13 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)11 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)7 PipelineState (com.thoughtworks.go.domain.PipelineState)6