Commit e01d7886 authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'mc_rocha-add-source-to-resolves-pipelines-338645' into 'master'

Add source as argument to ResolvesPipelines

See merge request gitlab-org/gitlab!69571
parents 518de54a 56ea9150
...@@ -17,6 +17,11 @@ module ResolvesPipelines ...@@ -17,6 +17,11 @@ module ResolvesPipelines
GraphQL::Types::String, GraphQL::Types::String,
required: false, required: false,
description: "Filter pipelines by the sha of the commit they are run for." description: "Filter pipelines by the sha of the commit they are run for."
argument :source,
GraphQL::Types::String,
required: false,
description: "Filter pipelines by their source. Will be ignored if `dast_view_scans` feature flag is disabled."
end end
class_methods do class_methods do
...@@ -30,6 +35,8 @@ module ResolvesPipelines ...@@ -30,6 +35,8 @@ module ResolvesPipelines
end end
def resolve_pipelines(project, params = {}) def resolve_pipelines(project, params = {})
params.delete(:source) unless Feature.enabled?(:dast_view_scans, project, default_enabled: :yaml)
Ci::PipelinesFinder.new(project, context[:current_user], params).execute Ci::PipelinesFinder.new(project, context[:current_user], params).execute
end end
end end
---
name: dast_view_scans
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69571
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/340388
milestone: '14.3'
type: development
group: group::dynamic analysis
default_enabled: false
...@@ -8369,6 +8369,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -8369,6 +8369,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="commitpipelinesref"></a>`ref` | [`String`](#string) | Filter pipelines by the ref they are run for. | | <a id="commitpipelinesref"></a>`ref` | [`String`](#string) | Filter pipelines by the ref they are run for. |
| <a id="commitpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. | | <a id="commitpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. |
| <a id="commitpipelinessource"></a>`source` | [`String`](#string) | Filter pipelines by their source. Will be ignored if `dast_view_scans` feature flag is disabled. |
| <a id="commitpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. | | <a id="commitpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. |
### `ComplianceFramework` ### `ComplianceFramework`
...@@ -10990,6 +10991,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -10990,6 +10991,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="mergerequestpipelinesref"></a>`ref` | [`String`](#string) | Filter pipelines by the ref they are run for. | | <a id="mergerequestpipelinesref"></a>`ref` | [`String`](#string) | Filter pipelines by the ref they are run for. |
| <a id="mergerequestpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. | | <a id="mergerequestpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. |
| <a id="mergerequestpipelinessource"></a>`source` | [`String`](#string) | Filter pipelines by their source. Will be ignored if `dast_view_scans` feature flag is disabled. |
| <a id="mergerequestpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. | | <a id="mergerequestpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. |
##### `MergeRequest.reference` ##### `MergeRequest.reference`
...@@ -12777,6 +12779,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -12777,6 +12779,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="projectpipelinesref"></a>`ref` | [`String`](#string) | Filter pipelines by the ref they are run for. | | <a id="projectpipelinesref"></a>`ref` | [`String`](#string) | Filter pipelines by the ref they are run for. |
| <a id="projectpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. | | <a id="projectpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. |
| <a id="projectpipelinessource"></a>`source` | [`String`](#string) | Filter pipelines by their source. Will be ignored if `dast_view_scans` feature flag is disabled. |
| <a id="projectpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. | | <a id="projectpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. |
##### `Project.projectMembers` ##### `Project.projectMembers`
......
...@@ -27,7 +27,7 @@ RSpec.describe ResolvesPipelines do ...@@ -27,7 +27,7 @@ RSpec.describe ResolvesPipelines do
project.add_developer(current_user) project.add_developer(current_user)
end end
it { is_expected.to have_graphql_arguments(:status, :ref, :sha) } it { is_expected.to have_graphql_arguments(:status, :ref, :sha, :source) }
it 'finds all pipelines' do it 'finds all pipelines' do
expect(resolve_pipelines).to contain_exactly(pipeline, failed_pipeline, ref_pipeline, sha_pipeline) expect(resolve_pipelines).to contain_exactly(pipeline, failed_pipeline, ref_pipeline, sha_pipeline)
...@@ -45,6 +45,30 @@ RSpec.describe ResolvesPipelines do ...@@ -45,6 +45,30 @@ RSpec.describe ResolvesPipelines do
expect(resolve_pipelines(sha: 'deadbeef')).to contain_exactly(sha_pipeline) expect(resolve_pipelines(sha: 'deadbeef')).to contain_exactly(sha_pipeline)
end end
context 'filtering by source' do
let_it_be(:source_pipeline) { create(:ci_pipeline, project: project, source: 'web') }
context 'when `dast_view_scans` feature flag is disabled' do
before do
stub_feature_flags(dast_view_scans: false)
end
it 'does not filter by source' do
expect(resolve_pipelines(source: 'web')).to contain_exactly(pipeline, failed_pipeline, ref_pipeline, sha_pipeline, source_pipeline)
end
end
context 'when `dast_view_scans` feature flag is enabled' do
it 'does filter by source' do
expect(resolve_pipelines(source: 'web')).to contain_exactly(source_pipeline)
end
it 'returns all the pipelines' do
expect(resolve_pipelines).to contain_exactly(pipeline, failed_pipeline, ref_pipeline, sha_pipeline, source_pipeline)
end
end
end
it 'does not return any pipelines if the user does not have access' do it 'does not return any pipelines if the user does not have access' do
expect(resolve_pipelines({}, {})).to be_empty expect(resolve_pipelines({}, {})).to be_empty
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment