Search in sources :

Example 6 with PipelineInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method findMatchingPipelineInstances_shouldMatchUpStreamPipelineLabel.

@Test
public void findMatchingPipelineInstances_shouldMatchUpStreamPipelineLabel() {
    final int limit = 3;
    PipelineConfig upstreamConfig = PipelineConfigMother.createPipelineConfig("upstream", "stage", "job");
    upstreamConfig.setLabelTemplate("${COUNT}-hello-world-${COUNT}");
    PipelineConfig downstreamConfig = PipelineConfigMother.createPipelineConfig("downstream", "stage", "job");
    downstreamConfig.materialConfigs().clear();
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("stage"));
    downstreamConfig.addMaterialConfig(dependencyMaterial.config());
    goConfigService.addPipeline(upstreamConfig, "pipeline-group");
    goConfigService.addPipeline(downstreamConfig, "pipeline-group");
    Pipeline upstreamPipeline = dbHelper.schedulePipeline(upstreamConfig, new TimeProvider());
    dbHelper.passStage(upstreamPipeline.getStages().get(0));
    Modification modification = new Modification(new Date(), DependencyMaterialRevision.create("upstream", 1, "1", "stage", 1).getRevision(), "1", upstreamPipeline.getId());
    MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(dependencyMaterial, modification));
    Pipeline downstreamPipeline = dbHelper.schedulePipeline(downstreamConfig, BuildCause.createWithModifications(materialRevisions, "cruise"), new TimeProvider());
    dbHelper.passStage(downstreamPipeline.getStages().get(0));
    PipelineInstanceModels actual = pipelineHistoryService.findMatchingPipelineInstances("downstream", "hello-world", limit, new Username(new CaseInsensitiveString("user")), new HttpLocalizedOperationResult());
    assertThat(actual.size(), is(1));
    assertThat(actual.get(0).getCounter(), is(downstreamPipeline.getCounter()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TimeProvider(com.thoughtworks.go.util.TimeProvider) Date(java.util.Date) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) Username(com.thoughtworks.go.server.domain.Username) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 7 with PipelineInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method findMatchingPipelineInstances_shouldReturnUnauthorizedWhenUserDoesNotHavePermission.

@Test
public void findMatchingPipelineInstances_shouldReturnUnauthorizedWhenUserDoesNotHavePermission() {
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline_name", "stage", "job");
    goConfigService.addPipeline(pipelineConfig, "pipeline-group");
    configHelper.addAuthorizedUserForPipelineGroup("valid-user");
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    PipelineInstanceModels pipelineInstances = pipelineHistoryService.findMatchingPipelineInstances("pipeline_name", "ABCD", 1000, new Username(new CaseInsensitiveString("fraud-user")), result);
    assertThat(pipelineInstances.size(), is(0));
    assertThat(result.isSuccessful(), is(false));
    assertThat(result.httpCode(), is(401));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.Test)

Example 8 with PipelineInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldFindAllPipelineInstancesForGivenPipelineName.

@Test
public void shouldFindAllPipelineInstancesForGivenPipelineName() {
    Pipeline pipeline = pipelineOne.createdPipelineWithAllStagesPassed();
    configHelper.setViewPermissionForGroup("group1", "foo");
    PipelineInstanceModels pipelineInstances = pipelineHistoryService.findAllPipelineInstances(pipeline.getName(), new Username(new CaseInsensitiveString("foo")), new HttpOperationResult());
    assertThat(pipelineInstances.size(), is(1));
    assertThat(pipelineInstances.first().getName(), is(pipeline.getName()));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.Test)

Example 9 with PipelineInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldNotLoadPipelinesThatTheUserDoesNotHavePermissionToSee.

@Test
public void shouldNotLoadPipelinesThatTheUserDoesNotHavePermissionToSee() throws Exception {
    configHelper.addSecurityWithAdminConfig();
    configHelper.setViewPermissionForGroup("group1", "foo");
    PipelineInstanceModels history = pipelineHistoryService.loadWithEmptyAsDefault(pipelineOne.pipelineName, Pagination.pageStartingAt(0, 1, 1), "non-admin-user");
    assertThat(history.size(), is(0));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) Test(org.junit.Test)

Example 10 with PipelineInstanceModels

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldUnderstandIfEmptyPipelineHasNoNewModifications.

@Test
public void shouldUnderstandIfEmptyPipelineHasNoNewModifications() throws Exception {
    configHelper.setViewPermissionForGroup("group1", "anyone");
    PipelineInstanceModels models = pipelineHistoryService.findPipelineInstances(pipelineOne.pipelineName, "latest", 3, "anyone");
    PipelineInstanceModel emptyModel = models.get(0);
    assertThat(emptyModel.hasNewRevisions(), is(false));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Aggregations

PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)63 Test (org.junit.Test)59 Username (com.thoughtworks.go.server.domain.Username)18 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)15 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)14 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)9 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)8 Modification (com.thoughtworks.go.domain.materials.Modification)6 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)5 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)5 Date (java.util.Date)5 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)4 Material (com.thoughtworks.go.domain.materials.Material)3 PipelineNotFoundException (com.thoughtworks.go.config.PipelineNotFoundException)2 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)2