Commit 4edca892 authored by Aleksandr Soborov's avatar Aleksandr Soborov Committed by Sanad Liaquat

Unquarantine security_reports_spec.rb tests

Further refactoring for test stability, and remove unused data selectors
and functions
parent 3708e662
......@@ -76,7 +76,10 @@ export default {
<div class="table-section flex-grow-1">
<div class="table-mobile-header" role="rowheader">{{ s__('Reports|Vulnerability') }}</div>
<div class="table-mobile-content vulnerability-info">
<div
class="table-mobile-content vulnerability-info"
data-qa-selector="vulnerability_info_content"
>
<gl-skeleton-loading v-if="isLoading" class="mt-2 js-skeleton-loader" :lines="2" />
<template v-else>
<gl-button
......
......@@ -22,9 +22,6 @@ export default {
className() {
return `vulnerability-count-${this.severity}`;
},
qaSelector() {
return `vulnerability_count_${this.severity}`;
},
severityTitle() {
return SEVERITY_LEVELS[this.severity] || this.severity;
},
......@@ -35,7 +32,7 @@ export default {
<template>
<div class="vulnerability-count" :class="className">
<div class="vulnerability-count-header">{{ severityTitle }}</div>
<div class="vulnerability-count-body" :data-qa-selector="qaSelector">
<div class="vulnerability-count-body">
<span v-if="isLoading">&mdash;</span> <span v-else>{{ count }}</span>
</div>
</div>
......
......@@ -5,15 +5,15 @@ module QA
module Page
module Group::Secure
class Show < QA::Page::Base
view 'ee/app/assets/javascripts/security_dashboard/components/vulnerability_count.vue' do
element :vulnerability_count, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
end
view 'ee/app/assets/javascripts/security_dashboard/components/filter.vue' do
element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
element :filter_dropdown_content
end
view 'ee/app/assets/javascripts/security_dashboard/components/security_dashboard_table_row.vue' do
element :vulnerability_info_content
end
def filter_project(project)
click_element(:filter_project_dropdown)
within_element(:filter_dropdown_content) do
......@@ -30,8 +30,8 @@ module QA
click_element(:filter_report_type_dropdown)
end
def has_low_vulnerability_count_of?(expected)
find_element(:vulnerability_count_low).has_content?(expected)
def has_vulnerability?(name)
has_element?(:vulnerability_info_content, text: name)
end
end
end
......
......@@ -22,6 +22,10 @@ module QA::EE
view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :security_tab
end
view 'ee/app/assets/javascripts/security_dashboard/components/security_dashboard_table_row.vue' do
element :vulnerability_info_content
end
end
end
......@@ -45,6 +49,10 @@ module QA::EE
def has_license_count_of?(count)
find_element(:licenses_counter).has_content?(count)
end
def has_vulnerability?(name)
has_element?(:vulnerability_info_content, text: name)
end
end
end
end
......
......@@ -5,15 +5,15 @@ module QA
module Page
module Project::Secure
class Show < QA::Page::Base
view 'ee/app/assets/javascripts/security_dashboard/components/vulnerability_count.vue' do
element :vulnerability_count, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
end
view 'ee/app/assets/javascripts/security_dashboard/components/filter.vue' do
element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
element :filter_dropdown_content
end
view 'ee/app/assets/javascripts/security_dashboard/components/security_dashboard_table_row.vue' do
element :vulnerability_info_content
end
def filter_report_type(report)
click_element(:filter_report_type_dropdown)
within_element(:filter_dropdown_content) do
......@@ -23,8 +23,8 @@ module QA
click_element(:filter_report_type_dropdown)
end
def has_low_vulnerability_count_of?(expected)
find_element(:vulnerability_count_low).has_content?(expected)
def has_vulnerability?(name)
has_element?(:vulnerability_info_content, text: name)
end
end
end
......
......@@ -3,17 +3,11 @@
require 'pathname'
module QA
# https://gitlab.com/gitlab-org/gitlab/issues/34900
context 'Secure', :docker, :quarantine do
context 'Secure', :docker do
let(:number_of_dependencies_in_fixture) { 1309 }
let(:total_vuln_count) { 54 }
let(:dependency_scan_vuln_count) { 4 }
let(:dependency_scan_example_vuln) { 'jQuery before 3.4.0' }
let(:container_scan_vuln_count) { 8 }
let(:dependency_scan_example_vuln) { 'Prototype pollution attack in mixin-deep' }
let(:container_scan_example_vuln) { 'CVE-2017-18269 in glibc' }
let(:sast_scan_vuln_count) { 33 }
let(:sast_scan_example_vuln) { 'Cipher with no integrity' }
let(:dast_scan_vuln_count) { 9 }
let(:dast_scan_example_vuln) { 'Cookie Without SameSite Attribute' }
describe 'Security Reports' do
......@@ -54,9 +48,7 @@ module QA
end.project.visit!
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline)
wait_for_job "dast"
Page::Project::Pipeline::Index.perform(&:wait_for_latest_pipeline_success)
end
it 'displays security reports in the pipeline' do
......@@ -66,26 +58,20 @@ module QA
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_on_security
expect(pipeline).to have_vulnerability_count_of total_vuln_count
filter_report_and_perform(pipeline, "Dependency Scanning") do
expect(pipeline).to have_vulnerability_count_of dependency_scan_vuln_count
expect(pipeline).to have_content dependency_scan_example_vuln
expect(pipeline).to have_vulnerability dependency_scan_example_vuln
end
filter_report_and_perform(pipeline, "Container Scanning") do
expect(pipeline).to have_vulnerability_count_of container_scan_vuln_count
expect(pipeline).to have_content container_scan_example_vuln
expect(pipeline).to have_vulnerability container_scan_example_vuln
end
filter_report_and_perform(pipeline, "SAST") do
expect(pipeline).to have_vulnerability_count_of sast_scan_vuln_count
expect(pipeline).to have_content sast_scan_example_vuln
expect(pipeline).to have_vulnerability sast_scan_example_vuln
end
filter_report_and_perform(pipeline, "DAST") do
expect(pipeline).to have_vulnerability_count_of dast_scan_vuln_count
expect(pipeline).to have_content dast_scan_example_vuln
expect(pipeline).to have_vulnerability dast_scan_example_vuln
end
end
end
......@@ -96,19 +82,19 @@ module QA
EE::Page::Project::Secure::Show.perform do |dashboard|
filter_report_and_perform(dashboard, "Dependency Scanning") do
expect(dashboard).to have_low_vulnerability_count_of 1
expect(dashboard).to have_vulnerability dependency_scan_example_vuln
end
filter_report_and_perform(dashboard, "Container Scanning") do
expect(dashboard).to have_low_vulnerability_count_of 2
expect(dashboard).to have_vulnerability container_scan_example_vuln
end
filter_report_and_perform(dashboard, "SAST") do
expect(dashboard).to have_low_vulnerability_count_of 17
expect(dashboard).to have_vulnerability sast_scan_example_vuln
end
filter_report_and_perform(dashboard, "DAST") do
expect(dashboard).to have_low_vulnerability_count_of 8
expect(dashboard).to have_vulnerability dast_scan_example_vuln
end
end
end
......@@ -124,19 +110,19 @@ module QA
dashboard.filter_project(@project.name)
filter_report_and_perform(dashboard, "Dependency Scanning") do
expect(dashboard).to have_content dependency_scan_example_vuln
expect(dashboard).to have_vulnerability dependency_scan_example_vuln
end
filter_report_and_perform(dashboard, "Container Scanning") do
expect(dashboard).to have_content container_scan_example_vuln
expect(dashboard).to have_vulnerability container_scan_example_vuln
end
filter_report_and_perform(dashboard, "SAST") do
expect(dashboard).to have_content sast_scan_example_vuln
expect(dashboard).to have_vulnerability sast_scan_example_vuln
end
filter_report_and_perform(dashboard, "DAST") do
expect(dashboard).to have_content dast_scan_example_vuln
expect(dashboard).to have_vulnerability dast_scan_example_vuln
end
end
end
......@@ -150,15 +136,6 @@ module QA
end
end
def wait_for_job(job_name)
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job(job_name)
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 600)
end
end
def filter_report_and_perform(page, report)
page.filter_report_type report
yield
......
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