Commit 91747f85 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '271169-fix-l7-policies' into 'master'

Fix L7 policies not being saved properly

See merge request gitlab-org/gitlab!54031
parents fa33a6a4 d93d6ef0
......@@ -176,7 +176,9 @@ export default {
},
savePolicy() {
const saveFn = this.isEditing ? this.updatePolicy : this.createPolicy;
const policy = { manifest: toYaml(this.policy) };
const policy = {
manifest: this.editorMode === EditorModeYAML ? this.yamlEditorValue : toYaml(this.policy),
};
if (this.isEditing) {
policy.name = this.existingPolicy.name;
}
......
......@@ -23,6 +23,25 @@ jest.mock('~/lib/utils/url_utility');
describe('PolicyEditorApp component', () => {
let store;
let wrapper;
const l7manifest = `apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: limit-inbound-ip
spec:
endpointSelector: {}
ingress:
- toPorts:
- ports:
- port: '80'
protocol: TCP
- port: '443'
protocol: TCP
rules:
http:
- headers:
- 'X-Forwarded-For: 192.168.1.1'
fromEntities:
- cluster`;
const factory = ({ propsData, provide = {}, state, data } = {}) => {
store = createStore();
......@@ -153,6 +172,23 @@ spec:
labels: { 'app.gitlab.com/proj': '21' },
});
});
it('saves L7 policies', async () => {
factory({
data: () => ({
editorMode: EditorModeYAML,
yamlEditorValue: l7manifest,
}),
});
findSavePolicy().vm.$emit('click');
await wrapper.vm.$nextTick();
expect(store.dispatch).toHaveBeenCalledWith('networkPolicies/createPolicy', {
environmentId: -1,
policy: { manifest: l7manifest },
});
expect(redirectTo).toHaveBeenCalledWith('/threat-monitoring');
});
});
describe('given there is a name change', () => {
......
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