use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldUnderstandIfEmptyPipelineHasNewModifications.
@Test
public void shouldUnderstandIfEmptyPipelineHasNewModifications() throws Exception {
saveRev(new MaterialRevision(pipelineOne.getMaterial(), new Modification(new Date(), "2", "MOCK_LABEL-12", null)));
configHelper.setViewPermissionForGroup("group1", "anyone");
PipelineInstanceModels models = pipelineHistoryService.findPipelineInstances(pipelineOne.pipelineName, "latest", 3, "anyone");
PipelineInstanceModel emptyModel = models.get(0);
assertThat(emptyModel.hasNewRevisions(), is(true));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method findPipelineInstanceShouldNotFindPipelineInstancesNotViewableByUser.
@Test
public void findPipelineInstanceShouldNotFindPipelineInstancesNotViewableByUser() {
Pipeline pipeline = pipelineOne.createdPipelineWithAllStagesPassed();
String groupName = configHelper.currentConfig().getGroups().findGroupNameByPipeline(new CaseInsensitiveString(pipeline.getName()));
configHelper.setViewPermissionForGroup(groupName, "admin");
HttpOperationResult result = new HttpOperationResult();
PipelineInstanceModel pipelineInstance = pipelineHistoryService.findPipelineInstance(pipeline.getName(), pipeline.getCounter(), new Username(new CaseInsensitiveString("foo")), result);
assertThat(pipelineInstance, is(nullValue()));
assertThat(result.httpCode(), is(401));
assertThat(result.message(), is("Not authorized to view pipeline"));
pipelineInstance = pipelineHistoryService.findPipelineInstance(pipeline.getName(), pipeline.getCounter(), new Username(new CaseInsensitiveString("admin")), new HttpOperationResult());
assertThat(pipelineInstance, is(not(nullValue())));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method updateComment_shouldUpdateTheCommentInTheDatabase.
@Test
public void updateComment_shouldUpdateTheCommentInTheDatabase() throws Exception {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline_name", "stage", "job");
goConfigService.addPipeline(pipelineConfig, "pipeline-group");
configHelper.addAuthorizedUserForPipelineGroup("valid-user");
configHelper.setAdminPermissionForGroup("pipeline-group", "valid-user");
dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
pipelineHistoryService.updateComment("pipeline_name", 1, "test comment", new Username(new CaseInsensitiveString("valid-user")), result);
PipelineInstanceModel pim = dbHelper.getPipelineDao().findPipelineHistoryByNameAndCounter("pipeline_name", 1);
assertThat(pim.getComment(), is("test comment"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldHaveAPipelineInstanceForAPipelineThatIsPreparingToSchedule.
@Test
public void shouldHaveAPipelineInstanceForAPipelineThatIsPreparingToSchedule() {
configHelper.addPipeline("pipeline-name", "stage-1");
triggerMonitor.markPipelineAsAlreadyTriggered("pipeline-name");
PipelineInstanceModel instance = pipelineHistoryService.latest("pipeline-name", new Username(new CaseInsensitiveString("admin")));
assertThat(instance.getName(), is("pipeline-name"));
assertThat(instance.getStageHistory().size(), is(1));
assertThat(instance.getStageHistory().get(0).isScheduled(), is(false));
assertThat(instance.isPreparingToSchedule(), is(true));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method updateComment_shouldNotUpdateTheCommentInTheDatabaseIfTheUserIsUnauthorized.
@Test
public void updateComment_shouldNotUpdateTheCommentInTheDatabaseIfTheUserIsUnauthorized() throws Exception {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline_name", "stage", "job");
goConfigService.addPipeline(pipelineConfig, "pipeline-group");
configHelper.addAuthorizedUserForPipelineGroup("valid-user");
dbHelper.newPipelineWithAllStagesPassed(pipelineConfig);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
pipelineHistoryService.updateComment("pipeline_name", 1, "test comment", new Username(new CaseInsensitiveString("invalid-user")), result);
PipelineInstanceModel pim = dbHelper.getPipelineDao().findPipelineHistoryByNameAndCounter("pipeline_name", 1);
assertThat(pim.getComment(), is(nullValue()));
assertThat(result.httpCode(), is(401));
assertThat(result.message(localizer), is("You do not have operate permissions for pipeline 'pipeline_name'."));
}
Aggregations