Commit c08b79f7 authored by Sam White's avatar Sam White Committed by Illya Klymov

Remove job dependency for license-check

parent ba24ccf6
...@@ -754,6 +754,10 @@ Developers of the project can view the policies configured in a project. ...@@ -754,6 +754,10 @@ Developers of the project can view the policies configured in a project.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/13067) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.3. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/13067) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.3.
Prerequisites:
- Maintainer or Owner [role](../../permissions.md#project-members-permissions).
`License-Check` is a [merge request approval](../../project/merge_requests/approvals/index.md) rule `License-Check` is a [merge request approval](../../project/merge_requests/approvals/index.md) rule
you can enable to allow an individual or group to approve a merge request that contains a `denied` you can enable to allow an individual or group to approve a merge request that contains a `denied`
license. license.
......
...@@ -21,27 +21,7 @@ export default { ...@@ -21,27 +21,7 @@ export default {
<template> <template>
<tr> <tr>
<!-- Suggested approval rule creation row --> <!-- Suggested approval rule creation row -->
<template v-if="rule.hasConfiguredJob"> <td class="js-name" colspan="4">
<td class="js-name" colspan="4">
<rule-name :name="rule.name" />
<div class="gl-text-gray-500">
<gl-sprintf :message="rule.enableDescription">
<template #link="{ content }">
<gl-link :href="rule.docsPath" target="_blank">{{ content }}</gl-link>
</template>
</gl-sprintf>
</div>
</td>
<td class="gl-px-2! gl-text-right">
<gl-button @click="$emit('enable')">
{{ __('Enable') }}
</gl-button>
</td>
</template>
<!-- Approval rule suggestion when lacking appropriate CI job for the rule -->
<td v-else class="js-name" colspan="5">
<rule-name :name="rule.name" /> <rule-name :name="rule.name" />
<div class="gl-text-gray-500"> <div class="gl-text-gray-500">
...@@ -52,5 +32,10 @@ export default { ...@@ -52,5 +32,10 @@ export default {
</gl-sprintf> </gl-sprintf>
</div> </div>
</td> </td>
<td class="gl-px-2! gl-text-right">
<gl-button @click="$emit('enable')">
{{ __('Enable') }}
</gl-button>
</td>
</tr> </tr>
</template> </template>
...@@ -4,7 +4,6 @@ import { mapState, mapActions } from 'vuex'; ...@@ -4,7 +4,6 @@ import { mapState, mapActions } from 'vuex';
import { import {
LICENSE_CHECK_NAME, LICENSE_CHECK_NAME,
VULNERABILITY_CHECK_NAME, VULNERABILITY_CHECK_NAME,
REPORT_TYPE_LICENSE_SCANNING,
COVERAGE_CHECK_NAME, COVERAGE_CHECK_NAME,
} from 'ee/approvals/constants'; } from 'ee/approvals/constants';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
...@@ -41,9 +40,6 @@ export default { ...@@ -41,9 +40,6 @@ export default {
{ {
name: VULNERABILITY_CHECK_NAME, name: VULNERABILITY_CHECK_NAME,
description: s__( description: s__(
'SecurityApprovals|Configurable if security scanners are enabled. %{linkStart}Learn more.%{linkEnd}',
),
enableDescription: s__(
'SecurityApprovals|Requires approval for vulnerabilities. %{linkStart}Learn more.%{linkEnd}', 'SecurityApprovals|Requires approval for vulnerabilities. %{linkStart}Learn more.%{linkEnd}',
), ),
docsPath: this.vulnerabilityCheckHelpPagePath, docsPath: this.vulnerabilityCheckHelpPagePath,
...@@ -51,9 +47,6 @@ export default { ...@@ -51,9 +47,6 @@ export default {
{ {
name: LICENSE_CHECK_NAME, name: LICENSE_CHECK_NAME,
description: s__( description: s__(
'SecurityApprovals|License Scanning must be enabled. %{linkStart}Learn more%{linkEnd}.',
),
enableDescription: s__(
'SecurityApprovals|Requires approval for Denied licenses. %{linkStart}More information%{linkEnd}', 'SecurityApprovals|Requires approval for Denied licenses. %{linkStart}More information%{linkEnd}',
), ),
docsPath: this.licenseCheckHelpPagePath, docsPath: this.licenseCheckHelpPagePath,
...@@ -61,9 +54,6 @@ export default { ...@@ -61,9 +54,6 @@ export default {
{ {
name: COVERAGE_CHECK_NAME, name: COVERAGE_CHECK_NAME,
description: s__( description: s__(
'SecurityApprovals|Test coverage must be enabled. %{linkStart}Learn more%{linkEnd}.',
),
enableDescription: s__(
'SecurityApprovals|Requires approval for decreases in test coverage. %{linkStart}Learn more.%{linkEnd}', 'SecurityApprovals|Requires approval for decreases in test coverage. %{linkStart}Learn more.%{linkEnd}',
), ),
docsPath: this.coverageCheckHelpPagePath, docsPath: this.coverageCheckHelpPagePath,
...@@ -73,10 +63,9 @@ export default { ...@@ -73,10 +63,9 @@ export default {
unconfiguredRules() { unconfiguredRules() {
return this.securityRules.reduce((filtered, securityRule) => { return this.securityRules.reduce((filtered, securityRule) => {
const hasApprovalRuleDefined = this.hasApprovalRuleDefined(securityRule); const hasApprovalRuleDefined = this.hasApprovalRuleDefined(securityRule);
const hasConfiguredJob = this.hasConfiguredJob(securityRule);
if (!hasApprovalRuleDefined || !hasConfiguredJob) { if (!hasApprovalRuleDefined) {
filtered.push({ ...securityRule, hasConfiguredJob }); filtered.push({ ...securityRule });
} }
return filtered; return filtered;
}, []); }, []);
...@@ -93,15 +82,6 @@ export default { ...@@ -93,15 +82,6 @@ export default {
return matchRule.name === rule.name; return matchRule.name === rule.name;
}); });
}, },
hasConfiguredJob(matchRule) {
const { features = [] } = this.configuration;
return (
matchRule.name !== LICENSE_CHECK_NAME ||
features.some((feature) => {
return feature.type === REPORT_TYPE_LICENSE_SCANNING && feature.configured;
})
);
},
}, },
}; };
</script> </script>
......
...@@ -20,22 +20,19 @@ describe('UnconfiguredSecurityRule component', () => { ...@@ -20,22 +20,19 @@ describe('UnconfiguredSecurityRule component', () => {
const vulnCheckRule = { const vulnCheckRule = {
name: VULNERABILITY_CHECK_NAME, name: VULNERABILITY_CHECK_NAME,
description: 'vuln-check description without enable button', description: 'vuln-check description with enable button',
enableDescription: 'vuln-check description with enable button',
docsPath: 'docs/vuln-check', docsPath: 'docs/vuln-check',
}; };
const licenseCheckRule = { const licenseCheckRule = {
name: LICENSE_CHECK_NAME, name: LICENSE_CHECK_NAME,
description: 'license-check description without enable button', description: 'license-check description with enable button',
enableDescription: 'license-check description with enable button',
docsPath: 'docs/license-check', docsPath: 'docs/license-check',
}; };
const coverageCheckRule = { const coverageCheckRule = {
name: COVERAGE_CHECK_NAME, name: COVERAGE_CHECK_NAME,
description: 'coverage-check description without enable button', description: 'coverage-check description with enable button',
enableDescription: 'coverage-check description with enable button',
docsPath: 'docs/coverage-check', docsPath: 'docs/coverage-check',
}; };
...@@ -56,13 +53,13 @@ describe('UnconfiguredSecurityRule component', () => { ...@@ -56,13 +53,13 @@ describe('UnconfiguredSecurityRule component', () => {
describe.each` describe.each`
rule | ruleName | descriptionText rule | ruleName | descriptionText
${licenseCheckRule} | ${licenseCheckRule.name} | ${licenseCheckRule.enableDescription} ${licenseCheckRule} | ${licenseCheckRule.name} | ${licenseCheckRule.description}
${vulnCheckRule} | ${vulnCheckRule.name} | ${vulnCheckRule.enableDescription} ${vulnCheckRule} | ${vulnCheckRule.name} | ${vulnCheckRule.description}
${coverageCheckRule} | ${coverageCheckRule.name} | ${coverageCheckRule.enableDescription} ${coverageCheckRule} | ${coverageCheckRule.name} | ${coverageCheckRule.description}
`('with a configured job that is eligible for $ruleName', ({ rule, descriptionText }) => { `('with $ruleName', ({ rule, descriptionText }) => {
beforeEach(() => { beforeEach(() => {
createWrapper({ createWrapper({
rule: { ...rule, hasConfiguredJob: true }, rule: { ...rule },
}); });
description = findDescription(); description = findDescription();
}); });
...@@ -78,24 +75,4 @@ describe('UnconfiguredSecurityRule component', () => { ...@@ -78,24 +75,4 @@ describe('UnconfiguredSecurityRule component', () => {
expect(wrapper.emitted('enable')).toEqual([[]]); expect(wrapper.emitted('enable')).toEqual([[]]);
}); });
}); });
describe.each`
rule | ruleName | descriptionText
${licenseCheckRule} | ${licenseCheckRule.name} | ${licenseCheckRule.description}
${vulnCheckRule} | ${vulnCheckRule.name} | ${vulnCheckRule.description}
${coverageCheckRule} | ${coverageCheckRule.name} | ${coverageCheckRule.description}
`('with a unconfigured job that is eligible for $ruleName', ({ rule, descriptionText }) => {
beforeEach(() => {
createWrapper({
rule: { ...rule, hasConfiguredJob: false },
});
description = findDescription();
});
it('should render the row with the decription and no button', () => {
expect(description.exists()).toBe(true);
expect(description.text()).toBe(descriptionText);
expect(findButton().exists()).toBe(false);
});
});
}); });
...@@ -3,7 +3,6 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; ...@@ -3,7 +3,6 @@ import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import UnconfiguredSecurityRule from 'ee/approvals/components/security_configuration/unconfigured_security_rule.vue'; import UnconfiguredSecurityRule from 'ee/approvals/components/security_configuration/unconfigured_security_rule.vue';
import UnconfiguredSecurityRules from 'ee/approvals/components/security_configuration/unconfigured_security_rules.vue'; import UnconfiguredSecurityRules from 'ee/approvals/components/security_configuration/unconfigured_security_rules.vue';
import { VULNERABILITY_CHECK_NAME, LICENSE_CHECK_NAME } from 'ee/approvals/constants';
import { createStoreOptions } from 'ee/approvals/stores'; import { createStoreOptions } from 'ee/approvals/stores';
import projectSettingsModule from 'ee/approvals/stores/modules/project_settings'; import projectSettingsModule from 'ee/approvals/stores/modules/project_settings';
...@@ -57,42 +56,6 @@ describe('UnconfiguredSecurityRules component', () => { ...@@ -57,42 +56,6 @@ describe('UnconfiguredSecurityRules component', () => {
it('should render a unconfigured-security-rule component for every security rule ', () => { it('should render a unconfigured-security-rule component for every security rule ', () => {
expect(wrapper.findAll(UnconfiguredSecurityRule).length).toBe(3); expect(wrapper.findAll(UnconfiguredSecurityRule).length).toBe(3);
}); });
describe('when license_scanning is set to true', () => {
beforeEach(() => {
store.state.securityConfiguration.configuration = {
features: [{ type: 'license_scanning', configured: true }],
};
});
it('returns true', () => {
expect(wrapper.vm.hasConfiguredJob({ name: LICENSE_CHECK_NAME })).toBe(true);
});
});
describe('when license_scanning is set to false', () => {
beforeEach(() => {
store.state.securityConfiguration.configuration = {
features: [{ type: 'license_scanning', configured: false }],
};
});
it('returns false', () => {
expect(wrapper.vm.hasConfiguredJob({ name: LICENSE_CHECK_NAME })).toBe(false);
});
});
describe('when all other scanners are set to false', () => {
beforeEach(() => {
store.state.securityConfiguration.configuration = {
features: [{ type: 'container_scanning', configured: false }],
};
});
it('returns true', () => {
expect(wrapper.vm.hasConfiguredJob({ name: VULNERABILITY_CHECK_NAME })).toBe(true);
});
});
}); });
describe.each` describe.each`
......
...@@ -29872,9 +29872,6 @@ msgstr "" ...@@ -29872,9 +29872,6 @@ msgstr ""
msgid "SecurityApprovals|A merge request approval is required when the license compliance report contains a denied license." msgid "SecurityApprovals|A merge request approval is required when the license compliance report contains a denied license."
msgstr "" msgstr ""
msgid "SecurityApprovals|Configurable if security scanners are enabled. %{linkStart}Learn more.%{linkEnd}"
msgstr ""
msgid "SecurityApprovals|Coverage-Check" msgid "SecurityApprovals|Coverage-Check"
msgstr "" msgstr ""
...@@ -29887,9 +29884,6 @@ msgstr "" ...@@ -29887,9 +29884,6 @@ msgstr ""
msgid "SecurityApprovals|Learn more about Vulnerability-Check" msgid "SecurityApprovals|Learn more about Vulnerability-Check"
msgstr "" msgstr ""
msgid "SecurityApprovals|License Scanning must be enabled. %{linkStart}Learn more%{linkEnd}."
msgstr ""
msgid "SecurityApprovals|License-Check" msgid "SecurityApprovals|License-Check"
msgstr "" msgstr ""
...@@ -29902,9 +29896,6 @@ msgstr "" ...@@ -29902,9 +29896,6 @@ msgstr ""
msgid "SecurityApprovals|Requires approval for vulnerabilities. %{linkStart}Learn more.%{linkEnd}" msgid "SecurityApprovals|Requires approval for vulnerabilities. %{linkStart}Learn more.%{linkEnd}"
msgstr "" msgstr ""
msgid "SecurityApprovals|Test coverage must be enabled. %{linkStart}Learn more%{linkEnd}."
msgstr ""
msgid "SecurityApprovals|Vulnerability-Check" msgid "SecurityApprovals|Vulnerability-Check"
msgstr "" msgstr ""
......
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