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