Skip to content

Commit

Permalink
[SecuritySolution][Endpoint] Update Responder command definition test…
Browse files Browse the repository at this point in the history
… so that it fails when new commands are added (#187491)

## Summary

Updates test so that it fails whenever we add a introduce a new
responder command.

### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
  • Loading branch information
ashokaditya authored Jul 5, 2024
1 parent 53722d5 commit fffc684
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export class EndpointMetadataGenerator extends BaseDataGenerator {
capabilities.push('upload_file');
}

// v8.15 introduced `scan` capability
if (gte(agentVersion, '8.15.0')) {
capabilities.push('scan');
}

const hostMetadataDoc: HostMetadataInterface = {
'@timestamp': ts,
event: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export type EndpointCapabilities = typeof ENDPOINT_CAPABILITIES[number];
export const CONSOLE_RESPONSE_ACTION_COMMANDS = [
'isolate',
'release',
'processes',
'kill-process',
'suspend-process',
'processes',
'get-file',
'execute',
'upload',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { HELP_GROUPS } from '../console_commands_definition';
import { ExperimentalFeaturesService } from '../../../../../common/experimental_features_service';
import type { CommandDefinition } from '../../../console';
import type { HostMetadataInterface } from '../../../../../../common/endpoint/types';
import { CONSOLE_RESPONSE_ACTION_COMMANDS } from '../../../../../../common/endpoint/service/response_actions/constants';

jest.mock('../../../../../common/experimental_features_service');

Expand All @@ -43,8 +44,9 @@ describe('When displaying Endpoint Response Actions', () => {

describe('for agent type endpoint', () => {
beforeEach(() => {
(ExperimentalFeaturesService.get as jest.Mock).mockReturnValueOnce({
(ExperimentalFeaturesService.get as jest.Mock).mockReturnValue({
responseActionUploadEnabled: true,
responseActionScanEnabled: true,
});
commands = getEndpointConsoleCommands({
agentType: 'endpoint',
Expand All @@ -71,17 +73,14 @@ describe('When displaying Endpoint Response Actions', () => {
HELP_GROUPS.responseActions.label
);

expect(commandsInPanel).toEqual([
'isolate',
'release',
'status',
'processes',
'kill-process --pid',
'suspend-process --pid',
'get-file --path',
'execute --command',
'upload --file',
]);
const expectedCommands: string[] = [...CONSOLE_RESPONSE_ACTION_COMMANDS];
// add status to the list of expected commands in that order
expectedCommands.splice(2, 0, 'status');

const helpCommandsString = commandsInPanel.map((command) => command.split(' ')[0]).join(',');

// verify that the help commands map to the command list in the same order
expect(helpCommandsString).toEqual(expectedCommands.join(','));
});
});

Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/security_solution/server/config.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { getDefaultConfigSettings } from '../common/config_settings';
import type { ConfigType } from './config';

export const createMockConfig = (): ConfigType => {
const enableExperimental: Array<keyof ExperimentalFeatures> = ['responseActionUploadEnabled'];
const enableExperimental: Array<keyof ExperimentalFeatures> = [
'responseActionUploadEnabled',
'responseActionScanEnabled',
];

return {
[SIGNALS_INDEX_KEY]: DEFAULT_SIGNALS_INDEX,
Expand Down

0 comments on commit fffc684

Please sign in to comment.