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
7f486498
Commit
7f486498
authored
Apr 27, 2021
by
Alexander Turinske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New policy starts out with a rule by default
- update tests Changelog: added
parent
55eebdf8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
8 deletions
+32
-8
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor.vue
...eat_monitoring/components/policy_editor/policy_editor.vue
+1
-1
ee/changelogs/unreleased/321419-new-policy-gets-rule-by-default.yml
...ogs/unreleased/321419-new-policy-gets-rule-by-default.yml
+5
-0
ee/spec/frontend/threat_monitoring/components/policy_editor/__snapshots__/policy_editor_spec.js.snap
...ts/policy_editor/__snapshots__/policy_editor_spec.js.snap
+12
-2
ee/spec/frontend/threat_monitoring/components/policy_editor/policy_editor_spec.js
...monitoring/components/policy_editor/policy_editor_spec.js
+14
-5
No files found.
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor.vue
View file @
7f486498
...
...
@@ -84,7 +84,7 @@ export default {
isEnabled
:
false
,
endpointMatchMode
:
EndpointMatchModeAny
,
endpointLabels
:
''
,
rules
:
[],
rules
:
[
buildRule
(
RuleTypeEndpoint
)
],
annotations
:
''
,
labels
:
''
,
};
...
...
ee/changelogs/unreleased/321419-new-policy-gets-rule-by-default.yml
0 → 100644
View file @
7f486498
---
title
:
New policy starts out with a rule by default
merge_request
:
60464
author
:
type
:
changed
ee/spec/frontend/threat_monitoring/components/policy_editor/__snapshots__/policy_editor_spec.js.snap
View file @
7f486498
...
...
@@ -155,7 +155,14 @@ exports[`PolicyEditorApp component renders the policy editor layout 1`] = `
<dim-disable-container-stub
data-testid="rule-builder-container"
>
<policy-rule-builder-stub
class="gl-mb-4"
endpointlabels=""
endpointmatchmode="any"
rule="[object Object]"
/>
<div
class="gl-p-3 gl-rounded-base gl-border-1 gl-border-solid gl-border-gray-100 gl-mb-5"
>
...
...
@@ -191,7 +198,7 @@ exports[`PolicyEditorApp component renders the policy editor layout 1`] = `
<policy-preview-stub
initialtab="0"
policydescription="
Deny all traffic
"
policydescription="
Allow all inbound traffic to <strong>all</strong> pods from <strong>all</strong> pods on <strong>any</strong> port
"
policyyaml="apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
...
...
@@ -202,6 +209,9 @@ spec:
endpointSelector:
matchLabels:
network-policy.gitlab.com/disabled_by: gitlab
ingress:
- fromEndpoints:
- matchLabels: {}
"
/>
</dim-disable-container-stub>
...
...
ee/spec/frontend/threat_monitoring/components/policy_editor/policy_editor_spec.js
View file @
7f486498
...
...
@@ -82,6 +82,7 @@ spec:
const
findPolicyDescription
=
()
=>
wrapper
.
find
(
"
[id='policyDescription']
"
);
const
findPolicyEnableContainer
=
()
=>
wrapper
.
findByTestId
(
'
policy-enable
'
);
const
findPolicyName
=
()
=>
wrapper
.
find
(
"
[id='policyName']
"
);
const
findPolicyRuleBuilder
=
()
=>
wrapper
.
findComponent
(
PolicyRuleBuilder
);
const
findSavePolicy
=
()
=>
wrapper
.
findByTestId
(
'
save-policy
'
);
const
findDeletePolicy
=
()
=>
wrapper
.
findByTestId
(
'
delete-policy
'
);
const
findEditorModeToggle
=
()
=>
wrapper
.
findByTestId
(
'
editor-mode
'
);
...
...
@@ -112,6 +113,14 @@ spec:
expect
(
wrapper
.
findComponent
(
GlToggle
).
props
(
'
label
'
)).
toBe
(
PolicyEditorApp
.
i18n
.
toggleLabel
);
});
it
(
'
renders a default rule with label
'
,
()
=>
{
expect
(
findPolicyRuleBuilder
().
exists
()).
toBe
(
true
);
expect
(
findPolicyRuleBuilder
().
attributes
()).
toMatchObject
({
endpointlabels
:
''
,
endpointmatchmode
:
'
any
'
,
});
});
it
(
'
does not render yaml editor
'
,
()
=>
{
expect
(
findYamlEditor
().
exists
()).
toBe
(
false
);
});
...
...
@@ -227,13 +236,13 @@ spec:
});
it
(
'
adds a new rule
'
,
async
()
=>
{
expect
(
wrapper
.
findAll
(
PolicyRuleBuilder
).
length
).
toEqual
(
0
);
expect
(
wrapper
.
findAll
(
PolicyRuleBuilder
).
length
).
toEqual
(
1
);
const
button
=
findAddRuleButton
();
button
.
vm
.
$emit
(
'
click
'
);
button
.
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$nextTick
();
const
elements
=
wrapper
.
findAll
(
PolicyRuleBuilder
);
expect
(
elements
.
length
).
toEqual
(
2
);
expect
(
elements
.
length
).
toEqual
(
3
);
elements
.
wrappers
.
forEach
((
builder
,
idx
)
=>
{
expect
(
builder
.
props
().
rule
).
toMatchObject
({
...
...
@@ -250,11 +259,11 @@ spec:
it
(
'
removes a new rule
'
,
async
()
=>
{
findAddRuleButton
().
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
findAll
(
PolicyRuleBuilder
).
length
).
toEqual
(
1
);
expect
(
wrapper
.
findAll
(
PolicyRuleBuilder
).
length
).
toEqual
(
2
);
wrapper
.
find
(
PolicyRuleBuilder
).
vm
.
$emit
(
'
remove
'
);
findPolicyRuleBuilder
(
).
vm
.
$emit
(
'
remove
'
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
findAll
(
PolicyRuleBuilder
).
length
).
toEqual
(
0
);
expect
(
wrapper
.
findAll
(
PolicyRuleBuilder
).
length
).
toEqual
(
1
);
});
it
(
'
updates yaml editor value on switch to yaml editor
'
,
async
()
=>
{
...
...
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