Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya committed Sep 16, 2024
1 parent 48a5ab5 commit 4cb32b0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import type { ScopedClusterClientMock } from '@kbn/core/server/mocks';
import {
analyticsServiceMock,
elasticsearchServiceMock,
httpServerMock,
httpServiceMock,
Expand Down Expand Up @@ -144,6 +145,7 @@ export const createMockEndpointAppContextServiceSetupContract =
securitySolutionRequestContextFactory: requestContextFactoryMock.create(),
cloud: cloudMock.createSetup(),
loggerFactory: loggingSystemMock.create(),
telemetry: analyticsServiceMock.createAnalyticsServiceSetup(),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,41 @@ describe('Response actions', () => {
);
});

describe('Telemetry', () => {
it.each([
['execute', EXECUTE_ROUTE],
['get-file', GET_FILE_ROUTE],
['running-processes', GET_PROCESSES_ROUTE],
['isolate', ISOLATE_HOST_ROUTE_V2],
['kill-process', KILL_PROCESS_ROUTE],
['scan', SCAN_ROUTE],
['suspend-process', SUSPEND_PROCESS_ROUTE],
['unisolate', UNISOLATE_HOST_ROUTE_V2],
['upload', UPLOAD_ROUTE],
])('sends analytics when %s action is created', async (command, route) => {
endpointContext.experimentalFeatures = {
...endpointContext.experimentalFeatures,
responseActionsTelemetryEnabled: true,
};

await callRoute(route, {
body: { endpoint_ids: ['XYZ'], parameters: { path: '/home/usr/' } },
version: '2023-10-31',
});

expect(
(await endpointAppContextService.getTelemetryService().reportEvent) as jest.Mock
).toHaveBeenCalledWith('endpoint_response_action_sent', {
responseActions: expect.objectContaining({
actionId: expect.any(String),
agentType: 'endpoint',
command,
endpointIds: ['agent-a'],
}),
});
});
});

describe('With endpoint data streams', () => {
it('handles unisolation', async () => {
const ctx = await callRoute(
Expand Down

0 comments on commit 4cb32b0

Please sign in to comment.