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