[Security Solution][Endpoint][Host Isolation] Unisolate host minor refactors (#100889)

This commit is contained in:
Candace Park 2021-06-03 12:27:06 -04:00 committed by GitHub
parent a0c20ac7aa
commit 0312839e34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 141 additions and 147 deletions

View file

@ -15,23 +15,24 @@ export const telemetryIndexPattern = 'metrics-endpoint.telemetry-*';
export const LIMITED_CONCURRENCY_ENDPOINT_ROUTE_TAG = 'endpoint:limited-concurrency';
export const LIMITED_CONCURRENCY_ENDPOINT_COUNT = 100;
export const HOST_METADATA_LIST_API = '/api/endpoint/metadata';
export const HOST_METADATA_GET_API = '/api/endpoint/metadata/{id}';
export const BASE_ENDPOINT_ROUTE = '/api/endpoint';
export const HOST_METADATA_LIST_ROUTE = `${BASE_ENDPOINT_ROUTE}/metadata`;
export const HOST_METADATA_GET_ROUTE = `${BASE_ENDPOINT_ROUTE}/metadata/{id}`;
export const TRUSTED_APPS_GET_API = '/api/endpoint/trusted_apps/{id}';
export const TRUSTED_APPS_LIST_API = '/api/endpoint/trusted_apps';
export const TRUSTED_APPS_CREATE_API = '/api/endpoint/trusted_apps';
export const TRUSTED_APPS_UPDATE_API = '/api/endpoint/trusted_apps/{id}';
export const TRUSTED_APPS_DELETE_API = '/api/endpoint/trusted_apps/{id}';
export const TRUSTED_APPS_SUMMARY_API = '/api/endpoint/trusted_apps/summary';
export const TRUSTED_APPS_GET_API = `${BASE_ENDPOINT_ROUTE}/trusted_apps/{id}`;
export const TRUSTED_APPS_LIST_API = `${BASE_ENDPOINT_ROUTE}/trusted_apps`;
export const TRUSTED_APPS_CREATE_API = `${BASE_ENDPOINT_ROUTE}/trusted_apps`;
export const TRUSTED_APPS_UPDATE_API = `${BASE_ENDPOINT_ROUTE}/trusted_apps/{id}`;
export const TRUSTED_APPS_DELETE_API = `${BASE_ENDPOINT_ROUTE}/trusted_apps/{id}`;
export const TRUSTED_APPS_SUMMARY_API = `${BASE_ENDPOINT_ROUTE}/trusted_apps/summary`;
export const BASE_POLICY_RESPONSE_ROUTE = `/api/endpoint/policy_response`;
export const BASE_POLICY_ROUTE = `/api/endpoint/policy`;
export const BASE_POLICY_RESPONSE_ROUTE = `${BASE_ENDPOINT_ROUTE}/policy_response`;
export const BASE_POLICY_ROUTE = `${BASE_ENDPOINT_ROUTE}/policy`;
export const AGENT_POLICY_SUMMARY_ROUTE = `${BASE_POLICY_ROUTE}/summaries`;
/** Host Isolation Routes */
export const ISOLATE_HOST_ROUTE = `/api/endpoint/isolate`;
export const UNISOLATE_HOST_ROUTE = `/api/endpoint/unisolate`;
export const ISOLATE_HOST_ROUTE = `${BASE_ENDPOINT_ROUTE}/isolate`;
export const UNISOLATE_HOST_ROUTE = `${BASE_ENDPOINT_ROUTE}/unisolate`;
/** Endpoint Actions Log Routes */
export const ENDPOINT_ACTION_LOG_ROUTE = `/api/endpoint/action_log/{agent_id}`;

View file

@ -27,25 +27,22 @@ export const EndpointIsolateSuccess = memo<EndpointIsolateSuccessProps>(
}) => {
return (
<>
{isolateAction === 'isolateHost' ? (
<EuiCallOut
iconType="check"
color="success"
title={GET_ISOLATION_SUCCESS_MESSAGE(hostName)}
data-test-subj="hostIsolateSuccessMessage"
>
{additionalInfo}
</EuiCallOut>
) : (
<EuiCallOut
iconType="check"
color="success"
title={GET_UNISOLATION_SUCCESS_MESSAGE(hostName)}
>
{additionalInfo}
</EuiCallOut>
)}
<EuiCallOut
iconType="check"
color="success"
title={
isolateAction === 'isolateHost'
? GET_ISOLATION_SUCCESS_MESSAGE(hostName)
: GET_UNISOLATION_SUCCESS_MESSAGE(hostName)
}
data-test-subj={
isolateAction === 'isolateHost'
? 'hostIsolateSuccessMessage'
: 'hostUnisolateSuccessMessage'
}
>
{additionalInfo}
</EuiCallOut>
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButtonEmpty

View file

@ -0,0 +1,45 @@
/*
* 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 { resolvePathVariables } from './resolve_path_variables';
describe('utils', () => {
describe('resolvePathVariables', () => {
it('should resolve defined variables', () => {
expect(resolvePathVariables('/segment1/{var1}/segment2', { var1: 'value1' })).toBe(
'/segment1/value1/segment2'
);
});
it('should not resolve undefined variables', () => {
expect(resolvePathVariables('/segment1/{var1}/segment2', {})).toBe(
'/segment1/{var1}/segment2'
);
});
it('should ignore unused variables', () => {
expect(resolvePathVariables('/segment1/{var1}/segment2', { var2: 'value2' })).toBe(
'/segment1/{var1}/segment2'
);
});
it('should replace multiple variable occurences', () => {
expect(resolvePathVariables('/{var1}/segment1/{var1}', { var1: 'value1' })).toBe(
'/value1/segment1/value1'
);
});
it('should replace multiple variables', () => {
const path = resolvePathVariables('/{var1}/segment1/{var2}', {
var1: 'value1',
var2: 'value2',
});
expect(path).toBe('/value1/segment1/value2');
});
});
});

View file

@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export const resolvePathVariables = (path: string, variables: { [K: string]: string | number }) =>
Object.keys(variables).reduce((acc, paramName) => {
return acc.replace(new RegExp(`\{${paramName}\}`, 'g'), String(variables[paramName]));
}, path);

View file

@ -36,12 +36,6 @@ export const HostIsolationPanel = React.memo(
return findHostName ? findHostName[0] : '';
}, [details]);
const alertRule = useMemo(() => {
const findAlertRule = find({ category: 'signal', field: 'signal.rule.name' }, details)
?.values;
return findAlertRule ? findAlertRule[0] : '';
}, [details]);
const alertId = useMemo(() => {
const findAlertId = find({ category: '_id', field: '_id' }, details)?.values;
return findAlertId ? findAlertId[0] : '';
@ -95,7 +89,6 @@ export const HostIsolationPanel = React.memo(
<IsolateHost
agentId={agentId}
hostName={hostName}
alertRule={alertRule}
cases={associatedCases}
caseIds={caseIds}
cancelCallback={cancelCallback}
@ -104,7 +97,6 @@ export const HostIsolationPanel = React.memo(
<UnisolateHost
agentId={agentId}
hostName={hostName}
alertRule={alertRule}
cases={associatedCases}
caseIds={caseIds}
cancelCallback={cancelCallback}

View file

@ -20,14 +20,12 @@ export const IsolateHost = React.memo(
({
agentId,
hostName,
alertRule,
cases,
caseIds,
cancelCallback,
}: {
agentId: string;
hostName: string;
alertRule: string;
cases: ReactNode;
caseIds: string[];
cancelCallback: () => void;
@ -80,15 +78,9 @@ export const IsolateHost = React.memo(
messageAppend={
<FormattedMessage
id="xpack.securitySolution.detections.hostIsolation.impactedCases"
defaultMessage="This action will be added to the {cases}."
defaultMessage="This action will be added to {cases}."
values={{
cases: (
<b>
{caseCount}
{CASES_ASSOCIATED_WITH_ALERT(caseCount)}
{alertRule}
</b>
),
cases: <b>{CASES_ASSOCIATED_WITH_ALERT(caseCount)}</b>,
}}
/>
}
@ -103,7 +95,6 @@ export const IsolateHost = React.memo(
comment,
loading,
caseCount,
alertRule,
]);
return isIsolated ? hostIsolatedSuccess : hostNotIsolated;

View file

@ -25,7 +25,8 @@ export const CASES_ASSOCIATED_WITH_ALERT = (caseCount: number): string =>
i18n.translate(
'xpack.securitySolution.endpoint.hostIsolation.isolateHost.casesAssociatedWithAlert',
{
defaultMessage: ' {caseCount, plural, one {case} other {cases}} associated with the rule ',
defaultMessage:
'{caseCount} {caseCount, plural, one {case} other {cases}} associated with this host',
values: { caseCount },
}
);

View file

@ -20,14 +20,12 @@ export const UnisolateHost = React.memo(
({
agentId,
hostName,
alertRule,
cases,
caseIds,
cancelCallback,
}: {
agentId: string;
hostName: string;
alertRule: string;
cases: ReactNode;
caseIds: string[];
cancelCallback: () => void;
@ -80,15 +78,9 @@ export const UnisolateHost = React.memo(
messageAppend={
<FormattedMessage
id="xpack.securitySolution.detections.hostIsolation.impactedCases"
defaultMessage="This action will be added to the {cases}."
defaultMessage="This action will be added to {cases}."
values={{
cases: (
<b>
{caseCount}
{CASES_ASSOCIATED_WITH_ALERT(caseCount)}
{alertRule}
</b>
),
cases: <b>{CASES_ASSOCIATED_WITH_ALERT(caseCount)}</b>,
}}
/>
}
@ -103,7 +95,6 @@ export const UnisolateHost = React.memo(
comment,
loading,
caseCount,
alertRule,
]);
return isUnIsolated ? hostUnisolatedSuccess : hostNotUnisolated;

View file

@ -14,7 +14,7 @@ import {
DETECTION_ENGINE_INDEX_URL,
DETECTION_ENGINE_PRIVILEGES_URL,
} from '../../../../../common/constants';
import { HOST_METADATA_GET_API } from '../../../../../common/endpoint/constants';
import { HOST_METADATA_GET_ROUTE } from '../../../../../common/endpoint/constants';
import { KibanaServices } from '../../../../common/lib/kibana';
import {
BasicSignals,
@ -25,8 +25,8 @@ import {
UpdateAlertStatusProps,
CasesFromAlertsResponse,
} from './types';
import { resolvePathVariables } from '../../../../management/common/utils';
import { isolateHost, unIsolateHost } from '../../../../common/lib/host_isolation';
import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables';
/**
* Fetch Alerts by providing a query
@ -181,6 +181,6 @@ export const getHostMetadata = async ({
agentId: string;
}): Promise<HostMetadataInfo> =>
KibanaServices.get().http.fetch<HostMetadataInfo>(
resolvePathVariables(HOST_METADATA_GET_API, { id: agentId }),
resolvePathVariables(HOST_METADATA_GET_ROUTE, { id: agentId }),
{ method: 'get' }
);

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { parseQueryFilterToKQL, resolvePathVariables } from './utils';
import { parseQueryFilterToKQL } from './utils';
describe('utils', () => {
const searchableFields = [`name`, `description`, `entries.value`, `entries.entries.value`];
@ -39,39 +39,4 @@ describe('utils', () => {
);
});
});
describe('resolvePathVariables', () => {
it('should resolve defined variables', () => {
expect(resolvePathVariables('/segment1/{var1}/segment2', { var1: 'value1' })).toBe(
'/segment1/value1/segment2'
);
});
it('should not resolve undefined variables', () => {
expect(resolvePathVariables('/segment1/{var1}/segment2', {})).toBe(
'/segment1/{var1}/segment2'
);
});
it('should ignore unused variables', () => {
expect(resolvePathVariables('/segment1/{var1}/segment2', { var2: 'value2' })).toBe(
'/segment1/{var1}/segment2'
);
});
it('should replace multiple variable occurences', () => {
expect(resolvePathVariables('/{var1}/segment1/{var1}', { var1: 'value1' })).toBe(
'/value1/segment1/value1'
);
});
it('should replace multiple variables', () => {
const path = resolvePathVariables('/{var1}/segment1/{var2}', {
var1: 'value1',
var2: 'value2',
});
expect(path).toBe('/value1/segment1/value2');
});
});
});

View file

@ -19,8 +19,3 @@ export const parseQueryFilterToKQL = (filter: string, fields: Readonly<string[]>
return kuery;
};
export const resolvePathVariables = (path: string, variables: { [K: string]: string | number }) =>
Object.keys(variables).reduce((acc, paramName) => {
return acc.replace(new RegExp(`\{${paramName}\}`, 'g'), String(variables[paramName]));
}, path);

View file

@ -41,12 +41,11 @@ import {
import { AGENT_POLICY_SAVED_OBJECT_TYPE } from '../../../../../../fleet/common';
import {
ENDPOINT_ACTION_LOG_ROUTE,
HOST_METADATA_GET_API,
HOST_METADATA_LIST_API,
HOST_METADATA_GET_ROUTE,
HOST_METADATA_LIST_ROUTE,
metadataCurrentIndexPattern,
} from '../../../../../common/endpoint/constants';
import { IIndexPattern, Query } from '../../../../../../../../src/plugins/data/public';
import { resolvePathVariables } from '../../../common/utils';
import {
createFailedResourceState,
createLoadedResourceState,
@ -54,6 +53,7 @@ import {
} from '../../../state';
import { isolateHost } from '../../../../common/lib/host_isolation';
import { AppAction } from '../../../../common/store/actions';
import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables';
type EndpointPageStore = ImmutableMiddlewareAPI<EndpointState, AppAction>;
@ -104,7 +104,7 @@ export const endpointMiddlewareFactory: ImmutableMiddlewareFactory<EndpointState
try {
const decodedQuery: Query = searchBarQuery(getState());
endpointResponse = await coreStart.http.post<HostResultList>(HOST_METADATA_LIST_API, {
endpointResponse = await coreStart.http.post<HostResultList>(HOST_METADATA_LIST_ROUTE, {
body: JSON.stringify({
paging_properties: [{ page_index: pageIndex }, { page_size: pageSize }],
filters: { kql: decodedQuery.query },
@ -253,7 +253,7 @@ export const endpointMiddlewareFactory: ImmutableMiddlewareFactory<EndpointState
if (listData(getState()).length === 0) {
const { page_index: pageIndex, page_size: pageSize } = uiQueryParams(getState());
try {
const response = await coreStart.http.post(HOST_METADATA_LIST_API, {
const response = await coreStart.http.post(HOST_METADATA_LIST_ROUTE, {
body: JSON.stringify({
paging_properties: [{ page_index: pageIndex }, { page_size: pageSize }],
}),
@ -303,7 +303,7 @@ export const endpointMiddlewareFactory: ImmutableMiddlewareFactory<EndpointState
const { selected_endpoint: selectedEndpoint } = uiQueryParams(getState());
try {
const response = await coreStart.http.get<HostInfo>(
resolvePathVariables(HOST_METADATA_GET_API, { id: selectedEndpoint as string })
resolvePathVariables(HOST_METADATA_GET_ROUTE, { id: selectedEndpoint as string })
);
dispatch({
type: 'serverReturnedEndpointDetails',
@ -458,7 +458,7 @@ const getAgentAndPoliciesForEndpointsList = async (
const endpointsTotal = async (http: HttpStart): Promise<number> => {
try {
return (
await http.post<HostResultList>(HOST_METADATA_LIST_API, {
await http.post<HostResultList>(HOST_METADATA_LIST_ROUTE, {
body: JSON.stringify({
paging_properties: [{ page_index: 0 }, { page_size: 1 }],
}),

View file

@ -29,8 +29,8 @@ import {
GetOneTrustedAppRequestParams,
GetOneTrustedAppResponse,
} from '../../../../../common/endpoint/types/trusted_apps';
import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables';
import { resolvePathVariables } from '../../../common/utils';
import { sendGetEndpointSpecificPackagePolicies } from '../../policy/store/services/ingest';
export interface TrustedAppsService {

View file

@ -31,9 +31,9 @@ import {
import { EndpointDocGenerator } from '../../../../../common/endpoint/generate_data';
import { isFailedResourceState, isLoadedResourceState } from '../state';
import { forceHTMLElementOffsetWidth } from './components/effected_policy_select/test_utils';
import { resolvePathVariables } from '../../../common/utils';
import { toUpdateTrustedApp } from '../../../../../common/endpoint/service/trusted_apps/to_update_trusted_app';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables';
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => () => 'mockId',

View file

@ -11,12 +11,14 @@ import { HostStatus, MetadataQueryStrategyVersions } from '../../../../common/en
import { EndpointAppContext } from '../../types';
import { getLogger, getMetadataListRequestHandler, getMetadataRequestHandler } from './handlers';
import type { SecuritySolutionPluginRouter } from '../../../types';
import {
BASE_ENDPOINT_ROUTE,
HOST_METADATA_GET_ROUTE,
HOST_METADATA_LIST_ROUTE,
} from '../../../../common/endpoint/constants';
export const BASE_ENDPOINT_ROUTE = '/api/endpoint';
export const METADATA_REQUEST_V1_ROUTE = `${BASE_ENDPOINT_ROUTE}/v1/metadata`;
export const GET_METADATA_REQUEST_V1_ROUTE = `${METADATA_REQUEST_V1_ROUTE}/{id}`;
export const METADATA_REQUEST_ROUTE = `${BASE_ENDPOINT_ROUTE}/metadata`;
export const GET_METADATA_REQUEST_ROUTE = `${METADATA_REQUEST_ROUTE}/{id}`;
/* Filters that can be applied to the endpoint fetch route */
export const endpointFilters = schema.object({
@ -82,7 +84,7 @@ export function registerEndpointRoutes(
router.post(
{
path: `${METADATA_REQUEST_ROUTE}`,
path: `${HOST_METADATA_LIST_ROUTE}`,
validate: GetMetadataListRequestSchema,
options: { authRequired: true, tags: ['access:securitySolution'] },
},
@ -100,7 +102,7 @@ export function registerEndpointRoutes(
router.get(
{
path: `${GET_METADATA_REQUEST_ROUTE}`,
path: `${HOST_METADATA_GET_ROUTE}`,
validate: GetMetadataRequestSchema,
options: { authRequired: true, tags: ['access:securitySolution'] },
},

View file

@ -26,7 +26,7 @@ import {
MetadataQueryStrategyVersions,
} from '../../../../common/endpoint/types';
import { parseExperimentalConfigValue } from '../../../../common/experimental_features';
import { registerEndpointRoutes, METADATA_REQUEST_ROUTE } from './index';
import { registerEndpointRoutes } from './index';
import {
createMockEndpointAppContextServiceStartContract,
createMockPackageService,
@ -45,7 +45,10 @@ import {
} from '../../../../../fleet/common/types/models';
import { createV1SearchResponse, createV2SearchResponse } from './support/test_support';
import { PackageService } from '../../../../../fleet/server/services';
import { metadataTransformPrefix } from '../../../../common/endpoint/constants';
import {
HOST_METADATA_LIST_ROUTE,
metadataTransformPrefix,
} from '../../../../common/endpoint/constants';
import type { SecuritySolutionPluginRouter } from '../../../types';
import { PackagePolicyServiceInterface } from '../../../../../fleet/server';
import {
@ -126,7 +129,7 @@ describe('test endpoint route', () => {
Promise.resolve({ body: response })
);
[routeConfig, routeHandler] = routerMock.post.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
mockAgentService.getAgentStatusById = jest.fn().mockReturnValue('error');
mockAgentService.listAgents = jest.fn().mockReturnValue(noUnenrolledAgent);
@ -167,7 +170,7 @@ describe('test endpoint route', () => {
);
[routeConfig, routeHandler] = routerMock.get.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(
@ -225,7 +228,7 @@ describe('test endpoint route', () => {
Promise.resolve({ body: response })
);
[routeConfig, routeHandler] = routerMock.post.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
mockAgentService.getAgentStatusById = jest.fn().mockReturnValue('error');
mockAgentService.listAgents = jest.fn().mockReturnValue(noUnenrolledAgent);
@ -273,7 +276,7 @@ describe('test endpoint route', () => {
})
);
[routeConfig, routeHandler] = routerMock.post.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(
@ -332,7 +335,7 @@ describe('test endpoint route', () => {
})
);
[routeConfig, routeHandler] = routerMock.post.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(
@ -416,7 +419,7 @@ describe('test endpoint route', () => {
} as unknown) as Agent);
[routeConfig, routeHandler] = routerMock.get.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(
createRouteHandlerContext(mockScopedClient, mockSavedObjectClient),
@ -449,7 +452,7 @@ describe('test endpoint route', () => {
);
[routeConfig, routeHandler] = routerMock.get.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(
@ -490,7 +493,7 @@ describe('test endpoint route', () => {
);
[routeConfig, routeHandler] = routerMock.get.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(
@ -525,7 +528,7 @@ describe('test endpoint route', () => {
);
[routeConfig, routeHandler] = routerMock.get.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(
@ -558,7 +561,7 @@ describe('test endpoint route', () => {
} as unknown) as Agent);
[routeConfig, routeHandler] = routerMock.get.mock.calls.find(([{ path }]) =>
path.startsWith(`${METADATA_REQUEST_ROUTE}`)
path.startsWith(`${HOST_METADATA_LIST_ROUTE}`)
)!;
await routeHandler(

View file

@ -12,8 +12,8 @@ import {
deleteAllDocsFromMetadataIndex,
deleteMetadataStream,
} from './data_stream_helper';
import { METADATA_REQUEST_ROUTE } from '../../../plugins/security_solution/server/endpoint/routes/metadata';
import { MetadataQueryStrategyVersions } from '../../../plugins/security_solution/common/endpoint/types';
import { HOST_METADATA_LIST_ROUTE } from '../../../plugins/security_solution/common/endpoint/constants';
/**
* The number of host documents in the es archive.
@ -25,13 +25,13 @@ export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
describe('test metadata api', () => {
describe(`POST ${METADATA_REQUEST_ROUTE} when index is empty`, () => {
describe(`POST ${HOST_METADATA_LIST_ROUTE} when index is empty`, () => {
it('metadata api should return empty result when index is empty', async () => {
await deleteMetadataStream(getService);
await deleteAllDocsFromMetadataIndex(getService);
await deleteAllDocsFromMetadataCurrentIndex(getService);
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send()
.expect(200);
@ -42,7 +42,7 @@ export default function ({ getService }: FtrProviderContext) {
});
});
describe(`POST ${METADATA_REQUEST_ROUTE} when index is not empty`, () => {
describe(`POST ${HOST_METADATA_LIST_ROUTE} when index is not empty`, () => {
before(async () => {
await esArchiver.load('endpoint/metadata/api_feature', { useCreate: true });
// wait for transform
@ -57,7 +57,7 @@ export default function ({ getService }: FtrProviderContext) {
});
it('metadata api should return one entry for each host with default paging', async () => {
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send()
.expect(200);
@ -69,7 +69,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return page based on paging properties passed.', async () => {
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
paging_properties: [
@ -94,7 +94,7 @@ export default function ({ getService }: FtrProviderContext) {
*/
it('metadata api should return accurate total metadata if page index produces no result', async () => {
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
paging_properties: [
@ -116,7 +116,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return 400 when pagingProperties is below boundaries.', async () => {
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
paging_properties: [
@ -134,7 +134,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return page based on filters passed.', async () => {
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
filters: {
@ -152,7 +152,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return page based on filters and paging passed.', async () => {
const notIncludedIp = '10.46.229.234';
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
paging_properties: [
@ -190,7 +190,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return page based on host.os.Ext.variant filter.', async () => {
const variantValue = 'Windows Pro';
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
filters: {
@ -212,7 +212,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return the latest event for all the events for an endpoint', async () => {
const targetEndpointIp = '10.46.229.234';
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
filters: {
@ -234,7 +234,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return the latest event for all the events where policy status is not success', async () => {
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
filters: {
@ -255,7 +255,7 @@ export default function ({ getService }: FtrProviderContext) {
const targetEndpointId = 'fc0ff548-feba-41b6-8367-65e8790d0eaf';
const targetElasticAgentId = '023fa40c-411d-4188-a941-4147bfadd095';
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
filters: {
@ -278,7 +278,7 @@ export default function ({ getService }: FtrProviderContext) {
it('metadata api should return all hosts when filter is empty string', async () => {
const { body } = await supertest
.post(`${METADATA_REQUEST_ROUTE}`)
.post(`${HOST_METADATA_LIST_ROUTE}`)
.set('kbn-xsrf', 'xxx')
.send({
filters: {