From 22eb17aca0136fcb519c9911fbdb532b2edf6db2 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Wed, 15 Sep 2021 11:53:22 +0200 Subject: [PATCH] [7.x] Add deprecation message for xpack.spaces.enabled --- .../server/config_deprecations.test.ts | 49 +++++++++++++++++++ .../security/server/config_deprecations.ts | 19 +++++++ 2 files changed, 68 insertions(+) diff --git a/x-pack/plugins/security/server/config_deprecations.test.ts b/x-pack/plugins/security/server/config_deprecations.test.ts index edb3dbd737451..e8739b6f1d4ec 100644 --- a/x-pack/plugins/security/server/config_deprecations.test.ts +++ b/x-pack/plugins/security/server/config_deprecations.test.ts @@ -426,4 +426,53 @@ describe('Config Deprecations', () => { expect(migrated).toEqual(config); expect(messages).toHaveLength(0); }); + + it('warns when the spaces plugin is disabled', () => { + const config = { + xpack: { + security: { + session: { idleTimeout: 123, lifespan: 345 }, + }, + spaces: { + enabled: false, + }, + }, + }; + const { messages, migrated } = applyConfigDeprecations(cloneDeep(config)); + expect(migrated).toEqual(config); + expect(messages).toMatchInlineSnapshot(` + Array [ + "Disabling the Spaces plugin will not be allowed in 8.0.", + ] + `); + }); + + it('does not warn when the spaces plugin is enabled', () => { + const config = { + xpack: { + security: { + session: { idleTimeout: 123, lifespan: 345 }, + }, + spaces: { + enabled: true, + }, + }, + }; + const { messages, migrated } = applyConfigDeprecations(cloneDeep(config)); + expect(migrated).toEqual(config); + expect(messages).toHaveLength(0); + }); + + it("does not warn when xpack.spaces.enabled isn't set", () => { + const config = { + xpack: { + security: { + session: { idleTimeout: 123, lifespan: 345 }, + }, + }, + }; + const { messages, migrated } = applyConfigDeprecations(cloneDeep(config)); + expect(migrated).toEqual(config); + expect(messages).toHaveLength(0); + }); }); diff --git a/x-pack/plugins/security/server/config_deprecations.ts b/x-pack/plugins/security/server/config_deprecations.ts index 8732a98d556c0..20e1ef63f19a9 100644 --- a/x-pack/plugins/security/server/config_deprecations.ts +++ b/x-pack/plugins/security/server/config_deprecations.ts @@ -161,6 +161,25 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({ }); } }, + (settings, fromPath, addDeprecation) => { + if (settings?.xpack?.spaces?.enabled === false) { + addDeprecation({ + title: i18n.translate('xpack.spaces.deprecations.enabledTitle', { + defaultMessage: 'Setting "xpack.spaces.enabled" is deprecated', + }), + message: i18n.translate('xpack.spaces.deprecations.enabledMessage', { + defaultMessage: 'Disabling the Spaces plugin will not be allowed in 8.0.', + }), + correctiveActions: { + manualSteps: [ + i18n.translate('xpack.spaces.deprecations.enabled.manualStepOneMessage', { + defaultMessage: `Remove "xpack.spaces.enabled" from kibana.yml.`, + }), + ], + }, + }); + } + }, // Default values for session expiration timeouts. (settings, fromPath, addDeprecation) => { if (settings?.xpack?.security?.session?.idleTimeout === undefined) {