Commit f080e57c authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '335868-update-license-compliance-constants' into 'master'

Update frontend to use new license compliance backend values

See merge request gitlab-org/gitlab!82865
parents 0fce8e36 df162aec
...@@ -55,12 +55,12 @@ export default { ...@@ -55,12 +55,12 @@ export default {
[LICENSE_APPROVAL_STATUS.ALLOWED]: s__('LicenseCompliance|Allowed'), [LICENSE_APPROVAL_STATUS.ALLOWED]: s__('LicenseCompliance|Allowed'),
[LICENSE_APPROVAL_STATUS.DENIED]: s__('LicenseCompliance|Denied'), [LICENSE_APPROVAL_STATUS.DENIED]: s__('LicenseCompliance|Denied'),
computed: { computed: {
approveIconClass() { allowedIconClass() {
return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED
? visibleClass ? visibleClass
: invisibleClass; : invisibleClass;
}, },
blacklistIconClass() { deniedIconClass() {
return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED
? visibleClass ? visibleClass
: invisibleClass; : invisibleClass;
...@@ -98,11 +98,11 @@ export default { ...@@ -98,11 +98,11 @@ export default {
right right
> >
<gl-dropdown-item @click="allowLicense(license)"> <gl-dropdown-item @click="allowLicense(license)">
<gl-icon :class="approveIconClass" name="mobile-issue-close" /> <gl-icon :class="allowedIconClass" name="mobile-issue-close" />
{{ $options[$options.LICENSE_APPROVAL_ACTION.ALLOW] }} {{ $options[$options.LICENSE_APPROVAL_ACTION.ALLOW] }}
</gl-dropdown-item> </gl-dropdown-item>
<gl-dropdown-item @click="denyLicense(license)"> <gl-dropdown-item @click="denyLicense(license)">
<gl-icon :class="blacklistIconClass" name="mobile-issue-close" /> <gl-icon :class="deniedIconClass" name="mobile-issue-close" />
{{ $options[$options.LICENSE_APPROVAL_ACTION.DENY] }} {{ $options[$options.LICENSE_APPROVAL_ACTION.DENY] }}
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
......
...@@ -7,8 +7,8 @@ import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constan ...@@ -7,8 +7,8 @@ import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constan
* even though we adopted 'allowed' & 'denied' in the UI * even though we adopted 'allowed' & 'denied' in the UI
*/ */
export const LICENSE_APPROVAL_STATUS = { export const LICENSE_APPROVAL_STATUS = {
ALLOWED: 'approved', ALLOWED: gon?.features?.lcRemoveLegacyApprovalStatus ? 'allowed' : 'approved',
DENIED: 'blacklisted', DENIED: gon?.features?.lcRemoveLegacyApprovalStatus ? 'denied' : 'blacklisted',
}; };
/* /*
......
...@@ -79,7 +79,7 @@ export default { ...@@ -79,7 +79,7 @@ export default {
'licenseReport', 'licenseReport',
'isLoading', 'isLoading',
'licenseSummaryText', 'licenseSummaryText',
'reportContainsBlacklistedLicense', 'reportContainsDeniedLicense',
'licenseReportGroups', 'licenseReportGroups',
]), ]),
hasLicenseReportIssues() { hasLicenseReportIssues() {
...@@ -177,7 +177,7 @@ export default { ...@@ -177,7 +177,7 @@ export default {
<div class="pr-3"> <div class="pr-3">
{{ licenseSummaryText }} {{ licenseSummaryText }}
<gl-link <gl-link
v-if="reportContainsBlacklistedLicense && licenseComplianceDocsPath" v-if="reportContainsDeniedLicense && licenseComplianceDocsPath"
:href="licenseComplianceDocsPath" :href="licenseComplianceDocsPath"
data-testid="security-approval-help-link" data-testid="security-approval-help-link"
target="_blank" target="_blank"
......
...@@ -62,7 +62,7 @@ export const licenseSummaryText = (state, getters) => { ...@@ -62,7 +62,7 @@ export const licenseSummaryText = (state, getters) => {
export const summaryTextWithLicenseCheck = (_, getters) => { export const summaryTextWithLicenseCheck = (_, getters) => {
if (!getters.baseReportHasLicenses) { if (!getters.baseReportHasLicenses) {
return getters.reportContainsBlacklistedLicense return getters.reportContainsDeniedLicense
? n__( ? n__(
'LicenseCompliance|License Compliance detected %d license and policy violation for the source branch only; approval required', 'LicenseCompliance|License Compliance detected %d license and policy violation for the source branch only; approval required',
'LicenseCompliance|License Compliance detected %d licenses and policy violations for the source branch only; approval required', 'LicenseCompliance|License Compliance detected %d licenses and policy violations for the source branch only; approval required',
...@@ -75,7 +75,7 @@ export const summaryTextWithLicenseCheck = (_, getters) => { ...@@ -75,7 +75,7 @@ export const summaryTextWithLicenseCheck = (_, getters) => {
); );
} }
return getters.reportContainsBlacklistedLicense return getters.reportContainsDeniedLicense
? n__( ? n__(
'LicenseCompliance|License Compliance detected %d new license and policy violation; approval required', 'LicenseCompliance|License Compliance detected %d new license and policy violation; approval required',
'LicenseCompliance|License Compliance detected %d new licenses and policy violations; approval required', 'LicenseCompliance|License Compliance detected %d new licenses and policy violations; approval required',
...@@ -90,7 +90,7 @@ export const summaryTextWithLicenseCheck = (_, getters) => { ...@@ -90,7 +90,7 @@ export const summaryTextWithLicenseCheck = (_, getters) => {
export const summaryTextWithoutLicenseCheck = (_, getters) => { export const summaryTextWithoutLicenseCheck = (_, getters) => {
if (!getters.baseReportHasLicenses) { if (!getters.baseReportHasLicenses) {
return getters.reportContainsBlacklistedLicense return getters.reportContainsDeniedLicense
? n__( ? n__(
'LicenseCompliance|License Compliance detected %d license and policy violation for the source branch only', 'LicenseCompliance|License Compliance detected %d license and policy violation for the source branch only',
'LicenseCompliance|License Compliance detected %d licenses and policy violations for the source branch only', 'LicenseCompliance|License Compliance detected %d licenses and policy violations for the source branch only',
...@@ -103,7 +103,7 @@ export const summaryTextWithoutLicenseCheck = (_, getters) => { ...@@ -103,7 +103,7 @@ export const summaryTextWithoutLicenseCheck = (_, getters) => {
); );
} }
return getters.reportContainsBlacklistedLicense return getters.reportContainsDeniedLicense
? n__( ? n__(
'LicenseCompliance|License Compliance detected %d new license and policy violation', 'LicenseCompliance|License Compliance detected %d new license and policy violation',
'LicenseCompliance|License Compliance detected %d new licenses and policy violations', 'LicenseCompliance|License Compliance detected %d new licenses and policy violations',
...@@ -116,7 +116,7 @@ export const summaryTextWithoutLicenseCheck = (_, getters) => { ...@@ -116,7 +116,7 @@ export const summaryTextWithoutLicenseCheck = (_, getters) => {
); );
}; };
export const reportContainsBlacklistedLicense = (_, getters) => export const reportContainsDeniedLicense = (_, getters) =>
(getters.licenseReport || []).some( (getters.licenseReport || []).some(
(license) => license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED, (license) => license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED,
); );
...@@ -19,6 +19,7 @@ module EE ...@@ -19,6 +19,7 @@ module EE
push_frontend_feature_flag(:refactor_mr_widgets_extensions, @project, default_enabled: :yaml) push_frontend_feature_flag(:refactor_mr_widgets_extensions, @project, default_enabled: :yaml)
push_frontend_feature_flag(:refactor_mr_widgets_extensions_user, current_user, default_enabled: :yaml) push_frontend_feature_flag(:refactor_mr_widgets_extensions_user, current_user, default_enabled: :yaml)
push_frontend_feature_flag(:status_checks_add_status_field, default_enabled: :yaml) push_frontend_feature_flag(:status_checks_add_status_field, default_enabled: :yaml)
push_frontend_feature_flag(:lc_remove_legacy_approval_status, @project, default_enabled: :yaml)
end end
before_action :authorize_read_pipeline!, only: [:container_scanning_reports, :dependency_scanning_reports, before_action :authorize_read_pipeline!, only: [:container_scanning_reports, :dependency_scanning_reports,
......
...@@ -4,6 +4,10 @@ module Projects ...@@ -4,6 +4,10 @@ module Projects
class LicensesController < Projects::ApplicationController class LicensesController < Projects::ApplicationController
include SecurityAndCompliancePermissions include SecurityAndCompliancePermissions
before_action do
push_frontend_feature_flag(:lc_remove_legacy_approval_status, @project, default_enabled: :yaml)
end
before_action :authorize_read_licenses!, only: [:index] before_action :authorize_read_licenses!, only: [:index]
before_action :authorize_admin_software_license_policy!, only: [:create, :update] before_action :authorize_admin_software_license_policy!, only: [:create, :update]
......
...@@ -11,6 +11,7 @@ RSpec.describe Projects::LicensesController do ...@@ -11,6 +11,7 @@ RSpec.describe Projects::LicensesController do
let(:get_licenses) { get :index, params: params, format: :json } let(:get_licenses) { get :index, params: params, format: :json }
before do before do
stub_feature_flags(lc_remove_legacy_approval_status: false)
sign_in(user) sign_in(user)
end end
......
...@@ -12,10 +12,7 @@ import * as getters from 'ee/license_compliance/store/modules/list/getters'; ...@@ -12,10 +12,7 @@ import * as getters from 'ee/license_compliance/store/modules/list/getters';
import { LICENSE_APPROVAL_CLASSIFICATION } from 'ee/vue_shared/license_compliance/constants'; import { LICENSE_APPROVAL_CLASSIFICATION } from 'ee/vue_shared/license_compliance/constants';
import LicenseManagement from 'ee/vue_shared/license_compliance/license_management.vue'; import LicenseManagement from 'ee/vue_shared/license_compliance/license_management.vue';
import { import { allowedLicense, deniedLicense } from 'ee_jest/vue_shared/license_compliance/mock_data';
approvedLicense,
blacklistedLicense,
} from 'ee_jest/vue_shared/license_compliance/mock_data';
import setWindowLocation from 'helpers/set_window_location_helper'; import setWindowLocation from 'helpers/set_window_location_helper';
import { stubTransition } from 'helpers/stub_transition'; import { stubTransition } from 'helpers/stub_transition';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
...@@ -25,7 +22,7 @@ Vue.use(Vuex); ...@@ -25,7 +22,7 @@ Vue.use(Vuex);
let wrapper; let wrapper;
const readLicensePoliciesEndpoint = `${TEST_HOST}/license_management`; const readLicensePoliciesEndpoint = `${TEST_HOST}/license_management`;
const managedLicenses = [approvedLicense, blacklistedLicense]; const managedLicenses = [allowedLicense, deniedLicense];
const licenses = [{}, {}]; const licenses = [{}, {}];
const emptyStateSvgPath = '/'; const emptyStateSvgPath = '/';
const documentationPath = '/'; const documentationPath = '/';
......
...@@ -5,7 +5,7 @@ import AdminLicenseManagementRow from 'ee/vue_shared/license_compliance/componen ...@@ -5,7 +5,7 @@ import AdminLicenseManagementRow from 'ee/vue_shared/license_compliance/componen
import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_compliance/constants'; import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_compliance/constants';
import { mountComponentWithStore } from 'helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { approvedLicense } from '../mock_data'; import { allowedLicense } from '../mock_data';
const visibleClass = 'visible'; const visibleClass = 'visible';
const invisibleClass = 'invisible'; const invisibleClass = 'invisible';
...@@ -19,7 +19,7 @@ describe('AdminLicenseManagementRow', () => { ...@@ -19,7 +19,7 @@ describe('AdminLicenseManagementRow', () => {
let store; let store;
let actions; let actions;
const createComponent = (props = { license: approvedLicense }) => { const createComponent = (props = { license: allowedLicense }) => {
vm = mountComponentWithStore(Component, { props, store }); vm = mountComponentWithStore(Component, { props, store });
}; };
...@@ -53,9 +53,9 @@ describe('AdminLicenseManagementRow', () => { ...@@ -53,9 +53,9 @@ describe('AdminLicenseManagementRow', () => {
vm.$destroy(); vm.$destroy();
}); });
describe('approved license', () => { describe('allowed license', () => {
beforeEach(async () => { beforeEach(async () => {
vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED }; vm.license = { ...allowedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED };
await nextTick(); await nextTick();
}); });
...@@ -64,12 +64,12 @@ describe('AdminLicenseManagementRow', () => { ...@@ -64,12 +64,12 @@ describe('AdminLicenseManagementRow', () => {
expect(vm.dropdownText).toBe('Allowed'); expect(vm.dropdownText).toBe('Allowed');
}); });
it('isApproved returns `true`', () => { it('isAllowed returns `true`', () => {
expect(vm.approveIconClass).toBe(visibleClass); expect(vm.allowedIconClass).toBe(visibleClass);
}); });
it('isBlacklisted returns `false`', () => { it('isDenied returns `false`', () => {
expect(vm.blacklistIconClass).toBe(invisibleClass); expect(vm.deniedIconClass).toBe(invisibleClass);
}); });
}); });
...@@ -88,9 +88,9 @@ describe('AdminLicenseManagementRow', () => { ...@@ -88,9 +88,9 @@ describe('AdminLicenseManagementRow', () => {
}); });
}); });
describe('blacklisted license', () => { describe('denied license', () => {
beforeEach(async () => { beforeEach(async () => {
vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED }; vm.license = { ...allowedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED };
await nextTick(); await nextTick();
}); });
...@@ -99,12 +99,12 @@ describe('AdminLicenseManagementRow', () => { ...@@ -99,12 +99,12 @@ describe('AdminLicenseManagementRow', () => {
expect(vm.dropdownText).toBe('Denied'); expect(vm.dropdownText).toBe('Denied');
}); });
it('isApproved returns `false`', () => { it('isAllowed returns `false`', () => {
expect(vm.approveIconClass).toBe(invisibleClass); expect(vm.allowedIconClass).toBe(invisibleClass);
}); });
it('isBlacklisted returns `true`', () => { it('isDenied returns `true`', () => {
expect(vm.blacklistIconClass).toBe(visibleClass); expect(vm.deniedIconClass).toBe(visibleClass);
}); });
}); });
...@@ -160,7 +160,7 @@ describe('AdminLicenseManagementRow', () => { ...@@ -160,7 +160,7 @@ describe('AdminLicenseManagementRow', () => {
it('renders license name', () => { it('renders license name', () => {
const nameEl = vm.$el.querySelector('.js-license-name'); const nameEl = vm.$el.querySelector('.js-license-name');
expect(nameEl.innerText.trim()).toBe(approvedLicense.name); expect(nameEl.innerText.trim()).toBe(allowedLicense.name);
}); });
it('renders the removal button', () => { it('renders the removal button', () => {
...@@ -199,7 +199,7 @@ describe('AdminLicenseManagementRow', () => { ...@@ -199,7 +199,7 @@ describe('AdminLicenseManagementRow', () => {
}); });
it('shows a loading icon and disables both the dropdown and the remove button while loading', () => { it('shows a loading icon and disables both the dropdown and the remove button while loading', () => {
createComponent({ license: approvedLicense, loading: true }); createComponent({ license: allowedLicense, loading: true });
expect(findLoadingIcon()).not.toBeNull(); expect(findLoadingIcon()).not.toBeNull();
expect(findDropdownToggle().disabled).toBe(true); expect(findDropdownToggle().disabled).toBe(true);
expect(findRemoveButton().disabled).toBe(true); expect(findRemoveButton().disabled).toBe(true);
......
...@@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import Component from 'ee/vue_shared/license_compliance/components/delete_confirmation_modal.vue'; import Component from 'ee/vue_shared/license_compliance/components/delete_confirmation_modal.vue';
import { approvedLicense } from '../mock_data'; import { allowedLicense } from '../mock_data';
Vue.use(Vuex); Vue.use(Vuex);
...@@ -23,7 +23,7 @@ describe('DeleteConfirmationModal', () => { ...@@ -23,7 +23,7 @@ describe('DeleteConfirmationModal', () => {
licenseManagement: { licenseManagement: {
namespaced: true, namespaced: true,
state: { state: {
currentLicenseInModal: approvedLicense, currentLicenseInModal: allowedLicense,
...initialState, ...initialState,
}, },
actions, actions,
...@@ -72,7 +72,7 @@ describe('DeleteConfirmationModal', () => { ...@@ -72,7 +72,7 @@ describe('DeleteConfirmationModal', () => {
it('should have the confirmation text', () => { it('should have the confirmation text', () => {
expect(findModal().html()).toContain( expect(findModal().html()).toContain(
`You are about to remove the license, <strong>${approvedLicense.name}</strong>, from this project.`, `You are about to remove the license, <strong>${allowedLicense.name}</strong>, from this project.`,
); );
}); });
...@@ -81,7 +81,7 @@ describe('DeleteConfirmationModal', () => { ...@@ -81,7 +81,7 @@ describe('DeleteConfirmationModal', () => {
const nameEscaped = '&lt;a href="#"&gt;BAD&lt;/a&gt;'; const nameEscaped = '&lt;a href="#"&gt;BAD&lt;/a&gt;';
const currentLicenseInModal = { const currentLicenseInModal = {
...approvedLicense, ...allowedLicense,
name, name,
}; };
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import LicenseManagementRow from 'ee/vue_shared/license_compliance/components/license_management_row.vue'; import LicenseManagementRow from 'ee/vue_shared/license_compliance/components/license_management_row.vue';
import { import { allowedLicense, deniedLicense } from 'ee_jest/vue_shared/license_compliance/mock_data';
approvedLicense,
blacklistedLicense,
} from 'ee_jest/vue_shared/license_compliance/mock_data';
let wrapper; let wrapper;
...@@ -15,7 +12,7 @@ describe('LicenseManagementRow', () => { ...@@ -15,7 +12,7 @@ describe('LicenseManagementRow', () => {
describe('allowed license', () => { describe('allowed license', () => {
beforeEach(() => { beforeEach(() => {
const props = { license: approvedLicense }; const props = { license: allowedLicense };
wrapper = shallowMount(LicenseManagementRow, { wrapper = shallowMount(LicenseManagementRow, {
propsData: { propsData: {
...@@ -35,7 +32,7 @@ describe('LicenseManagementRow', () => { ...@@ -35,7 +32,7 @@ describe('LicenseManagementRow', () => {
describe('denied license', () => { describe('denied license', () => {
beforeEach(() => { beforeEach(() => {
const props = { license: blacklistedLicense }; const props = { license: deniedLicense };
wrapper = shallowMount(LicenseManagementRow, { wrapper = shallowMount(LicenseManagementRow, {
propsData: { propsData: {
......
...@@ -8,13 +8,13 @@ import AdminLicenseManagementRow from 'ee/vue_shared/license_compliance/componen ...@@ -8,13 +8,13 @@ import AdminLicenseManagementRow from 'ee/vue_shared/license_compliance/componen
import DeleteConfirmationModal from 'ee/vue_shared/license_compliance/components/delete_confirmation_modal.vue'; import DeleteConfirmationModal from 'ee/vue_shared/license_compliance/components/delete_confirmation_modal.vue';
import LicenseManagementRow from 'ee/vue_shared/license_compliance/components/license_management_row.vue'; import LicenseManagementRow from 'ee/vue_shared/license_compliance/components/license_management_row.vue';
import LicenseManagement from 'ee/vue_shared/license_compliance/license_management.vue'; import LicenseManagement from 'ee/vue_shared/license_compliance/license_management.vue';
import { approvedLicense, blacklistedLicense } from './mock_data'; import { allowedLicense, deniedLicense } from './mock_data';
Vue.use(Vuex); Vue.use(Vuex);
let wrapper; let wrapper;
const managedLicenses = [approvedLicense, blacklistedLicense]; const managedLicenses = [allowedLicense, deniedLicense];
const PaginatedList = { const PaginatedList = {
props: ['list'], props: ['list'],
......
import { range } from 'lodash'; import { range } from 'lodash';
import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_compliance/constants'; import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_compliance/constants';
export const approvedLicense = { export const allowedLicense = {
id: 5, id: 5,
name: 'MIT', name: 'MIT',
approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
}; };
export const blacklistedLicense = { export const deniedLicense = {
id: 6, id: 6,
name: 'New BSD', name: 'New BSD',
approvalStatus: LICENSE_APPROVAL_STATUS.DENIED, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
......
...@@ -9,8 +9,8 @@ import ReportItem from '~/reports/components/report_item.vue'; ...@@ -9,8 +9,8 @@ import ReportItem from '~/reports/components/report_item.vue';
import ReportSection from '~/reports/components/report_section.vue'; import ReportSection from '~/reports/components/report_section.vue';
import { LOADING, ERROR, SUCCESS } from '~/reports/constants'; import { LOADING, ERROR, SUCCESS } from '~/reports/constants';
import { import {
approvedLicense, allowedLicense,
blacklistedLicense, deniedLicense,
licenseReport as licenseReportMock, licenseReport as licenseReportMock,
generateReportGroup, generateReportGroup,
} from './mock_data'; } from './mock_data';
...@@ -23,7 +23,7 @@ describe('License Report MR Widget', () => { ...@@ -23,7 +23,7 @@ describe('License Report MR Widget', () => {
let wrapper; let wrapper;
const defaultState = { const defaultState = {
managedLicenses: [approvedLicense, blacklistedLicense], managedLicenses: [allowedLicense, deniedLicense],
currentLicenseInModal: licenseReportMock[0], currentLicenseInModal: licenseReportMock[0],
isLoadingManagedLicenses: true, isLoadingManagedLicenses: true,
}; };
...@@ -38,7 +38,7 @@ describe('License Report MR Widget', () => { ...@@ -38,7 +38,7 @@ describe('License Report MR Widget', () => {
licenseSummaryText() { licenseSummaryText() {
return 'FOO'; return 'FOO';
}, },
reportContainsBlacklistedLicense() { reportContainsDeniedLicense() {
return false; return false;
}, },
licenseReportGroups() { licenseReportGroups() {
...@@ -414,16 +414,16 @@ describe('License Report MR Widget', () => { ...@@ -414,16 +414,16 @@ describe('License Report MR Widget', () => {
const findLicenseComplianceHelpLink = () => const findLicenseComplianceHelpLink = () =>
wrapper.find('[data-testid="security-approval-help-link"]'); wrapper.find('[data-testid="security-approval-help-link"]');
it('does not show a link to security approval help page if report does not contain blacklisted licenses', () => { it('does not show a link to security approval help page if report does not contain denied licenses', () => {
mountComponent(); mountComponent();
expect(findLicenseComplianceHelpLink().exists()).toBe(false); expect(findLicenseComplianceHelpLink().exists()).toBe(false);
}); });
it('shows a link to security approval help page if report contains blacklisted licenses', () => { it('shows a link to security approval help page if report contains denied licenses', () => {
const getters = { const getters = {
...defaultGetters, ...defaultGetters,
reportContainsBlacklistedLicense() { reportContainsDeniedLicense() {
return true; return true;
}, },
}; };
......
...@@ -7,7 +7,7 @@ import createState from 'ee/vue_shared/license_compliance/store/state'; ...@@ -7,7 +7,7 @@ import createState from 'ee/vue_shared/license_compliance/store/state';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { approvedLicense, blacklistedLicense } from '../mock_data'; import { allowedLicense, deniedLicense } from '../mock_data';
describe('License store actions', () => { describe('License store actions', () => {
const apiUrlManageLicenses = `${TEST_HOST}/licenses/management`; const apiUrlManageLicenses = `${TEST_HOST}/licenses/management`;
...@@ -29,9 +29,9 @@ describe('License store actions', () => { ...@@ -29,9 +29,9 @@ describe('License store actions', () => {
...createState(), ...createState(),
apiUrlManageLicenses, apiUrlManageLicenses,
approvalsApiPath, approvalsApiPath,
currentLicenseInModal: approvedLicense, currentLicenseInModal: allowedLicense,
}; };
licenseId = approvedLicense.id; licenseId = allowedLicense.id;
mockDispatch = jest.fn(() => Promise.resolve()); mockDispatch = jest.fn(() => Promise.resolve());
mockCommit = jest.fn(); mockCommit = jest.fn();
store = { store = {
...@@ -79,9 +79,9 @@ describe('License store actions', () => { ...@@ -79,9 +79,9 @@ describe('License store actions', () => {
it('commits SET_LICENSE_IN_MODAL with license', (done) => { it('commits SET_LICENSE_IN_MODAL with license', (done) => {
testAction( testAction(
actions.setLicenseInModal, actions.setLicenseInModal,
approvedLicense, allowedLicense,
state, state,
[{ type: mutationTypes.SET_LICENSE_IN_MODAL, payload: approvedLicense }], [{ type: mutationTypes.SET_LICENSE_IN_MODAL, payload: allowedLicense }],
[], [],
) )
.then(done) .then(done)
...@@ -283,10 +283,10 @@ describe('License store actions', () => { ...@@ -283,10 +283,10 @@ describe('License store actions', () => {
}); });
return actions return actions
.setLicenseApproval(store, { license: approvedLicense, newStatus }) .setLicenseApproval(store, { license: allowedLicense, newStatus })
.then(() => { .then(() => {
expectDispatched('addPendingLicense', approvedLicense.id); expectDispatched('addPendingLicense', allowedLicense.id);
expectDispatched('receiveSetLicenseApproval', approvedLicense.id); expectDispatched('receiveSetLicenseApproval', allowedLicense.id);
}); });
}); });
...@@ -297,11 +297,11 @@ describe('License store actions', () => { ...@@ -297,11 +297,11 @@ describe('License store actions', () => {
}); });
return actions return actions
.setLicenseApproval(store, { license: approvedLicense, newStatus }) .setLicenseApproval(store, { license: allowedLicense, newStatus })
.then(() => { .then(() => {
expectDispatched('addPendingLicense', approvedLicense.id); expectDispatched('addPendingLicense', allowedLicense.id);
expectDispatched('receiveSetLicenseApprovalError'); expectDispatched('receiveSetLicenseApprovalError');
expectDispatched('removePendingLicense', approvedLicense.id); expectDispatched('removePendingLicense', allowedLicense.id);
}); });
}); });
}); });
...@@ -310,7 +310,7 @@ describe('License store actions', () => { ...@@ -310,7 +310,7 @@ describe('License store actions', () => {
describe('allowLicense', () => { describe('allowLicense', () => {
const newStatus = LICENSE_APPROVAL_STATUS.ALLOWED; const newStatus = LICENSE_APPROVAL_STATUS.ALLOWED;
it('dispatches setLicenseApproval for un-approved licenses', (done) => { it('dispatches setLicenseApproval for un-allowed licenses', (done) => {
const license = { name: 'FOO' }; const license = { name: 'FOO' };
testAction( testAction(
...@@ -324,8 +324,8 @@ describe('License store actions', () => { ...@@ -324,8 +324,8 @@ describe('License store actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('dispatches setLicenseApproval for blacklisted licenses', (done) => { it('dispatches setLicenseApproval for denied licenses', (done) => {
const license = blacklistedLicense; const license = deniedLicense;
testAction( testAction(
actions.allowLicense, actions.allowLicense,
...@@ -338,15 +338,15 @@ describe('License store actions', () => { ...@@ -338,15 +338,15 @@ describe('License store actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does not dispatch setLicenseApproval for approved licenses', (done) => { it('does not dispatch setLicenseApproval for allowed licenses', (done) => {
testAction(actions.allowLicense, approvedLicense, state, [], []).then(done).catch(done.fail); testAction(actions.allowLicense, allowedLicense, state, [], []).then(done).catch(done.fail);
}); });
}); });
describe('denyLicense', () => { describe('denyLicense', () => {
const newStatus = LICENSE_APPROVAL_STATUS.DENIED; const newStatus = LICENSE_APPROVAL_STATUS.DENIED;
it('dispatches setLicenseApproval for un-approved licenses', (done) => { it('dispatches setLicenseApproval for un-allowed licenses', (done) => {
const license = { name: 'FOO' }; const license = { name: 'FOO' };
testAction( testAction(
...@@ -360,8 +360,8 @@ describe('License store actions', () => { ...@@ -360,8 +360,8 @@ describe('License store actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('dispatches setLicenseApproval for approved licenses', (done) => { it('dispatches setLicenseApproval for allowed licenses', (done) => {
const license = approvedLicense; const license = allowedLicense;
testAction( testAction(
actions.denyLicense, actions.denyLicense,
...@@ -374,10 +374,8 @@ describe('License store actions', () => { ...@@ -374,10 +374,8 @@ describe('License store actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('does not dispatch setLicenseApproval for blacklisted licenses', (done) => { it('does not dispatch setLicenseApproval for denied licenses', (done) => {
testAction(actions.denyLicense, blacklistedLicense, state, [], []) testAction(actions.denyLicense, deniedLicense, state, [], []).then(done).catch(done.fail);
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -397,7 +395,7 @@ describe('License store actions', () => { ...@@ -397,7 +395,7 @@ describe('License store actions', () => {
describe('receiveManagedLicensesSuccess', () => { describe('receiveManagedLicensesSuccess', () => {
it('commits RECEIVE_MANAGED_LICENSES_SUCCESS', (done) => { it('commits RECEIVE_MANAGED_LICENSES_SUCCESS', (done) => {
const payload = [approvedLicense]; const payload = [allowedLicense];
testAction( testAction(
actions.receiveManagedLicensesSuccess, actions.receiveManagedLicensesSuccess,
payload, payload,
...@@ -658,7 +656,7 @@ describe('License store actions', () => { ...@@ -658,7 +656,7 @@ describe('License store actions', () => {
rawLicenseReport = [ rawLicenseReport = [
{ {
name: 'MIT', name: 'MIT',
classification: { id: 2, approval_status: 'blacklisted', name: 'MIT' }, classification: { id: 2, approval_status: LICENSE_APPROVAL_STATUS.DENIED, name: 'MIT' },
dependencies: [{ name: 'vue' }], dependencies: [{ name: 'vue' }],
count: 1, count: 1,
url: 'http://opensource.org/licenses/mit-license', url: 'http://opensource.org/licenses/mit-license',
...@@ -675,7 +673,7 @@ describe('License store actions', () => { ...@@ -675,7 +673,7 @@ describe('License store actions', () => {
{ {
...rawLicenseReport[0], ...rawLicenseReport[0],
id: 2, id: 2,
approvalStatus: 'blacklisted', approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
packages: [{ name: 'vue' }], packages: [{ name: 'vue' }],
status: 'failed', status: 'failed',
}, },
...@@ -720,7 +718,11 @@ describe('License store actions', () => { ...@@ -720,7 +718,11 @@ describe('License store actions', () => {
new_licenses: [ new_licenses: [
{ {
name: 'Apache 2.0', name: 'Apache 2.0',
classification: { id: 1, approval_status: 'approved', name: 'Apache 2.0' }, classification: {
id: 1,
approval_status: LICENSE_APPROVAL_STATUS.ALLOWED,
name: 'Apache 2.0',
},
dependencies: [{ name: 'echarts' }], dependencies: [{ name: 'echarts' }],
count: 1, count: 1,
url: 'http://www.apache.org/licenses/LICENSE-2.0.txt', url: 'http://www.apache.org/licenses/LICENSE-2.0.txt',
...@@ -736,7 +738,11 @@ describe('License store actions', () => { ...@@ -736,7 +738,11 @@ describe('License store actions', () => {
existing_licenses: [ existing_licenses: [
{ {
name: 'MIT', name: 'MIT',
classification: { id: 2, approval_status: 'blacklisted', name: 'MIT' }, classification: {
id: 2,
approval_status: LICENSE_APPROVAL_STATUS.DENIED,
name: 'MIT',
},
dependencies: [{ name: 'vue' }], dependencies: [{ name: 'vue' }],
count: 1, count: 1,
url: 'http://opensource.org/licenses/mit-license', url: 'http://opensource.org/licenses/mit-license',
...@@ -754,7 +760,7 @@ describe('License store actions', () => { ...@@ -754,7 +760,7 @@ describe('License store actions', () => {
{ {
...rawLicenseReport.existing_licenses[0], ...rawLicenseReport.existing_licenses[0],
id: 2, id: 2,
approvalStatus: 'blacklisted', approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
packages: [{ name: 'vue' }], packages: [{ name: 'vue' }],
status: 'failed', status: 'failed',
}, },
...@@ -763,7 +769,7 @@ describe('License store actions', () => { ...@@ -763,7 +769,7 @@ describe('License store actions', () => {
{ {
...rawLicenseReport.new_licenses[0], ...rawLicenseReport.new_licenses[0],
id: 1, id: 1,
approvalStatus: 'approved', approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
packages: [{ name: 'echarts' }], packages: [{ name: 'echarts' }],
status: 'success', status: 'success',
}, },
......
...@@ -3,7 +3,7 @@ import createStore from 'ee/vue_shared/license_compliance/store'; ...@@ -3,7 +3,7 @@ import createStore from 'ee/vue_shared/license_compliance/store';
import * as types from 'ee/vue_shared/license_compliance/store/mutation_types'; import * as types from 'ee/vue_shared/license_compliance/store/mutation_types';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import { approvedLicense } from '../mock_data'; import { allowedLicense } from '../mock_data';
describe('License store mutations', () => { describe('License store mutations', () => {
let store; let store;
...@@ -14,9 +14,9 @@ describe('License store mutations', () => { ...@@ -14,9 +14,9 @@ describe('License store mutations', () => {
describe('SET_LICENSE_IN_MODAL', () => { describe('SET_LICENSE_IN_MODAL', () => {
it('opens modal and sets passed license', () => { it('opens modal and sets passed license', () => {
store.commit(`licenseManagement/${types.SET_LICENSE_IN_MODAL}`, approvedLicense); store.commit(`licenseManagement/${types.SET_LICENSE_IN_MODAL}`, allowedLicense);
expect(store.state.licenseManagement.currentLicenseInModal).toBe(approvedLicense); expect(store.state.licenseManagement.currentLicenseInModal).toBe(allowedLicense);
}); });
}); });
...@@ -34,7 +34,7 @@ describe('License store mutations', () => { ...@@ -34,7 +34,7 @@ describe('License store mutations', () => {
store.replaceState({ store.replaceState({
...store.state, ...store.state,
licenseManagement: { licenseManagement: {
currentLicenseInModal: approvedLicense, currentLicenseInModal: allowedLicense,
}, },
}); });
......
...@@ -14,7 +14,7 @@ import { licenseReport } from '../mock_data'; ...@@ -14,7 +14,7 @@ import { licenseReport } from '../mock_data';
describe('utils', () => { describe('utils', () => {
describe('normalizeLicense', () => { describe('normalizeLicense', () => {
it('should convert `approval_status` to `approvalStatus`', () => { it('should convert `approval_status` to `approvalStatus`', () => {
const src = { name: 'Foo', approval_status: 'approved', id: 3 }; const src = { name: 'Foo', approval_status: 'allowed', id: 3 };
const result = normalizeLicense(src); const result = normalizeLicense(src);
expect(result.approvalStatus).toBe(src.approval_status); expect(result.approvalStatus).toBe(src.approval_status);
...@@ -65,11 +65,11 @@ describe('utils', () => { ...@@ -65,11 +65,11 @@ describe('utils', () => {
}); });
describe('getIssueStatusFromLicenseStatus', () => { describe('getIssueStatusFromLicenseStatus', () => {
it('returns SUCCESS status for approved license status', () => { it('returns SUCCESS status for allowed license status', () => {
expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.ALLOWED)).toBe(STATUS_SUCCESS); expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.ALLOWED)).toBe(STATUS_SUCCESS);
}); });
it('returns FAILED status for blacklisted licenses', () => { it('returns FAILED status for denied licenses', () => {
expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.DENIED)).toBe(STATUS_FAILED); expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.DENIED)).toBe(STATUS_FAILED);
}); });
......
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