Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2a082e24
Commit
2a082e24
authored
Mar 23, 2022
by
Savas Vedova
Committed by
Phil Hughes
Mar 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove scan result policies feature flag
- it is in the process of being removed in another MR
parent
4f17d97c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
2 deletions
+187
-2
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/new_policy.vue
...threat_monitoring/components/policy_editor/new_policy.vue
+1
-1
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor_v2.vue
..._monitoring/components/policy_editor/policy_editor_v2.vue
+96
-0
ee/spec/frontend/threat_monitoring/components/policy_editor/new_policy_spec.js
...at_monitoring/components/policy_editor/new_policy_spec.js
+1
-1
ee/spec/frontend/threat_monitoring/components/policy_editor/policy_editor_v2_spec.js
...itoring/components/policy_editor/policy_editor_v2_spec.js
+89
-0
No files found.
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/new_policy.vue
View file @
2a082e24
...
@@ -4,7 +4,7 @@ import { s__ } from '~/locale';
...
@@ -4,7 +4,7 @@ import { s__ } from '~/locale';
import
{
getParameterByName
,
removeParams
,
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
getParameterByName
,
removeParams
,
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
../constants
'
;
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
../constants
'
;
import
PolicySelection
from
'
./policy_selection.vue
'
;
import
PolicySelection
from
'
./policy_selection.vue
'
;
import
PolicyEditor
from
'
./policy_editor.vue
'
;
import
PolicyEditor
from
'
./policy_editor
_v2
.vue
'
;
export
default
{
export
default
{
components
:
{
components
:
{
...
...
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor_v2.vue
0 → 100644
View file @
2a082e24
<
script
>
import
{
GlAlert
,
GlFormGroup
,
GlFormSelect
}
from
'
@gitlab/ui
'
;
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
../constants
'
;
import
EnvironmentPicker
from
'
../environment_picker.vue
'
;
import
NetworkPolicyEditor
from
'
./network_policy/network_policy_editor.vue
'
;
import
ScanExecutionPolicyEditor
from
'
./scan_execution_policy/scan_execution_policy_editor.vue
'
;
import
ScanResultPolicyEditor
from
'
./scan_result_policy/scan_result_policy_editor.vue
'
;
export
default
{
components
:
{
GlAlert
,
GlFormGroup
,
GlFormSelect
,
EnvironmentPicker
,
NetworkPolicyEditor
,
ScanExecutionPolicyEditor
,
ScanResultPolicyEditor
,
},
props
:
{
assignedPolicyProject
:
{
type
:
Object
,
required
:
true
,
},
existingPolicy
:
{
type
:
Object
,
required
:
false
,
default
:
null
,
},
// This is the `value` field of the POLICY_TYPE_COMPONENT_OPTIONS
selectedPolicyType
:
{
type
:
String
,
required
:
true
,
},
},
data
()
{
return
{
error
:
''
,
errorMessages
:
[],
};
},
computed
:
{
isEditing
()
{
if
(
!
this
.
existingPolicy
)
{
return
false
;
}
return
Boolean
(
this
.
existingPolicy
.
creation_timestamp
||
[
POLICY_TYPE_COMPONENT_OPTIONS
.
scanExecution
.
urlParameter
,
POLICY_TYPE_COMPONENT_OPTIONS
.
scanResult
?.
urlParameter
,
].
includes
(
this
.
existingPolicy
.
type
),
);
},
policyTypes
()
{
return
Object
.
values
(
POLICY_TYPE_COMPONENT_OPTIONS
);
},
policyOptions
()
{
return
(
this
.
policyTypes
.
find
(({
value
})
=>
value
===
this
.
selectedPolicyType
)
||
POLICY_TYPE_COMPONENT_OPTIONS
.
container
);
},
shouldAllowPolicyTypeSelection
()
{
return
!
this
.
existingPolicy
;
},
},
methods
:
{
setError
(
errors
)
{
[
this
.
error
,
...
this
.
errorMessages
]
=
errors
.
split
(
'
\n
'
);
},
},
};
</
script
>
<
template
>
<section
class=
"policy-editor"
>
<gl-alert
v-if=
"error"
:title=
"error"
dismissible
variant=
"danger"
@
dismiss=
"setError('')"
>
<ul
v-if=
"errorMessages.length"
class=
"gl-mb-0! gl-ml-5"
>
<li
v-for=
"errorMessage in errorMessages"
:key=
"errorMessage"
>
{{
errorMessage
}}
</li>
</ul>
</gl-alert>
<div
class=
"gl-display-flex"
>
<environment-picker
v-if=
"policyOptions.shouldShowEnvironmentPicker"
/>
</div>
<component
:is=
"policyOptions.component"
:existing-policy=
"existingPolicy"
:assigned-policy-project=
"assignedPolicyProject"
:is-editing=
"isEditing"
@
error=
"setError($event)"
/>
</section>
</
template
>
ee/spec/frontend/threat_monitoring/components/new_policy_spec.js
→
ee/spec/frontend/threat_monitoring/components/
policy_editor/
new_policy_spec.js
View file @
2a082e24
...
@@ -4,7 +4,7 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
...
@@ -4,7 +4,7 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
ee/threat_monitoring/components/constants
'
;
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
ee/threat_monitoring/components/constants
'
;
import
NewPolicy
from
'
ee/threat_monitoring/components/policy_editor/new_policy.vue
'
;
import
NewPolicy
from
'
ee/threat_monitoring/components/policy_editor/new_policy.vue
'
;
import
PolicySelection
from
'
ee/threat_monitoring/components/policy_editor/policy_selection.vue
'
;
import
PolicySelection
from
'
ee/threat_monitoring/components/policy_editor/policy_selection.vue
'
;
import
PolicyEditor
from
'
ee/threat_monitoring/components/policy_editor/policy_editor.vue
'
;
import
PolicyEditor
from
'
ee/threat_monitoring/components/policy_editor/policy_editor
_v2
.vue
'
;
describe
(
'
NewPolicy component
'
,
()
=>
{
describe
(
'
NewPolicy component
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
...
...
ee/spec/frontend/threat_monitoring/components/policy_editor/policy_editor_v2_spec.js
0 → 100644
View file @
2a082e24
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
ee/threat_monitoring/components/constants
'
;
import
EnvironmentPicker
from
'
ee/threat_monitoring/components/environment_picker.vue
'
;
import
NetworkPolicyEditor
from
'
ee/threat_monitoring/components/policy_editor/network_policy/network_policy_editor.vue
'
;
import
PolicyEditor
from
'
ee/threat_monitoring/components/policy_editor/policy_editor_v2.vue
'
;
import
ScanExecutionPolicyEditor
from
'
ee/threat_monitoring/components/policy_editor/scan_execution_policy/scan_execution_policy_editor.vue
'
;
import
ScanResultPolicyEditor
from
'
ee/threat_monitoring/components/policy_editor/scan_result_policy/scan_result_policy_editor.vue
'
;
import
{
DEFAULT_ASSIGNED_POLICY_PROJECT
}
from
'
ee/threat_monitoring/constants
'
;
describe
(
'
PolicyEditor V2 component
'
,
()
=>
{
let
wrapper
;
const
findAlert
=
()
=>
wrapper
.
findComponent
(
GlAlert
);
const
findEnvironmentPicker
=
()
=>
wrapper
.
findComponent
(
EnvironmentPicker
);
const
findNetworkPolicyEditor
=
()
=>
wrapper
.
findComponent
(
NetworkPolicyEditor
);
const
findScanExecutionPolicyEditor
=
()
=>
wrapper
.
findComponent
(
ScanExecutionPolicyEditor
);
const
findScanResultPolicyEditor
=
()
=>
wrapper
.
findComponent
(
ScanResultPolicyEditor
);
const
factory
=
({
propsData
=
{},
provide
=
{}
}
=
{})
=>
{
wrapper
=
shallowMount
(
PolicyEditor
,
{
propsData
:
{
assignedPolicyProject
:
DEFAULT_ASSIGNED_POLICY_PROJECT
,
selectedPolicyType
:
'
container
'
,
...
propsData
,
},
provide
:
{
policyType
:
undefined
,
...
provide
,
},
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
describe
(
'
default
'
,
()
=>
{
beforeEach
(
factory
);
it
.
each
`
component | status | findComponent | state
${
'
environment picker
'
}
|
${
'
does display
'
}
|
${
findEnvironmentPicker
}
|
${
true
}
${
'
alert
'
}
|
${
'
does not display
'
}
|
${
findAlert
}
|
${
false
}
`
(
'
$status the $component
'
,
({
findComponent
,
state
})
=>
{
expect
(
findComponent
().
exists
()).
toBe
(
state
);
});
it
(
'
renders the network policy editor component
'
,
()
=>
{
expect
(
findNetworkPolicyEditor
().
props
(
'
existingPolicy
'
)).
toBe
(
null
);
});
it
(
'
shows an alert when "error" is emitted from the component
'
,
async
()
=>
{
const
errorMessage
=
'
test
'
;
findNetworkPolicyEditor
().
vm
.
$emit
(
'
error
'
,
errorMessage
);
await
nextTick
();
const
alert
=
findAlert
();
expect
(
alert
.
exists
()).
toBe
(
true
);
expect
(
alert
.
props
(
'
title
'
)).
toBe
(
errorMessage
);
});
it
(
'
shows an alert with details when multiline "error" is emitted from the component
'
,
async
()
=>
{
const
errorMessages
=
'
title
\n
detail1
'
;
findNetworkPolicyEditor
().
vm
.
$emit
(
'
error
'
,
errorMessages
);
await
nextTick
();
const
alert
=
findAlert
();
expect
(
alert
.
exists
()).
toBe
(
true
);
expect
(
alert
.
props
(
'
title
'
)).
toBe
(
'
title
'
);
expect
(
alert
.
text
()).
toBe
(
'
detail1
'
);
});
it
.
each
`
policyTypeId | findComponent
${
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
value
}
|
${
findNetworkPolicyEditor
}
${
POLICY_TYPE_COMPONENT_OPTIONS
.
scanExecution
.
value
}
|
${
findScanExecutionPolicyEditor
}
${
POLICY_TYPE_COMPONENT_OPTIONS
.
scanResult
.
value
}
|
${
findScanResultPolicyEditor
}
`
(
'
renders the policy editor of type $policyType when selected
'
,
async
({
findComponent
,
policyTypeId
})
=>
{
wrapper
.
setProps
({
selectedPolicyType
:
policyTypeId
});
await
nextTick
();
const
component
=
findComponent
();
expect
(
component
.
exists
()).
toBe
(
true
);
expect
(
component
.
props
(
'
isEditing
'
)).
toBe
(
false
);
},
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment