Search in sources :

Example 61 with HttpOperationResult

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()));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 62 with HttpOperationResult

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));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 63 with HttpOperationResult

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));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 64 with HttpOperationResult

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())));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 65 with HttpOperationResult

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())));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Aggregations

HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)146 Test (org.junit.jupiter.api.Test)64 Test (org.junit.Test)53 Username (com.thoughtworks.go.server.domain.Username)34 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 TriStateSelection (com.thoughtworks.go.presentation.TriStateSelection)12 Pagination (com.thoughtworks.go.server.util.Pagination)7 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)6 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)6 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)6 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 NullStage (com.thoughtworks.go.domain.NullStage)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 PipelineStatusModel (com.thoughtworks.go.presentation.PipelineStatusModel)4 Stage (com.thoughtworks.go.domain.Stage)3