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 {
[LICENSE_APPROVAL_STATUS.ALLOWED]: s__('LicenseCompliance|Allowed'),
[LICENSE_APPROVAL_STATUS.DENIED]: s__('LicenseCompliance|Denied'),
computed: {
approveIconClass() {
allowedIconClass() {
return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED
? visibleClass
: invisibleClass;
},
blacklistIconClass() {
deniedIconClass() {
return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED
? visibleClass
: invisibleClass;
......@@ -98,11 +98,11 @@ export default {
right
>
<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] }}
</gl-dropdown-item>
<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] }}
</gl-dropdown-item>
</gl-dropdown>
......
......@@ -7,8 +7,8 @@ import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constan
* even though we adopted 'allowed' & 'denied' in the UI
*/
export const LICENSE_APPROVAL_STATUS = {
ALLOWED: 'approved',
DENIED: 'blacklisted',
ALLOWED: gon?.features?.lcRemoveLegacyApprovalStatus ? 'allowed' : 'approved',
DENIED: gon?.features?.lcRemoveLegacyApprovalStatus ? 'denied' : 'blacklisted',
};
/*
......
......@@ -79,7 +79,7 @@ export default {
'licenseReport',
'isLoading',
'licenseSummaryText',
'reportContainsBlacklistedLicense',
'reportContainsDeniedLicense',
'licenseReportGroups',
]),
hasLicenseReportIssues() {
......@@ -177,7 +177,7 @@ export default {
<div class="pr-3">
{{ licenseSummaryText }}
<gl-link
v-if="reportContainsBlacklistedLicense && licenseComplianceDocsPath"
v-if="reportContainsDeniedLicense && licenseComplianceDocsPath"
:href="licenseComplianceDocsPath"
data-testid="security-approval-help-link"
target="_blank"
......
......@@ -62,7 +62,7 @@ export const licenseSummaryText = (state, getters) => {
export const summaryTextWithLicenseCheck = (_, getters) => {
if (!getters.baseReportHasLicenses) {
return getters.reportContainsBlacklistedLicense
return getters.reportContainsDeniedLicense
? n__(
'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',
......@@ -75,7 +75,7 @@ export const summaryTextWithLicenseCheck = (_, getters) => {
);
}
return getters.reportContainsBlacklistedLicense
return getters.reportContainsDeniedLicense
? n__(
'LicenseCompliance|License Compliance detected %d new license and policy violation; approval required',
'LicenseCompliance|License Compliance detected %d new licenses and policy violations; approval required',
......@@ -90,7 +90,7 @@ export const summaryTextWithLicenseCheck = (_, getters) => {
export const summaryTextWithoutLicenseCheck = (_, getters) => {
if (!getters.baseReportHasLicenses) {
return getters.reportContainsBlacklistedLicense
return getters.reportContainsDeniedLicense
? n__(
'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',
......@@ -103,7 +103,7 @@ export const summaryTextWithoutLicenseCheck = (_, getters) => {
);
}
return getters.reportContainsBlacklistedLicense
return getters.reportContainsDeniedLicense
? n__(
'LicenseCompliance|License Compliance detected %d new license and policy violation',
'LicenseCompliance|License Compliance detected %d new licenses and policy violations',
......@@ -116,7 +116,7 @@ export const summaryTextWithoutLicenseCheck = (_, getters) => {
);
};
export const reportContainsBlacklistedLicense = (_, getters) =>
export const reportContainsDeniedLicense = (_, getters) =>
(getters.licenseReport || []).some(
(license) => license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED,
);
......@@ -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_user, current_user, 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
before_action :authorize_read_pipeline!, only: [:container_scanning_reports, :dependency_scanning_reports,
......
......@@ -4,6 +4,10 @@ module Projects
class LicensesController < Projects::ApplicationController
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_admin_software_license_policy!, only: [:create, :update]
......
......@@ -11,6 +11,7 @@ RSpec.describe Projects::LicensesController do
let(:get_licenses) { get :index, params: params, format: :json }
before do
stub_feature_flags(lc_remove_legacy_approval_status: false)
sign_in(user)
end
......
......@@ -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 LicenseManagement from 'ee/vue_shared/license_compliance/license_management.vue';
import {
approvedLicense,
blacklistedLicense,
} from 'ee_jest/vue_shared/license_compliance/mock_data';
import { allowedLicense, deniedLicense } from 'ee_jest/vue_shared/license_compliance/mock_data';
import setWindowLocation from 'helpers/set_window_location_helper';
import { stubTransition } from 'helpers/stub_transition';
import { TEST_HOST } from 'helpers/test_constants';
......@@ -25,7 +22,7 @@ Vue.use(Vuex);
let wrapper;
const readLicensePoliciesEndpoint = `${TEST_HOST}/license_management`;
const managedLicenses = [approvedLicense, blacklistedLicense];
const managedLicenses = [allowedLicense, deniedLicense];
const licenses = [{}, {}];
const emptyStateSvgPath = '/';
const documentationPath = '/';
......
......@@ -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 { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { approvedLicense } from '../mock_data';
import { allowedLicense } from '../mock_data';
const visibleClass = 'visible';
const invisibleClass = 'invisible';
......@@ -19,7 +19,7 @@ describe('AdminLicenseManagementRow', () => {
let store;
let actions;
const createComponent = (props = { license: approvedLicense }) => {
const createComponent = (props = { license: allowedLicense }) => {
vm = mountComponentWithStore(Component, { props, store });
};
......@@ -53,9 +53,9 @@ describe('AdminLicenseManagementRow', () => {
vm.$destroy();
});
describe('approved license', () => {
describe('allowed license', () => {
beforeEach(async () => {
vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED };
vm.license = { ...allowedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED };
await nextTick();
});
......@@ -64,12 +64,12 @@ describe('AdminLicenseManagementRow', () => {
expect(vm.dropdownText).toBe('Allowed');
});
it('isApproved returns `true`', () => {
expect(vm.approveIconClass).toBe(visibleClass);
it('isAllowed returns `true`', () => {
expect(vm.allowedIconClass).toBe(visibleClass);
});
it('isBlacklisted returns `false`', () => {
expect(vm.blacklistIconClass).toBe(invisibleClass);
it('isDenied returns `false`', () => {
expect(vm.deniedIconClass).toBe(invisibleClass);
});
});
......@@ -88,9 +88,9 @@ describe('AdminLicenseManagementRow', () => {
});
});
describe('blacklisted license', () => {
describe('denied license', () => {
beforeEach(async () => {
vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED };
vm.license = { ...allowedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED };
await nextTick();
});
......@@ -99,12 +99,12 @@ describe('AdminLicenseManagementRow', () => {
expect(vm.dropdownText).toBe('Denied');
});
it('isApproved returns `false`', () => {
expect(vm.approveIconClass).toBe(invisibleClass);
it('isAllowed returns `false`', () => {
expect(vm.allowedIconClass).toBe(invisibleClass);
});
it('isBlacklisted returns `true`', () => {
expect(vm.blacklistIconClass).toBe(visibleClass);
it('isDenied returns `true`', () => {
expect(vm.deniedIconClass).toBe(visibleClass);
});
});
......@@ -160,7 +160,7 @@ describe('AdminLicenseManagementRow', () => {
it('renders 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', () => {
......@@ -199,7 +199,7 @@ describe('AdminLicenseManagementRow', () => {
});
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(findDropdownToggle().disabled).toBe(true);
expect(findRemoveButton().disabled).toBe(true);
......
......@@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import Vuex from 'vuex';
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);
......@@ -23,7 +23,7 @@ describe('DeleteConfirmationModal', () => {
licenseManagement: {
namespaced: true,
state: {
currentLicenseInModal: approvedLicense,
currentLicenseInModal: allowedLicense,
...initialState,
},
actions,
......@@ -72,7 +72,7 @@ describe('DeleteConfirmationModal', () => {
it('should have the confirmation text', () => {
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', () => {
const nameEscaped = '&lt;a href="#"&gt;BAD&lt;/a&gt;';
const currentLicenseInModal = {
...approvedLicense,
...allowedLicense,
name,
};
......
import { shallowMount } from '@vue/test-utils';
import LicenseManagementRow from 'ee/vue_shared/license_compliance/components/license_management_row.vue';
import {
approvedLicense,
blacklistedLicense,
} from 'ee_jest/vue_shared/license_compliance/mock_data';
import { allowedLicense, deniedLicense } from 'ee_jest/vue_shared/license_compliance/mock_data';
let wrapper;
......@@ -15,7 +12,7 @@ describe('LicenseManagementRow', () => {
describe('allowed license', () => {
beforeEach(() => {
const props = { license: approvedLicense };
const props = { license: allowedLicense };
wrapper = shallowMount(LicenseManagementRow, {
propsData: {
......@@ -35,7 +32,7 @@ describe('LicenseManagementRow', () => {
describe('denied license', () => {
beforeEach(() => {
const props = { license: blacklistedLicense };
const props = { license: deniedLicense };
wrapper = shallowMount(LicenseManagementRow, {
propsData: {
......
......@@ -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 LicenseManagementRow from 'ee/vue_shared/license_compliance/components/license_management_row.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);
let wrapper;
const managedLicenses = [approvedLicense, blacklistedLicense];
const managedLicenses = [allowedLicense, deniedLicense];
const PaginatedList = {
props: ['list'],
......
import { range } from 'lodash';
import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_compliance/constants';
export const approvedLicense = {
export const allowedLicense = {
id: 5,
name: 'MIT',
approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
};
export const blacklistedLicense = {
export const deniedLicense = {
id: 6,
name: 'New BSD',
approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
......
......@@ -9,8 +9,8 @@ import ReportItem from '~/reports/components/report_item.vue';
import ReportSection from '~/reports/components/report_section.vue';
import { LOADING, ERROR, SUCCESS } from '~/reports/constants';
import {
approvedLicense,
blacklistedLicense,
allowedLicense,
deniedLicense,
licenseReport as licenseReportMock,
generateReportGroup,
} from './mock_data';
......@@ -23,7 +23,7 @@ describe('License Report MR Widget', () => {
let wrapper;
const defaultState = {
managedLicenses: [approvedLicense, blacklistedLicense],
managedLicenses: [allowedLicense, deniedLicense],
currentLicenseInModal: licenseReportMock[0],
isLoadingManagedLicenses: true,
};
......@@ -38,7 +38,7 @@ describe('License Report MR Widget', () => {
licenseSummaryText() {
return 'FOO';
},
reportContainsBlacklistedLicense() {
reportContainsDeniedLicense() {
return false;
},
licenseReportGroups() {
......@@ -414,16 +414,16 @@ describe('License Report MR Widget', () => {
const findLicenseComplianceHelpLink = () =>
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();
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 = {
...defaultGetters,
reportContainsBlacklistedLicense() {
reportContainsDeniedLicense() {
return true;
},
};
......
......@@ -7,7 +7,7 @@ import createState from 'ee/vue_shared/license_compliance/store/state';
import testAction from 'helpers/vuex_action_helper';
import { TEST_HOST } from 'spec/test_constants';
import axios from '~/lib/utils/axios_utils';
import { approvedLicense, blacklistedLicense } from '../mock_data';
import { allowedLicense, deniedLicense } from '../mock_data';
describe('License store actions', () => {
const apiUrlManageLicenses = `${TEST_HOST}/licenses/management`;
......@@ -29,9 +29,9 @@ describe('License store actions', () => {
...createState(),
apiUrlManageLicenses,
approvalsApiPath,
currentLicenseInModal: approvedLicense,
currentLicenseInModal: allowedLicense,
};
licenseId = approvedLicense.id;
licenseId = allowedLicense.id;
mockDispatch = jest.fn(() => Promise.resolve());
mockCommit = jest.fn();
store = {
......@@ -79,9 +79,9 @@ describe('License store actions', () => {
it('commits SET_LICENSE_IN_MODAL with license', (done) => {
testAction(
actions.setLicenseInModal,
approvedLicense,
allowedLicense,
state,
[{ type: mutationTypes.SET_LICENSE_IN_MODAL, payload: approvedLicense }],
[{ type: mutationTypes.SET_LICENSE_IN_MODAL, payload: allowedLicense }],
[],
)
.then(done)
......@@ -283,10 +283,10 @@ describe('License store actions', () => {
});
return actions
.setLicenseApproval(store, { license: approvedLicense, newStatus })
.setLicenseApproval(store, { license: allowedLicense, newStatus })
.then(() => {
expectDispatched('addPendingLicense', approvedLicense.id);
expectDispatched('receiveSetLicenseApproval', approvedLicense.id);
expectDispatched('addPendingLicense', allowedLicense.id);
expectDispatched('receiveSetLicenseApproval', allowedLicense.id);
});
});
......@@ -297,11 +297,11 @@ describe('License store actions', () => {
});
return actions
.setLicenseApproval(store, { license: approvedLicense, newStatus })
.setLicenseApproval(store, { license: allowedLicense, newStatus })
.then(() => {
expectDispatched('addPendingLicense', approvedLicense.id);
expectDispatched('addPendingLicense', allowedLicense.id);
expectDispatched('receiveSetLicenseApprovalError');
expectDispatched('removePendingLicense', approvedLicense.id);
expectDispatched('removePendingLicense', allowedLicense.id);
});
});
});
......@@ -310,7 +310,7 @@ describe('License store actions', () => {
describe('allowLicense', () => {
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' };
testAction(
......@@ -324,8 +324,8 @@ describe('License store actions', () => {
.catch(done.fail);
});
it('dispatches setLicenseApproval for blacklisted licenses', (done) => {
const license = blacklistedLicense;
it('dispatches setLicenseApproval for denied licenses', (done) => {
const license = deniedLicense;
testAction(
actions.allowLicense,
......@@ -338,15 +338,15 @@ describe('License store actions', () => {
.catch(done.fail);
});
it('does not dispatch setLicenseApproval for approved licenses', (done) => {
testAction(actions.allowLicense, approvedLicense, state, [], []).then(done).catch(done.fail);
it('does not dispatch setLicenseApproval for allowed licenses', (done) => {
testAction(actions.allowLicense, allowedLicense, state, [], []).then(done).catch(done.fail);
});
});
describe('denyLicense', () => {
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' };
testAction(
......@@ -360,8 +360,8 @@ describe('License store actions', () => {
.catch(done.fail);
});
it('dispatches setLicenseApproval for approved licenses', (done) => {
const license = approvedLicense;
it('dispatches setLicenseApproval for allowed licenses', (done) => {
const license = allowedLicense;
testAction(
actions.denyLicense,
......@@ -374,10 +374,8 @@ describe('License store actions', () => {
.catch(done.fail);
});
it('does not dispatch setLicenseApproval for blacklisted licenses', (done) => {
testAction(actions.denyLicense, blacklistedLicense, state, [], [])
.then(done)
.catch(done.fail);
it('does not dispatch setLicenseApproval for denied licenses', (done) => {
testAction(actions.denyLicense, deniedLicense, state, [], []).then(done).catch(done.fail);
});
});
......@@ -397,7 +395,7 @@ describe('License store actions', () => {
describe('receiveManagedLicensesSuccess', () => {
it('commits RECEIVE_MANAGED_LICENSES_SUCCESS', (done) => {
const payload = [approvedLicense];
const payload = [allowedLicense];
testAction(
actions.receiveManagedLicensesSuccess,
payload,
......@@ -658,7 +656,7 @@ describe('License store actions', () => {
rawLicenseReport = [
{
name: 'MIT',
classification: { id: 2, approval_status: 'blacklisted', name: 'MIT' },
classification: { id: 2, approval_status: LICENSE_APPROVAL_STATUS.DENIED, name: 'MIT' },
dependencies: [{ name: 'vue' }],
count: 1,
url: 'http://opensource.org/licenses/mit-license',
......@@ -675,7 +673,7 @@ describe('License store actions', () => {
{
...rawLicenseReport[0],
id: 2,
approvalStatus: 'blacklisted',
approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
packages: [{ name: 'vue' }],
status: 'failed',
},
......@@ -720,7 +718,11 @@ describe('License store actions', () => {
new_licenses: [
{
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' }],
count: 1,
url: 'http://www.apache.org/licenses/LICENSE-2.0.txt',
......@@ -736,7 +738,11 @@ describe('License store actions', () => {
existing_licenses: [
{
name: 'MIT',
classification: { id: 2, approval_status: 'blacklisted', name: 'MIT' },
classification: {
id: 2,
approval_status: LICENSE_APPROVAL_STATUS.DENIED,
name: 'MIT',
},
dependencies: [{ name: 'vue' }],
count: 1,
url: 'http://opensource.org/licenses/mit-license',
......@@ -754,7 +760,7 @@ describe('License store actions', () => {
{
...rawLicenseReport.existing_licenses[0],
id: 2,
approvalStatus: 'blacklisted',
approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
packages: [{ name: 'vue' }],
status: 'failed',
},
......@@ -763,7 +769,7 @@ describe('License store actions', () => {
{
...rawLicenseReport.new_licenses[0],
id: 1,
approvalStatus: 'approved',
approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
packages: [{ name: 'echarts' }],
status: 'success',
},
......
import * as getters from 'ee/vue_shared/license_compliance/store/getters';
import createState from 'ee/vue_shared/license_compliance/store/state';
import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_compliance/constants';
import { licenseReport as licenseReportMock } from '../mock_data';
......@@ -220,11 +221,11 @@ describe('getters', () => {
};
});
describe('when blacklisted licenses exist on the HEAD', () => {
describe('when denied licenses exist on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 new license and policy violation; approval required"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: true,
licenseReportLength: 1,
};
......@@ -238,7 +239,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return License Compliance detected 2 new licenses and policy violations; approval required', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: true,
licenseReportLength: 2,
};
......@@ -250,11 +251,11 @@ describe('getters', () => {
});
});
describe('when blacklisted licenses are not detected on the HEAD', () => {
describe('when denied licenses are not detected on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 new license"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: true,
licenseReportLength: 1,
};
......@@ -268,7 +269,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return "License Compliance detected 2 new licenses"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: true,
licenseReportLength: 2,
};
......@@ -288,11 +289,11 @@ describe('getters', () => {
};
});
describe('when blacklisted licenses exist on the HEAD', () => {
describe('when denied licenses exist on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 license and policy violation for the source branch only; approval required"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: false,
licenseReportLength: 1,
};
......@@ -306,7 +307,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return "License Compliance detected 2 licenses and policy violations for the source branch only; approval required"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: false,
licenseReportLength: 2,
};
......@@ -318,11 +319,11 @@ describe('getters', () => {
});
});
describe('when blacklisted licenses are not detected on the HEAD', () => {
describe('when denied licenses are not detected on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 license for the source branch only"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: false,
licenseReportLength: 1,
};
......@@ -336,7 +337,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return "License Compliance detected 2 licenses for the source branch only"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: false,
licenseReportLength: 2,
};
......@@ -358,11 +359,11 @@ describe('getters', () => {
};
});
describe('when blacklisted licenses exist on the HEAD', () => {
describe('when denied licenses exist on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 new license and policy violation"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: true,
licenseReportLength: 1,
};
......@@ -376,7 +377,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return "License Compliance detected 2 new licenses and policy violations"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: true,
licenseReportLength: 2,
};
......@@ -388,11 +389,11 @@ describe('getters', () => {
});
});
describe('when blacklisted licenses are not detected on the HEAD', () => {
describe('when denied licenses are not detected on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 new license"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: true,
licenseReportLength: 1,
};
......@@ -406,7 +407,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return "License Compliance detected 2 new licenses"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: true,
licenseReportLength: 2,
};
......@@ -426,11 +427,11 @@ describe('getters', () => {
};
});
describe('when blacklisted licenses exist on the HEAD', () => {
describe('when denied licenses exist on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 license and policy violation for the source branch only"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: false,
licenseReportLength: 1,
};
......@@ -444,7 +445,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return "License Compliance detected 2 licenses and policy violations for the source branch only"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: true,
reportContainsDeniedLicense: true,
baseReportHasLicenses: false,
licenseReportLength: 2,
};
......@@ -456,11 +457,11 @@ describe('getters', () => {
});
});
describe('when blacklisted licenses are not detected on the HEAD', () => {
describe('when denied licenses are not detected on the HEAD', () => {
describe('when a single license is detected', () => {
it('should return "License Compliance detected 1 license for the source branch only"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: false,
licenseReportLength: 1,
};
......@@ -474,7 +475,7 @@ describe('getters', () => {
describe('when multiple licenses are detected', () => {
it('should return "License Compliance detected 2 licenses for the source branch only"', () => {
const mockGetters = {
reportContainsBlacklistedLicense: false,
reportContainsDeniedLicense: false,
baseReportHasLicenses: false,
licenseReportLength: 2,
};
......@@ -488,24 +489,24 @@ describe('getters', () => {
});
});
describe('reportContainsBlacklistedLicense', () => {
it('should be false if the report does not contain blacklisted licenses', () => {
describe('reportContainsDeniedLicense', () => {
it('should be false if the report does not contain denied licenses', () => {
const mockGetters = {
licenseReport: [licenseReportMock[0], licenseReportMock[0]],
};
expect(getters.reportContainsBlacklistedLicense(state, mockGetters)).toBe(false);
expect(getters.reportContainsDeniedLicense(state, mockGetters)).toBe(false);
});
it('should be true if the report contains blacklisted licenses', () => {
it('should be true if the report contains denied licenses', () => {
const mockGetters = {
licenseReport: [
licenseReportMock[0],
{ ...licenseReportMock[0], approvalStatus: 'blacklisted' },
{ ...licenseReportMock[0], approvalStatus: LICENSE_APPROVAL_STATUS.DENIED },
],
};
expect(getters.reportContainsBlacklistedLicense(state, mockGetters)).toBe(true);
expect(getters.reportContainsDeniedLicense(state, mockGetters)).toBe(true);
});
});
});
......@@ -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 { TEST_HOST } from 'spec/test_constants';
import { approvedLicense } from '../mock_data';
import { allowedLicense } from '../mock_data';
describe('License store mutations', () => {
let store;
......@@ -14,9 +14,9 @@ describe('License store mutations', () => {
describe('SET_LICENSE_IN_MODAL', () => {
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', () => {
store.replaceState({
...store.state,
licenseManagement: {
currentLicenseInModal: approvedLicense,
currentLicenseInModal: allowedLicense,
},
});
......
......@@ -14,7 +14,7 @@ import { licenseReport } from '../mock_data';
describe('utils', () => {
describe('normalizeLicense', () => {
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);
expect(result.approvalStatus).toBe(src.approval_status);
......@@ -65,11 +65,11 @@ describe('utils', () => {
});
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);
});
it('returns FAILED status for blacklisted licenses', () => {
it('returns FAILED status for denied licenses', () => {
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