use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldNotFindPipelineInstancesForGivenPipelineNameWhenNonViewableForUser.
@Test
public void shouldNotFindPipelineInstancesForGivenPipelineNameWhenNonViewableForUser() {
Pipeline pipeline = pipelineOne.createdPipelineWithAllStagesPassed();
String groupName = configHelper.currentConfig().getGroups().findGroupNameByPipeline(new CaseInsensitiveString(pipeline.getName()));
configHelper.setViewPermissionForGroup(groupName, "admin");
HttpOperationResult result = new HttpOperationResult();
PipelineInstanceModels pipelineInstances = pipelineHistoryService.findAllPipelineInstances(pipeline.getName(), new Username(new CaseInsensitiveString("foo")), result);
assertThat(pipelineInstances, is(nullValue()));
assertThat(result.httpCode(), is(403));
assertThat(result.message(), is("Not authorized to view pipeline"));
pipelineInstances = pipelineHistoryService.findAllPipelineInstances(pipeline.getName(), new Username(new CaseInsensitiveString("admin")), new HttpOperationResult());
assertThat(pipelineInstances.size(), is(1));
assertThat(pipelineInstances.first().getName(), is(pipeline.getName()));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldNotThrowUpWhenPipelineCounterIs0AndShouldReturnAnEmptyPIM.
@Test
public void shouldNotThrowUpWhenPipelineCounterIs0AndShouldReturnAnEmptyPIM() {
PipelineConfig mingleConfig = PipelineConfigMother.createPipelineConfig("mingle", "stage", "job");
goConfigService.addPipeline(mingleConfig, "pipeline-group");
configHelper.addAuthorizedUserForPipelineGroup("user1", "pipeline-group");
PipelineInstanceModel pim = pipelineHistoryService.findPipelineInstance("mingle", 0, new Username(new CaseInsensitiveString("user1")), new HttpOperationResult());
assertThat(pim, instanceOf(EmptyPipelineInstanceModel.class));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldPopulateResultAsNotFoundWhenPipelineNotFound.
@Test
public void shouldPopulateResultAsNotFoundWhenPipelineNotFound() {
HttpOperationResult result = new HttpOperationResult();
PipelineInstanceModel pipelineInstance = pipelineHistoryService.load(-1, new Username(new CaseInsensitiveString("foo")), result);
assertThat(pipelineInstance, is(nullValue()));
assertThat(result.httpCode(), is(404));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldPopulateResultAsUnauthorizedWhenUserNotAllowedToViewPipeline.
@Test
public void shouldPopulateResultAsUnauthorizedWhenUserNotAllowedToViewPipeline() {
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.load(pipeline.getId(), new Username(new CaseInsensitiveString("foo")), result);
assertThat(pipelineInstance, is(nullValue()));
assertThat(result.httpCode(), is(403));
result = new HttpOperationResult();
pipelineInstance = pipelineHistoryService.load(pipeline.getId(), new Username(new CaseInsensitiveString("admin")), result);
assertThat(pipelineInstance, is(not(nullValue())));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult 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(403));
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())));
}
Aggregations