mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Cases][Timeline] Adding multiple-isolated changes (#113552)
* Adding multiple-isolated changes * Working alias match tests * Adding tests for alias match Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
b9db370c1a
commit
4243c57ee8
16 changed files with 6328 additions and 17 deletions
|
@ -251,7 +251,7 @@ export const resolve = async (
|
|||
}
|
||||
|
||||
const {
|
||||
saved_object: savedObject,
|
||||
saved_object: resolvedSavedObject,
|
||||
...resolveData
|
||||
}: SavedObjectsResolveResponse<CaseAttributes> = await caseService.getResolveCase({
|
||||
unsecuredSavedObjectsClient,
|
||||
|
@ -262,8 +262,8 @@ export const resolve = async (
|
|||
operation: Operations.resolveCase,
|
||||
entities: [
|
||||
{
|
||||
id: savedObject.id,
|
||||
owner: savedObject.attributes.owner,
|
||||
id: resolvedSavedObject.id,
|
||||
owner: resolvedSavedObject.attributes.owner,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -272,7 +272,7 @@ export const resolve = async (
|
|||
if (ENABLE_CASE_CONNECTOR) {
|
||||
const subCasesForCaseId = await caseService.findSubCasesByCaseId({
|
||||
unsecuredSavedObjectsClient,
|
||||
ids: [id],
|
||||
ids: [resolvedSavedObject.id],
|
||||
});
|
||||
subCaseIds = subCasesForCaseId.saved_objects.map((so) => so.id);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ export const resolve = async (
|
|||
return CaseResolveResponseRt.encode({
|
||||
...resolveData,
|
||||
case: flattenCaseSavedObject({
|
||||
savedObject,
|
||||
savedObject: resolvedSavedObject,
|
||||
subCaseIds,
|
||||
}),
|
||||
});
|
||||
|
@ -289,7 +289,7 @@ export const resolve = async (
|
|||
|
||||
const theComments = await caseService.getAllCaseComments({
|
||||
unsecuredSavedObjectsClient,
|
||||
id,
|
||||
id: resolvedSavedObject.id,
|
||||
options: {
|
||||
sortField: 'created_at',
|
||||
sortOrder: 'asc',
|
||||
|
@ -300,11 +300,11 @@ export const resolve = async (
|
|||
return CaseResolveResponseRt.encode({
|
||||
...resolveData,
|
||||
case: flattenCaseSavedObject({
|
||||
savedObject,
|
||||
savedObject: resolvedSavedObject,
|
||||
subCaseIds,
|
||||
comments: theComments.saved_objects,
|
||||
totalComment: theComments.total,
|
||||
totalAlerts: countAlertsForID({ comments: theComments, id }),
|
||||
totalAlerts: countAlertsForID({ comments: theComments, id: resolvedSavedObject.id }),
|
||||
}),
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
|
@ -23,7 +23,8 @@ export const createCaseSavedObjectType = (
|
|||
): SavedObjectsType => ({
|
||||
name: CASE_SAVED_OBJECT,
|
||||
hidden: true,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: {
|
||||
properties: {
|
||||
closed_at: {
|
||||
|
|
|
@ -16,7 +16,8 @@ export const createCaseCommentSavedObjectType = ({
|
|||
}): SavedObjectsType => ({
|
||||
name: CASE_COMMENT_SAVED_OBJECT,
|
||||
hidden: true,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: {
|
||||
properties: {
|
||||
associationType: {
|
||||
|
|
|
@ -12,7 +12,8 @@ import { configureMigrations } from './migrations';
|
|||
export const caseConfigureSavedObjectType: SavedObjectsType = {
|
||||
name: CASE_CONFIGURE_SAVED_OBJECT,
|
||||
hidden: true,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: {
|
||||
properties: {
|
||||
created_at: {
|
||||
|
|
|
@ -12,7 +12,8 @@ import { connectorMappingsMigrations } from './migrations';
|
|||
export const caseConnectorMappingsSavedObjectType: SavedObjectsType = {
|
||||
name: CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT,
|
||||
hidden: true,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: {
|
||||
properties: {
|
||||
mappings: {
|
||||
|
|
|
@ -12,7 +12,8 @@ import { subCasesMigrations } from './migrations';
|
|||
export const subCaseSavedObjectType: SavedObjectsType = {
|
||||
name: SUB_CASE_SAVED_OBJECT,
|
||||
hidden: true,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: {
|
||||
properties: {
|
||||
closed_at: {
|
||||
|
|
|
@ -12,7 +12,8 @@ import { userActionsMigrations } from './migrations';
|
|||
export const caseUserActionSavedObjectType: SavedObjectsType = {
|
||||
name: CASE_USER_ACTION_SAVED_OBJECT,
|
||||
hidden: true,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: {
|
||||
properties: {
|
||||
action_field: {
|
||||
|
|
|
@ -36,7 +36,8 @@ export const noteSavedObjectMappings: SavedObjectsType['mappings'] = {
|
|||
export const noteType: SavedObjectsType = {
|
||||
name: noteSavedObjectType,
|
||||
hidden: false,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: noteSavedObjectMappings,
|
||||
migrations: notesMigrations,
|
||||
};
|
||||
|
|
|
@ -33,7 +33,8 @@ export const pinnedEventSavedObjectMappings: SavedObjectsType['mappings'] = {
|
|||
export const pinnedEventType: SavedObjectsType = {
|
||||
name: pinnedEventSavedObjectType,
|
||||
hidden: false,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: pinnedEventSavedObjectMappings,
|
||||
migrations: pinnedEventsMigrations,
|
||||
};
|
||||
|
|
|
@ -318,7 +318,8 @@ export const timelineSavedObjectMappings: SavedObjectsType['mappings'] = {
|
|||
export const timelineType: SavedObjectsType = {
|
||||
name: timelineSavedObjectType,
|
||||
hidden: false,
|
||||
namespaceType: 'single',
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
mappings: timelineSavedObjectMappings,
|
||||
migrations: timelinesMigrations,
|
||||
};
|
||||
|
|
|
@ -37,6 +37,79 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
const esArchiver = getService('esArchiver');
|
||||
const es = getService('es');
|
||||
|
||||
describe('8.0 id migration', () => {
|
||||
const resolveWithSpaceApi = '/s/awesome-space/api/timeline/resolve';
|
||||
|
||||
before(async () => {
|
||||
await esArchiver.load(
|
||||
'x-pack/test/functional/es_archives/security_solution/timelines/7.15.0_space'
|
||||
);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await esArchiver.unload(
|
||||
'x-pack/test/functional/es_archives/security_solution/timelines/7.15.0_space'
|
||||
);
|
||||
});
|
||||
|
||||
describe('resolve', () => {
|
||||
it('should return an aliasMatch outcome', async () => {
|
||||
const resp = await supertest
|
||||
.get(resolveWithSpaceApi)
|
||||
.query({ id: '1e2e9850-25f8-11ec-a981-b77847c6ef30' });
|
||||
|
||||
expect(resp.body.data.outcome).to.be('aliasMatch');
|
||||
expect(resp.body.data.alias_target_id).to.not.be(undefined);
|
||||
expect(resp.body.data.timeline.title).to.be('An awesome timeline');
|
||||
});
|
||||
|
||||
describe('notes', () => {
|
||||
it('should return the notes with the correct eventId', async () => {
|
||||
const resp = await supertest
|
||||
.get(resolveWithSpaceApi)
|
||||
.query({ id: '1e2e9850-25f8-11ec-a981-b77847c6ef30' });
|
||||
|
||||
expect(resp.body.data.timeline.notes[0].eventId).to.be('StU_UXwBAowmaxx6YdiS');
|
||||
});
|
||||
|
||||
it('should return notes with the timelineId matching the resolved timeline id', async () => {
|
||||
const resp = await supertest
|
||||
.get(resolveWithSpaceApi)
|
||||
.query({ id: '1e2e9850-25f8-11ec-a981-b77847c6ef30' });
|
||||
|
||||
expect(resp.body.data.timeline.notes[0].timelineId).to.be(
|
||||
resp.body.data.timeline.savedObjectId
|
||||
);
|
||||
expect(resp.body.data.timeline.notes[1].timelineId).to.be(
|
||||
resp.body.data.timeline.savedObjectId
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pinned events', () => {
|
||||
it('should pinned events with eventId', async () => {
|
||||
const resp = await supertest
|
||||
.get(resolveWithSpaceApi)
|
||||
.query({ id: '1e2e9850-25f8-11ec-a981-b77847c6ef30' });
|
||||
|
||||
expect(resp.body.data.timeline.pinnedEventsSaveObject[0].eventId).to.be(
|
||||
'StU_UXwBAowmaxx6YdiS'
|
||||
);
|
||||
});
|
||||
|
||||
it('should return pinned events with the timelineId matching request id', async () => {
|
||||
const resp = await supertest
|
||||
.get(resolveWithSpaceApi)
|
||||
.query({ id: '1e2e9850-25f8-11ec-a981-b77847c6ef30' });
|
||||
|
||||
expect(resp.body.data.timeline.pinnedEventsSaveObject[0].timelineId).to.be(
|
||||
resp.body.data.timeline.savedObjectId
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('7.16.0', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load(
|
||||
|
|
|
@ -12,6 +12,8 @@ import {
|
|||
SECURITY_SOLUTION_OWNER,
|
||||
} from '../../../../../../plugins/cases/common/constants';
|
||||
import { getCase, getCaseSavedObjectsFromES, resolveCase } from '../../../../common/lib/utils';
|
||||
import { superUser } from '../../../../common/lib/authentication/users';
|
||||
import { AttributesTypeUser } from '../../../../../../plugins/cases/common';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function createGetTests({ getService }: FtrProviderContext) {
|
||||
|
@ -278,5 +280,58 @@ export default function createGetTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('8.0 id migration', () => {
|
||||
describe('awesome space', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/cases/migrations/7.16.0_space');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await esArchiver.unload(
|
||||
'x-pack/test/functional/es_archives/cases/migrations/7.16.0_space'
|
||||
);
|
||||
});
|
||||
|
||||
describe('resolve', () => {
|
||||
const auth = { user: superUser, space: 'awesome-space' };
|
||||
|
||||
it('should return aliasMatch outcome', async () => {
|
||||
const { outcome } = await resolveCase({
|
||||
supertest,
|
||||
caseId: 'a97a13b0-22f3-11ec-9f3b-fbc97859d7ed',
|
||||
auth,
|
||||
});
|
||||
|
||||
expect(outcome).to.be('aliasMatch');
|
||||
});
|
||||
|
||||
it('should preserve the same case info', async () => {
|
||||
const { case: theCase } = await resolveCase({
|
||||
supertest,
|
||||
caseId: 'a97a13b0-22f3-11ec-9f3b-fbc97859d7ed',
|
||||
auth,
|
||||
});
|
||||
|
||||
expect(theCase.title).to.be('Case name');
|
||||
expect(theCase.description).to.be('a description');
|
||||
expect(theCase.owner).to.be(SECURITY_SOLUTION_OWNER);
|
||||
});
|
||||
|
||||
it('should preserve the comment', async () => {
|
||||
const { case: theCase } = await resolveCase({
|
||||
supertest,
|
||||
caseId: 'a97a13b0-22f3-11ec-9f3b-fbc97859d7ed',
|
||||
auth,
|
||||
includeComments: true,
|
||||
});
|
||||
|
||||
const comment = theCase.comments![0] as AttributesTypeUser;
|
||||
expect(comment.comment).to.be('a comment');
|
||||
expect(comment.owner).to.be(SECURITY_SOLUTION_OWNER);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue