Commit 7cf716ff authored by Savas Vedova's avatar Savas Vedova

Merge branch '336947-fix-predefined-container-policies' into 'master'

Fix editing predefined container policies

See merge request gitlab-org/gitlab!69251
parents aec6ac9f b7826f7c
...@@ -6,8 +6,10 @@ export const INVALID_CURRENT_ENVIRONMENT_NAME = '–'; ...@@ -6,8 +6,10 @@ export const INVALID_CURRENT_ENVIRONMENT_NAME = '–';
export const PREDEFINED_NETWORK_POLICIES = [ export const PREDEFINED_NETWORK_POLICIES = [
{ {
__typename: 'NetworkPolicy',
name: 'drop-outbound', name: 'drop-outbound',
enabled: false, enabled: false,
kind: 'CiliumNetworkPolicy',
yaml: `--- yaml: `---
apiVersion: cilium.io/v2 apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy kind: CiliumNetworkPolicy
...@@ -19,8 +21,10 @@ spec: ...@@ -19,8 +21,10 @@ spec:
- {}`, - {}`,
}, },
{ {
__typename: 'NetworkPolicy',
name: 'allow-inbound-http', name: 'allow-inbound-http',
enabled: false, enabled: false,
kind: 'CiliumNetworkPolicy',
yaml: `--- yaml: `---
apiVersion: cilium.io/v2 apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy kind: CiliumNetworkPolicy
......
...@@ -5,6 +5,7 @@ import VueApollo from 'vue-apollo'; ...@@ -5,6 +5,7 @@ import VueApollo from 'vue-apollo';
import { POLICY_TYPE_OPTIONS } from 'ee/threat_monitoring/components/constants'; import { POLICY_TYPE_OPTIONS } from 'ee/threat_monitoring/components/constants';
import PoliciesList from 'ee/threat_monitoring/components/policies/policies_list.vue'; import PoliciesList from 'ee/threat_monitoring/components/policies/policies_list.vue';
import PolicyDrawer from 'ee/threat_monitoring/components/policy_drawer/policy_drawer.vue'; import PolicyDrawer from 'ee/threat_monitoring/components/policy_drawer/policy_drawer.vue';
import { PREDEFINED_NETWORK_POLICIES } from 'ee/threat_monitoring/constants';
import networkPoliciesQuery from 'ee/threat_monitoring/graphql/queries/network_policies.query.graphql'; import networkPoliciesQuery from 'ee/threat_monitoring/graphql/queries/network_policies.query.graphql';
import scanExecutionPoliciesQuery from 'ee/threat_monitoring/graphql/queries/scan_execution_policies.query.graphql'; import scanExecutionPoliciesQuery from 'ee/threat_monitoring/graphql/queries/scan_execution_policies.query.graphql';
import createStore from 'ee/threat_monitoring/store'; import createStore from 'ee/threat_monitoring/store';
...@@ -190,8 +191,8 @@ describe('PoliciesList component', () => { ...@@ -190,8 +191,8 @@ describe('PoliciesList component', () => {
rowIndex | expectedPolicyName | expectedPolicyType rowIndex | expectedPolicyName | expectedPolicyType
${1} | ${mockScanExecutionPoliciesResponse[0].name} | ${'Scan execution'} ${1} | ${mockScanExecutionPoliciesResponse[0].name} | ${'Scan execution'}
${3} | ${mockNetworkPoliciesResponse[0].name} | ${'Network'} ${3} | ${mockNetworkPoliciesResponse[0].name} | ${'Network'}
${4} | ${'drop-outbound'} | ${'Network'} ${4} | ${PREDEFINED_NETWORK_POLICIES[0].name} | ${'Network'}
${5} | ${'allow-inbound-http'} | ${'Network'} ${5} | ${PREDEFINED_NETWORK_POLICIES[1].name} | ${'Network'}
`('policy in row #$rowIndex', ({ rowIndex, expectedPolicyName, expectedPolicyType }) => { `('policy in row #$rowIndex', ({ rowIndex, expectedPolicyName, expectedPolicyType }) => {
let row; let row;
...@@ -277,10 +278,12 @@ describe('PoliciesList component', () => { ...@@ -277,10 +278,12 @@ describe('PoliciesList component', () => {
}); });
describe.each` describe.each`
description | policy | policyType | editPolicyPath description | policy | policyType | editPolicyPath
${'network'} | ${mockNetworkPoliciesResponse[0]} | ${'container'} | ${'path/to/policy?environment_id=2&type=container_policy&kind=NetworkPolicy'} ${'network'} | ${mockNetworkPoliciesResponse[0]} | ${'container'} | ${'path/to/policy?environment_id=2&type=container_policy&kind=NetworkPolicy'}
${'container'} | ${mockNetworkPoliciesResponse[1]} | ${'container'} | ${'path/to/policy?environment_id=2&type=container_policy&kind=CiliumNetworkPolicy'} ${'container'} | ${mockNetworkPoliciesResponse[1]} | ${'container'} | ${'path/to/policy?environment_id=2&type=container_policy&kind=CiliumNetworkPolicy'}
${'scan execution'} | ${mockScanExecutionPoliciesResponse[0]} | ${'scanExecution'} | ${'path/to/policy?environment_id=2&type=scan_execution_policy'} ${PREDEFINED_NETWORK_POLICIES[0].name} | ${PREDEFINED_NETWORK_POLICIES[0]} | ${'container'} | ${'path/to/policy?environment_id=2&type=container_policy&kind=CiliumNetworkPolicy'}
${PREDEFINED_NETWORK_POLICIES[1].name} | ${PREDEFINED_NETWORK_POLICIES[1]} | ${'container'} | ${'path/to/policy?environment_id=2&type=container_policy&kind=CiliumNetworkPolicy'}
${'scan execution'} | ${mockScanExecutionPoliciesResponse[0]} | ${'scanExecution'} | ${'path/to/policy?environment_id=2&type=scan_execution_policy'}
`('given there is a $description policy selected', ({ policy, policyType, editPolicyPath }) => { `('given there is a $description policy selected', ({ policy, policyType, editPolicyPath }) => {
beforeEach(() => { beforeEach(() => {
mountShallowWrapper(); mountShallowWrapper();
......
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