Skip to content
Snippets Groups Projects

Fix GraphQL pipeline findings pagination

Merged Malcolm Locke requested to merge 441306-security-report-finding-pagination into master
All threads resolved!
1 file
+ 11
11
Compare changes
  • Side-by-side
  • Inline
  • 979b0c79
    Fix vuln findings pagination tests · 979b0c79
    Malcolm Locke authored
    These tests are checking for the presence of the `X-Total` pagination
    header but we do not actually want these on this endoint.
    The endpoint uses pagination without counts which does not produce this
    header.
    
    Other changes on this MR have removed the headers and highlighted these
    outdated tests, so we're removing them here.
@@ -63,14 +63,14 @@
it 'returns all non-dismissed vulnerabilities', :aggregate_failures do
# all findings except one that was dismissed
finding_count = (sast_report.findings.count + ds_report.findings.count - 1).to_s
finding_count = (sast_report.findings.count + ds_report.findings.count - 1)
get api(project_vulnerability_findings_path, user), params: pagination
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(response).to include_limited_pagination_headers
expect(response).to match_response_schema('vulnerabilities/finding_list', dir: 'ee')
expect(response.headers['X-Total']).to eq finding_count
expect(json_response.count).to eq finding_count
expect(json_response.map { |v| v['report_type'] }.uniq).to match_array %w[dependency_scanning sast]
end
@@ -109,13 +109,13 @@
describe 'filtering' do
it 'returns vulnerabilities with sast report_type', :aggregate_failures do
finding_count = (sast_report.findings.count - 1).to_s # all SAST findings except one that was dismissed
finding_count = (sast_report.findings.count - 1) # all SAST findings except one that was dismissed
get api(project_vulnerability_findings_path, user), params: { report_type: 'sast' }
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Total']).to eq finding_count
expect(json_response.count).to eq finding_count
expect(json_response.map { |v| v['report_type'] }.uniq).to match_array %w[sast]
@@ -125,13 +125,13 @@
end
it 'returns vulnerabilities with dependency_scanning report_type', :aggregate_failures do
finding_count = ds_report.findings.count.to_s
finding_count = ds_report.findings.count
get api(project_vulnerability_findings_path, user), params: { report_type: 'dependency_scanning' }
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Total']).to eq finding_count
expect(json_response.count).to eq finding_count
expect(json_response.map { |v| v['report_type'] }.uniq).to match_array %w[dependency_scanning]
@@ -147,13 +147,13 @@
end
it 'returns dismissed vulnerabilities with `all` scope', :aggregate_failures do
finding_count = (sast_report.findings.count + ds_report.findings.count).to_s
finding_count = (sast_report.findings.count + ds_report.findings.count)
get api(project_vulnerability_findings_path, user), params: { scope: 'all' }.merge(pagination) # rubocop:disable Performance/CollectionLiteralInLoop
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Total']).to eq finding_count
expect(json_response.count).to eq finding_count
end
it 'returns vulnerabilities with low severity', :aggregate_failures do
@@ -186,13 +186,13 @@
context 'when pipeline_id is supplied' do
it 'returns vulnerabilities from supplied pipeline', :aggregate_failures do
finding_count = (sast_report.findings.count + ds_report.findings.count - 1).to_s
finding_count = (sast_report.findings.count + ds_report.findings.count - 1)
get api(project_vulnerability_findings_path, user), params: { pipeline_id: pipeline.id }.merge(pagination)
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Total']).to eq finding_count
expect(json_response.count).to eq finding_count
end
context 'pipeline has no reports' do
Loading