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
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42438')
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]
when :parsing
::Gitlab::PollingInterval.set_header(response, interval: 3000)
......
......@@ -28,27 +28,27 @@ module EE
end
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
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
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
def sast_reports
reports_response(merge_request.compare_sast_reports(current_user))
reports_response(merge_request.compare_sast_reports(current_user), head_pipeline)
end
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
def dast_reports
reports_response(merge_request.compare_dast_reports(current_user))
reports_response(merge_request.compare_dast_reports(current_user), head_pipeline)
end
def metrics_reports
......@@ -56,7 +56,7 @@ module EE
end
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
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
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
include ProjectForksHelper
......@@ -332,6 +354,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'dependency_scanning').and_return(comparison_status)
end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } }
......@@ -402,6 +426,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'container_scanning').and_return(comparison_status)
end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } }
......@@ -472,6 +498,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'sast').and_return(comparison_status)
end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } }
......@@ -543,6 +571,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'secret_detection').and_return(comparison_status)
end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } }
......@@ -613,6 +643,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareSecurityReportsService, viewer, 'dast').and_return(comparison_status)
end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do
let(:comparison_status) { { status: :parsing } }
......@@ -684,6 +716,8 @@ RSpec.describe Projects::MergeRequestsController do
.with(::Ci::CompareLicenseScanningReportsService, viewer).and_return(comparison_status)
end
it_behaves_like 'pending pipeline response'
context 'when comparison is being processed' do
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