diff --git a/x-pack/legacy/plugins/spaces/index.ts b/x-pack/legacy/plugins/spaces/index.ts index 9bc5293a3475e..b522f346e58f4 100644 --- a/x-pack/legacy/plugins/spaces/index.ts +++ b/x-pack/legacy/plugins/spaces/index.ts @@ -73,6 +73,7 @@ export const spaces = (kibana: Record) => savedObjectSchemas: { space: { isNamespaceAgnostic: true, + hidden: true, }, }, home: ['plugins/spaces/register_feature'], diff --git a/x-pack/legacy/plugins/spaces/server/lib/create_default_space.ts b/x-pack/legacy/plugins/spaces/server/lib/create_default_space.ts index a7b7281ff75bf..81e391c8f5710 100644 --- a/x-pack/legacy/plugins/spaces/server/lib/create_default_space.ts +++ b/x-pack/legacy/plugins/spaces/server/lib/create_default_space.ts @@ -20,7 +20,7 @@ export async function createDefaultSpace({ elasticsearch, savedObjects }: Deps) const client = await elasticsearch.dataClient$.pipe(first()).toPromise(); - const savedObjectsRepository = getSavedObjectsRepository(client.callAsInternalUser); + const savedObjectsRepository = getSavedObjectsRepository(client.callAsInternalUser, ['space']); const defaultSpaceExists = await doesDefaultSpaceExist( SavedObjectsClient, diff --git a/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/__snapshots__/spaces_saved_objects_client.test.ts.snap b/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/__snapshots__/spaces_saved_objects_client.test.ts.snap index e52af9a98001a..8b1a258138355 100644 --- a/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/__snapshots__/spaces_saved_objects_client.test.ts.snap +++ b/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/__snapshots__/spaces_saved_objects_client.test.ts.snap @@ -1,65 +1,29 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`default space #bulkCreate throws error if objects type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`default space #bulkCreate throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`default space #bulkGet throws error if objects type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`default space #bulkGet throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; exports[`default space #create throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`default space #create throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`default space #delete throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`default space #delete throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - -exports[`default space #find if options.type isn't provided specifies options.type based on the types excluding the space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`default space #find throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`default space #find throws error if options.type is array containing space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - -exports[`default space #find throws error if options.type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`default space #get throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`default space #get throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`default space #update throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`default space #update throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - -exports[`space_1 space #bulkCreate throws error if objects type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`space_1 space #bulkCreate throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`space_1 space #bulkGet throws error if objects type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`space_1 space #bulkGet throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; exports[`space_1 space #create throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`space_1 space #create throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`space_1 space #delete throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`space_1 space #delete throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - -exports[`space_1 space #find if options.type isn't provided specifies options.type based on the types excluding the space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`space_1 space #find throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`space_1 space #find throws error if options.type is array containing space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - -exports[`space_1 space #find throws error if options.type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`space_1 space #get throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; -exports[`space_1 space #get throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; - exports[`space_1 space #update throws error if options.namespace is specified 1`] = `"Spaces currently determines the namespaces"`; - -exports[`space_1 space #update throws error if type is space 1`] = `"Spaces can not be accessed using the SavedObjectsClient"`; diff --git a/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.test.ts b/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.test.ts index 0e298f4367d4a..40cd3200e8f2a 100644 --- a/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.test.ts +++ b/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.test.ts @@ -54,21 +54,6 @@ const createSpacesService = async (spaceId: string) => { ).rejects.toThrowErrorMatchingSnapshot(); }); - test(`throws error if type is space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect(client.get('space', '')).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`supplements options with undefined namespace`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); @@ -114,23 +99,6 @@ const createSpacesService = async (spaceId: string) => { ).rejects.toThrowErrorMatchingSnapshot(); }); - test(`throws error if objects type is space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect( - client.bulkGet([{ id: '', type: 'foo' }, { id: '', type: 'space' }], { namespace: 'bar' }) - ).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`supplements options with undefined namespace`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); @@ -174,23 +142,6 @@ const createSpacesService = async (spaceId: string) => { await expect(client.find({ namespace: 'bar' })).rejects.toThrowErrorMatchingSnapshot(); }); - test(`throws error if options.type is space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const expectedReturnValue = Symbol(); - baseClient.find.mockReturnValue(expectedReturnValue); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect(client.find({ type: 'space' })).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`passes options.type to baseClient if valid singular type specified`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); @@ -215,44 +166,6 @@ const createSpacesService = async (spaceId: string) => { }); }); - test(`throws error if options.type is array containing space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const expectedReturnValue = Symbol(); - baseClient.find.mockReturnValue(expectedReturnValue); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect( - client.find({ type: ['space', 'foo'] }) - ).rejects.toThrowErrorMatchingSnapshot(); - }); - - test(`if options.type isn't provided specifies options.type based on the types excluding the space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const expectedReturnValue = Symbol(); - baseClient.find.mockReturnValue(expectedReturnValue); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect( - client.find({ type: ['space', 'foo'] }) - ).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`supplements options with undefined namespace`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); @@ -296,21 +209,6 @@ const createSpacesService = async (spaceId: string) => { ).rejects.toThrowErrorMatchingSnapshot(); }); - test(`throws error if type is space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect(client.create('space', {})).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`supplements options with undefined namespace`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); @@ -357,26 +255,6 @@ const createSpacesService = async (spaceId: string) => { ).rejects.toThrowErrorMatchingSnapshot(); }); - test(`throws error if objects type is space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect( - client.bulkCreate([ - { id: '', type: 'foo', attributes: {} }, - { id: '', type: 'space', attributes: {} }, - ]) - ).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`supplements options with undefined namespace`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); @@ -423,21 +301,6 @@ const createSpacesService = async (spaceId: string) => { ).rejects.toThrowErrorMatchingSnapshot(); }); - test(`throws error if type is space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect(client.update('space', '', {})).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`supplements options with undefined namespace`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); @@ -486,21 +349,6 @@ const createSpacesService = async (spaceId: string) => { ).rejects.toThrowErrorMatchingSnapshot(); }); - test(`throws error if type is space`, async () => { - const request = createMockRequest(); - const baseClient = createMockClient(); - const spacesService = await createSpacesService(currentSpace.id); - - const client = new SpacesSavedObjectsClient({ - request, - baseClient, - spacesService, - types, - }); - - await expect(client.delete('space', 'foo')).rejects.toThrowErrorMatchingSnapshot(); - }); - test(`supplements options with undefined namespace`, async () => { const request = createMockRequest(); const baseClient = createMockClient(); diff --git a/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts b/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts index 009b0bbdac5f0..5027413f14154 100644 --- a/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts +++ b/x-pack/legacy/plugins/spaces/server/lib/saved_objects_client/spaces_saved_objects_client.ts @@ -38,18 +38,6 @@ const throwErrorIfNamespaceSpecified = (options: any) => { } }; -const throwErrorIfTypeIsSpace = (type: string) => { - if (type === 'space') { - throw new Error('Spaces can not be accessed using the SavedObjectsClient'); - } -}; - -const throwErrorIfTypesContainsSpace = (types: string[]) => { - for (const type of types) { - throwErrorIfTypeIsSpace(type); - } -}; - export class SpacesSavedObjectsClient implements SavedObjectsClientContract { private readonly client: SavedObjectsClientContract; private readonly spaceId: string; @@ -81,7 +69,6 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { attributes: T = {} as T, options: SavedObjectsCreateOptions = {} ) { - throwErrorIfTypeIsSpace(type); throwErrorIfNamespaceSpecified(options); return await this.client.create(type, attributes, { @@ -103,7 +90,6 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { objects: SavedObjectsBulkCreateObject[], options: SavedObjectsBaseOptions = {} ) { - throwErrorIfTypesContainsSpace(objects.map(object => object.type)); throwErrorIfNamespaceSpecified(options); return await this.client.bulkCreate(objects, { @@ -122,7 +108,6 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { * @returns {promise} */ public async delete(type: string, id: string, options: SavedObjectsBaseOptions = {}) { - throwErrorIfTypeIsSpace(type); throwErrorIfNamespaceSpecified(options); return await this.client.delete(type, id, { @@ -148,10 +133,6 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { * @returns {promise} - { saved_objects: [{ id, type, version, attributes }], total, per_page, page } */ public async find(options: SavedObjectsFindOptions = {}) { - if (options.type) { - throwErrorIfTypesContainsSpace(coerceToArray(options.type)); - } - throwErrorIfNamespaceSpecified(options); return await this.client.find({ @@ -181,7 +162,6 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { objects: SavedObjectsBulkGetObject[] = [], options: SavedObjectsBaseOptions = {} ) { - throwErrorIfTypesContainsSpace(objects.map(object => object.type)); throwErrorIfNamespaceSpecified(options); return await this.client.bulkGet(objects, { @@ -200,7 +180,6 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { * @returns {promise} - { id, type, version, attributes } */ public async get(type: string, id: string, options: SavedObjectsBaseOptions = {}) { - throwErrorIfTypeIsSpace(type); throwErrorIfNamespaceSpecified(options); return await this.client.get(type, id, { @@ -225,7 +204,6 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract { attributes: Partial, options: SavedObjectsUpdateOptions = {} ) { - throwErrorIfTypeIsSpace(type); throwErrorIfNamespaceSpecified(options); return await this.client.update(type, id, attributes, { diff --git a/x-pack/legacy/plugins/spaces/server/new_platform/spaces_service/spaces_service.ts b/x-pack/legacy/plugins/spaces/server/new_platform/spaces_service/spaces_service.ts index d801be4f5be09..74fff82f5cc70 100644 --- a/x-pack/legacy/plugins/spaces/server/new_platform/spaces_service/spaces_service.ts +++ b/x-pack/legacy/plugins/spaces/server/new_platform/spaces_service/spaces_service.ts @@ -93,12 +93,16 @@ export class SpacesService { .pipe( map(([clusterClient, config]) => { const internalRepository = savedObjects.getSavedObjectsRepository( - clusterClient.callAsInternalUser + clusterClient.callAsInternalUser, + ['space'] ); const callCluster = clusterClient.asScoped(request).callAsCurrentUser; - const callWithRequestRepository = savedObjects.getSavedObjectsRepository(callCluster); + const callWithRequestRepository = savedObjects.getSavedObjectsRepository( + callCluster, + ['space'] + ); const authorization = security.isEnabled ? security.authorization : null; diff --git a/x-pack/test/api_integration/apis/index.js b/x-pack/test/api_integration/apis/index.js index 4dd380a15c63a..8e3aa624e71fb 100644 --- a/x-pack/test/api_integration/apis/index.js +++ b/x-pack/test/api_integration/apis/index.js @@ -12,6 +12,7 @@ export default function ({ loadTestFile }) { loadTestFile(require.resolve('./alerting')); loadTestFile(require.resolve('./es')); loadTestFile(require.resolve('./security')); + loadTestFile(require.resolve('./spaces')); loadTestFile(require.resolve('./monitoring')); loadTestFile(require.resolve('./xpack_main')); loadTestFile(require.resolve('./telemetry')); diff --git a/x-pack/test/api_integration/apis/spaces/index.ts b/x-pack/test/api_integration/apis/spaces/index.ts new file mode 100644 index 0000000000000..1a4df65b0856e --- /dev/null +++ b/x-pack/test/api_integration/apis/spaces/index.ts @@ -0,0 +1,14 @@ +/* + * 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. + */ + +// eslint-disable-next-line import/no-default-export +export default function({ loadTestFile }: Record) { + describe('spaces', function() { + this.tags('ciGroup6'); + + loadTestFile(require.resolve('./saved_objects')); + }); +} diff --git a/x-pack/test/api_integration/apis/spaces/saved_objects.ts b/x-pack/test/api_integration/apis/spaces/saved_objects.ts new file mode 100644 index 0000000000000..b08d435627e10 --- /dev/null +++ b/x-pack/test/api_integration/apis/spaces/saved_objects.ts @@ -0,0 +1,101 @@ +/* + * 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 expect from '@kbn/expect/expect.js'; +import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers'; + +// eslint-disable-next-line import/no-default-export +export default function({ getService }: KibanaFunctionalTestDefaultProviders) { + const supertest = getService('supertest'); + + describe('`space` saved object type', () => { + describe('GET /api/saved_objects/space/default', () => { + it('should not return the default space', async () => { + await supertest + .get('/api/saved_objects/space/default') + .set('kbn-xsrf', 'xxx') + .send() + .expect(404) + .then((response: Record) => { + expect(response.body).to.eql({ + message: `Saved object [space/default] not found`, + statusCode: 404, + error: 'Not Found', + }); + }); + }); + }); + + describe('GET /api/saved_objects/_find?type=space', () => { + it('should not locate any spaces', async () => { + await supertest + .get('/api/saved_objects/_find?type=space') + .set('kbn-xsrf', 'xxx') + .send() + .expect(200) + .then((response: Record) => { + expect(response.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + }); + }); + }); + + describe('POST /api/saved_objects/space/my-space', () => { + it('should not allow a space to be created', async () => { + await supertest + .post('/api/saved_objects/space/my-space') + .set('kbn-xsrf', 'xxx') + .send({ attributes: {} }) + .expect(400) + .then((response: Record) => { + expect(response.body).to.eql({ + message: "Unsupported saved object type: 'space': Bad Request", + statusCode: 400, + error: 'Bad Request', + }); + }); + }); + }); + + describe('PUT /api/saved_objects/space/default', () => { + it('should not allow a space to be updated', async () => { + await supertest + .post('/api/saved_objects/space/default') + .set('kbn-xsrf', 'xxx') + .send({ attributes: {} }) + .expect(400) + .then((response: Record) => { + expect(response.body).to.eql({ + message: "Unsupported saved object type: 'space': Bad Request", + statusCode: 400, + error: 'Bad Request', + }); + }); + }); + }); + + describe('DELETE /api/saved_objects/space/default', () => { + it('should not allow a space to be deleted', async () => { + await supertest + .delete('/api/saved_objects/space/default') + .set('kbn-xsrf', 'xxx') + .send() + .expect(404) + .then((response: Record) => { + expect(response.body).to.eql({ + message: 'Not Found', + statusCode: 404, + error: 'Not Found', + }); + }); + }); + }); + }); +} 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 8dc2c336b0ee1..8c2a99b975011 100644 --- a/x-pack/test/saved_object_api_integration/common/config.ts +++ b/x-pack/test/saved_object_api_integration/common/config.ts @@ -65,6 +65,7 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) '--optimize.enabled=false', '--server.xsrf.disableProtection=true', `--plugin-path=${path.join(__dirname, 'fixtures', 'namespace_agnostic_type_plugin')}`, + `--plugin-path=${path.join(__dirname, 'fixtures', 'hidden_type_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 new file mode 100644 index 0000000000000..f95967700b7a5 --- /dev/null +++ b/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/index.js @@ -0,0 +1,25 @@ +/* + * 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() {}, + }); +} 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 new file mode 100644 index 0000000000000..e4815273964a1 --- /dev/null +++ b/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/mappings.json @@ -0,0 +1,15 @@ +{ + "hiddentype": { + "properties": { + "name": { + "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 new file mode 100644 index 0000000000000..009bae982ee15 --- /dev/null +++ b/x-pack/test/saved_object_api_integration/common/fixtures/hidden_type_plugin/package.json @@ -0,0 +1,7 @@ +{ + "name": "hidden_type_plugin", + "version": "0.0.0", + "kibana": { + "version": "kibana" + } +} diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts index 080aeef930c29..e2ec45151418d 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts @@ -24,6 +24,7 @@ interface BulkCreateCustomTest extends BulkCreateTest { interface BulkCreateTests { default: BulkCreateTest; + includingSpace: BulkCreateTest; custom?: BulkCreateCustomTest; } @@ -132,11 +133,35 @@ export function bulkCreateTestSuiteFactory(es: any, esArchiver: any, supertest: } }; - const expectRbacForbidden = (resp: { [key: string]: any }) => { + const expectBadRequestForHiddenType = (resp: { [key: string]: any }) => { + const spaceEntry = resp.body.saved_objects.find( + (entry: any) => entry.id === 'my-hiddentype' && entry.type === 'hiddentype' + ); + expect(spaceEntry).to.eql({ + id: 'my-hiddentype', + type: 'hiddentype', + error: { + message: "Unsupported saved object type: 'hiddentype': Bad Request", + statusCode: 400, + error: 'Bad Request', + }, + }); + }; + + const expectedForbiddenTypes = ['dashboard', 'globaltype', 'visualization']; + const expectedForbiddenTypesWithHiddenType = [ + 'dashboard', + 'globaltype', + 'hiddentype', + 'visualization', + ]; + const createExpectRbacForbidden = (types: string[] = expectedForbiddenTypes) => (resp: { + [key: string]: any; + }) => { expect(resp.body).to.eql({ statusCode: 403, error: 'Forbidden', - message: `Unable to bulk_create dashboard,globaltype,visualization`, + message: `Unable to bulk_create ${types.join(',')}`, }); }; @@ -159,6 +184,25 @@ export function bulkCreateTestSuiteFactory(es: any, esArchiver: any, supertest: .then(tests.default.response); }); + it(`including a hiddentype saved object should return ${tests.includingSpace.statusCode}`, async () => { + await supertest + .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_create`) + .auth(user.username, user.password) + .send( + createBulkRequests(spaceId).concat([ + { + type: 'hiddentype', + id: `my-hiddentype`, + attributes: { + name: 'My awesome hiddentype', + }, + }, + ]) + ) + .expect(tests.includingSpace.statusCode) + .then(tests.includingSpace.response); + }); + if (tests.custom) { it(tests.custom!.description, async () => { await supertest @@ -179,6 +223,8 @@ export function bulkCreateTestSuiteFactory(es: any, esArchiver: any, supertest: return { bulkCreateTest, createExpectResults, - expectRbacForbidden, + createExpectRbacForbidden, + expectBadRequestForHiddenType, + expectedForbiddenTypesWithHiddenType, }; } diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts index 83f02ed083f6a..ab7babff8dead 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts @@ -17,6 +17,7 @@ interface BulkGetTest { interface BulkGetTests { default: BulkGetTest; + includingHiddenType: BulkGetTest; } interface BulkGetTestDefinition { @@ -75,11 +76,35 @@ export function bulkGetTestSuiteFactory(esArchiver: any, supertest: SuperTest { + const expectBadRequestForHiddenType = (resp: { [key: string]: any }) => { + const spaceEntry = resp.body.saved_objects.find( + (entry: any) => entry.id === 'my-hiddentype' && entry.type === 'hiddentype' + ); + expect(spaceEntry).to.eql({ + id: 'my-hiddentype', + type: 'hiddentype', + error: { + message: "Unsupported saved object type: 'hiddentype': Bad Request", + statusCode: 400, + error: 'Bad Request', + }, + }); + }; + + const expectedForbiddenTypes = ['dashboard', 'globaltype', 'visualization']; + const expectedForbiddenTypesWithHiddenType = [ + 'dashboard', + 'globaltype', + 'hiddentype', + 'visualization', + ]; + const createExpectRbacForbidden = (types: string[] = expectedForbiddenTypes) => (resp: { + [key: string]: any; + }) => { expect(resp.body).to.eql({ statusCode: 403, error: 'Forbidden', - message: `Unable to bulk_get dashboard,globaltype,visualization`, + message: `Unable to bulk_get ${types.join(',')}`, }); }; @@ -149,6 +174,22 @@ export function bulkGetTestSuiteFactory(esArchiver: any, supertest: SuperTest { + await supertest + .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_bulk_get`) + .auth(user.username, user.password) + .send( + createBulkRequests(otherSpaceId || spaceId).concat([ + { + type: 'hiddentype', + id: `my-hiddentype`, + }, + ]) + ) + .expect(tests.includingHiddenType.statusCode) + .then(tests.includingHiddenType.response); + }); }); }; @@ -160,6 +201,8 @@ export function bulkGetTestSuiteFactory(esArchiver: any, supertest: SuperTest { + expect(resp.body).to.eql({ + message: "Unsupported saved object type: 'hiddentype': Bad Request", + statusCode: 400, + error: 'Bad Request', + }); + }; + const createExpectSpaceAwareResults = (spaceId = DEFAULT_SPACE_ID) => async (resp: { [key: string]: any; }) => { @@ -123,6 +132,8 @@ export function createTestSuiteFactory(es: any, esArchiver: any, supertest: Supe const expectSpaceAwareRbacForbidden = createExpectRbacForbidden(spaceAwareType); + const expectHiddenTypeRbacForbidden = createExpectRbacForbidden('hiddentype'); + const makeCreateTest = (describeFn: DescribeFn) => ( description: string, definition: CreateTestDefinition @@ -157,6 +168,19 @@ export function createTestSuiteFactory(es: any, esArchiver: any, supertest: Supe .then(tests.notSpaceAware.response); }); + it(`should return ${tests.hiddenType.statusCode} for the hiddentype`, async () => { + await supertest + .post(`${getUrlPrefix(spaceId)}/api/saved_objects/hiddentype`) + .auth(user.username, user.password) + .send({ + attributes: { + name: `Can't be created via the Saved Objects API`, + }, + }) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response); + }); + if (tests.custom) { it(tests.custom.description, async () => { await supertest @@ -180,5 +204,7 @@ export function createTestSuiteFactory(es: any, esArchiver: any, supertest: Supe expectNotSpaceAwareRbacForbidden, expectNotSpaceAwareResults, expectSpaceAwareRbacForbidden, + expectBadRequestForHiddenType, + expectHiddenTypeRbacForbidden, }; } diff --git a/x-pack/test/saved_object_api_integration/common/suites/delete.ts b/x-pack/test/saved_object_api_integration/common/suites/delete.ts index eac0a83b9347a..9581a2b3983ef 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/delete.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/delete.ts @@ -18,6 +18,7 @@ interface DeleteTest { interface DeleteTests { spaceAware: DeleteTest; notSpaceAware: DeleteTest; + hiddenType: DeleteTest; invalidId: DeleteTest; } @@ -47,6 +48,14 @@ export function deleteTestSuiteFactory(esArchiver: any, supertest: SuperTest { + expect(resp.body).to.eql({ + statusCode: 404, + error: 'Not Found', + message: `Not Found`, + }); + }; + const createExpectSpaceAwareNotFound = (spaceId: string = DEFAULT_SPACE_ID) => (resp: { [key: string]: any; }) => { @@ -69,6 +78,8 @@ export function deleteTestSuiteFactory(esArchiver: any, supertest: SuperTest ( description: string, definition: DeleteTestDefinition @@ -101,6 +112,13 @@ export function deleteTestSuiteFactory(esArchiver: any, supertest: SuperTest + await supertest + .delete(`${getUrlPrefix(spaceId)}/api/saved_objects/hiddentype/hiddentype_1`) + .auth(user.username, user.password) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response)); + it(`should return ${tests.invalidId.statusCode} when deleting an unknown doc`, async () => await supertest .delete( @@ -119,6 +137,7 @@ export function deleteTestSuiteFactory(esArchiver: any, supertest: SuperTest { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: `child \"objects\" fails because [\"objects\" at position 0 fails because [child \"type\" fails because [\"type\" must be one of [config, globaltype, map, canvas-workpad, canvas-element, index-pattern, visualization, search, dashboard, url]]]]`, + validation: { + source: 'payload', + keys: ['objects.0.type'], + }, + }); + }; + const createExpectVisualizationResults = (spaceId = DEFAULT_SPACE_ID) => (resp: { [key: string]: any; }) => { @@ -113,6 +126,24 @@ export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTest { + it(`should return ${tests.hiddenType.statusCode} with ${tests.hiddenType.description}`, async () => { + await supertest + .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_export`) + .send({ + objects: [ + { + type: 'hiddentype', + id: `hiddentype_1`, + }, + ], + }) + .auth(user.username, user.password) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response); + }); + }); + describe('no type or objects', () => { it(`should return ${tests.noTypeOrObjects.statusCode} with ${tests.noTypeOrObjects.description}`, async () => { await supertest @@ -132,6 +163,7 @@ export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTest) .expect(tests.notSpaceAwareType.statusCode) .then(tests.notSpaceAwareType.response)); + it(`finding a hiddentype should return ${tests.hiddenType.statusCode} with ${tests.hiddenType.description}`, async () => + await supertest + .get(`${getUrlPrefix(spaceId)}/api/saved_objects/_find?type=hiddentype&fields=name`) + .auth(user.username, user.password) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response)); + describe('unknown type', () => { it(`should return ${tests.unknownType.statusCode} with ${tests.unknownType.description}`, async () => await supertest diff --git a/x-pack/test/saved_object_api_integration/common/suites/get.ts b/x-pack/test/saved_object_api_integration/common/suites/get.ts index b60de1c079140..39bfc5df4d6e3 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/get.ts @@ -17,6 +17,7 @@ interface GetTest { interface GetTests { spaceAware: GetTest; notSpaceAware: GetTest; + hiddenType: GetTest; doesntExist: GetTest; } @@ -33,22 +34,24 @@ const doesntExistId = 'foobar'; export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) { const createExpectDoesntExistNotFound = (spaceId = DEFAULT_SPACE_ID) => { - return createExpectNotFound(doesntExistId, spaceId); + return createExpectNotFound('visualization', doesntExistId, spaceId); }; - const createExpectNotFound = (id: string, spaceId = DEFAULT_SPACE_ID) => (resp: { + const createExpectNotFound = (type: string, id: string, spaceId = DEFAULT_SPACE_ID) => (resp: { [key: string]: any; }) => { expect(resp.body).to.eql({ error: 'Not Found', - message: `Saved object [visualization/${getIdPrefix(spaceId)}${id}] not found`, + message: `Saved object [${type}/${getIdPrefix(spaceId)}${id}] not found`, statusCode: 404, }); }; - const createExpectNotSpaceAwareNotFound = (spaceId = DEFAULT_SPACE_ID) => { - return createExpectNotFound(spaceAwareId, spaceId); - }; + const expectHiddenTypeNotFound = createExpectNotFound( + 'hiddentype', + 'hiddentype_1', + DEFAULT_SPACE_ID + ); const createExpectNotSpaceAwareRbacForbidden = () => (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ @@ -82,11 +85,12 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) }; const createExpectSpaceAwareNotFound = (spaceId = DEFAULT_SPACE_ID) => { - return createExpectNotFound(spaceAwareId, spaceId); + return createExpectNotFound('visualization', spaceAwareId, spaceId); }; const expectSpaceAwareRbacForbidden = createExpectRbacForbidden('visualization'); const expectNotSpaceAwareRbacForbidden = createExpectRbacForbidden('globaltype'); + const expectHiddenTypeRbacForbidden = createExpectRbacForbidden('hiddentype'); const expectDoesntExistRbacForbidden = createExpectRbacForbidden('visualization'); const createExpectSpaceAwareResults = (spaceId = DEFAULT_SPACE_ID) => (resp: { @@ -139,7 +143,7 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) .then(tests.spaceAware.response); }); - it(`should return ${tests.notSpaceAware.statusCode} when deleting a non-space-aware doc`, async () => { + it(`should return ${tests.notSpaceAware.statusCode} when getting a non-space-aware doc`, async () => { await supertest .get(`${getUrlPrefix(spaceId)}/api/saved_objects/globaltype/${notSpaceAwareId}`) .auth(user.username, user.password) @@ -147,6 +151,14 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) .then(tests.notSpaceAware.response); }); + it(`should return ${tests.hiddenType.statusCode} when getting a hiddentype doc`, async () => { + await supertest + .get(`${getUrlPrefix(spaceId)}/api/saved_objects/hiddentype/hiddentype_1`) + .auth(user.username, user.password) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response); + }); + describe('document does not exist', () => { it(`should return ${tests.doesntExist.statusCode}`, async () => { await supertest @@ -169,14 +181,15 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) return { createExpectDoesntExistNotFound, - createExpectNotSpaceAwareNotFound, createExpectNotSpaceAwareRbacForbidden, createExpectNotSpaceAwareResults, createExpectSpaceAwareNotFound, createExpectSpaceAwareResults, + expectHiddenTypeNotFound, expectSpaceAwareRbacForbidden, expectNotSpaceAwareRbacForbidden, expectDoesntExistRbacForbidden, + expectHiddenTypeRbacForbidden, getTest, }; } diff --git a/x-pack/test/saved_object_api_integration/common/suites/import.ts b/x-pack/test/saved_object_api_integration/common/suites/import.ts index f3a484549d3e6..8e4ef61cf3c12 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/import.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/import.ts @@ -17,6 +17,7 @@ interface ImportTest { interface ImportTests { default: ImportTest; + hiddenType: ImportTest; unknownType: ImportTest; } @@ -53,7 +54,23 @@ export function importTestSuiteFactory(es: any, esArchiver: any, supertest: Supe }); }; - const expectUnknownType = (resp: { [key: string]: any }) => { + const expectResultsWithUnsupportedHiddenType = async (resp: { [key: string]: any }) => { + expect(resp.body).to.eql({ + success: false, + successCount: 2, + errors: [ + { + error: { + type: 'unsupported_type', + }, + id: '1', + type: 'hiddentype', + }, + ], + }); + }; + + const expectUnknownTypeUnsupported = (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ success: false, successCount: 2, @@ -70,6 +87,22 @@ export function importTestSuiteFactory(es: any, esArchiver: any, supertest: Supe }); }; + const expectHiddenTypeUnsupported = (resp: { [key: string]: any }) => { + expect(resp.body).to.eql({ + success: false, + successCount: 2, + errors: [ + { + id: '1', + type: 'hiddentype', + error: { + type: 'unsupported_type', + }, + }, + ], + }); + }; + const expectRbacForbidden = (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ statusCode: 403, @@ -102,6 +135,30 @@ export function importTestSuiteFactory(es: any, esArchiver: any, supertest: Supe .then(tests.default.response); }); + describe('hiddentype', () => { + it(`should return ${tests.hiddenType.statusCode}`, async () => { + const data = createImportData(spaceId); + data.push({ + type: 'hiddentype', + id: '1', + attributes: { + name: 'My Hidden Type', + }, + }); + await supertest + .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_import`) + .query({ overwrite: true }) + .auth(user.username, user.password) + .attach( + 'file', + Buffer.from(data.map(obj => JSON.stringify(obj)).join('\n'), 'utf8'), + 'export.ndjson' + ) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response); + }); + }); + describe('unknown type', () => { it(`should return ${tests.unknownType.statusCode}`, async () => { const data = createImportData(spaceId); @@ -135,7 +192,9 @@ export function importTestSuiteFactory(es: any, esArchiver: any, supertest: Supe return { importTest, createExpectResults, + expectResultsWithUnsupportedHiddenType, expectRbacForbidden, - expectUnknownType, + expectUnknownTypeUnsupported, + expectHiddenTypeUnsupported, }; } diff --git a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts index ab323ab0ae38d..8ae3a1258ab3a 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts @@ -17,6 +17,7 @@ interface ResolveImportErrorsTest { interface ResolveImportErrorsTests { default: ResolveImportErrorsTest; + hiddenType: ResolveImportErrorsTest; unknownType: ResolveImportErrorsTest; } @@ -57,7 +58,7 @@ export function resolveImportErrorsTestSuiteFactory( }); }; - const expectUnknownType = (resp: { [key: string]: any }) => { + const expectUnknownTypeUnsupported = (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ success: false, successCount: 1, @@ -74,6 +75,22 @@ export function resolveImportErrorsTestSuiteFactory( }); }; + const expectHiddenTypeUnsupported = (resp: { [key: string]: any }) => { + expect(resp.body).to.eql({ + success: false, + successCount: 1, + errors: [ + { + id: '1', + type: 'hiddentype', + error: { + type: 'unsupported_type', + }, + }, + ], + }); + }; + const expectRbacForbidden = (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ statusCode: 403, @@ -153,6 +170,43 @@ export function resolveImportErrorsTestSuiteFactory( .then(tests.unknownType.response); }); }); + describe('hidden type', () => { + it(`should return ${tests.hiddenType.statusCode}`, async () => { + const data = createImportData(spaceId); + data.push({ + type: 'hiddentype', + id: '1', + attributes: { + name: 'My Hidden Type', + }, + }); + await supertest + .post(`${getUrlPrefix(spaceId)}/api/saved_objects/_resolve_import_errors`) + .auth(user.username, user.password) + .field( + 'retries', + JSON.stringify([ + { + type: 'hiddentype', + id: '1', + overwrite: true, + }, + { + type: 'dashboard', + id: `${getIdPrefix(spaceId)}a01b2f57-fcfd-4864-b735-09e28f0d815e`, + overwrite: true, + }, + ]) + ) + .attach( + 'file', + Buffer.from(data.map(obj => JSON.stringify(obj)).join('\n'), 'utf8'), + 'export.ndjson' + ) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response); + }); + }); }); }; @@ -164,6 +218,7 @@ export function resolveImportErrorsTestSuiteFactory( resolveImportErrorsTest, createExpectResults, expectRbacForbidden, - expectUnknownType, + expectUnknownTypeUnsupported, + expectHiddenTypeUnsupported, }; } diff --git a/x-pack/test/saved_object_api_integration/common/suites/update.ts b/x-pack/test/saved_object_api_integration/common/suites/update.ts index a77b049d40dc3..7c4adb0225382 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/update.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/update.ts @@ -18,6 +18,7 @@ interface UpdateTest { interface UpdateTests { spaceAware: UpdateTest; notSpaceAware: UpdateTest; + hiddenType: UpdateTest; doesntExist: UpdateTest; } @@ -47,6 +48,12 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest (resp: { [key: string]: any }) => { expect(resp.body).to.eql({ statusCode: 403, @@ -59,6 +66,8 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest { // loose uuid validation expect(resp.body) @@ -150,6 +159,19 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest { + await supertest + .put(`${getUrlPrefix(otherSpaceId || spaceId)}/api/saved_objects/hiddentype/hiddentype_1`) + .auth(user.username, user.password) + .send({ + attributes: { + name: 'My favorite hidden type', + }, + }) + .expect(tests.hiddenType.statusCode) + .then(tests.hiddenType.response); + }); + describe('unknown id', () => { it(`should return ${tests.doesntExist.statusCode}`, async () => { await supertest @@ -178,11 +200,13 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest { [ @@ -60,7 +62,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -73,6 +79,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingSpace: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, }, }); @@ -82,7 +92,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -95,6 +109,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -104,7 +122,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -117,6 +139,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -126,7 +152,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -139,6 +169,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -148,7 +182,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -159,7 +197,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_get.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_get.ts index 0feb9567917c4..41651e4ea744e 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_get.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_get.ts @@ -14,10 +14,13 @@ export default function({ getService }: TestInvoker) { const supertest = getService('supertestWithoutAuth'); const esArchiver = getService('esArchiver'); - const { bulkGetTest, createExpectResults, expectRbacForbidden } = bulkGetTestSuiteFactory( - esArchiver, - supertest - ); + const { + bulkGetTest, + createExpectResults, + createExpectRbacForbidden, + expectBadRequestForHiddenType, + expectedForbiddenTypesWithHiddenType, + } = bulkGetTestSuiteFactory(esArchiver, supertest); describe('_bulk_get', () => { [ @@ -58,7 +61,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -71,6 +78,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingHiddenType: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, }, }); @@ -80,7 +91,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -93,6 +108,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -104,6 +123,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -115,6 +138,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -126,6 +153,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -137,6 +168,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -148,6 +183,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -157,7 +196,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/create.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/create.ts index 73119f346e3ae..a4013c8faf0f5 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/create.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/create.ts @@ -21,6 +21,8 @@ export default function({ getService }: TestInvoker) { expectNotSpaceAwareResults, expectNotSpaceAwareRbacForbidden, expectSpaceAwareRbacForbidden, + expectBadRequestForHiddenType, + expectHiddenTypeRbacForbidden, } = createTestSuiteFactory(es, esArchiver, supertestWithoutAuth); describe('create', () => { @@ -68,6 +70,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -83,6 +89,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 400, + response: expectBadRequestForHiddenType, + }, }, }); @@ -98,6 +108,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -113,6 +127,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -128,6 +146,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -143,6 +165,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -158,6 +184,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -173,6 +203,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -188,6 +222,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -203,6 +241,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); }); diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/delete.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/delete.ts index 6990b1e851744..2507161cf787c 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/delete.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/delete.ts @@ -22,6 +22,8 @@ export default function({ getService }: TestInvoker) { expectRbacSpaceAwareForbidden, expectRbacNotSpaceAwareForbidden, expectRbacInvalidIdForbidden, + expectGenericNotFound, + expectRbacHiddenTypeForbidden, } = deleteTestSuiteFactory(esArchiver, supertest); [ @@ -68,6 +70,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -87,6 +93,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 404, + response: expectGenericNotFound, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(scenario.spaceId), @@ -106,6 +116,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -125,6 +139,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(scenario.spaceId), @@ -144,6 +162,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -163,6 +185,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(scenario.spaceId), @@ -182,6 +208,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -201,6 +231,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(scenario.spaceId), @@ -220,6 +254,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -239,6 +277,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacHiddenTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/export.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/export.ts index 4e32aafeb8b27..50dd1dabbd2d2 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/export.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/export.ts @@ -19,6 +19,7 @@ export default function({ getService }: TestInvoker) { createExpectRbacForbidden, expectTypeOrObjectsRequired, createExpectVisualizationResults, + expectInvalidTypeSpecified, exportTest, } = exportTestSuiteFactory(esArchiver, supertest); @@ -63,6 +64,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -80,6 +86,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(scenario.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -97,6 +108,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -114,6 +130,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(scenario.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -131,6 +152,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(scenario.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -148,6 +174,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(scenario.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -165,6 +196,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(scenario.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -182,6 +218,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(scenario.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -199,6 +240,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(scenario.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -216,6 +262,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/find.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/find.ts index 59986fdad744b..6a1a60ba83e36 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/find.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/find.ts @@ -70,6 +70,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -107,6 +112,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'empty result', + statusCode: 200, + response: createExpectEmpty(1, 20, 0), + }, unknownType: { description: 'empty result', statusCode: 200, @@ -144,6 +154,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -181,6 +196,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -218,6 +238,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -255,6 +280,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -292,6 +322,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -329,6 +364,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -366,6 +406,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -403,6 +448,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/get.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/get.ts index 15d498b009dd7..e913ec064037c 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/get.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/get.ts @@ -21,6 +21,8 @@ export default function({ getService }: TestInvoker) { expectSpaceAwareRbacForbidden, expectNotSpaceAwareRbacForbidden, expectDoesntExistRbacForbidden, + expectHiddenTypeRbacForbidden, + expectHiddenTypeNotFound, getTest, } = getTestSuiteFactory(esArchiver, supertest); @@ -69,6 +71,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -88,6 +94,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(scenario.spaceId), }, + hiddenType: { + statusCode: 404, + response: expectHiddenTypeNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -107,6 +117,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -126,6 +140,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(scenario.spaceId), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -145,6 +163,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(scenario.spaceId), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -164,6 +186,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(scenario.spaceId), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -183,6 +209,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(scenario.spaceId), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -202,6 +232,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(scenario.spaceId), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -221,6 +255,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(scenario.spaceId), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -240,6 +278,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/import.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/import.ts index be9dd88ce3871..d336f65469ef4 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/import.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/import.ts @@ -19,7 +19,8 @@ export default function({ getService }: TestInvoker) { importTest, createExpectResults, expectRbacForbidden, - expectUnknownType, + expectUnknownTypeUnsupported: expectUnknownTypeUnsupported, + expectHiddenTypeUnsupported, } = importTestSuiteFactory(es, esArchiver, supertest); describe('_import', () => { @@ -63,6 +64,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -78,9 +83,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -93,6 +102,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -108,9 +121,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -123,6 +140,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -138,9 +159,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -153,6 +178,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -168,9 +197,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -183,6 +216,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -198,6 +235,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/resolve_import_errors.ts index 48065bc1f58fa..1ff7414b702f9 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/resolve_import_errors.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/resolve_import_errors.ts @@ -19,7 +19,8 @@ export default function({ getService }: TestInvoker) { resolveImportErrorsTest, createExpectResults, expectRbacForbidden, - expectUnknownType, + expectUnknownTypeUnsupported, + expectHiddenTypeUnsupported, } = resolveImportErrorsTestSuiteFactory(es, esArchiver, supertest); describe('_resolve_import_errors', () => { @@ -63,6 +64,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -78,9 +83,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -93,6 +102,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -108,9 +121,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -125,6 +142,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -141,9 +162,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -156,6 +181,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -173,9 +202,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(scenario.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, } @@ -191,6 +224,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -209,6 +246,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/update.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/update.ts index 650b05c754c70..13bc58ac00274 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/update.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/update.ts @@ -22,6 +22,8 @@ export default function({ getService }: TestInvoker) { expectNotSpaceAwareRbacForbidden, expectSpaceAwareRbacForbidden, expectSpaceAwareResults, + expectSpaceNotFound, + expectHiddenTypeRbacForbidden, updateTest, } = updateTestSuiteFactory(esArchiver, supertest); @@ -69,6 +71,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -88,6 +94,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 404, + response: expectSpaceNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -107,6 +117,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -126,6 +140,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -145,6 +163,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -164,6 +186,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -183,6 +209,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -202,6 +232,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(scenario.spaceId), @@ -221,6 +255,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -240,6 +278,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/bulk_create.ts b/x-pack/test/saved_object_api_integration/security_only/apis/bulk_create.ts index 30118ba9ecc39..9f6087b9a5699 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/bulk_create.ts @@ -14,11 +14,13 @@ export default function({ getService }: TestInvoker) { const esArchiver = getService('esArchiver'); const es = getService('es'); - const { bulkCreateTest, createExpectResults, expectRbacForbidden } = bulkCreateTestSuiteFactory( - es, - esArchiver, - supertest - ); + const { + bulkCreateTest, + createExpectResults, + createExpectRbacForbidden, + expectBadRequestForHiddenType, + expectedForbiddenTypesWithHiddenType: expectedForbiddenTypesWithHiddenType, + } = bulkCreateTestSuiteFactory(es, esArchiver, supertest); describe('_bulk_create', () => { bulkCreateTest(`user with no access`, { @@ -26,7 +28,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -38,6 +44,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingSpace: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, }, }); @@ -46,7 +56,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -58,6 +72,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -66,7 +84,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -78,6 +100,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -86,7 +112,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -96,7 +126,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -106,7 +140,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -116,7 +154,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -126,7 +168,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingSpace: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/bulk_get.ts b/x-pack/test/saved_object_api_integration/security_only/apis/bulk_get.ts index 9edc790702a1b..11b9ec6fc53af 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/bulk_get.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/bulk_get.ts @@ -13,10 +13,13 @@ export default function({ getService }: TestInvoker) { const supertest = getService('supertestWithoutAuth'); const esArchiver = getService('esArchiver'); - const { bulkGetTest, createExpectResults, expectRbacForbidden } = bulkGetTestSuiteFactory( - esArchiver, - supertest - ); + const { + bulkGetTest, + createExpectResults, + createExpectRbacForbidden, + expectedForbiddenTypesWithHiddenType, + expectBadRequestForHiddenType, + } = bulkGetTestSuiteFactory(esArchiver, supertest); describe('_bulk_get', () => { bulkGetTest(`user with no access`, { @@ -24,7 +27,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -36,6 +43,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingHiddenType: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, }, }); @@ -44,7 +55,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -56,6 +71,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -66,6 +85,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -76,6 +99,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -86,6 +113,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(['hiddentype']), + }, }, }); @@ -94,7 +125,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -104,7 +139,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -114,7 +153,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); @@ -124,7 +167,11 @@ export default function({ getService }: TestInvoker) { tests: { default: { statusCode: 403, - response: expectRbacForbidden, + response: createExpectRbacForbidden(), + }, + includingHiddenType: { + statusCode: 403, + response: createExpectRbacForbidden(expectedForbiddenTypesWithHiddenType), }, }, }); diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/create.ts b/x-pack/test/saved_object_api_integration/security_only/apis/create.ts index 0aafa976063ad..f80d0ef851629 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/create.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/create.ts @@ -20,6 +20,8 @@ export default function({ getService }: TestInvoker) { expectNotSpaceAwareResults, expectNotSpaceAwareRbacForbidden, expectSpaceAwareRbacForbidden, + expectBadRequestForHiddenType, + expectHiddenTypeRbacForbidden, } = createTestSuiteFactory(es, esArchiver, supertestWithoutAuth); describe('create', () => { @@ -34,6 +36,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -48,6 +54,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 400, + response: expectBadRequestForHiddenType, + }, }, }); @@ -62,6 +72,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -76,6 +90,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -90,6 +108,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -104,6 +126,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -118,6 +144,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -132,6 +162,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -146,6 +180,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -160,6 +198,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); @@ -174,6 +216,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, }, }); }); diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/delete.ts b/x-pack/test/saved_object_api_integration/security_only/apis/delete.ts index 8fb932518b8a2..79765b37fd806 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/delete.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/delete.ts @@ -21,6 +21,8 @@ export default function({ getService }: TestInvoker) { expectRbacSpaceAwareForbidden, expectRbacNotSpaceAwareForbidden, expectRbacInvalidIdForbidden, + expectRbacHiddenTypeForbidden: expectRbacSpaceTypeForbidden, + expectGenericNotFound, } = deleteTestSuiteFactory(esArchiver, supertest); deleteTest(`user with no access`, { @@ -34,6 +36,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -52,6 +58,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 404, + response: expectGenericNotFound, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(), @@ -70,6 +80,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -88,6 +102,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(), @@ -106,6 +124,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -124,6 +146,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(), @@ -142,6 +168,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -160,6 +190,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -178,6 +212,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -196,6 +234,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, @@ -214,6 +256,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacNotSpaceAwareForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacSpaceTypeForbidden, + }, invalidId: { statusCode: 403, response: expectRbacInvalidIdForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/export.ts b/x-pack/test/saved_object_api_integration/security_only/apis/export.ts index d7deb6a86cb97..f6e1d033218d7 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/export.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/export.ts @@ -18,6 +18,7 @@ export default function({ getService }: TestInvoker) { createExpectRbacForbidden, expectTypeOrObjectsRequired, createExpectVisualizationResults, + expectInvalidTypeSpecified, exportTest, } = exportTestSuiteFactory(esArchiver, supertest); @@ -29,6 +30,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -45,6 +51,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -61,6 +72,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -77,6 +93,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -93,6 +114,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -109,6 +135,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -125,6 +156,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -141,6 +177,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -157,6 +198,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -173,6 +219,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -189,6 +240,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('visualization'), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/find.ts b/x-pack/test/saved_object_api_integration/security_only/apis/find.ts index a7d939daf2b2a..3d14f7b945a2b 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/find.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/find.ts @@ -36,6 +36,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden login and find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -72,6 +77,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'empty result', + statusCode: 200, + response: createExpectEmpty(1, 20, 0), + }, unknownType: { description: 'empty result', statusCode: 200, @@ -108,6 +118,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden login and find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -144,6 +159,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -180,6 +200,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -216,6 +241,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -252,6 +282,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -288,6 +323,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -324,6 +364,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -360,6 +405,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, @@ -396,6 +446,11 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: createExpectRbacForbidden('globaltype'), }, + hiddenType: { + description: 'forbidden find hiddentype message', + statusCode: 403, + response: createExpectRbacForbidden('hiddentype'), + }, unknownType: { description: 'forbidden find wigwags message', statusCode: 403, diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/get.ts b/x-pack/test/saved_object_api_integration/security_only/apis/get.ts index 458e62a404219..91c9f7cb5cf8e 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/get.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/get.ts @@ -20,6 +20,8 @@ export default function({ getService }: TestInvoker) { expectSpaceAwareRbacForbidden, expectNotSpaceAwareRbacForbidden, expectDoesntExistRbacForbidden, + expectHiddenTypeRbacForbidden, + expectHiddenTypeNotFound, getTest, } = getTestSuiteFactory(esArchiver, supertest); @@ -31,6 +33,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, notSpaceAware: { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, @@ -53,6 +59,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(), }, + hiddenType: { + statusCode: 404, + response: expectHiddenTypeNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -71,6 +81,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -89,6 +103,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -107,6 +125,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -125,6 +147,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -143,6 +169,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(), }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -161,6 +191,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -179,6 +213,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -197,6 +235,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -215,6 +257,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/import.ts b/x-pack/test/saved_object_api_integration/security_only/apis/import.ts index 7ff0079fb0acf..c988b4d006ac7 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/import.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/import.ts @@ -18,7 +18,8 @@ export default function({ getService }: TestInvoker) { importTest, createExpectResults, expectRbacForbidden, - expectUnknownType, + expectUnknownTypeUnsupported, + expectResultsWithUnsupportedHiddenType, } = importTestSuiteFactory(es, esArchiver, supertest); describe('_import', () => { @@ -29,6 +30,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -43,9 +48,14 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + hiddenType: { + // import filters out the space type, so the remaining objects will import successfully + statusCode: 200, + response: expectResultsWithUnsupportedHiddenType, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -57,6 +67,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -71,9 +85,14 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + hiddenType: { + // import filters out the space type, so the remaining objects will import successfully + statusCode: 200, + response: expectResultsWithUnsupportedHiddenType, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -85,6 +104,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -99,9 +122,14 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + hiddenType: { + // import filters out the space type, so the remaining objects will import successfully + statusCode: 200, + response: expectResultsWithUnsupportedHiddenType, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -113,6 +141,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -127,6 +159,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -141,6 +177,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -155,6 +195,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -169,6 +213,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/security_only/apis/resolve_import_errors.ts index 20013b10301aa..08b7a15c292b7 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/resolve_import_errors.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/resolve_import_errors.ts @@ -17,8 +17,10 @@ export default function({ getService }: TestInvoker) { const { resolveImportErrorsTest, createExpectResults, + expectRbacForbidden, - expectUnknownType, + expectUnknownTypeUnsupported, + expectHiddenTypeUnsupported, } = resolveImportErrorsTestSuiteFactory(es, esArchiver, supertest); describe('_resolve_import_errors', () => { @@ -29,6 +31,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -43,9 +49,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -57,6 +67,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -71,9 +85,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -85,6 +103,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -99,9 +121,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -113,6 +139,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -127,6 +157,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -141,6 +175,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -155,6 +193,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, @@ -169,6 +211,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectRbacForbidden, + }, unknownType: { statusCode: 403, response: expectRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/security_only/apis/update.ts b/x-pack/test/saved_object_api_integration/security_only/apis/update.ts index 4aa7b9c937d29..d98c8ae1ef5ee 100644 --- a/x-pack/test/saved_object_api_integration/security_only/apis/update.ts +++ b/x-pack/test/saved_object_api_integration/security_only/apis/update.ts @@ -21,6 +21,8 @@ export default function({ getService }: TestInvoker) { expectNotSpaceAwareRbacForbidden, expectSpaceAwareRbacForbidden, expectSpaceAwareResults, + expectSpaceNotFound, + expectHiddenTypeRbacForbidden, updateTest, } = updateTestSuiteFactory(esArchiver, supertest); @@ -35,6 +37,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -53,6 +59,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 404, + response: expectSpaceNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -71,6 +81,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -89,6 +103,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -107,6 +125,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -125,6 +147,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(), @@ -143,6 +169,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -161,6 +191,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -179,6 +213,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -197,6 +235,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, @@ -215,6 +257,10 @@ export default function({ getService }: TestInvoker) { statusCode: 403, response: expectNotSpaceAwareRbacForbidden, }, + hiddenType: { + statusCode: 403, + response: expectHiddenTypeRbacForbidden, + }, doesntExist: { statusCode: 403, response: expectDoesntExistRbacForbidden, diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts index 7b22ae0ef54b8..5a1afd28d10f8 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts @@ -28,11 +28,11 @@ export default function({ getService }: TestInvoker) { const esArchiver = getService('esArchiver'); const es = getService('es'); - const { bulkCreateTest, createExpectResults } = bulkCreateTestSuiteFactory( - es, - esArchiver, - supertest - ); + const { + bulkCreateTest, + createExpectResults, + expectBadRequestForHiddenType, + } = bulkCreateTestSuiteFactory(es, esArchiver, supertest); describe('_bulk_create', () => { bulkCreateTest('in the current space (space_1)', { @@ -42,6 +42,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(SPACES.SPACE_1.spaceId), }, + includingSpace: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, custom: { description: 'when a namespace is specified on the saved object', requestBody: [ @@ -66,6 +70,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(SPACES.DEFAULT.spaceId), }, + includingSpace: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, custom: { description: 'when a namespace is specified on the saved object', requestBody: [ diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_get.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_get.ts index 7855ddecc233d..bbe86109d981b 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_get.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_get.ts @@ -13,10 +13,12 @@ export default function({ getService }: TestInvoker) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); - const { bulkGetTest, createExpectResults, createExpectNotFoundResults } = bulkGetTestSuiteFactory( - esArchiver, - supertest - ); + const { + bulkGetTest, + createExpectResults, + createExpectNotFoundResults, + expectBadRequestForHiddenType, + } = bulkGetTestSuiteFactory(esArchiver, supertest); describe('_bulk_get', () => { bulkGetTest(`objects within the current space (space_1)`, { @@ -26,6 +28,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(SPACES.SPACE_1.spaceId), }, + includingHiddenType: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, }, }); @@ -37,6 +43,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotFoundResults(SPACES.SPACE_2.spaceId), }, + includingHiddenType: { + statusCode: 200, + response: expectBadRequestForHiddenType, + }, }, }); }); diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/create.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/create.ts index e77b498f7569c..edba7ca45f564 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/create.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/create.ts @@ -31,6 +31,7 @@ export default function({ getService }: TestInvoker) { createTest, createExpectSpaceAwareResults, expectNotSpaceAwareResults, + expectBadRequestForHiddenType, } = createTestSuiteFactory(es, esArchiver, supertestWithoutAuth); describe('create', () => { @@ -45,6 +46,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 400, + response: expectBadRequestForHiddenType, + }, custom: { description: 'when a namespace is specified on the saved object', type: 'visualization', @@ -71,6 +76,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 400, + response: expectBadRequestForHiddenType, + }, custom: { description: 'when a namespace is specified on the saved object', type: 'visualization', diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/delete.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/delete.ts index f75cd37aca852..cb08d5c12aa23 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/delete.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/delete.ts @@ -19,6 +19,7 @@ export default function({ getService }: TestInvoker) { createExpectUnknownDocNotFound, deleteTest, expectEmpty, + expectGenericNotFound, } = deleteTestSuiteFactory(esArchiver, supertest); deleteTest(`in the default space`, { @@ -32,6 +33,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 404, + response: expectGenericNotFound, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(SPACES.DEFAULT.spaceId), @@ -50,6 +55,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 404, + response: expectGenericNotFound, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(SPACES.SPACE_1.spaceId), @@ -69,6 +78,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectEmpty, }, + hiddenType: { + statusCode: 404, + response: expectGenericNotFound, + }, invalidId: { statusCode: 404, response: createExpectUnknownDocNotFound(SPACES.SPACE_2.spaceId), diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/export.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/export.ts index 21247d10e8ead..5149888424f17 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/export.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/export.ts @@ -16,6 +16,7 @@ export default function({ getService }: TestInvoker) { const { expectTypeOrObjectsRequired, createExpectVisualizationResults, + expectInvalidTypeSpecified, exportTest, } = exportTestSuiteFactory(esArchiver, supertest); @@ -28,6 +29,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(SPACES.SPACE_1.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, @@ -44,6 +50,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectVisualizationResults(SPACES.DEFAULT.spaceId), }, + hiddenType: { + description: 'exporting space not allowed', + statusCode: 400, + response: expectInvalidTypeSpecified, + }, noTypeOrObjects: { description: 'bad request, type or object is required', statusCode: 400, diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/find.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/find.ts index 1e80e410686ec..7a9e459ade652 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/find.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/find.ts @@ -35,6 +35,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'empty result', + statusCode: 200, + response: createExpectEmpty(1, 20, 0), + }, unknownType: { description: 'empty result', statusCode: 200, @@ -71,6 +76,11 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + description: 'empty result', + statusCode: 200, + response: createExpectEmpty(1, 20, 0), + }, unknownType: { description: 'empty result', statusCode: 200, diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/get.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/get.ts index c9b87e8950586..bd1c3d03a2d31 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/get.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/get.ts @@ -18,6 +18,7 @@ export default function({ getService }: TestInvoker) { createExpectSpaceAwareNotFound, createExpectSpaceAwareResults, createExpectNotSpaceAwareResults, + expectHiddenTypeNotFound: expectHiddenTypeNotFound, getTest, } = getTestSuiteFactory(esArchiver, supertest); @@ -33,6 +34,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(SPACES.DEFAULT.spaceId), }, + hiddenType: { + statusCode: 404, + response: expectHiddenTypeNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(SPACES.DEFAULT.spaceId), @@ -51,6 +56,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(SPACES.SPACE_1.spaceId), }, + hiddenType: { + statusCode: 404, + response: expectHiddenTypeNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(SPACES.SPACE_1.spaceId), @@ -70,6 +79,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectNotSpaceAwareResults(SPACES.SPACE_1.spaceId), }, + hiddenType: { + statusCode: 404, + response: expectHiddenTypeNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(SPACES.SPACE_1.spaceId), diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/import.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/import.ts index ceba14bdf5174..1e905fee86664 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/import.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/import.ts @@ -14,11 +14,12 @@ export default function({ getService }: TestInvoker) { const esArchiver = getService('esArchiver'); const es = getService('es'); - const { importTest, createExpectResults, expectUnknownType } = importTestSuiteFactory( - es, - esArchiver, - supertest - ); + const { + importTest, + createExpectResults, + expectUnknownTypeUnsupported, + expectHiddenTypeUnsupported, + } = importTestSuiteFactory(es, esArchiver, supertest); describe('_import', () => { importTest('in the current space (space_1)', { @@ -28,9 +29,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(SPACES.SPACE_1.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -42,9 +47,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(SPACES.DEFAULT.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/resolve_import_errors.ts index 1a34a0b76118a..e500f555725b0 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/resolve_import_errors.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/resolve_import_errors.ts @@ -17,7 +17,8 @@ export default function({ getService }: TestInvoker) { const { resolveImportErrorsTest, createExpectResults, - expectUnknownType, + expectUnknownTypeUnsupported, + expectHiddenTypeUnsupported, } = resolveImportErrorsTestSuiteFactory(es, esArchiver, supertest); describe('_resolve_import_errors', () => { @@ -28,9 +29,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(SPACES.SPACE_1.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); @@ -42,9 +47,13 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: createExpectResults(SPACES.DEFAULT.spaceId), }, + hiddenType: { + statusCode: 200, + response: expectHiddenTypeUnsupported, + }, unknownType: { statusCode: 200, - response: expectUnknownType, + response: expectUnknownTypeUnsupported, }, }, }); diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/update.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/update.ts index a55e6a636bf51..bc53c5a0ba7db 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/update.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/update.ts @@ -19,6 +19,7 @@ export default function({ getService }: TestInvoker) { expectSpaceAwareResults, createExpectDoesntExistNotFound, expectNotSpaceAwareResults, + expectSpaceNotFound, updateTest, } = updateTestSuiteFactory(esArchiver, supertest); @@ -33,6 +34,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 404, + response: expectSpaceNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(SPACES.DEFAULT.spaceId), @@ -51,6 +56,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 404, + response: expectSpaceNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(SPACES.SPACE_1.spaceId), @@ -70,6 +79,10 @@ export default function({ getService }: TestInvoker) { statusCode: 200, response: expectNotSpaceAwareResults, }, + hiddenType: { + statusCode: 404, + response: expectSpaceNotFound, + }, doesntExist: { statusCode: 404, response: createExpectDoesntExistNotFound(),