[Cases] Refactor integration helper functions (#149640)

This PR refactors the cases integration test API helper functions so
that splitting up the `utils.ts` file will be easier in the future
because it will all be hidden under the `api/index.ts` import. That way
moving functions out of the `index.ts` file into their own will not
require a ton of test files to be updated.
This commit is contained in:
Jonathan Buttner 2023-02-08 15:02:32 -05:00 committed by GitHub
parent 820500f3d9
commit 375a863349
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
106 changed files with 666 additions and 621 deletions

View file

@ -11,11 +11,11 @@ import { APP_ID as SECURITY_SOLUTION_APP_ID } from '@kbn/security-solution-plugi
import { observabilityFeatureId as OBSERVABILITY_APP_ID } from '@kbn/observability-plugin/common';
import { FtrProviderContext } from '../../ftr_provider_context';
import { deleteAllCaseItems } from '../../../cases_api_integration/common/lib/utils';
import { deleteAllCaseItems } from '../../../cases_api_integration/common/lib/api';
import {
bulkGetUserProfiles,
suggestUserProfiles,
} from '../../../cases_api_integration/common/lib/user_profiles';
} from '../../../cases_api_integration/common/lib/api/user_profiles';
import {
casesAllUser,
casesReadUser,

View file

@ -10,7 +10,7 @@ import {
deleteUsersAndRoles,
} from '../../../cases_api_integration/common/lib/authentication';
import { loginUsers } from '../../../cases_api_integration/common/lib/user_profiles';
import { loginUsers } from '../../../cases_api_integration/common/lib/api/user_profiles';
import { casesAllUser, obsCasesAllUser, secAllUser, users } from './common/users';
import { roles } from './common/roles';
import { FtrProviderContext } from '../../ftr_provider_context';

View file

@ -16,7 +16,7 @@ import {
deleteAllCaseItems,
deleteCases,
getCase,
} from '../../../cases_api_integration/common/lib/utils';
} from '../../../cases_api_integration/common/lib/api';
import {
casesAllUser,
casesNoDeleteUser,

View file

@ -11,8 +11,8 @@ import { APP_ID as SECURITY_SOLUTION_APP_ID } from '@kbn/security-solution-plugi
import { observabilityFeatureId as OBSERVABILITY_APP_ID } from '@kbn/observability-plugin/common';
import { FtrProviderContext } from '../../ftr_provider_context';
import { deleteAllCaseItems } from '../../../cases_api_integration/common/lib/utils';
import { suggestUserProfiles } from '../../../cases_api_integration/common/lib/user_profiles';
import { deleteAllCaseItems } from '../../../cases_api_integration/common/lib/api';
import { suggestUserProfiles } from '../../../cases_api_integration/common/lib/api/user_profiles';
import {
casesAllUser,
casesOnlyDeleteUser,

View file

@ -19,7 +19,7 @@ import {
createCase,
deleteAllCaseItems,
getCase,
} from '../../../cases_api_integration/common/lib/utils';
} from '../../../cases_api_integration/common/lib/api';
import { getPostCaseRequest } from '../../../cases_api_integration/common/lib/mock';
const secAll: Role = {

View file

@ -0,0 +1,260 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type SuperTest from 'supertest';
import { CASES_INTERNAL_URL, CASES_URL } from '@kbn/cases-plugin/common/constants';
import {
AllCommentsResponse,
BulkCreateCommentRequest,
BulkGetAttachmentsResponse,
CaseResponse,
CommentPatchRequest,
CommentRequest,
CommentResponse,
CommentType,
} from '@kbn/cases-plugin/common/api';
import { User } from '../authentication/types';
import { superUser } from '../authentication/users';
import { getSpaceUrlPrefix, setupAuth } from './helpers';
import { createCase } from './case';
import { postCaseReq } from '../mock';
export const bulkGetAttachments = async ({
supertest,
attachmentIds,
caseId,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
attachmentIds: string[];
caseId: string;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<BulkGetAttachmentsResponse> => {
const { body: comments } = await supertest
.post(`${getSpaceUrlPrefix(auth.space)}${CASES_INTERNAL_URL}/${caseId}/attachments/_bulk_get`)
.send({ ids: attachmentIds })
.set('kbn-xsrf', 'abc')
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode);
return comments;
};
export const createComment = async ({
supertest,
caseId,
params,
auth = { user: superUser, space: null },
expectedHttpCode = 200,
headers = {},
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
params: CommentRequest;
auth?: { user: User; space: string | null } | null;
expectedHttpCode?: number;
headers?: Record<string, unknown>;
}): Promise<CaseResponse> => {
const apiCall = supertest.post(
`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments`
);
setupAuth({ apiCall, headers, auth });
const { body: theCase } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(params)
.expect(expectedHttpCode);
return theCase;
};
export const bulkCreateAttachments = async ({
supertest,
caseId,
params,
auth = { user: superUser, space: null },
expectedHttpCode = 200,
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
params: BulkCreateCommentRequest;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<CaseResponse> => {
const { body: theCase } = await supertest
.post(
`${getSpaceUrlPrefix(auth.space)}${CASES_INTERNAL_URL}/${caseId}/attachments/_bulk_create`
)
.auth(auth.user.username, auth.user.password)
.set('kbn-xsrf', 'true')
.send(params)
.expect(expectedHttpCode);
return theCase;
};
export const createCaseAndBulkCreateAttachments = async ({
supertest,
numberOfAttachments = 3,
auth = { user: superUser, space: null },
expectedHttpCode = 200,
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
numberOfAttachments?: number;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<{ theCase: CaseResponse; attachments: BulkCreateCommentRequest }> => {
const postedCase = await createCase(supertest, postCaseReq);
const attachments = getAttachments(numberOfAttachments);
const patchedCase = await bulkCreateAttachments({
supertest,
caseId: postedCase.id,
params: attachments,
});
return { theCase: patchedCase, attachments };
};
export const getAttachments = (numberOfAttachments: number): BulkCreateCommentRequest => {
return [...Array(numberOfAttachments)].map((index) => {
if (index % 0) {
return {
type: CommentType.user,
comment: `Test ${index + 1}`,
owner: 'securitySolutionFixture',
};
}
return {
type: CommentType.alert,
alertId: `test-id-${index + 1}`,
index: `test-index-${index + 1}`,
rule: {
id: `rule-test-id-${index + 1}`,
name: `Test ${index + 1}`,
},
owner: 'securitySolutionFixture',
};
});
};
export const deleteComment = async ({
supertest,
caseId,
commentId,
expectedHttpCode = 204,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
commentId: string;
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}): Promise<{} | Error> => {
const { body: comment } = await supertest
.delete(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments/${commentId}`)
.set('kbn-xsrf', 'true')
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode)
.send();
return comment;
};
export const deleteAllComments = async ({
supertest,
caseId,
expectedHttpCode = 204,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}): Promise<{} | Error> => {
const { body: comment } = await supertest
.delete(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments`)
.set('kbn-xsrf', 'true')
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode)
.send();
return comment;
};
export const getAllComments = async ({
supertest,
caseId,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<AllCommentsResponse> => {
const { body: comments } = await supertest
.get(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments`)
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode);
return comments;
};
export const getComment = async ({
supertest,
caseId,
commentId,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
commentId: string;
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}): Promise<CommentResponse> => {
const { body: comment } = await supertest
.get(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments/${commentId}`)
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode);
return comment;
};
export const updateComment = async ({
supertest,
caseId,
req,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
headers = {},
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
req: CommentPatchRequest;
expectedHttpCode?: number;
auth?: { user: User; space: string | null } | null;
headers?: Record<string, unknown>;
}): Promise<CaseResponse> => {
const apiCall = supertest.patch(
`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments`
);
setupAuth({ apiCall, headers, auth });
const { body: res } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(req)
.expect(expectedHttpCode);
return res;
};

View file

@ -0,0 +1,61 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CASES_URL } from '@kbn/cases-plugin/common';
import { CasePostRequest, CaseResponse } from '@kbn/cases-plugin/common/api';
import type SuperTest from 'supertest';
import { User } from '../authentication/types';
import { superUser } from '../authentication/users';
import { getSpaceUrlPrefix, setupAuth } from './helpers';
export const createCase = async (
supertest: SuperTest.SuperTest<SuperTest.Test>,
params: CasePostRequest,
expectedHttpCode: number = 200,
auth: { user: User; space: string | null } | null = { user: superUser, space: null },
headers: Record<string, unknown> = {}
): Promise<CaseResponse> => {
const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`);
setupAuth({ apiCall, headers, auth });
const { body: theCase } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(params)
.expect(expectedHttpCode);
return theCase;
};
/**
* Sends a delete request for the specified case IDs.
*/
export const deleteCases = async ({
supertest,
caseIDs,
expectedHttpCode = 204,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseIDs: string[];
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}) => {
const { body } = await supertest
.delete(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}`)
.auth(auth.user.username, auth.user.password)
// we need to json stringify here because just passing in the array of case IDs will cause a 400 with Kibana
// not being able to parse the array correctly. The format ids=["1", "2"] seems to work, which stringify outputs.
.query({ ids: JSON.stringify(caseIDs) })
.set('kbn-xsrf', 'true')
.send()
.expect(expectedHttpCode);
return body;
};

View file

@ -0,0 +1,77 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import {
CaseConnector,
CasesConfigureRequest,
CasesConfigureResponse,
ConnectorTypes,
} from '@kbn/cases-plugin/common/api';
import { CASE_CONFIGURE_URL } from '@kbn/cases-plugin/common/constants';
import type SuperTest from 'supertest';
import { User } from '../authentication/types';
import { superUser } from '../authentication/users';
import { getSpaceUrlPrefix, setupAuth } from './helpers';
type ConfigRequestParams = Partial<CaseConnector> & {
overrides?: Record<string, unknown>;
};
export const getConfigurationRequest = ({
id = 'none',
name = 'none',
type = ConnectorTypes.none,
fields = null,
overrides,
}: ConfigRequestParams = {}): CasesConfigureRequest => {
return {
connector: {
id,
name,
type,
fields,
} as CaseConnector,
closure_type: 'close-by-user',
owner: 'securitySolutionFixture',
...overrides,
};
};
export const getConfigurationOutput = (
update = false,
overwrite = {}
): Partial<CasesConfigureResponse> => {
return {
...getConfigurationRequest(),
error: null,
mappings: [],
created_by: { email: null, full_name: null, username: 'elastic' },
updated_by: update ? { email: null, full_name: null, username: 'elastic' } : null,
...overwrite,
};
};
export const createConfiguration = async (
supertest: SuperTest.SuperTest<SuperTest.Test>,
req: CasesConfigureRequest = getConfigurationRequest(),
expectedHttpCode: number = 200,
auth: { user: User; space: string | null } | null = { user: superUser, space: null },
headers: Record<string, unknown> = {}
): Promise<CasesConfigureResponse> => {
const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}`);
setupAuth({ apiCall, headers, auth });
const { body: configuration } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(req)
.expect(expectedHttpCode);
return configuration;
};

View file

@ -20,18 +20,15 @@ import {
getCaseConnectorsUrl,
} from '@kbn/cases-plugin/common/api';
import { ActionResult, FindActionResult } from '@kbn/actions-plugin/server/types';
import { User } from './authentication/types';
import { superUser } from './authentication/users';
import { getPostCaseRequest } from './mock';
import { ObjectRemover as ActionsRemover } from '../../../alerting_api_integration/common/lib';
import { getServiceNowServer } from '../../../alerting_api_integration/common/plugins/actions_simulators/server/plugin';
import { RecordingServiceNowSimulator } from '../../../alerting_api_integration/common/plugins/actions_simulators/server/servicenow_simulation';
import {
createConfiguration,
getConfigurationRequest,
createCase,
getSpaceUrlPrefix,
} from './utils';
import { User } from '../authentication/types';
import { superUser } from '../authentication/users';
import { getPostCaseRequest } from '../mock';
import { ObjectRemover as ActionsRemover } from '../../../../alerting_api_integration/common/lib';
import { getServiceNowServer } from '../../../../alerting_api_integration/common/plugins/actions_simulators/server/plugin';
import { RecordingServiceNowSimulator } from '../../../../alerting_api_integration/common/plugins/actions_simulators/server/servicenow_simulation';
import { createConfiguration, getConfigurationRequest } from './configuration';
import { createCase } from './case';
import { getSpaceUrlPrefix } from './helpers';
export const getResilientConnector = () => ({
name: 'Resilient Connector',

View file

@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type SuperTest from 'supertest';
import { User } from '../authentication/types';
export const getSpaceUrlPrefix = (spaceId: string | undefined | null) => {
return spaceId && spaceId !== 'default' ? `/s/${spaceId}` : ``;
};
export const setupAuth = ({
apiCall,
headers,
auth,
}: {
apiCall: SuperTest.Test;
headers: Record<string, unknown>;
auth?: { user: User; space: string | null } | null;
}): SuperTest.Test => {
if (!Object.hasOwn(headers, 'Cookie') && auth != null) {
return apiCall.auth(auth.user.username, auth.user.password);
}
return apiCall;
};

View file

@ -5,8 +5,6 @@
* 2.0.
*/
import { omit } from 'lodash';
import expect from '@kbn/expect';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { TransportResult } from '@elastic/elasticsearch';
@ -23,20 +21,12 @@ import {
CASE_TAGS_URL,
} from '@kbn/cases-plugin/common/constants';
import {
CasesConfigureRequest,
CasesConfigureResponse,
CaseConnector,
ConnectorTypes,
CasePostRequest,
CaseResponse,
CaseStatuses,
CasesResponse,
CasesFindResponse,
CommentRequest,
CommentResponse,
CasesPatchRequest,
AllCommentsResponse,
CommentPatchRequest,
CasesConfigurePatch,
CasesStatusResponse,
CasesConfigurationsResponse,
@ -45,8 +35,6 @@ import {
CasesByAlertId,
CaseResolveResponse,
SingleCaseMetricsResponse,
BulkCreateCommentRequest,
CommentType,
CasesMetricsResponse,
CasesBulkGetResponse,
} from '@kbn/cases-plugin/common/api';
@ -55,9 +43,18 @@ import { ActionResult } from '@kbn/actions-plugin/server/types';
import { ESCasesConfigureAttributes } from '@kbn/cases-plugin/server/services/configure/types';
import { ESCaseAttributes } from '@kbn/cases-plugin/server/services/cases/types';
import type { SavedObjectsRawDocSource } from '@kbn/core/server';
import { User } from './authentication/types';
import { superUser } from './authentication/users';
import { postCaseReq } from './mock';
import { User } from '../authentication/types';
import { superUser } from '../authentication/users';
import { getSpaceUrlPrefix, setupAuth } from './helpers';
export * from './attachments';
export * from './case';
export * from './connectors';
export * from './user_actions';
export * from './user_profiles';
export * from './omit';
export * from './configuration';
export { getSpaceUrlPrefix } from './helpers';
function toArray<T>(input: T | T[]): T[] {
if (Array.isArray(input)) {
@ -162,44 +159,6 @@ export const deleteCaseAction = async (
await supertest.delete(`/api/actions/connector/${id}`).set('kbn-xsrf', 'foo');
};
type ConfigRequestParams = Partial<CaseConnector> & {
overrides?: Record<string, unknown>;
};
export const getConfigurationRequest = ({
id = 'none',
name = 'none',
type = ConnectorTypes.none,
fields = null,
overrides,
}: ConfigRequestParams = {}): CasesConfigureRequest => {
return {
connector: {
id,
name,
type,
fields,
} as CaseConnector,
closure_type: 'close-by-user',
owner: 'securitySolutionFixture',
...overrides,
};
};
export const getConfigurationOutput = (
update = false,
overwrite = {}
): Partial<CasesConfigureResponse> => {
return {
...getConfigurationRequest(),
error: null,
mappings: [],
created_by: { email: null, full_name: null, username: 'elastic' },
updated_by: update ? { email: null, full_name: null, username: 'elastic' } : null,
...overwrite,
};
};
export const getMappings = () => [
{
source: 'title',
@ -218,48 +177,6 @@ export const getMappings = () => [
},
];
interface CommonSavedObjectAttributes {
id?: string | null;
created_at?: string | null;
updated_at?: string | null;
version?: string | null;
[key: string]: unknown;
}
const savedObjectCommonAttributes = ['created_at', 'updated_at', 'version', 'id'];
export const removeServerGeneratedPropertiesFromObject = <T extends object, K extends keyof T>(
object: T,
keys: K[]
): Omit<T, K> => {
return omit<T, K>(object, keys);
};
export const removeServerGeneratedPropertiesFromSavedObject = <
T extends CommonSavedObjectAttributes
>(
attributes: T,
keys: Array<keyof T> = []
): Omit<T, typeof savedObjectCommonAttributes[number] | typeof keys[number]> => {
return removeServerGeneratedPropertiesFromObject(attributes, [
...savedObjectCommonAttributes,
...keys,
]);
};
export const removeServerGeneratedPropertiesFromCase = (
theCase: CaseResponse
): Partial<CaseResponse> => {
return removeServerGeneratedPropertiesFromSavedObject<CaseResponse>(theCase, ['closed_at']);
};
export const removeServerGeneratedPropertiesFromComments = (
comments: CommentResponse[] | undefined
): Array<Partial<CommentResponse>> | undefined => {
return comments?.map((comment) => {
return removeServerGeneratedPropertiesFromSavedObject<CommentResponse>(comment, []);
});
};
export const deleteAllCaseItems = async (es: Client) => {
await Promise.all([
deleteCasesByESQuery(es),
@ -345,10 +262,6 @@ export function getActionsSpace(space: string | null) {
return space ?? 'default';
}
export const getSpaceUrlPrefix = (spaceId: string | undefined | null) => {
return spaceId && spaceId !== 'default' ? `/s/${spaceId}` : ``;
};
interface OwnerEntity {
owner: string;
}
@ -445,124 +358,6 @@ export const getCaseSavedObjectsFromES = async ({ es }: { es: Client }) => {
return configure;
};
export const createCase = async (
supertest: SuperTest.SuperTest<SuperTest.Test>,
params: CasePostRequest,
expectedHttpCode: number = 200,
auth: { user: User; space: string | null } | null = { user: superUser, space: null },
headers: Record<string, unknown> = {}
): Promise<CaseResponse> => {
const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}`);
setupAuth({ apiCall, headers, auth });
const { body: theCase } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(params)
.expect(expectedHttpCode);
return theCase;
};
const setupAuth = ({
apiCall,
headers,
auth,
}: {
apiCall: SuperTest.Test;
headers: Record<string, unknown>;
auth?: { user: User; space: string | null } | null;
}): SuperTest.Test => {
if (!Object.hasOwn(headers, 'Cookie') && auth != null) {
return apiCall.auth(auth.user.username, auth.user.password);
}
return apiCall;
};
/**
* Sends a delete request for the specified case IDs.
*/
export const deleteCases = async ({
supertest,
caseIDs,
expectedHttpCode = 204,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseIDs: string[];
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}) => {
const { body } = await supertest
.delete(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}`)
.auth(auth.user.username, auth.user.password)
// we need to json stringify here because just passing in the array of case IDs will cause a 400 with Kibana
// not being able to parse the array correctly. The format ids=["1", "2"] seems to work, which stringify outputs.
.query({ ids: JSON.stringify(caseIDs) })
.set('kbn-xsrf', 'true')
.send()
.expect(expectedHttpCode);
return body;
};
export const createComment = async ({
supertest,
caseId,
params,
auth = { user: superUser, space: null },
expectedHttpCode = 200,
headers = {},
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
params: CommentRequest;
auth?: { user: User; space: string | null } | null;
expectedHttpCode?: number;
headers?: Record<string, unknown>;
}): Promise<CaseResponse> => {
const apiCall = supertest.post(
`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments`
);
setupAuth({ apiCall, headers, auth });
const { body: theCase } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(params)
.expect(expectedHttpCode);
return theCase;
};
export const bulkCreateAttachments = async ({
supertest,
caseId,
params,
auth = { user: superUser, space: null },
expectedHttpCode = 200,
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
params: BulkCreateCommentRequest;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<CaseResponse> => {
const { body: theCase } = await supertest
.post(
`${getSpaceUrlPrefix(auth.space)}${CASES_INTERNAL_URL}/${caseId}/attachments/_bulk_create`
)
.auth(auth.user.username, auth.user.password)
.set('kbn-xsrf', 'true')
.send(params)
.expect(expectedHttpCode);
return theCase;
};
export const updateCase = async ({
supertest,
params,
@ -589,119 +384,6 @@ export const updateCase = async ({
return cases;
};
export const deleteComment = async ({
supertest,
caseId,
commentId,
expectedHttpCode = 204,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
commentId: string;
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}): Promise<{} | Error> => {
const { body: comment } = await supertest
.delete(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments/${commentId}`)
.set('kbn-xsrf', 'true')
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode)
.send();
return comment;
};
export const deleteAllComments = async ({
supertest,
caseId,
expectedHttpCode = 204,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}): Promise<{} | Error> => {
const { body: comment } = await supertest
.delete(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments`)
.set('kbn-xsrf', 'true')
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode)
.send();
return comment;
};
export const getAllComments = async ({
supertest,
caseId,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<AllCommentsResponse> => {
const { body: comments } = await supertest
.get(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments`)
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode);
return comments;
};
export const getComment = async ({
supertest,
caseId,
commentId,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
commentId: string;
expectedHttpCode?: number;
auth?: { user: User; space: string | null };
}): Promise<CommentResponse> => {
const { body: comment } = await supertest
.get(`${getSpaceUrlPrefix(auth.space)}${CASES_URL}/${caseId}/comments/${commentId}`)
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode);
return comment;
};
export const updateComment = async ({
supertest,
caseId,
req,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
headers = {},
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
caseId: string;
req: CommentPatchRequest;
expectedHttpCode?: number;
auth?: { user: User; space: string | null } | null;
headers?: Record<string, unknown>;
}): Promise<CaseResponse> => {
const apiCall = supertest.patch(
`${getSpaceUrlPrefix(auth?.space)}${CASES_URL}/${caseId}/comments`
);
setupAuth({ apiCall, headers, auth });
const { body: res } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(req)
.expect(expectedHttpCode);
return res;
};
export const getConfiguration = async ({
supertest,
query = { owner: 'securitySolutionFixture' },
@ -723,26 +405,6 @@ export const getConfiguration = async ({
return configuration;
};
export const createConfiguration = async (
supertest: SuperTest.SuperTest<SuperTest.Test>,
req: CasesConfigureRequest = getConfigurationRequest(),
expectedHttpCode: number = 200,
auth: { user: User; space: string | null } | null = { user: superUser, space: null },
headers: Record<string, unknown> = {}
): Promise<CasesConfigureResponse> => {
const apiCall = supertest.post(`${getSpaceUrlPrefix(auth?.space)}${CASE_CONFIGURE_URL}`);
setupAuth({ apiCall, headers, auth });
const { body: configuration } = await apiCall
.set('kbn-xsrf', 'true')
.set(headers)
.send(req)
.expect(expectedHttpCode);
return configuration;
};
export type CreateConnectorResponse = Omit<ActionResult, 'actionTypeId'> & {
connector_type_id: string;
};
@ -1007,51 +669,6 @@ export const extractWarningValueFromWarningHeader = (warningHeader: string) => {
return warningValue;
};
export const getAttachments = (numberOfAttachments: number): BulkCreateCommentRequest => {
return [...Array(numberOfAttachments)].map((index) => {
if (index % 0) {
return {
type: CommentType.user,
comment: `Test ${index + 1}`,
owner: 'securitySolutionFixture',
};
}
return {
type: CommentType.alert,
alertId: `test-id-${index + 1}`,
index: `test-index-${index + 1}`,
rule: {
id: `rule-test-id-${index + 1}`,
name: `Test ${index + 1}`,
},
owner: 'securitySolutionFixture',
};
});
};
export const createCaseAndBulkCreateAttachments = async ({
supertest,
numberOfAttachments = 3,
auth = { user: superUser, space: null },
expectedHttpCode = 200,
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
numberOfAttachments?: number;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<{ theCase: CaseResponse; attachments: BulkCreateCommentRequest }> => {
const postedCase = await createCase(supertest, postCaseReq);
const attachments = getAttachments(numberOfAttachments);
const patchedCase = await bulkCreateAttachments({
supertest,
caseId: postedCase.id,
params: attachments,
});
return { theCase: patchedCase, attachments };
};
export const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
export const calculateDuration = (closedAt: string | null, createdAt: string | null): number => {

View file

@ -0,0 +1,51 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CaseResponse, CommentResponse } from '@kbn/cases-plugin/common/api';
import { omit } from 'lodash';
interface CommonSavedObjectAttributes {
id?: string | null;
created_at?: string | null;
updated_at?: string | null;
version?: string | null;
[key: string]: unknown;
}
const savedObjectCommonAttributes = ['created_at', 'updated_at', 'version', 'id'];
export const removeServerGeneratedPropertiesFromObject = <T extends object, K extends keyof T>(
object: T,
keys: K[]
): Omit<T, K> => {
return omit<T, K>(object, keys);
};
export const removeServerGeneratedPropertiesFromSavedObject = <
T extends CommonSavedObjectAttributes
>(
attributes: T,
keys: Array<keyof T> = []
): Omit<T, typeof savedObjectCommonAttributes[number] | typeof keys[number]> => {
return removeServerGeneratedPropertiesFromObject(attributes, [
...savedObjectCommonAttributes,
...keys,
]);
};
export const removeServerGeneratedPropertiesFromCase = (
theCase: CaseResponse
): Partial<CaseResponse> => {
return removeServerGeneratedPropertiesFromSavedObject<CaseResponse>(theCase, ['closed_at']);
};
export const removeServerGeneratedPropertiesFromComments = (
comments: CommentResponse[] | undefined
): Array<Partial<CommentResponse>> | undefined => {
return comments?.map((comment) => {
return removeServerGeneratedPropertiesFromSavedObject<CommentResponse>(comment, []);
});
};

View file

@ -18,10 +18,11 @@ import {
getCaseUsersUrl,
} from '@kbn/cases-plugin/common/api';
import type SuperTest from 'supertest';
import { User } from './authentication/types';
import { User } from '../authentication/types';
import { superUser } from './authentication/users';
import { getSpaceUrlPrefix, removeServerGeneratedPropertiesFromObject } from './utils';
import { superUser } from '../authentication/users';
import { getSpaceUrlPrefix } from './helpers';
import { removeServerGeneratedPropertiesFromObject } from './omit';
export const removeServerGeneratedPropertiesFromUserAction = (
attributes: CaseUserActionDeprecatedResponse

View file

@ -12,11 +12,11 @@ import { UserProfileBulkGetParams, UserProfileServiceStart } from '@kbn/security
import { INTERNAL_SUGGEST_USER_PROFILES_URL } from '@kbn/cases-plugin/common/constants';
import { SuggestUserProfilesRequest } from '@kbn/cases-plugin/common/api';
import { UserProfileService } from '@kbn/cases-plugin/server/services';
import { superUser } from './authentication/users';
import { User } from './authentication/types';
import { getSpaceUrlPrefix } from './utils';
import { FtrProviderContext as CommonFtrProviderContext } from '../ftr_provider_context';
import { getUserInfo } from './authentication';
import { superUser } from '../authentication/users';
import { User } from '../authentication/types';
import { getSpaceUrlPrefix } from './helpers';
import { FtrProviderContext as CommonFtrProviderContext } from '../../ftr_provider_context';
import { getUserInfo } from '../authentication';
type BulkGetUserProfilesParams = Omit<UserProfileBulkGetParams, 'uids'> & { uids: string[] };

View file

@ -1,38 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type SuperTest from 'supertest';
import {
BulkGetAttachmentsResponse,
getCaseBulkGetAttachmentsUrl,
} from '@kbn/cases-plugin/common/api';
import { User } from './authentication/types';
import { superUser } from './authentication/users';
import { getSpaceUrlPrefix } from './utils';
export const bulkGetAttachments = async ({
supertest,
attachmentIds,
caseId,
expectedHttpCode = 200,
auth = { user: superUser, space: null },
}: {
supertest: SuperTest.SuperTest<SuperTest.Test>;
attachmentIds: string[];
caseId: string;
auth?: { user: User; space: string | null };
expectedHttpCode?: number;
}): Promise<BulkGetAttachmentsResponse> => {
const { body: comments } = await supertest
.post(`${getSpaceUrlPrefix(auth.space)}${getCaseBulkGetAttachmentsUrl(caseId)}`)
.send({ ids: attachmentIds })
.set('kbn-xsrf', 'abc')
.auth(auth.user.username, auth.user.password)
.expect(expectedHttpCode);
return comments;
};

View file

@ -10,7 +10,7 @@ import { Role, User, UserInfo } from './types';
import { obsOnly, secOnly, secOnlyNoDelete, secOnlyRead, users } from './users';
import { roles } from './roles';
import { spaces } from './spaces';
import { loginUsers } from '../user_profiles';
import { loginUsers } from '../api';
export const getUserInfo = (user: User): UserInfo => ({
username: user.username,

View file

@ -7,12 +7,7 @@
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { getPostCaseRequest } from '../../../../common/lib/mock';
import {
createCase,
updateCase,
findCases,
deleteAllCaseItems,
} from '../../../../common/lib/utils';
import { createCase, updateCase, findCases, deleteAllCaseItems } from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -18,9 +18,9 @@ import {
createConfiguration,
createCase,
pushCase,
} from '../../../../common/lib/utils';
import { getServiceNowConnector, createConnector } from '../../../../common/lib/connectors';
createConnector,
getServiceNowConnector,
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -8,7 +8,7 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { getCaseConnectors } from '../../../../common/lib/connectors';
import { getCaseConnectors } from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -6,8 +6,7 @@
*/
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { deleteAllCaseItems } from '../../../../common/lib/utils';
import { suggestUserProfiles } from '../../../../common/lib/user_profiles';
import { deleteAllCaseItems, suggestUserProfiles } from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -14,7 +14,7 @@ import {
createComment,
deleteAllCaseItems,
getAlertsAttachedToCase,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -20,7 +20,7 @@ import {
createComment,
getCasesByAlert,
deleteAllCaseItems,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { validateCasesFromAlertIDResponse } from '../../../../common/lib/validation';
import {
globalRead,

View file

@ -30,8 +30,8 @@ import {
updateComment,
getSOFromKibanaIndex,
getReferenceFromEsResponse,
} from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
getCaseUserActions,
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -30,8 +30,8 @@ import {
getReferenceFromEsResponse,
bulkCreateAttachments,
updateComment,
} from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
getCaseUserActions,
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -19,8 +19,8 @@ import {
getComment,
getCase,
superUserSpace1Auth,
} from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
getCaseUserActions,
} from '../../../../common/lib/api';
import {
secOnly,
secOnlyRead,

View file

@ -30,7 +30,7 @@ import {
createCase,
updateCase,
createComment,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
obsOnly,
secOnly,

View file

@ -25,7 +25,7 @@ import {
removeServerGeneratedPropertiesFromCase,
removeServerGeneratedPropertiesFromSavedObject,
extractWarningValueFromWarningHeader,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
secOnly,
obsOnly,

View file

@ -35,8 +35,8 @@ import {
createCase,
createComment,
findCases,
} from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
getCaseUserActions,
} from '../../../../common/lib/api';
import { getPostCaseRequest, postCommentUserReq } from '../../../../common/lib/mock';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

View file

@ -15,7 +15,7 @@ import {
getCase,
getCaseSavedObjectsFromES,
resolveCase,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { superUser } from '../../../../common/lib/authentication/users';
// eslint-disable-next-line import/no-default-export

View file

@ -35,11 +35,9 @@ import {
superUserSpace1Auth,
delay,
calculateDuration,
} from '../../../../common/lib/utils';
import {
getCaseUserActions,
removeServerGeneratedPropertiesFromUserAction,
} from '../../../../common/lib/user_actions';
} from '../../../../common/lib/api';
import {
createSignalsIndex,
deleteSignalsIndex,

View file

@ -19,11 +19,9 @@ import {
deleteCasesByESQuery,
createCase,
removeServerGeneratedPropertiesFromCase,
} from '../../../../common/lib/utils';
import {
getCaseUserActions,
removeServerGeneratedPropertiesFromUserAction,
} from '../../../../common/lib/user_actions';
} from '../../../../common/lib/api';
import {
secOnly,
secOnlyRead,

View file

@ -9,7 +9,7 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { defaultUser, getPostCaseRequest } from '../../../../../common/lib/mock';
import { createCase, deleteCasesByESQuery, getReporters } from '../../../../../common/lib/utils';
import { createCase, deleteCasesByESQuery, getReporters } from '../../../../../common/lib/api';
import {
secOnly,
obsOnly,

View file

@ -24,7 +24,7 @@ import {
createComment,
removeServerGeneratedPropertiesFromCase,
removeServerGeneratedPropertiesFromSavedObject,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
secOnly,
obsOnly,

View file

@ -18,7 +18,7 @@ import {
deleteAllCaseItems,
superUserSpace1Auth,
extractWarningValueFromWarningHeader,
} from '../../../../../common/lib/utils';
} from '../../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -8,7 +8,7 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { deleteCasesByESQuery, createCase, getTags } from '../../../../../common/lib/utils';
import { deleteCasesByESQuery, createCase, getTags } from '../../../../../common/lib/api';
import { getPostCaseRequest } from '../../../../../common/lib/mock';
import {
secOnly,

View file

@ -15,7 +15,7 @@ import {
createComment,
deleteAllCaseItems,
getSignalsWithES,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -19,7 +19,7 @@ import {
deleteComment,
deleteAllComments,
superUserSpace1Auth,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -26,7 +26,7 @@ import {
getSpaceUrlPrefix,
createCase,
superUserSpace1Auth,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
obsOnly,

View file

@ -17,7 +17,7 @@ import {
getAllComments,
superUserSpace1Auth,
extractWarningValueFromWarningHeader,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -15,7 +15,7 @@ import {
createComment,
getComment,
superUserSpace1Auth,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -9,7 +9,7 @@ import expect from '@kbn/expect';
import { CASES_URL, SECURITY_SOLUTION_OWNER } from '@kbn/cases-plugin/common/constants';
import { CommentResponseAlertsType } from '@kbn/cases-plugin/common/api';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { deleteAllCaseItems, getComment } from '../../../../common/lib/utils';
import { deleteAllCaseItems, getComment } from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default function createGetTests({ getService }: FtrProviderContext) {

View file

@ -30,7 +30,7 @@ import {
createComment,
updateComment,
superUserSpace1Auth,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -34,11 +34,9 @@ import {
removeServerGeneratedPropertiesFromSavedObject,
superUserSpace1Auth,
updateCase,
} from '../../../../common/lib/utils';
import {
getCaseUserActions,
removeServerGeneratedPropertiesFromUserAction,
} from '../../../../common/lib/user_actions';
} from '../../../../common/lib/api';
import {
createSignalsIndex,
deleteSignalsIndex,

View file

@ -16,7 +16,7 @@ import {
createConfiguration,
getConfigurationRequest,
ensureSavedObjectIsAuthorized,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
obsOnly,
secOnly,

View file

@ -12,7 +12,7 @@ import {
getConfiguration,
getConfigureSavedObjectsFromES,
getConnectorMappingsFromES,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default function ({ getService }: FtrProviderContext) {

View file

@ -18,7 +18,7 @@ import {
updateConfiguration,
getConfigurationRequest,
getConfiguration,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
secOnly,
obsOnlyRead,

View file

@ -18,7 +18,7 @@ import {
createConfiguration,
getConfiguration,
ensureSavedObjectIsAuthorized,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
secOnly,

View file

@ -33,11 +33,9 @@ import {
createCaseAndBulkCreateAttachments,
bulkCreateAttachments,
updateCase,
} from '../../../../common/lib/utils';
import {
getCaseUserActions,
removeServerGeneratedPropertiesFromUserAction,
} from '../../../../common/lib/user_actions';
} from '../../../../common/lib/api';
import {
createSignalsIndex,
deleteSignalsIndex,

View file

@ -29,8 +29,8 @@ import {
createComment,
bulkCreateAttachments,
ensureSavedObjectIsAuthorized,
} from '../../../../common/lib/utils';
import { bulkGetAttachments } from '../../../../common/lib/attachments';
bulkGetAttachments,
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -16,7 +16,7 @@ import {
createCase,
createComment,
ensureSavedObjectIsAuthorized,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import {
secOnly,
obsOnly,

View file

@ -8,9 +8,9 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { createCase, deleteAllCaseItems } from '../../../../common/lib/utils';
import { createCase, deleteAllCaseItems } from '../../../../common/lib/api';
import { getPostCaseRequest } from '../../../../common/lib/mock';
import { getConnectors } from '../../../../common/lib/connectors';
import { getConnectors } from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -10,10 +10,16 @@ import { Cookie } from 'tough-cookie';
import { UserProfile } from '@kbn/security-plugin/common';
import { securitySolutionOnlyAllSpacesRole } from '../../../../common/lib/authentication/roles';
import { getPostCaseRequest } from '../../../../common/lib/mock';
import { createCase, deleteAllCaseItems, getCase, updateCase } from '../../../../common/lib/utils';
import {
createCase,
deleteAllCaseItems,
getCase,
updateCase,
getCaseUsers,
loginUsers,
bulkGetUserProfiles,
} from '../../../../common/lib/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { getCaseUsers } from '../../../../common/lib/user_actions';
import { loginUsers, bulkGetUserProfiles } from '../../../../common/lib/user_profiles';
import { createUsersAndRoles, deleteUsersAndRoles } from '../../../../common/lib/authentication';
import {
obsOnly,

View file

@ -8,7 +8,7 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { createCase, deleteAllCaseItems, getCaseMetrics } from '../../../../common/lib/utils';
import { createCase, deleteAllCaseItems, getCaseMetrics } from '../../../../common/lib/api';
import {
secOnly,
obsOnly,

View file

@ -14,7 +14,7 @@ import {
createComment,
deleteAllCaseItems,
getCaseMetrics,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -14,7 +14,7 @@ import {
createComment,
deleteAllCaseItems,
getCaseMetrics,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { arraysToEqual } from '../../../../common/lib/validation';
// eslint-disable-next-line import/no-default-export

View file

@ -16,7 +16,7 @@ import {
deleteAllCaseItems,
getCaseMetrics,
updateCase,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -23,7 +23,7 @@ import {
deleteAllCaseItems,
getCasesMetrics,
updateCase,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { getPostCaseRequest } from '../../../../common/lib/mock';
// eslint-disable-next-line import/no-default-export

View file

@ -24,7 +24,6 @@ import {
secOnlyRead,
superUser,
} from '../../../../common/lib/authentication/users';
import { findCaseUserActions, getCaseUserActions } from '../../../../common/lib/user_actions';
import {
getPostCaseRequest,
persistableStateAttachment,
@ -39,7 +38,9 @@ import {
updateCase,
createComment,
bulkCreateAttachments,
} from '../../../../common/lib/utils';
findCaseUserActions,
getCaseUserActions,
} from '../../../../common/lib/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

View file

@ -28,8 +28,8 @@ import {
updateComment,
deleteComment,
extractWarningValueFromWarningHeader,
} from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
getCaseUserActions,
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,

View file

@ -24,7 +24,6 @@ import {
obsOnly,
obsOnlyRead,
} from '../../../../common/lib/authentication/users';
import { getCaseUserActionStats } from '../../../../common/lib/user_actions';
import {
getPostCaseRequest,
persistableStateAttachment,
@ -42,7 +41,8 @@ import {
deleteAllCaseItems,
updateCase,
superUserSpace1Auth,
} from '../../../../common/lib/utils';
getCaseUserActionStats,
} from '../../../../common/lib/api';
const getCaseUpdateData = (id: string, version: string) => ({
status: CaseStatuses.open,

View file

@ -13,8 +13,7 @@ import {
CommentType,
} from '@kbn/cases-plugin/common/api';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import { deleteAllCaseItems } from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
import { deleteAllCaseItems, getCaseUserActions } from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default function createGetTests({ getService }: FtrProviderContext) {

View file

@ -18,11 +18,13 @@ import {
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { ObjectRemover as ActionsRemover } from '../../../../alerting_api_integration/common/lib';
import { pushCase, deleteAllCaseItems, bulkCreateAttachments } from '../../../common/lib/utils';
import {
pushCase,
deleteAllCaseItems,
bulkCreateAttachments,
createCaseWithConnector,
getRecordingServiceNowSimulatorServer,
} from '../../../common/lib/connectors';
} from '../../../common/lib/api';
import { RecordingServiceNowSimulator } from '../../../../alerting_api_integration/common/plugins/actions_simulators/server/servicenow_simulation';
// eslint-disable-next-line import/no-default-export

View file

@ -14,12 +14,12 @@ import {
findCases,
updateCase,
deleteAllCaseItems,
} from '../../../../common/lib/utils';
import { generateFakeAssignees, suggestUserProfiles } from '../../../../common/lib/user_profiles';
generateFakeAssignees,
suggestUserProfiles,
bulkGetUserProfiles,
} from '../../../../common/lib/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { bulkGetUserProfiles } from '../../../../common/lib/user_profiles';
import { superUser } from '../../../../common/lib/authentication/users';
// eslint-disable-next-line import/no-default-export

View file

@ -12,9 +12,14 @@ import { UserProfile } from '@kbn/security-plugin/common';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { findCasesResp, getPostCaseRequest } from '../../../../common/lib/mock';
import { findCases, createCase, deleteAllCaseItems } from '../../../../common/lib/utils';
import {
findCases,
createCase,
deleteAllCaseItems,
suggestUserProfiles,
loginUsers,
} from '../../../../common/lib/api';
import { secOnlySpacesAll, superUser } from '../../../../common/lib/authentication/users';
import { suggestUserProfiles, loginUsers } from '../../../../common/lib/user_profiles';
import { getUserInfo } from '../../../../common/lib/authentication';
import { createUsersAndRoles, deleteUsersAndRoles } from '../../../../common/lib/authentication';
import { securitySolutionOnlyAllSpacesRole } from '../../../../common/lib/authentication/roles';

View file

@ -42,14 +42,14 @@ import {
calculateDuration,
getComment,
bulkCreateAttachments,
} from '../../../../common/lib/utils';
import {
loginUsers,
setupSuperUserProfile,
getServiceNowConnector,
createCaseWithConnector,
getRecordingServiceNowSimulatorServer,
getServiceNowSimulationServer,
createConnector,
} from '../../../../common/lib/connectors';
} from '../../../../common/lib/api';
import {
globalRead,
noKibanaPrivileges,
@ -60,7 +60,6 @@ import {
superUser,
} from '../../../../common/lib/authentication/users';
import { RecordingServiceNowSimulator } from '../../../../../alerting_api_integration/common/plugins/actions_simulators/server/servicenow_simulation';
import { loginUsers, setupSuperUserProfile } from '../../../../common/lib/user_profiles';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -14,12 +14,10 @@ import {
createCase,
updateCase,
pushCase,
} from '../../../../../common/lib/utils';
import {
createCaseWithConnector,
getServiceNowSimulationServer,
} from '../../../../../common/lib/connectors';
import { findCaseUserActions } from '../../../../../common/lib/user_actions';
findCaseUserActions,
} from '../../../../../common/lib/api';
import { ObjectRemover as ActionsRemover } from '../../../../../../alerting_api_integration/common/lib';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';

View file

@ -24,15 +24,13 @@ import {
pushCase,
updateCase,
updateConfiguration,
} from '../../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../../common/lib/user_actions';
import {
createCaseWithConnector,
getServiceNowSimulationServer,
} from '../../../../../common/lib/connectors';
getCaseUserActions,
} from '../../../../../common/lib/api';
import { ObjectRemover as ActionsRemover } from '../../../../../../alerting_api_integration/common/lib';
import { setupSuperUserProfile } from '../../../../../common/lib/user_profiles';
import { setupSuperUserProfile } from '../../../../../common/lib/api/user_profiles';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -17,12 +17,10 @@ import {
getConfigurationRequest,
removeServerGeneratedPropertiesFromSavedObject,
getConfigurationOutput,
} from '../../../../common/lib/utils';
import {
getServiceNowConnector,
getServiceNowSimulationServer,
createConnector,
} from '../../../../common/lib/connectors';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -19,7 +19,7 @@ import {
getEmailConnector,
getCaseConnectors,
getCasesWebhookConnector,
} from '../../../../common/lib/connectors';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -18,12 +18,10 @@ import {
deleteConfiguration,
createConfiguration,
updateConfiguration,
} from '../../../../common/lib/utils';
import {
getServiceNowConnector,
createConnector,
getServiceNowSimulationServer,
} from '../../../../common/lib/connectors';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -17,12 +17,10 @@ import {
getConfigurationOutput,
deleteConfiguration,
createConfiguration,
} from '../../../../common/lib/utils';
import {
getServiceNowConnector,
getServiceNowSimulationServer,
createConnector,
} from '../../../../common/lib/connectors';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -21,7 +21,7 @@ import {
getSpaceUrlPrefix,
updateComment,
deleteAllComments,
} from '../../../common/lib/utils';
} from '../../../common/lib/api';
import {
superUser,
secOnlyDelete,

View file

@ -33,17 +33,15 @@ import {
deleteAllCaseItems,
pushCase,
updateCase,
} from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
import { getPostCaseRequest, postCommentUserReq } from '../../../../common/lib/mock';
import {
createCaseWithConnector,
createConnector,
getConnectors,
getJiraConnector,
getServiceNowConnector,
getServiceNowSimulationServer,
} from '../../../../common/lib/connectors';
} from '../../../../common/lib/api';
import { getCaseUserActions } from '../../../../common/lib/api/user_actions';
import { getPostCaseRequest, postCommentUserReq } from '../../../../common/lib/mock';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -11,15 +11,18 @@ import expect from '@kbn/expect';
import { ConnectorTypes } from '@kbn/cases-plugin/common/api';
import { ObjectRemover as ActionsRemover } from '../../../../../alerting_api_integration/common/lib';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { createCase, deleteAllCaseItems, pushCase, updateCase } from '../../../../common/lib/utils';
import { postCaseReq } from '../../../../common/lib/mock';
import {
createCaseWithConnector,
createConnector,
getJiraConnector,
getServiceNowSimulationServer,
} from '../../../../common/lib/connectors';
import { getCaseUserActionStats } from '../../../../common/lib/user_actions';
getCaseUserActionStats,
createCase,
deleteAllCaseItems,
pushCase,
updateCase,
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -6,7 +6,7 @@
*/
import expect from '@kbn/expect';
import { loginUsers, suggestUserProfiles } from '../../../../common/lib/user_profiles';
import { loginUsers, suggestUserProfiles } from '../../../../common/lib/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import {
superUser,

View file

@ -10,10 +10,15 @@ import { Cookie } from 'tough-cookie';
import { UserProfile } from '@kbn/security-plugin/common';
import { securitySolutionOnlyAllSpacesRole } from '../../../../common/lib/authentication/roles';
import { getPostCaseRequest } from '../../../../common/lib/mock';
import { createCase, deleteAllCaseItems, updateCase } from '../../../../common/lib/utils';
import {
createCase,
deleteAllCaseItems,
updateCase,
getCaseUsers,
loginUsers,
bulkGetUserProfiles,
} from '../../../../common/lib/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { getCaseUsers } from '../../../../common/lib/user_actions';
import { loginUsers, bulkGetUserProfiles } from '../../../../common/lib/user_profiles';
import { createUsersAndRoles, deleteUsersAndRoles } from '../../../../common/lib/authentication';
import { secOnlySpacesAll, superUser } from '../../../../common/lib/authentication/users';

View file

@ -8,7 +8,7 @@
import expect from '@kbn/expect';
import { CaseStatuses, CommentType } from '@kbn/cases-plugin/common';
import { CreateCaseUserAction, User } from '@kbn/cases-plugin/common/api';
import { setupSuperUserProfile } from '../../../../common/lib/user_profiles';
import { setupSuperUserProfile } from '../../../../common/lib/api/user_profiles';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { superUser } from '../../../../common/lib/authentication/users';
import {
@ -21,8 +21,8 @@ import {
updateComment,
getConfigurationRequest,
updateConfiguration,
} from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
} from '../../../../common/lib/api';
import { getCaseUserActions } from '../../../../common/lib/api/user_actions';
import { getPostCaseRequest, postCommentUserReq } from '../../../../common/lib/mock';
// eslint-disable-next-line import/no-default-export

View file

@ -15,7 +15,7 @@ import {
getCasesByAlert,
deleteAllCaseItems,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { validateCasesFromAlertIDResponse } from '../../../../common/lib/validation';
// eslint-disable-next-line import/no-default-export

View file

@ -15,7 +15,7 @@ import {
deleteCases,
getCase,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -14,7 +14,7 @@ import {
findCases,
createCase,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -15,7 +15,7 @@ import {
getCase,
removeServerGeneratedPropertiesFromCase,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -15,7 +15,7 @@ import {
updateCase,
removeServerGeneratedPropertiesFromCase,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -14,7 +14,7 @@ import {
createCase,
removeServerGeneratedPropertiesFromCase,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

View file

@ -14,7 +14,7 @@ import {
deleteCasesByESQuery,
getAuthWithSuperUser,
getReporters,
} from '../../../../../common/lib/utils';
} from '../../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -16,7 +16,7 @@ import {
getAllCasesStatuses,
deleteAllCaseItems,
getAuthWithSuperUser,
} from '../../../../../common/lib/utils';
} from '../../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -13,7 +13,7 @@ import {
createCase,
getTags,
getAuthWithSuperUser,
} from '../../../../../common/lib/utils';
} from '../../../../../common/lib/api';
import { getPostCaseRequest } from '../../../../../common/lib/mock';
// eslint-disable-next-line import/no-default-export

View file

@ -17,7 +17,7 @@ import {
createComment,
deleteComment,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -18,7 +18,7 @@ import {
getSpaceUrlPrefix,
createCase,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -15,7 +15,7 @@ import {
createComment,
getAllComments,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -15,7 +15,7 @@ import {
createComment,
getComment,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -18,7 +18,7 @@ import {
createComment,
updateComment,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -16,7 +16,7 @@ import {
removeServerGeneratedPropertiesFromSavedObject,
getAuthWithSuperUser,
deleteAllCaseItems,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -17,7 +17,7 @@ import {
createConfiguration,
getConfigurationRequest,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -16,7 +16,7 @@ import {
createConfiguration,
updateConfiguration,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { nullUser } from '../../../../common/lib/mock';
// eslint-disable-next-line import/no-default-export

View file

@ -15,7 +15,7 @@ import {
deleteConfiguration,
createConfiguration,
getAuthWithSuperUser,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
import { nullUser } from '../../../../common/lib/mock';
// eslint-disable-next-line import/no-default-export

View file

@ -16,7 +16,7 @@ import {
getAuthWithSuperUser,
bulkCreateAttachments,
deleteAllCaseItems,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -6,7 +6,7 @@
*/
import expect from '@kbn/expect';
import { suggestUserProfiles } from '../../../../common/lib/user_profiles';
import { suggestUserProfiles } from '../../../../common/lib/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
// eslint-disable-next-line import/no-default-export

View file

@ -12,7 +12,7 @@ import {
deleteAllCaseItems,
getAuthWithSuperUser,
getCasesMetrics,
} from '../../../../common/lib/utils';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -9,8 +9,8 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { getPostCaseRequest } from '../../../../common/lib/mock';
import { deleteAllCaseItems, createCase, getAuthWithSuperUser } from '../../../../common/lib/utils';
import { getCaseUserActions } from '../../../../common/lib/user_actions';
import { deleteAllCaseItems, createCase, getAuthWithSuperUser } from '../../../../common/lib/api';
import { getCaseUserActions } from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

View file

@ -12,12 +12,13 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import { ObjectRemover as ActionsRemover } from '../../../../../alerting_api_integration/common/lib';
import { nullUser } from '../../../../common/lib/mock';
import { pushCase, deleteAllCaseItems, getAuthWithSuperUser } from '../../../../common/lib/utils';
import {
pushCase,
deleteAllCaseItems,
getAuthWithSuperUser,
createCaseWithConnector,
getServiceNowSimulationServer,
} from '../../../../common/lib/connectors';
} from '../../../../common/lib/api';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {

Some files were not shown because too many files have changed in this diff Show more