Commit 8fe3212e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '241063-add-pipeline-parameter-to-MergeRequestsController' into 'master'

Added `pipeline` parameter to MergeRequestsController

See merge request gitlab-org/gitlab!41539
parents d318043a 0bd8f559
...@@ -428,7 +428,13 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -428,7 +428,13 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42438') Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42438')
end end
def reports_response(report_comparison) def reports_response(report_comparison, pipeline = nil)
if pipeline&.active?
::Gitlab::PollingInterval.set_header(response, interval: 3000)
render json: '', status: :no_content && return
end
case report_comparison[:status] case report_comparison[:status]
when :parsing when :parsing
::Gitlab::PollingInterval.set_header(response, interval: 3000) ::Gitlab::PollingInterval.set_header(response, interval: 3000)
......
...@@ -28,27 +28,27 @@ module EE ...@@ -28,27 +28,27 @@ module EE
end end
def license_scanning_reports def license_scanning_reports
reports_response(merge_request.compare_license_scanning_reports(current_user)) reports_response(merge_request.compare_license_scanning_reports(current_user), head_pipeline)
end end
def container_scanning_reports def container_scanning_reports
reports_response(merge_request.compare_container_scanning_reports(current_user)) reports_response(merge_request.compare_container_scanning_reports(current_user), head_pipeline)
end end
def dependency_scanning_reports def dependency_scanning_reports
reports_response(merge_request.compare_dependency_scanning_reports(current_user)) reports_response(merge_request.compare_dependency_scanning_reports(current_user), head_pipeline)
end end
def sast_reports def sast_reports
reports_response(merge_request.compare_sast_reports(current_user)) reports_response(merge_request.compare_sast_reports(current_user), head_pipeline)
end end
def secret_detection_reports def secret_detection_reports
reports_response(merge_request.compare_secret_detection_reports(current_user)) reports_response(merge_request.compare_secret_detection_reports(current_user), head_pipeline)
end end
def dast_reports def dast_reports
reports_response(merge_request.compare_dast_reports(current_user)) reports_response(merge_request.compare_dast_reports(current_user), head_pipeline)
end end
def metrics_reports def metrics_reports
...@@ -56,7 +56,7 @@ module EE ...@@ -56,7 +56,7 @@ module EE
end end
def coverage_fuzzing_reports def coverage_fuzzing_reports
reports_response(merge_request.compare_coverage_fuzzing_reports(current_user)) reports_response(merge_request.compare_coverage_fuzzing_reports(current_user), head_pipeline)
end end
private private
......
---
title: Disable loading vulnerabilities in MR when pipeline is running
merge_request: 41539
author: Justin Zeng
type: fixed
...@@ -25,6 +25,28 @@ RSpec.shared_examples 'authorize read pipeline' do ...@@ -25,6 +25,28 @@ RSpec.shared_examples 'authorize read pipeline' do
end end
end end
RSpec.shared_examples 'pending pipeline response' do
context 'when pipeline is pending' do
let(:comparison_status) { nil }
before do
merge_request.head_pipeline.run!
end
it 'sends polling interval' do
expect(::Gitlab::PollingInterval).to receive(:set_header)
subject
end
it 'returns 204 HTTP status' do
subject
expect(response).to have_gitlab_http_status(:no_content)
end
end
end
RSpec.describe Projects::MergeRequestsController do RSpec.describe Projects::MergeRequestsController do
include ProjectForksHelper include ProjectForksHelper
...@@ -332,6 +354,8 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -332,6 +354,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'dependency_scanning').and_return(comparison_status) .with(::Ci::CompareSecurityReportsService, viewer, 'dependency_scanning').and_return(comparison_status)
end end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } } let(:comparison_status) { { status: :parsing } }
...@@ -402,6 +426,8 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -402,6 +426,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'container_scanning').and_return(comparison_status) .with(::Ci::CompareSecurityReportsService, viewer, 'container_scanning').and_return(comparison_status)
end end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } } let(:comparison_status) { { status: :parsing } }
...@@ -472,6 +498,8 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -472,6 +498,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'sast').and_return(comparison_status) .with(::Ci::CompareSecurityReportsService, viewer, 'sast').and_return(comparison_status)
end end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } } let(:comparison_status) { { status: :parsing } }
...@@ -543,6 +571,8 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -543,6 +571,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'secret_detection').and_return(comparison_status) .with(::Ci::CompareSecurityReportsService, viewer, 'secret_detection').and_return(comparison_status)
end end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } } let(:comparison_status) { { status: :parsing } }
...@@ -613,6 +643,8 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -613,6 +643,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'dast').and_return(comparison_status) .with(::Ci::CompareSecurityReportsService, viewer, 'dast').and_return(comparison_status)
end end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } } let(:comparison_status) { { status: :parsing } }
...@@ -684,6 +716,8 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -684,6 +716,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareLicenseScanningReportsService, viewer).and_return(comparison_status) .with(::Ci::CompareLicenseScanningReportsService, viewer).and_return(comparison_status)
end end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } } let(:comparison_status) { { status: :parsing } }
......
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