Commit 5ec89907 authored by Mark Florian's avatar Mark Florian

Merge branch 'leipert-permissions-cleanup' into 'master'

Security Reports: Permissions cleanup

See merge request gitlab-org/gitlab!15088
parents 98ce07de 7be1a94e
...@@ -323,9 +323,6 @@ export default { ...@@ -323,9 +323,6 @@ export default {
:create-vulnerability-feedback-dismissal-path="mr.createVulnerabilityFeedbackDismissalPath" :create-vulnerability-feedback-dismissal-path="mr.createVulnerabilityFeedbackDismissalPath"
:pipeline-path="mr.pipeline.path" :pipeline-path="mr.pipeline.path"
:pipeline-id="mr.securityReportsPipelineId" :pipeline-id="mr.securityReportsPipelineId"
:can-create-issue="mr.canCreateIssue"
:can-create-merge-request="mr.canCreateMergeRequest"
:can-dismiss-vulnerability="mr.canDismissVulnerability"
:diverged-commits-count="mr.divergedCommitsCount" :diverged-commits-count="mr.divergedCommitsCount"
:mr-state="mr.state" :mr-state="mr.state"
:target-branch-tree-path="mr.targetBranchTreePath" :target-branch-tree-path="mr.targetBranchTreePath"
......
...@@ -24,10 +24,6 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -24,10 +24,6 @@ export default class MergeRequestStore extends CEMergeRequestStore {
data.create_vulnerability_feedback_merge_request_path; data.create_vulnerability_feedback_merge_request_path;
this.createVulnerabilityFeedbackDismissalPath = this.createVulnerabilityFeedbackDismissalPath =
data.create_vulnerability_feedback_dismissal_path; data.create_vulnerability_feedback_dismissal_path;
this.canCreateIssue = Boolean(this.createVulnerabilityFeedbackIssuePath);
this.canCreateMergeRequest = Boolean(this.createVulnerabilityFeedbackMergeRequestPath);
this.canDismissVulnerability = Boolean(this.createVulnerabilityFeedbackDismissalPath);
this.canCreateFeedback = data.can_create_feedback || false;
this.visualReviewAppAvailable = Boolean(data.visual_review_app_available); this.visualReviewAppAvailable = Boolean(data.visual_review_app_available);
this.appUrl = gon && gon.gitlab_url; this.appUrl = gon && gon.gitlab_url;
......
...@@ -104,18 +104,6 @@ export default { ...@@ -104,18 +104,6 @@ export default {
required: false, required: false,
default: undefined, default: undefined,
}, },
canDismissVulnerability: {
type: Boolean,
required: true,
},
canCreateMergeRequest: {
type: Boolean,
required: true,
},
canCreateIssue: {
type: Boolean,
required: true,
},
divergedCommitsCount: { divergedCommitsCount: {
type: Number, type: Number,
required: false, required: false,
...@@ -146,8 +134,6 @@ export default { ...@@ -146,8 +134,6 @@ export default {
'dependencyScanning', 'dependencyScanning',
'summaryCounts', 'summaryCounts',
'modal', 'modal',
'canCreateIssuePermission',
'canCreateFeedbackPermission',
]), ]),
...mapGetters([ ...mapGetters([
'groupedSummaryText', 'groupedSummaryText',
...@@ -159,6 +145,9 @@ export default { ...@@ -159,6 +145,9 @@ export default {
'dastStatusIcon', 'dastStatusIcon',
'dependencyScanningStatusIcon', 'dependencyScanningStatusIcon',
'isBaseSecurityReportOutOfDate', 'isBaseSecurityReportOutOfDate',
'canCreateIssue',
'canCreateMergeRequest',
'canDismissVulnerability',
]), ]),
...mapGetters('sast', ['groupedSastText', 'sastStatusIcon']), ...mapGetters('sast', ['groupedSastText', 'sastStatusIcon']),
securityTab() { securityTab() {
...@@ -198,9 +187,6 @@ export default { ...@@ -198,9 +187,6 @@ export default {
this.setCreateVulnerabilityFeedbackDismissalPath(this.createVulnerabilityFeedbackDismissalPath); this.setCreateVulnerabilityFeedbackDismissalPath(this.createVulnerabilityFeedbackDismissalPath);
this.setPipelineId(this.pipelineId); this.setPipelineId(this.pipelineId);
this.setCanCreateIssuePermission(this.canCreateIssue);
this.setCanCreateFeedbackPermission(this.canCreateFeedback);
const sastDiffEndpoint = gl?.mrWidgetData?.sast_comparison_path; const sastDiffEndpoint = gl?.mrWidgetData?.sast_comparison_path;
if (sastDiffEndpoint && this.hasSastReports) { if (sastDiffEndpoint && this.hasSastReports) {
...@@ -241,8 +227,6 @@ export default { ...@@ -241,8 +227,6 @@ export default {
'setCreateVulnerabilityFeedbackMergeRequestPath', 'setCreateVulnerabilityFeedbackMergeRequestPath',
'setCreateVulnerabilityFeedbackDismissalPath', 'setCreateVulnerabilityFeedbackDismissalPath',
'setPipelineId', 'setPipelineId',
'setCanCreateIssuePermission',
'setCanCreateFeedbackPermission',
'dismissVulnerability', 'dismissVulnerability',
'revertDismissVulnerability', 'revertDismissVulnerability',
'createNewIssue', 'createNewIssue',
......
...@@ -41,12 +41,6 @@ export const setCreateVulnerabilityFeedbackDismissalPath = ({ commit }, path) => ...@@ -41,12 +41,6 @@ export const setCreateVulnerabilityFeedbackDismissalPath = ({ commit }, path) =>
export const setPipelineId = ({ commit }, id) => commit(types.SET_PIPELINE_ID, id); export const setPipelineId = ({ commit }, id) => commit(types.SET_PIPELINE_ID, id);
export const setCanCreateIssuePermission = ({ commit }, permission) =>
commit(types.SET_CAN_CREATE_ISSUE_PERMISSION, permission);
export const setCanCreateFeedbackPermission = ({ commit }, permission) =>
commit(types.SET_CAN_CREATE_FEEDBACK_PERMISSION, permission);
/** /**
* CONTAINER SCANNING * CONTAINER SCANNING
*/ */
......
...@@ -140,5 +140,13 @@ export const isBaseSecurityReportOutOfDate = state => ...@@ -140,5 +140,13 @@ export const isBaseSecurityReportOutOfDate = state =>
state.containerScanning.baseReportOutofDate || state.containerScanning.baseReportOutofDate ||
state.dependencyScanning.baseReportOutofDate; state.dependencyScanning.baseReportOutofDate;
export const canCreateIssue = state => Boolean(state.createVulnerabilityFeedbackIssuePath);
export const canCreateMergeRequest = state =>
Boolean(state.createVulnerabilityFeedbackMergeRequestPath);
export const canDismissVulnerability = state =>
Boolean(state.createVulnerabilityFeedbackDismissalPath);
// prevent babel-plugin-rewire from generating an invalid default during karma tests // prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {}; export default () => {};
...@@ -10,8 +10,6 @@ export const SET_CREATE_VULNERABILITY_FEEDBACK_MERGE_REQUEST_PATH = ...@@ -10,8 +10,6 @@ export const SET_CREATE_VULNERABILITY_FEEDBACK_MERGE_REQUEST_PATH =
export const SET_CREATE_VULNERABILITY_FEEDBACK_DISMISSAL_PATH = export const SET_CREATE_VULNERABILITY_FEEDBACK_DISMISSAL_PATH =
'SET_CREATE_VULNERABILITY_FEEDBACK_DISMISSAL_PATH'; 'SET_CREATE_VULNERABILITY_FEEDBACK_DISMISSAL_PATH';
export const SET_PIPELINE_ID = 'SET_PIPELINE_ID'; export const SET_PIPELINE_ID = 'SET_PIPELINE_ID';
export const SET_CAN_CREATE_ISSUE_PERMISSION = 'SET_CAN_CREATE_ISSUE_PERMISSION';
export const SET_CAN_CREATE_FEEDBACK_PERMISSION = 'SET_CAN_CREATE_FEEDBACK_PERMISSION';
// CONTAINER SCANNING // CONTAINER SCANNING
export const SET_CONTAINER_SCANNING_DIFF_ENDPOINT = 'SET_CONTAINER_SCANNING_DIFF_ENDPOINT'; export const SET_CONTAINER_SCANNING_DIFF_ENDPOINT = 'SET_CONTAINER_SCANNING_DIFF_ENDPOINT';
......
...@@ -40,14 +40,6 @@ export default { ...@@ -40,14 +40,6 @@ export default {
state.pipelineId = id; state.pipelineId = id;
}, },
[types.SET_CAN_CREATE_ISSUE_PERMISSION](state, permission) {
state.canCreateIssuePermission = permission;
},
[types.SET_CAN_CREATE_FEEDBACK_PERMISSION](state, permission) {
state.canCreateFeedbackPermission = permission;
},
// CONTAINER SCANNING // CONTAINER SCANNING
[types.SET_CONTAINER_SCANNING_DIFF_ENDPOINT](state, path) { [types.SET_CONTAINER_SCANNING_DIFF_ENDPOINT](state, path) {
Vue.set(state.containerScanning.paths, 'diffEndpoint', path); Vue.set(state.containerScanning.paths, 'diffEndpoint', path);
......
...@@ -11,8 +11,6 @@ export default () => ({ ...@@ -11,8 +11,6 @@ export default () => ({
createVulnerabilityFeedbackMergeRequestPath: null, createVulnerabilityFeedbackMergeRequestPath: null,
createVulnerabilityFeedbackDismissalPath: null, createVulnerabilityFeedbackDismissalPath: null,
pipelineId: null, pipelineId: null,
canCreateIssuePermission: false,
canCreateFeedbackPermission: false,
containerScanning: { containerScanning: {
paths: { paths: {
......
...@@ -38,9 +38,6 @@ describe('Grouped security reports app', () => { ...@@ -38,9 +38,6 @@ describe('Grouped security reports app', () => {
vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json', vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json',
vulnerabilityFeedbackHelpPath: 'path', vulnerabilityFeedbackHelpPath: 'path',
pipelineId: 123, pipelineId: 123,
canCreateIssue: true,
canCreateMergeRequest: true,
canDismissVulnerability: true,
}; };
const createWrapper = (propsData, provide = {}) => { const createWrapper = (propsData, provide = {}) => {
...@@ -235,9 +232,6 @@ describe('Grouped security reports app', () => { ...@@ -235,9 +232,6 @@ describe('Grouped security reports app', () => {
beforeEach(() => { beforeEach(() => {
createWrapper({ createWrapper({
headBlobPath: 'path', headBlobPath: 'path',
canCreateIssue: false,
canCreateMergeRequest: false,
canDismissVulnerability: false,
pipelinePath, pipelinePath,
}); });
}); });
......
...@@ -5,8 +5,6 @@ import { ...@@ -5,8 +5,6 @@ import {
setVulnerabilityFeedbackPath, setVulnerabilityFeedbackPath,
setVulnerabilityFeedbackHelpPath, setVulnerabilityFeedbackHelpPath,
setPipelineId, setPipelineId,
setCanCreateIssuePermission,
setCanCreateFeedbackPermission,
requestContainerScanningDiff, requestContainerScanningDiff,
requestDastDiff, requestDastDiff,
requestDependencyScanningDiff, requestDependencyScanningDiff,
...@@ -194,42 +192,6 @@ describe('security reports actions', () => { ...@@ -194,42 +192,6 @@ describe('security reports actions', () => {
}); });
}); });
describe('setCanCreateIssuePermission', () => {
it('should commit set can create issue permission', done => {
testAction(
setCanCreateIssuePermission,
true,
mockedState,
[
{
type: types.SET_CAN_CREATE_ISSUE_PERMISSION,
payload: true,
},
],
[],
done,
);
});
});
describe('setCanCreateFeedbackPermission', () => {
it('should commit set can create feedback permission', done => {
testAction(
setCanCreateFeedbackPermission,
true,
mockedState,
[
{
type: types.SET_CAN_CREATE_FEEDBACK_PERMISSION,
payload: true,
},
],
[],
done,
);
});
});
describe('requestContainerScanningDiff', () => { describe('requestContainerScanningDiff', () => {
it('should commit request mutation', done => { it('should commit request mutation', done => {
testAction( testAction(
......
...@@ -14,10 +14,14 @@ import { ...@@ -14,10 +14,14 @@ import {
anyReportHasError, anyReportHasError,
summaryCounts, summaryCounts,
isBaseSecurityReportOutOfDate, isBaseSecurityReportOutOfDate,
canCreateIssue,
canCreateMergeRequest,
canDismissVulnerability,
} from 'ee/vue_shared/security_reports/store/getters'; } from 'ee/vue_shared/security_reports/store/getters';
const BASE_PATH = 'fake/base/path.json'; const BASE_PATH = 'fake/base/path.json';
const HEAD_PATH = 'fake/head/path.json'; const HEAD_PATH = 'fake/head/path.json';
const MOCK_PATH = 'fake/path.json';
describe('Security reports getters', () => { describe('Security reports getters', () => {
function removeBreakLine(data) { function removeBreakLine(data) {
...@@ -542,4 +546,40 @@ describe('Security reports getters', () => { ...@@ -542,4 +546,40 @@ describe('Security reports getters', () => {
expect(isBaseSecurityReportOutOfDate(state)).toEqual(true); expect(isBaseSecurityReportOutOfDate(state)).toEqual(true);
}); });
}); });
describe('canCreateIssue', () => {
it('returns false if no feedback path is defined', () => {
expect(canCreateIssue(state)).toEqual(false);
});
it('returns true if a feedback path is defined', () => {
state.createVulnerabilityFeedbackIssuePath = MOCK_PATH;
expect(canCreateIssue(state)).toEqual(true);
});
});
describe('canCreateMergeRequest', () => {
it('returns false if no feedback path is defined', () => {
expect(canCreateMergeRequest(state)).toEqual(false);
});
it('returns true if a feedback path is defined', () => {
state.createVulnerabilityFeedbackMergeRequestPath = MOCK_PATH;
expect(canCreateMergeRequest(state)).toEqual(true);
});
});
describe('canDismissVulnerability', () => {
it('returns false if no feedback path is defined', () => {
expect(canDismissVulnerability(state)).toEqual(false);
});
it('returns true if a feedback path is defined', () => {
state.createVulnerabilityFeedbackDismissalPath = MOCK_PATH;
expect(canDismissVulnerability(state)).toEqual(true);
});
});
}); });
...@@ -55,22 +55,6 @@ describe('security reports mutations', () => { ...@@ -55,22 +55,6 @@ describe('security reports mutations', () => {
}); });
}); });
describe('SET_CAN_CREATE_ISSUE_PERMISSION', () => {
it('should set permission for create issue', () => {
mutations[types.SET_CAN_CREATE_ISSUE_PERMISSION](stateCopy, true);
expect(stateCopy.canCreateIssuePermission).toEqual(true);
});
});
describe('SET_CAN_CREATE_FEEDBACK_PERMISSION', () => {
it('should set permission for create feedback', () => {
mutations[types.SET_CAN_CREATE_FEEDBACK_PERMISSION](stateCopy, true);
expect(stateCopy.canCreateFeedbackPermission).toEqual(true);
});
});
describe('REQUEST_CONTAINER_SCANNING_DIFF', () => { describe('REQUEST_CONTAINER_SCANNING_DIFF', () => {
it('should set container scanning loading flag to true', () => { it('should set container scanning loading flag to true', () => {
mutations[types.REQUEST_CONTAINER_SCANNING_DIFF](stateCopy); mutations[types.REQUEST_CONTAINER_SCANNING_DIFF](stateCopy);
......
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