diff --git a/x-pack/test/saved_object_api_integration/common/config.ts b/x-pack/test/saved_object_api_integration/common/config.ts index eaf7230a832a80..c6a8599b1797f9 100644 --- a/x-pack/test/saved_object_api_integration/common/config.ts +++ b/x-pack/test/saved_object_api_integration/common/config.ts @@ -56,10 +56,7 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) ...config.xpack.api.get('kbnTestServer.serverArgs'), '--optimize.enabled=false', '--server.xsrf.disableProtection=true', - `--plugin-path=${path.join(__dirname, 'fixtures', 'isolated_type_plugin')}`, - `--plugin-path=${path.join(__dirname, 'fixtures', 'namespace_agnostic_type_plugin')}`, - `--plugin-path=${path.join(__dirname, 'fixtures', 'hidden_type_plugin')}`, - `--plugin-path=${path.join(__dirname, 'fixtures', 'shared_type_plugin')}`, + `--plugin-path=${path.join(__dirname, 'fixtures', 'saved_object_test_plugin')}`, ...disabledPlugins.map(key => `--xpack.${key}.enabled=false`), ], }, diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/index.js b/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/index.js deleted file mode 100644 index 5989db84e22902..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/index.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import mappings from './mappings.json'; - -export default function(kibana) { - return new kibana.Plugin({ - require: ['kibana', 'elasticsearch', 'xpack_main'], - name: 'hidden_type_plugin', - uiExports: { - savedObjectsManagement: {}, - savedObjectSchemas: { - hiddentype: { - hidden: true, - }, - }, - mappings, - }, - - config() {}, - - init() {}, // need empty init for plugin to load - }); -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/mappings.json b/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/mappings.json deleted file mode 100644 index 45f898e10e2bac..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/mappings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "hiddentype": { - "properties": { - "title": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } - } - } - } -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/package.json b/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/package.json deleted file mode 100644 index 009bae982ee156..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "hidden_type_plugin", - "version": "0.0.0", - "kibana": { - "version": "kibana" - } -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/index.js b/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/index.js deleted file mode 100644 index a406c6737da5f5..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/index.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import mappings from './mappings.json'; - -export default function(kibana) { - return new kibana.Plugin({ - require: ['kibana', 'elasticsearch', 'xpack_main'], - name: 'isolated_type_plugin', - uiExports: { - savedObjectsManagement: { - isolatedtype: { - isImportableAndExportable: true, - }, - }, - mappings, - }, - - config() {}, - - init() {}, // need empty init for plugin to load - }); -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/mappings.json b/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/mappings.json deleted file mode 100644 index 141ebbc93c2908..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/mappings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "isolatedtype": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchId": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/package.json b/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/package.json deleted file mode 100644 index 665ecb1b31d7ee..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/isolated_type_plugin/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "isolated_type_plugin", - "version": "0.0.0", - "kibana": { - "version": "kibana" - } -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/namespace_agnostic_type_plugin/kibana.json b/x-pack/test/saved_object_api_integration/common/fixtures/namespace_agnostic_type_plugin/kibana.json deleted file mode 100644 index ec3077999d8bdc..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/namespace_agnostic_type_plugin/kibana.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "namespace_agnostic_type_plugin", - "version": "1.0.0", - "kibanaVersion": "kibana", - "requiredPlugins": ["features"], - "server": true, - "ui": false -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/namespace_agnostic_type_plugin/server/index.ts b/x-pack/test/saved_object_api_integration/common/fixtures/namespace_agnostic_type_plugin/server/index.ts deleted file mode 100644 index d8940c96e676a0..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/namespace_agnostic_type_plugin/server/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import { CoreSetup, Plugin } from 'src/core/server'; -import { PluginSetupContract as FeaturesPluginSetupContract } from '../../../../../../plugins/features/server'; - -export const plugin = () => new NamespaceAgnosticTypePlugin(); - -interface SetupDeps { - features: FeaturesPluginSetupContract; -} - -class NamespaceAgnosticTypePlugin implements Plugin { - setup(core: CoreSetup, plugins: SetupDeps) { - core.savedObjects.registerType({ - name: 'globaltype', - hidden: false, - namespaceType: 'agnostic', - management: { - importableAndExportable: true, - }, - mappings: { - properties: { - title: { - type: 'text', - fields: { - keyword: { - type: 'keyword', - ignore_above: 2048, - }, - }, - }, - }, - }, - }); - - plugins.features.registerFeature({ - id: 'namespace_agnostic_type_plugin', - name: 'namespace_agnostic_type_plugin', - icon: 'upArrow', - navLinkId: 'namespace_agnostic_type_plugin', - app: [], - privileges: { - all: { - savedObject: { - all: ['globaltype'], - read: [], - }, - ui: [], - }, - read: { - savedObject: { - all: [], - read: ['globaltype'], - }, - ui: [], - }, - }, - }); - } - start() {} -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/kibana.json b/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/kibana.json new file mode 100644 index 00000000000000..55cd29686fdefa --- /dev/null +++ b/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/kibana.json @@ -0,0 +1,6 @@ +{ + "id": "savedObjectTestPlugin", + "version": "kibana", + "server": true, + "ui": false +} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/server/index.ts b/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/server/index.ts new file mode 100644 index 00000000000000..cb4cc2a845a4c6 --- /dev/null +++ b/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/server/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin } from './plugin'; + +export function plugin() { + return new Plugin(); +} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/server/plugin.ts b/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/server/plugin.ts new file mode 100644 index 00000000000000..0c15ab4bd2f804 --- /dev/null +++ b/x-pack/test/saved_object_api_integration/common/fixtures/saved_object_test_plugin/server/plugin.ts @@ -0,0 +1,75 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { CoreSetup, SavedObject } from 'kibana/server'; + +export class Plugin { + constructor() {} + + public setup(core: CoreSetup) { + // called when plugin is setting up during Kibana's startup sequence + const management = { + importableAndExportable: true, + getTitle(obj: SavedObject) { + return obj.attributes.title; + }, + }; + const mappings = { + properties: { + title: { type: 'text' }, + }, + }; + + core.savedObjects.registerType({ + name: 'isolatedtype', + hidden: false, + namespaceType: 'single', + management, + mappings: { + properties: { + description: { type: 'text' }, + kibanaSavedObjectMeta: { + properties: { + searchSourceJSON: { type: 'text' }, + }, + }, + savedSearchId: { type: 'keyword' }, + title: { type: 'text' }, + uiStateJSON: { type: 'text' }, + version: { type: 'integer' }, + visState: { type: 'text' }, + }, + }, + }); + core.savedObjects.registerType({ + name: 'sharedtype', + hidden: false, + namespaceType: 'multiple', + mappings, + }); + core.savedObjects.registerType({ + name: 'globaltype', + hidden: false, + namespaceType: 'agnostic', + management, + mappings, + }); + core.savedObjects.registerType({ + name: 'hiddentype', + hidden: true, + namespaceType: 'single', + mappings, + }); + } + + public start() { + // called after all plugins are set up + } + + public stop() { + // called when plugin is torn down during Kibana's shutdown sequence + } +} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/index.js b/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/index.js deleted file mode 100644 index 91a24fb9f4f564..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/index.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import mappings from './mappings.json'; - -export default function(kibana) { - return new kibana.Plugin({ - require: ['kibana', 'elasticsearch', 'xpack_main'], - name: 'shared_type_plugin', - uiExports: { - savedObjectsManagement: {}, - savedObjectSchemas: { - sharedtype: { - multiNamespace: true, - }, - }, - mappings, - }, - - config() {}, - - init() {}, // need empty init for plugin to load - }); -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/mappings.json b/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/mappings.json deleted file mode 100644 index 918958aec0d6df..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/mappings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "sharedtype": { - "properties": { - "title": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } - } - } - } -} diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/package.json b/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/package.json deleted file mode 100644 index c52f4256c5c06b..00000000000000 --- a/x-pack/test/saved_object_api_integration/common/fixtures/shared_type_plugin/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "shared_type_plugin", - "version": "0.0.0", - "kibana": { - "version": "kibana" - } -} diff --git a/x-pack/test/spaces_api_integration/common/config.ts b/x-pack/test/spaces_api_integration/common/config.ts index 19743e09f94209..66bf3cf7b683ba 100644 --- a/x-pack/test/spaces_api_integration/common/config.ts +++ b/x-pack/test/spaces_api_integration/common/config.ts @@ -67,7 +67,7 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) // disable anonymouse access so that we're testing both on and off in different suites '--status.allowAnonymous=false', '--server.xsrf.disableProtection=true', - `--plugin-path=${path.join(__dirname, 'fixtures', 'shared_type_plugin')}`, + `--plugin-path=${path.join(__dirname, 'fixtures', 'spaces_test_plugin')}`, ...disabledPlugins.map(key => `--xpack.${key}.enabled=false`), ], }, diff --git a/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/index.js b/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/index.js deleted file mode 100644 index 91a24fb9f4f564..00000000000000 --- a/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/index.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import mappings from './mappings.json'; - -export default function(kibana) { - return new kibana.Plugin({ - require: ['kibana', 'elasticsearch', 'xpack_main'], - name: 'shared_type_plugin', - uiExports: { - savedObjectsManagement: {}, - savedObjectSchemas: { - sharedtype: { - multiNamespace: true, - }, - }, - mappings, - }, - - config() {}, - - init() {}, // need empty init for plugin to load - }); -} diff --git a/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/mappings.json b/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/mappings.json deleted file mode 100644 index 918958aec0d6df..00000000000000 --- a/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/mappings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "sharedtype": { - "properties": { - "title": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } - } - } - } -} diff --git a/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/package.json b/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/package.json deleted file mode 100644 index c52f4256c5c06b..00000000000000 --- a/x-pack/test/spaces_api_integration/common/fixtures/shared_type_plugin/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "shared_type_plugin", - "version": "0.0.0", - "kibana": { - "version": "kibana" - } -} diff --git a/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/kibana.json b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/kibana.json new file mode 100644 index 00000000000000..a567e520318547 --- /dev/null +++ b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/kibana.json @@ -0,0 +1,6 @@ +{ + "id": "spacesTestPlugin", + "version": "kibana", + "server": true, + "ui": false +} diff --git a/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/index.ts b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/index.ts new file mode 100644 index 00000000000000..cb4cc2a845a4c6 --- /dev/null +++ b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin } from './plugin'; + +export function plugin() { + return new Plugin(); +} diff --git a/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/plugin.ts b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/plugin.ts new file mode 100644 index 00000000000000..ee03fa6b648af8 --- /dev/null +++ b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/plugin.ts @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { CoreSetup } from 'kibana/server'; + +export class Plugin { + constructor() {} + + public setup(core: CoreSetup) { + // called when plugin is setting up during Kibana's startup sequence + core.savedObjects.registerType({ + name: 'sharedtype', + hidden: false, + namespaceType: 'multiple', + mappings: { + properties: { + title: { type: 'text' }, + }, + }, + }); + } + + public start() { + // called after all plugins are set up + } + + public stop() { + // called when plugin is torn down during Kibana's shutdown sequence + } +}