diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-31 12:10:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-31 12:10:22 +0300 |
commit | e5f7ee6673f47290d860565f13a5a26391822260 (patch) | |
tree | f0e7c7bdd83bb8bc6ed783acdba961ce71fcfcf7 /spec/frontend/clusters | |
parent | d6ae5ba9dfaf8a39bf570a72e2152fc23501ed34 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/clusters')
5 files changed, 1 insertions, 223 deletions
diff --git a/spec/frontend/clusters/components/applications_spec.js b/spec/frontend/clusters/components/applications_spec.js index db5915cb1eb..e371ad998d2 100644 --- a/spec/frontend/clusters/components/applications_spec.js +++ b/spec/frontend/clusters/components/applications_spec.js @@ -3,7 +3,6 @@ import ApplicationRow from '~/clusters/components/application_row.vue'; import Applications from '~/clusters/components/applications.vue'; import CrossplaneProviderStack from '~/clusters/components/crossplane_provider_stack.vue'; import FluentdOutputSettings from '~/clusters/components/fluentd_output_settings.vue'; -import IngressModsecuritySettings from '~/clusters/components/ingress_modsecurity_settings.vue'; import KnativeDomainEditor from '~/clusters/components/knative_domain_editor.vue'; import { CLUSTER_TYPE, PROVIDER_TYPE } from '~/clusters/constants'; import eventHub from '~/clusters/event_hub'; @@ -185,24 +184,6 @@ describe('Applications', () => { expect(findByTestId('ingressCostWarning').element).toMatchSnapshot(); }); - describe('with nested component', () => { - const propsData = { - applications: { - ingress: { - title: 'Ingress', - status: 'installed', - }, - }, - }; - - beforeEach(() => createShallowComponent(propsData)); - - it('renders IngressModsecuritySettings', () => { - const modsecuritySettings = wrapper.find(IngressModsecuritySettings); - expect(modsecuritySettings.exists()).toBe(true); - }); - }); - describe('when installed', () => { describe('with ip address', () => { it('renders ip address with a clipboard button', () => { @@ -231,7 +212,6 @@ describe('Applications', () => { title: 'Ingress', status: 'installed', externalHostname: 'localhost.localdomain', - modsecurity_enabled: false, }, cert_manager: { title: 'Cert-Manager' }, crossplane: { title: 'Crossplane', stack: '' }, diff --git a/spec/frontend/clusters/components/fluentd_output_settings_spec.js b/spec/frontend/clusters/components/fluentd_output_settings_spec.js index 2c6e5bbd46a..fdb67a0426a 100644 --- a/spec/frontend/clusters/components/fluentd_output_settings_spec.js +++ b/spec/frontend/clusters/components/fluentd_output_settings_spec.js @@ -13,7 +13,6 @@ describe('FluentdOutputSettings', () => { protocol: 'tcp', host: '127.0.0.1', port: 514, - wafLogEnabled: true, ciliumLogEnabled: false, }; const defaultProps = { @@ -52,9 +51,8 @@ describe('FluentdOutputSettings', () => { const changePort = (val) => changeInput(findPort(), val); const changeHost = (val) => changeInput(findHost(), val); const changeProtocol = (idx) => findProtocolDropdown().vm.$children[idx].$emit('click'); - const toApplicationSettings = ({ wafLogEnabled, ciliumLogEnabled, ...settings }) => ({ + const toApplicationSettings = ({ ciliumLogEnabled, ...settings }) => ({ ...settings, - waf_log_enabled: wafLogEnabled, cilium_log_enabled: ciliumLogEnabled, }); @@ -74,7 +72,6 @@ describe('FluentdOutputSettings', () => { ${'when protocol dropdown is triggered'} | ${() => changeProtocol(1)} | ${'protocol'} | ${'udp'} ${'when host is changed'} | ${() => changeHost('test-host')} | ${'host'} | ${'test-host'} ${'when port is changed'} | ${() => changePort(123)} | ${'port'} | ${123} - ${'when wafLogEnabled changes'} | ${() => changeCheckbox(findCheckbox('Send Web Application Firewall Logs'))} | ${'wafLogEnabled'} | ${!defaultSettings.wafLogEnabled} ${'when ciliumLogEnabled changes'} | ${() => changeCheckbox(findCheckbox('Send Container Network Policies Logs'))} | ${'ciliumLogEnabled'} | ${!defaultSettings.ciliumLogEnabled} `('$desc', ({ changeFn, key, value }) => { beforeEach(() => { diff --git a/spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js b/spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js deleted file mode 100644 index f83a350a27c..00000000000 --- a/spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js +++ /dev/null @@ -1,192 +0,0 @@ -import { GlAlert, GlToggle, GlDropdown } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; -import IngressModsecuritySettings from '~/clusters/components/ingress_modsecurity_settings.vue'; -import { APPLICATION_STATUS, INGRESS } from '~/clusters/constants'; -import eventHub from '~/clusters/event_hub'; - -const { UPDATING } = APPLICATION_STATUS; - -describe('IngressModsecuritySettings', () => { - let wrapper; - - const defaultProps = { - modsecurity_enabled: false, - status: 'installable', - installed: false, - modsecurity_mode: 'logging', - updateAvailable: false, - }; - - const createComponent = (props = defaultProps) => { - wrapper = shallowMount(IngressModsecuritySettings, { - propsData: { - ingress: { - ...defaultProps, - ...props, - }, - }, - }); - }; - - const findSaveButton = () => - wrapper.find('[data-qa-selector="save_ingress_modsecurity_settings"]'); - const findCancelButton = () => - wrapper.find('[data-qa-selector="cancel_ingress_modsecurity_settings"]'); - const findModSecurityToggle = () => wrapper.find(GlToggle); - const findModSecurityDropdown = () => wrapper.find(GlDropdown); - - describe('when ingress is installed', () => { - beforeEach(() => { - createComponent({ installed: true, status: 'installed' }); - jest.spyOn(eventHub, '$emit'); - }); - - it('does not render save and cancel buttons', () => { - expect(findSaveButton().exists()).toBe(false); - expect(findCancelButton().exists()).toBe(false); - }); - - describe('with toggle changed by the user', () => { - beforeEach(() => { - findModSecurityToggle().vm.$emit('change'); - wrapper.setProps({ - ingress: { - ...defaultProps, - installed: true, - status: 'installed', - modsecurity_enabled: true, - }, - }); - }); - - it('renders toggle with label', () => { - expect(findModSecurityToggle().props('label')).toBe( - IngressModsecuritySettings.i18n.modSecurityEnabled, - ); - }); - - it('renders save and cancel buttons', () => { - expect(findSaveButton().exists()).toBe(true); - expect(findCancelButton().exists()).toBe(true); - }); - - it('enables related toggle and buttons', () => { - expect(findSaveButton().attributes().disabled).toBeUndefined(); - expect(findCancelButton().attributes().disabled).toBeUndefined(); - }); - - describe('with dropdown changed by the user', () => { - beforeEach(() => { - findModSecurityDropdown().vm.$children[1].$emit('click'); - wrapper.setProps({ - ingress: { - ...defaultProps, - installed: true, - status: 'installed', - modsecurity_enabled: true, - modsecurity_mode: 'blocking', - }, - }); - }); - - it('renders both save and cancel buttons', () => { - expect(findSaveButton().exists()).toBe(true); - expect(findCancelButton().exists()).toBe(true); - }); - - describe('and the save changes button is clicked', () => { - beforeEach(() => { - findSaveButton().vm.$emit('click'); - }); - - it('triggers save event and pass current modsecurity value', () => { - expect(eventHub.$emit).toHaveBeenCalledWith('updateApplication', { - id: INGRESS, - params: { modsecurity_enabled: true, modsecurity_mode: 'blocking' }, - }); - }); - }); - }); - - describe('and the cancel button is clicked', () => { - beforeEach(() => { - findCancelButton().vm.$emit('click'); - }); - - it('triggers reset event and hides both cancel and save changes button', () => { - expect(eventHub.$emit).toHaveBeenCalledWith('resetIngressModSecurityChanges', INGRESS); - expect(findSaveButton().exists()).toBe(false); - expect(findCancelButton().exists()).toBe(false); - }); - }); - - describe('with a new version available', () => { - beforeEach(() => { - wrapper.setProps({ - ingress: { - ...defaultProps, - installed: true, - status: 'installed', - modsecurity_enabled: true, - updateAvailable: true, - }, - }); - }); - - it('disables related toggle and buttons', () => { - expect(findSaveButton().attributes().disabled).toBe('true'); - expect(findCancelButton().attributes().disabled).toBe('true'); - }); - }); - }); - - it('triggers set event to be propagated with the current modsecurity value', () => { - wrapper.setData({ modSecurityEnabled: true }); - return wrapper.vm.$nextTick().then(() => { - expect(eventHub.$emit).toHaveBeenCalledWith('setIngressModSecurityEnabled', { - id: INGRESS, - modSecurityEnabled: true, - }); - }); - }); - - describe(`when ingress status is ${UPDATING}`, () => { - beforeEach(() => { - createComponent({ installed: true, status: UPDATING }); - }); - - it('renders loading spinner in save button', () => { - expect(findSaveButton().props('loading')).toBe(true); - }); - - it('renders disabled save button', () => { - expect(findSaveButton().props('disabled')).toBe(true); - }); - - it('renders save button with "Saving" label', () => { - expect(findSaveButton().text()).toBe('Saving'); - }); - }); - - describe('when ingress fails to update', () => { - beforeEach(() => { - createComponent({ updateFailed: true }); - }); - - it('displays a error message', () => { - expect(wrapper.find(GlAlert).exists()).toBe(true); - }); - }); - }); - - describe('when ingress is not installed', () => { - beforeEach(() => { - createComponent(); - }); - - it('does not render the save button', () => { - expect(findSaveButton().exists()).toBe(false); - expect(findModSecurityToggle().props('value')).toBe(false); - }); - }); -}); diff --git a/spec/frontend/clusters/services/mock_data.js b/spec/frontend/clusters/services/mock_data.js index 4f8b27d623c..6ab94d6d95b 100644 --- a/spec/frontend/clusters/services/mock_data.js +++ b/spec/frontend/clusters/services/mock_data.js @@ -20,7 +20,6 @@ const CLUSTERS_MOCK_DATA = { external_ip: null, external_hostname: null, can_uninstall: false, - modsecurity_enabled: false, }, { name: 'runner', @@ -154,7 +153,6 @@ const APPLICATIONS_MOCK_STATE = { ingress: { title: 'Ingress', status: 'installable', - modsecurity_enabled: false, }, crossplane: { title: 'Crossplane', status: 'installable', stack: '' }, cert_manager: { title: 'Cert-Manager', status: 'installable' }, diff --git a/spec/frontend/clusters/stores/clusters_store_spec.js b/spec/frontend/clusters/stores/clusters_store_spec.js index c80949531c8..8fa373349b8 100644 --- a/spec/frontend/clusters/stores/clusters_store_spec.js +++ b/spec/frontend/clusters/stores/clusters_store_spec.js @@ -84,16 +84,12 @@ describe('Clusters Store', () => { externalHostname: null, installable: true, installed: false, - isEditingModSecurityEnabled: false, - isEditingModSecurityMode: false, installFailed: true, uninstallable: false, updateFailed: false, uninstallSuccessful: false, uninstallFailed: false, validationError: null, - modsecurity_enabled: false, - modsecurity_mode: undefined, }, runner: { title: 'GitLab Runner', @@ -143,7 +139,6 @@ describe('Clusters Store', () => { uninstallSuccessful: false, uninstallFailed: false, validationError: null, - wafLogEnabled: null, }, jupyter: { title: 'JupyterHub', |