diff --git a/test/api_integration/apis/saved_objects_management/find.ts b/test/api_integration/apis/saved_objects_management/find.ts index 0b744b7991b38f..8822c444f124ef 100644 --- a/test/api_integration/apis/saved_objects_management/find.ts +++ b/test/api_integration/apis/saved_objects_management/find.ts @@ -202,7 +202,7 @@ export default function ({ getService }: FtrProviderContext) { path: '/app/dashboards#/view/b70c7ae0-3224-11e8-a572-ffca06da1357', uiCapabilitiesPath: 'dashboard.show', }, - namespaceType: 'single', + namespaceType: 'multiple-isolated', }); })); diff --git a/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/data.json b/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/data.json index 3b2a87d924e88a..f98a17d22f2c76 100644 --- a/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/data.json +++ b/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/data.json @@ -56,15 +56,11 @@ { "type": "_doc", "value": { - "id": "space_2:dashboard:my_dashboard", + "id": "isolatedtype:my_isolated_object", "index": ".kibana", "source": { - "dashboard": { - "description": "Space 2", - "title": "This is the second test space" - }, "namespace": "space_2", - "type": "dashboard", + "type": "isolatedtype", "updated_at": "2017-09-21T18:49:16.270Z" }, "type": "_doc" @@ -74,15 +70,11 @@ { "type": "_doc", "value": { - "id": "space_1:dashboard:my_dashboard", + "id": "isolatedtype:my_isolated_object", "index": ".kibana", "source": { - "dashboard": { - "description": "Space 1", - "title": "This is the second test space" - }, "namespace": "space_1", - "type": "dashboard", + "type": "isolatedtype", "updated_at": "2017-09-21T18:49:16.270Z" }, "type": "_doc" @@ -92,14 +84,10 @@ { "type": "_doc", "value": { - "id": "dashboard:my_dashboard", + "id": "isolatedtype:my_isolated_object", "index": ".kibana", "source": { - "dashboard": { - "description": "Default Space", - "title": "This is the default test space" - }, - "type": "dashboard", + "type": "isolatedtype", "updated_at": "2017-09-21T18:49:16.270Z" }, "type": "_doc" @@ -109,9 +97,10 @@ { "type": "_doc", "value": { - "id": "dashboard:cts_dashboard", + "id": "dashboard:cts_dashboard_default", "index": ".kibana", "source": { + "originId": "cts_dashboard", "dashboard": { "description": "Copy to Space Dashboard from the default space", "title": "This is the default test space CTS dashboard" @@ -130,7 +119,8 @@ "name": "CTS Vis 3" }], "type": "dashboard", - "updated_at": "2017-09-21T18:49:16.270Z" + "updated_at": "2017-09-21T18:49:16.270Z", + "namespaces": ["default"] }, "type": "_doc" } @@ -227,9 +217,10 @@ { "type": "_doc", "value": { - "id": "space_1:dashboard:cts_dashboard", + "id": "dashboard:cts_dashboard_space_1", "index": ".kibana", "source": { + "originId": "cts_dashboard", "dashboard": { "description": "Copy to Space Dashboard from space_1 space", "title": "This is the space_1 test space CTS dashboard" @@ -253,7 +244,7 @@ ], "type": "dashboard", "updated_at": "2017-09-21T18:49:16.270Z", - "namespace": "space_1" + "namespaces": ["space_1"] }, "type": "_doc" } diff --git a/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/plugin.ts b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/plugin.ts index a0021e9eedb5e3..88c168b6f62979 100644 --- a/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/plugin.ts +++ b/x-pack/test/spaces_api_integration/common/fixtures/spaces_test_plugin/server/plugin.ts @@ -29,6 +29,23 @@ export class Plugin { }, }, }); + core.savedObjects.registerType({ + name: 'isolatedtype', + hidden: false, + namespaceType: 'single', + management: { + icon: 'beaker', + importableAndExportable: true, + getTitle(obj) { + return obj.attributes.title; + }, + }, + mappings: { + properties: { + title: { type: 'text' }, + }, + }, + }); } public start() { diff --git a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts index 3a3f0f889c91c4..bce548d4f4f8c1 100644 --- a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts +++ b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts @@ -64,9 +64,8 @@ interface SpaceBucket { } const INITIAL_COUNTS: Record> = { - [DEFAULT_SPACE_ID]: { dashboard: 2, visualization: 3, 'index-pattern': 1 }, - space_1: { dashboard: 2, visualization: 3, 'index-pattern': 1 }, - space_2: { dashboard: 1 }, + [DEFAULT_SPACE_ID]: { dashboard: 1, visualization: 3, 'index-pattern': 1 }, + space_1: { dashboard: 1, visualization: 3, 'index-pattern': 1 }, }; const UUID_PATTERN = new RegExp( /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i @@ -148,18 +147,23 @@ export function copyToSpaceTestSuiteFactory( (spaceId: string, destination: string, expectedDashboardCount: number) => async (resp: TestResponse) => { const result = resp.body as CopyResponse; + + const dashboardDestinationId = result[destination].successResults![0].destinationId; + expect(dashboardDestinationId).to.match(UUID_PATTERN); // this was copied to space 2 and hit an unresolvable conflict, so the object ID was regenerated silently / the destinationId is a UUID + expect(result).to.eql({ [destination]: { success: true, successCount: 1, successResults: [ { - id: 'cts_dashboard', + id: `cts_dashboard_${spaceId}`, type: 'dashboard', meta: { title: `This is the ${spaceId} test space CTS dashboard`, icon: 'dashboardApp', }, + destinationId: dashboardDestinationId, }, ], }, @@ -172,7 +176,7 @@ export function copyToSpaceTestSuiteFactory( }; const expectNoConflictsWithoutReferencesResult = (spaceId: string = DEFAULT_SPACE_ID) => - createExpectNoConflictsWithoutReferencesForSpace(spaceId, getDestinationWithoutConflicts(), 2); + createExpectNoConflictsWithoutReferencesForSpace(spaceId, getDestinationWithoutConflicts(), 1); const expectNoConflictsForNonExistentSpaceResult = (spaceId: string = DEFAULT_SPACE_ID) => createExpectNoConflictsWithoutReferencesForSpace(spaceId, 'non_existent_space', 1); @@ -189,6 +193,8 @@ export function copyToSpaceTestSuiteFactory( expect(vis2DestinationId).to.match(UUID_PATTERN); // this was copied to space 2 and hit an unresolvable conflict, so the object ID was regenerated silently / the destinationId is a UUID const vis3DestinationId = result[destination].successResults![3].destinationId; expect(vis3DestinationId).to.match(UUID_PATTERN); // this was copied to space 2 and hit an unresolvable conflict, so the object ID was regenerated silently / the destinationId is a UUID + const dashboardDestinationId = result[destination].successResults![4].destinationId; + expect(dashboardDestinationId).to.match(UUID_PATTERN); // this was copied to space 2 and hit an unresolvable conflict, so the object ID was regenerated silently / the destinationId is a UUID expect(result).to.eql({ [destination]: { @@ -222,12 +228,13 @@ export function copyToSpaceTestSuiteFactory( destinationId: vis3DestinationId, }, { - id: 'cts_dashboard', + id: `cts_dashboard_${spaceId}`, type: 'dashboard', meta: { icon: 'dashboardApp', title: `This is the ${spaceId} test space CTS dashboard`, }, + destinationId: dashboardDestinationId, }, ], }, @@ -235,7 +242,7 @@ export function copyToSpaceTestSuiteFactory( // Query ES to ensure that we copied everything we expected await assertSpaceCounts(destination, { - dashboard: 2, + dashboard: 1, visualization: 3, 'index-pattern': 1, }); @@ -349,13 +356,14 @@ export function copyToSpaceTestSuiteFactory( destinationId: `cts_vis_3_${destination}`, // this conflicted with another visualization in the destination space because of a shared originId }, { - id: 'cts_dashboard', + id: `cts_dashboard_${spaceId}`, type: 'dashboard', meta: { icon: 'dashboardApp', title: `This is the ${spaceId} test space CTS dashboard`, }, overwrite: true, + destinationId: `cts_dashboard_${destination}`, // this conflicted with another dashboard in the destination space because of a shared originId }, ], }, @@ -363,7 +371,7 @@ export function copyToSpaceTestSuiteFactory( // Query ES to ensure that we copied everything we expected await assertSpaceCounts(destination, { - dashboard: 2, + dashboard: 1, visualization: 5, 'index-pattern': 1, }); @@ -399,8 +407,11 @@ export function copyToSpaceTestSuiteFactory( ]; const expectedErrors = [ { - error: { type: 'conflict' }, - id: 'cts_dashboard', + error: { + type: 'conflict', + destinationId: `cts_dashboard_${destination}`, // this conflicted with another dashboard in the destination space because of a shared originId + }, + id: `cts_dashboard_${spaceId}`, title: `This is the ${spaceId} test space CTS dashboard`, type: 'dashboard', meta: { @@ -655,7 +666,7 @@ export function copyToSpaceTestSuiteFactory( ) ); - const dashboardObject = { type: 'dashboard', id: 'cts_dashboard' }; + const dashboardObject = { type: 'dashboard', id: `cts_dashboard_${spaceId}` }; it(`should return ${tests.noConflictsWithoutReferences.statusCode} when copying to space without conflicts or references`, async () => { const destination = getDestinationWithoutConflicts(); diff --git a/x-pack/test/spaces_api_integration/common/suites/delete.ts b/x-pack/test/spaces_api_integration/common/suites/delete.ts index 4bf44d88db8e05..f6fe05682e2da2 100644 --- a/x-pack/test/spaces_api_integration/common/suites/delete.ts +++ b/x-pack/test/spaces_api_integration/common/suites/delete.ts @@ -65,28 +65,28 @@ export function deleteTestSuiteFactory( const expectedBuckets = [ { key: 'default', - doc_count: 8, + doc_count: 7, countByType: { doc_count_error_upper_bound: 0, sum_other_doc_count: 0, buckets: [ { key: 'visualization', doc_count: 3 }, - { key: 'dashboard', doc_count: 2 }, { key: 'space', doc_count: 2 }, // since space objects are namespace-agnostic, they appear in the "default" agg bucket + { key: 'dashboard', doc_count: 1 }, { key: 'index-pattern', doc_count: 1 }, // legacy-url-alias objects cannot exist for the default space ], }, }, { - doc_count: 7, + doc_count: 6, key: 'space_1', countByType: { doc_count_error_upper_bound: 0, sum_other_doc_count: 0, buckets: [ { key: 'visualization', doc_count: 3 }, - { key: 'dashboard', doc_count: 2 }, + { key: 'dashboard', doc_count: 1 }, { key: 'index-pattern', doc_count: 1 }, { key: 'legacy-url-alias', doc_count: 1 }, // alias (1) ], diff --git a/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts b/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts index ed704a9a8bdcc5..883c1230f5d102 100644 --- a/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts +++ b/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts @@ -43,7 +43,7 @@ const { export const TEST_CASE_OBJECTS: Record = deepFreeze({ SHAREABLE_TYPE: { type: 'sharedtype', id: CASES.EACH_SPACE.id }, // contains references to four other objects SHAREABLE_TYPE_DOES_NOT_EXIST: { type: 'sharedtype', id: 'does-not-exist' }, - NON_SHAREABLE_TYPE: { type: 'dashboard', id: 'my_dashboard' }, // one of these exists in each space + NON_SHAREABLE_TYPE: { type: 'isolatedtype', id: 'my_isolated_object' }, // one of these exists in each space }); // Expected results for each space are defined here since they are used in multiple test suites export const EXPECTED_RESULTS: Record = { diff --git a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts index b190a37965b0bc..288e774ac0b879 100644 --- a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts +++ b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts @@ -63,7 +63,7 @@ export function resolveCopyToSpaceConflictsSuite( }; const getDashboardAtSpace = async (spaceId: string): Promise> => { return supertestWithAuth - .get(`${getUrlPrefix(spaceId)}/api/saved_objects/dashboard/cts_dashboard`) + .get(`${getUrlPrefix(spaceId)}/api/saved_objects/dashboard/cts_dashboard_${spaceId}`) .then((response: any) => response.body); }; @@ -114,12 +114,13 @@ export function resolveCopyToSpaceConflictsSuite( successCount: 1, successResults: [ { - id: 'cts_dashboard', + id: `cts_dashboard_${sourceSpaceId}`, type: 'dashboard', meta: { title: `This is the ${sourceSpaceId} test space CTS dashboard`, icon: 'dashboardApp', }, + destinationId: `cts_dashboard_${destinationSpaceId}`, // this conflicted with another dashboard in the destination space because of a shared originId overwrite: true, }, ], @@ -181,8 +182,11 @@ export function resolveCopyToSpaceConflictsSuite( successCount: 0, errors: [ { - error: { type: 'conflict' }, - id: 'cts_dashboard', + error: { + type: 'conflict', + destinationId: `cts_dashboard_${destination}`, // this conflicted with another visualization in the destination space because of a shared originId + }, + id: `cts_dashboard_${sourceSpaceId}`, type: 'dashboard', title: `This is the ${sourceSpaceId} test space CTS dashboard`, meta: { @@ -447,7 +451,7 @@ export function resolveCopyToSpaceConflictsSuite( ) ); - const dashboardObject = { type: 'dashboard', id: 'cts_dashboard' }; + const dashboardObject = { type: 'dashboard', id: `cts_dashboard_${spaceId}` }; const visualizationObject = { type: 'visualization', id: `cts_vis_3_${spaceId}` }; it(`should return ${tests.withReferencesNotOverwriting.statusCode} when not overwriting, with references`, async () => { @@ -508,7 +512,15 @@ export function resolveCopyToSpaceConflictsSuite( objects: [dashboardObject], includeReferences: false, createNewCopies: false, - retries: { [destination]: [{ ...dashboardObject, overwrite: true }] }, + retries: { + [destination]: [ + { + ...dashboardObject, + destinationId: `cts_dashboard_${destination}`, + overwrite: true, + }, + ], + }, }) .expect(tests.withoutReferencesOverwriting.statusCode) .then(tests.withoutReferencesOverwriting.response); @@ -524,7 +536,15 @@ export function resolveCopyToSpaceConflictsSuite( objects: [dashboardObject], includeReferences: false, createNewCopies: false, - retries: { [destination]: [{ ...dashboardObject, overwrite: false }] }, + retries: { + [destination]: [ + { + ...dashboardObject, + destinationId: `cts_dashboard_${destination}`, + overwrite: false, + }, + ], + }, }) .expect(tests.withoutReferencesNotOverwriting.statusCode) .then(tests.withoutReferencesNotOverwriting.response); @@ -540,7 +560,17 @@ export function resolveCopyToSpaceConflictsSuite( objects: [dashboardObject], includeReferences: false, createNewCopies: false, - retries: { [destination]: [{ ...dashboardObject, overwrite: true }] }, + retries: { + [destination]: [ + { + ...dashboardObject, + destinationId: `cts_dashboard_${destination}`, + // realistically a retry wouldn't use a destinationId, because it wouldn't have an origin conflict with another + // object in a non-existent space, but for the simplicity of testing we'll use this here + overwrite: true, + }, + ], + }, }) .expect(tests.nonExistentSpace.statusCode) .then(tests.nonExistentSpace.response);