Skip to content
Snippets Groups Projects
Commit 7078a138 authored by Alan (Maciej) Paruszewski's avatar Alan (Maciej) Paruszewski Committed by Florie Guibert
Browse files

Add Uknown license to Scan Result Policies

Changelog: changed
EE: true
parent 42551b3c
No related branches found
No related tags found
1 merge request!123565Add Unknown license to Scan Result Policies
......@@ -3,6 +3,11 @@ import { s__ } from '~/locale';
export const SEVERITY = 'severity';
export const STATUS = 'status';
export const UNKNOWN_LICENSE = {
value: 'unknown',
text: s__('ScanResultPolicy|Unknown'),
};
export const FILTERS = [
{
text: s__('ScanResultPolicy|New severity'),
......
......@@ -4,6 +4,7 @@ import { sprintf, s__ } from '~/locale';
import { parseBoolean } from '~/lib/utils/common_utils';
import BaseLayoutComponent from '../base_layout/base_layout_component.vue';
import { EXCEPT, MATCHING } from '../lib/rules';
import { UNKNOWN_LICENSE } from './constants';
export default {
i18n: {
......@@ -42,14 +43,17 @@ export default {
};
},
computed: {
allLicenses() {
return [...this.parsedSoftwareLicenses, UNKNOWN_LICENSE];
},
filteredLicenses() {
if (this.searchTerm) {
return this.parsedSoftwareLicenses.filter(({ value }) => {
return this.allLicenses.filter(({ value }) => {
return value.toLowerCase().includes(this.searchTerm.toLowerCase());
});
}
return this.parsedSoftwareLicenses;
return this.allLicenses;
},
licenseTypes: {
get() {
......@@ -75,8 +79,7 @@ export default {
const selectedValues = [this.licenseTypes].flat();
if (selectedValues.length === 1) {
toggleText = this.parsedSoftwareLicenses.find(({ value }) => value === selectedValues[0])
.text;
toggleText = this.allLicenses.find(({ value }) => value === selectedValues[0]).text;
}
if (selectedValues.length > 1) {
......
import BaseLayoutComponent from 'ee/security_orchestration/components/policy_editor/scan_result_policy/base_layout/base_layout_component.vue';
import LicenseFilter from 'ee/security_orchestration/components/policy_editor/scan_result_policy/scan_filters/license_filter.vue';
import { UNKNOWN_LICENSE } from 'ee/security_orchestration/components/policy_editor/scan_result_policy/scan_filters/constants';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { licenseScanBuildRule } from 'ee/security_orchestration/components/policy_editor/scan_result_policy/lib/rules';
......@@ -17,6 +18,7 @@ describe('LicenseFilter', () => {
license_states: ['newly_detected', 'detected'],
});
const parsedSoftwareLicenses = [APACHE_LICENSE, MIT_LICENSE].map((l) => ({ text: l, value: l }));
const allLicenses = [...parsedSoftwareLicenses, UNKNOWN_LICENSE];
const createComponent = (props = DEFAULT_PROPS) => {
wrapper = shallowMountExtended(LicenseFilter, {
......@@ -57,9 +59,12 @@ describe('LicenseFilter', () => {
expect(wrapper.emitted('changed')).toStrictEqual([[{ license_types: MIT_LICENSE }]]);
});
it('displays all licenses', () => {
expect(findLicenseTypeListBox().props('items')).toStrictEqual(allLicenses);
});
it('filters the licenses when searching', async () => {
const listBox = findLicenseTypeListBox();
expect(listBox.props('items')).toStrictEqual(parsedSoftwareLicenses);
await listBox.vm.$emit('search', APACHE_LICENSE);
expect(listBox.props('items')).toStrictEqual([
{ value: APACHE_LICENSE, text: APACHE_LICENSE },
......@@ -96,7 +101,7 @@ describe('LicenseFilter', () => {
it('can select single all licence types', () => {
findLicenseTypeListBox().vm.$emit('select-all');
expect(wrapper.emitted('changed')).toEqual([
[expect.objectContaining({ license_types: parsedSoftwareLicenses })],
[expect.objectContaining({ license_types: allLicenses })],
]);
});
......
......@@ -40483,6 +40483,9 @@ msgstr ""
msgid "ScanResultPolicy|Status is:"
msgstr ""
 
msgid "ScanResultPolicy|Unknown"
msgstr ""
msgid "ScanResultPolicy|When %{scanType} %{scanners} runs against the %{branches} and find(s) %{vulnerabilitiesNumber} %{boldDescription} of the following criteria:"
msgstr ""
 
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment