Commit a6623454 authored by Savas Vedova's avatar Savas Vedova

Merge branch '336947-fix-scan-execution-policy-edit' into 'master'

Fix editing of scan execution policies

See merge request gitlab-org/gitlab!69249
parents 73a32a6d cd0b8533
......@@ -40,7 +40,10 @@ export default {
return this.isEditing ? this.policyType : this.newPolicyType;
},
isEditing() {
return Boolean(this.existingPolicy?.creation_timestamp || this.existingPolicy?.updatedAt);
return Boolean(
this.existingPolicy?.creation_timestamp ||
this.existingPolicy?.type === POLICY_TYPE_COMPONENT_OPTIONS.scanExecution.urlParameter,
);
},
policyTypes() {
return Object.values(POLICY_TYPE_COMPONENT_OPTIONS);
......
......@@ -93,9 +93,9 @@ describe('PolicyEditor component', () => {
describe('when an existing policy is present', () => {
it.each`
policyType | option | existingPolicy | findComponent
${'container_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.container} | ${{ manifest: mockL3Manifest, updatedAt: '2020-04-14T00:08:30Z' }} | ${findNeworkPolicyEditor}
${'scan_execution_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.scanExecution} | ${mockDastScanExecutionObject} | ${findScanExecutionPolicyEditor}
policyType | option | existingPolicy | findComponent
${'container_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.container} | ${{ manifest: mockL3Manifest, creation_timestamp: '2020-04-14T00:08:30Z' }} | ${findNeworkPolicyEditor}
${'scan_execution_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.scanExecution} | ${mockDastScanExecutionObject} | ${findScanExecutionPolicyEditor}
`(
'renders the disabled form select for existing policy of type $policyType',
async ({ existingPolicy, findComponent, option, policyType }) => {
......
......@@ -6,6 +6,6 @@ import {
describe('fromYaml', () => {
it('returns policy object', () => {
expect(fromYaml(mockDastScanExecutionManifest)).toMatchObject(mockDastScanExecutionObject);
expect(fromYaml(mockDastScanExecutionManifest)).toStrictEqual(mockDastScanExecutionObject);
});
});
......@@ -57,7 +57,6 @@ rules:
- type: pipeline
branches:
- main
updatedAt: '2020-04-14T00:08:30Z'
actions:
- scan: dast
site_profile: required_site_profile
......@@ -70,7 +69,6 @@ export const mockDastScanExecutionObject = {
description: 'This policy enforces pipeline configuration to have a job with DAST scan',
enabled: false,
rules: [{ type: 'pipeline', branches: ['main'] }],
updatedAt: '2020-04-14T00:08:30Z',
actions: [
{
scan: 'dast',
......
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