summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-14 22:06:19 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-14 22:06:19 +0000
commita16072c2f88191585b0a69825b4b0fe53984cc80 (patch)
treeacc57b77209fd7a54512e75324b174e4cff6198a /spec
parent045e5c9a98f55302c35a50ff184d436ca3c3c0e3 (diff)
downloadgitlab-ce-a16072c2f88191585b0a69825b4b0fe53984cc80.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/features/merge_request/user_sees_merge_widget_spec.rb1
-rw-r--r--spec/frontend/gitlab_version_check/components/security_patch_upgrade_alert_spec.js84
-rw-r--r--spec/frontend/gitlab_version_check/index_spec.js19
-rw-r--r--spec/frontend/gitlab_version_check/mock_data.js6
-rw-r--r--spec/helpers/version_check_helper_spec.rb31
-rw-r--r--spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb22
-rw-r--r--spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb4
7 files changed, 47 insertions, 120 deletions
diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb
index 237f361bd72..0297bb5b935 100644
--- a/spec/features/merge_request/user_sees_merge_widget_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb
@@ -18,6 +18,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category:
end
before do
+ stub_feature_flags(refactor_security_extension: false)
project.add_maintainer(user)
project_only_mwps.add_maintainer(user)
sign_in(user)
diff --git a/spec/frontend/gitlab_version_check/components/security_patch_upgrade_alert_spec.js b/spec/frontend/gitlab_version_check/components/security_patch_upgrade_alert_spec.js
deleted file mode 100644
index 665dacd5c47..00000000000
--- a/spec/frontend/gitlab_version_check/components/security_patch_upgrade_alert_spec.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import { GlAlert, GlButton, GlLink, GlSprintf } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
-import SecurityPatchUpgradeAlert from '~/gitlab_version_check/components/security_patch_upgrade_alert.vue';
-import { UPGRADE_DOCS_URL, ABOUT_RELEASES_PAGE } from '~/gitlab_version_check/constants';
-
-describe('SecurityPatchUpgradeAlert', () => {
- let wrapper;
- let trackingSpy;
-
- const defaultProps = {
- currentVersion: '99.9',
- };
-
- const createComponent = () => {
- trackingSpy = mockTracking(undefined, undefined, jest.spyOn);
-
- wrapper = shallowMount(SecurityPatchUpgradeAlert, {
- propsData: {
- ...defaultProps,
- },
- stubs: {
- GlAlert,
- GlSprintf,
- },
- });
- };
-
- afterEach(() => {
- unmockTracking();
- });
-
- const findGlAlert = () => wrapper.findComponent(GlAlert);
- const findGlButton = () => wrapper.findComponent(GlButton);
- const findGlLink = () => wrapper.findComponent(GlLink);
-
- describe('template', () => {
- beforeEach(() => {
- createComponent();
- });
-
- it('renders non-dismissible GlAlert with version information', () => {
- expect(findGlAlert().text()).toContain(
- `You are currently on version ${defaultProps.currentVersion}.`,
- );
- expect(findGlAlert().props('dismissible')).toBe(false);
- });
-
- it('tracks render security_patch_upgrade_alert correctly', () => {
- expect(trackingSpy).toHaveBeenCalledWith(undefined, 'render', {
- label: 'security_patch_upgrade_alert',
- property: defaultProps.currentVersion,
- });
- });
-
- it('renders GlLink with correct text and link', () => {
- expect(findGlLink().text()).toBe('Learn more about this critical security release.');
- expect(findGlLink().attributes('href')).toBe(ABOUT_RELEASES_PAGE);
- });
-
- it('tracks click security_patch_upgrade_alert_learn_more when link is clicked', async () => {
- await findGlLink().vm.$emit('click');
-
- expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_link', {
- label: 'security_patch_upgrade_alert_learn_more',
- property: defaultProps.currentVersion,
- });
- });
-
- it('renders GlButton with correct text and link', () => {
- expect(findGlButton().text()).toBe('Upgrade now');
- expect(findGlButton().attributes('href')).toBe(UPGRADE_DOCS_URL);
- });
-
- it('tracks click security_patch_upgrade_alert_upgrade_now when button is clicked', async () => {
- await findGlButton().vm.$emit('click');
-
- expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_link', {
- label: 'security_patch_upgrade_alert_upgrade_now',
- property: defaultProps.currentVersion,
- });
- });
- });
-});
diff --git a/spec/frontend/gitlab_version_check/index_spec.js b/spec/frontend/gitlab_version_check/index_spec.js
index 92bc103cede..893105969ed 100644
--- a/spec/frontend/gitlab_version_check/index_spec.js
+++ b/spec/frontend/gitlab_version_check/index_spec.js
@@ -7,9 +7,6 @@ import {
VERSION_CHECK_BADGE_FIXTURE,
VERSION_CHECK_BADGE_FINDER,
VERSION_BADGE_TEXT,
- SECURITY_PATCH_FIXTURE,
- SECURITY_PATCH_FINDER,
- SECURITY_PATCH_TEXT,
SECURITY_MODAL_FIXTURE,
SECURITY_MODAL_FINDER,
SECURITY_MODAL_TEXT,
@@ -29,15 +26,13 @@ describe('initGitlabVersionCheck', () => {
});
describe.each`
- description | fixture | finders | componentTexts
- ${'with no version check elements'} | ${'<div></div>'} | ${[]} | ${[]}
- ${'with version check badge el but no prop data'} | ${VERSION_CHECK_BADGE_NO_PROP_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[undefined]}
- ${'with version check badge el but no severity data'} | ${VERSION_CHECK_BADGE_NO_SEVERITY_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[undefined]}
- ${'with version check badge el and version data'} | ${VERSION_CHECK_BADGE_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[VERSION_BADGE_TEXT]}
- ${'with security patch el'} | ${SECURITY_PATCH_FIXTURE} | ${[SECURITY_PATCH_FINDER]} | ${[SECURITY_PATCH_TEXT]}
- ${'with security patch and version badge els'} | ${`${SECURITY_PATCH_FIXTURE}${VERSION_CHECK_BADGE_FIXTURE}`} | ${[SECURITY_PATCH_FINDER, VERSION_CHECK_BADGE_FINDER]} | ${[SECURITY_PATCH_TEXT, VERSION_BADGE_TEXT]}
- ${'with security modal el'} | ${SECURITY_MODAL_FIXTURE} | ${[SECURITY_MODAL_FINDER]} | ${[SECURITY_MODAL_TEXT]}
- ${'with security modal, security patch, and version badge els'} | ${`${SECURITY_PATCH_FIXTURE}${SECURITY_MODAL_FIXTURE}${VERSION_CHECK_BADGE_FIXTURE}`} | ${[SECURITY_PATCH_FINDER, SECURITY_MODAL_FINDER, VERSION_CHECK_BADGE_FINDER]} | ${[SECURITY_PATCH_TEXT, SECURITY_MODAL_TEXT, VERSION_BADGE_TEXT]}
+ description | fixture | finders | componentTexts
+ ${'with no version check elements'} | ${'<div></div>'} | ${[]} | ${[]}
+ ${'with version check badge el but no prop data'} | ${VERSION_CHECK_BADGE_NO_PROP_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[undefined]}
+ ${'with version check badge el but no severity data'} | ${VERSION_CHECK_BADGE_NO_SEVERITY_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[undefined]}
+ ${'with version check badge el and version data'} | ${VERSION_CHECK_BADGE_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[VERSION_BADGE_TEXT]}
+ ${'with security modal el'} | ${SECURITY_MODAL_FIXTURE} | ${[SECURITY_MODAL_FINDER]} | ${[SECURITY_MODAL_TEXT]}
+ ${'with security modal and version badge els'} | ${`${SECURITY_MODAL_FIXTURE}${VERSION_CHECK_BADGE_FIXTURE}`} | ${[SECURITY_MODAL_FINDER, VERSION_CHECK_BADGE_FINDER]} | ${[SECURITY_MODAL_TEXT, VERSION_BADGE_TEXT]}
`('$description', ({ fixture, finders, componentTexts }) => {
beforeEach(() => {
createApp(fixture);
diff --git a/spec/frontend/gitlab_version_check/mock_data.js b/spec/frontend/gitlab_version_check/mock_data.js
index 707d45550eb..fb8c9ec81a7 100644
--- a/spec/frontend/gitlab_version_check/mock_data.js
+++ b/spec/frontend/gitlab_version_check/mock_data.js
@@ -9,12 +9,6 @@ export const VERSION_CHECK_BADGE_FINDER = '[data-testid="badge-click-wrapper"]';
export const VERSION_BADGE_TEXT = 'Up to date';
-export const SECURITY_PATCH_FIXTURE = `<div id="js-security-patch-upgrade-alert" data-current-version="15.1"></div>`;
-
-export const SECURITY_PATCH_FINDER = 'h2';
-
-export const SECURITY_PATCH_TEXT = 'Critical security upgrade available';
-
export const SECURITY_MODAL_FIXTURE = `<div id="js-security-patch-upgrade-alert-modal" data-current-version="15.1" data-version='{ "details": "test details", "latest-stable-versions": "[]" }'></div>`;
export const SECURITY_MODAL_FINDER = '[data-testid="alert-modal-title"]';
diff --git a/spec/helpers/version_check_helper_spec.rb b/spec/helpers/version_check_helper_spec.rb
index c76eb08820a..1c8eacf088a 100644
--- a/spec/helpers/version_check_helper_spec.rb
+++ b/spec/helpers/version_check_helper_spec.rb
@@ -49,26 +49,29 @@ RSpec.describe VersionCheckHelper do
describe '#show_security_patch_upgrade_alert?' do
describe 'return conditions' do
- where(:feature_enabled, :show_version_check, :gitlab_version_check, :result) do
+ where(:show_version_check, :gitlab_version_check, :result) do
[
- [false, false, nil, false],
- [false, false, { "severity" => "success" }, false],
- [false, false, { "severity" => "danger" }, false],
- [false, true, nil, false],
- [false, true, { "severity" => "success" }, false],
- [false, true, { "severity" => "danger" }, false],
- [true, false, nil, false],
- [true, false, { "severity" => "success" }, false],
- [true, false, { "severity" => "danger" }, false],
- [true, true, nil, false],
- [true, true, { "severity" => "success" }, false],
- [true, true, { "severity" => "danger" }, true]
+ [false, nil, false],
+ [false, { "severity" => "success" }, false],
+ [false, { "severity" => "danger" }, false],
+ [false, { "severity" => "danger", "critical_vulnerability" => 'some text' }, false],
+ [false, { "severity" => "danger", "critical_vulnerability" => 'false' }, false],
+ [false, { "severity" => "danger", "critical_vulnerability" => false }, false],
+ [false, { "severity" => "danger", "critical_vulnerability" => 'true' }, false],
+ [false, { "severity" => "danger", "critical_vulnerability" => true }, false],
+ [true, nil, false],
+ [true, { "severity" => "success" }, nil],
+ [true, { "severity" => "danger" }, nil],
+ [true, { "severity" => "danger", "critical_vulnerability" => 'some text' }, nil],
+ [true, { "severity" => "danger", "critical_vulnerability" => 'false' }, false],
+ [true, { "severity" => "danger", "critical_vulnerability" => false }, false],
+ [true, { "severity" => "danger", "critical_vulnerability" => 'true' }, true],
+ [true, { "severity" => "danger", "critical_vulnerability" => true }, true]
]
end
with_them do
before do
- stub_feature_flags(critical_security_alert: feature_enabled)
allow(helper).to receive(:show_version_check?).and_return(show_version_check)
allow(helper).to receive(:gitlab_version_check).and_return(gitlab_version_check)
end
diff --git a/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb b/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb
index 12886c79d7d..5fbaae58a73 100644
--- a/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb
+++ b/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb
@@ -567,6 +567,28 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu
end
it { is_expected.to match_array([message]) }
+
+ context 'without license', unless: Gitlab.ee? do
+ let(:schema_path) { Rails.root.join(*%w[lib gitlab ci parsers security validators schemas]) }
+
+ it 'tries to validate against the latest patch version available' do
+ expect(File).to receive(:file?).with("#{schema_path}/#{report_version}/#{report_type}-report-format.json")
+ expect(File).to receive(:file?).with("#{schema_path}/#{latest_patch_version}/#{report_type}-report-format.json")
+
+ subject
+ end
+ end
+
+ context 'with license', if: Gitlab.ee? do
+ let(:schema_path) { Rails.root.join(*%w[ee lib ee gitlab ci parsers security validators schemas]) }
+
+ it 'tries to validate against the latest patch version available' do
+ expect(File).to receive(:file?).with("#{schema_path}/#{report_version}/#{report_type}-report-format.json")
+ expect(File).to receive(:file?).with("#{schema_path}/#{latest_patch_version}/#{report_type}-report-format.json")
+
+ subject
+ end
+ end
end
context 'and the report is invalid' do
diff --git a/spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb b/spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb
index 4387a3f5b07..c94511a0c82 100644
--- a/spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb
+++ b/spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb
@@ -9,10 +9,6 @@ RSpec.describe 'shared/gitlab_version/_security_patch_upgrade_alert' do
render
end
- it 'renders the security patch upgrade alert' do
- expect(rendered).to have_selector('#js-security-patch-upgrade-alert')
- end
-
it 'renders the security patch upgrade alert modal' do
expect(rendered).to have_selector('#js-security-patch-upgrade-alert-modal')
end