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));
}
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));
}
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));
}
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()));
}
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"));
}
Aggregations