-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Endpoint][Sentinel One] Gate calls to `/agent_sta…
…tus` on `endpoint` agent (#180600) ## Summary Gates call to internal `agent_status` API call that supports only `sentinel_one` to be called on `endpoint` agent responder. ### Checklist Delete any items that are not applicable to this PR. - [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
1 parent
8162230
commit 3ad523d
Showing
6 changed files
with
123 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...y_solution/public/detections/components/host_isolation/use_host_isolation_action.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { useHostIsolationAction } from './use_host_isolation_action'; | ||
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { useGetSentinelOneAgentStatus } from './use_sentinelone_host_isolation'; | ||
|
||
jest.mock('./use_sentinelone_host_isolation'); | ||
jest.mock('../../../common/hooks/use_experimental_features'); | ||
const useIsExperimentalFeatureEnabledMock = useIsExperimentalFeatureEnabled as jest.Mock; | ||
const useGetSentinelOneAgentStatusMock = useGetSentinelOneAgentStatus as jest.Mock; | ||
|
||
describe('useHostIsolationAction', () => { | ||
const createReactQueryWrapper = () => { | ||
const queryClient = new QueryClient(); | ||
const wrapper: React.FC = ({ children }) => ( | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
); | ||
return wrapper; | ||
}; | ||
|
||
const render = (isSentinelAlert: boolean = true) => | ||
renderHook( | ||
() => | ||
useHostIsolationAction({ | ||
closePopover: jest.fn(), | ||
detailsData: isSentinelAlert | ||
? [ | ||
{ | ||
category: 'event', | ||
field: 'event.module', | ||
values: ['sentinel_one'], | ||
originalValue: ['sentinel_one'], | ||
isObjectArray: false, | ||
}, | ||
{ | ||
category: 'observer', | ||
field: 'observer.serial_number', | ||
values: ['some-agent-id'], | ||
originalValue: ['some-agent-id'], | ||
isObjectArray: false, | ||
}, | ||
] | ||
: [ | ||
{ | ||
category: 'agent', | ||
field: 'agent.id', | ||
values: ['some-agent-id'], | ||
originalValue: ['some-agent-id'], | ||
isObjectArray: false, | ||
}, | ||
], | ||
isHostIsolationPanelOpen: false, | ||
onAddIsolationStatusClick: jest.fn(), | ||
}), | ||
{ | ||
wrapper: createReactQueryWrapper(), | ||
} | ||
); | ||
|
||
beforeEach(() => { | ||
useIsExperimentalFeatureEnabledMock.mockReturnValue(true); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('`useGetSentinelOneAgentStatusMock` is invoked as `enabled` when SentinelOne alert and FF enabled', () => { | ||
render(); | ||
|
||
expect(useGetSentinelOneAgentStatusMock).toHaveBeenCalledWith(['some-agent-id'], { | ||
enabled: true, | ||
}); | ||
}); | ||
|
||
it('`useGetSentinelOneAgentStatusMock` is invoked as `disabled` when SentinelOne alert and FF disabled', () => { | ||
useIsExperimentalFeatureEnabledMock.mockReturnValue(false); | ||
render(); | ||
|
||
expect(useGetSentinelOneAgentStatusMock).toHaveBeenCalledWith(['some-agent-id'], { | ||
enabled: false, | ||
}); | ||
}); | ||
|
||
it('`useGetSentinelOneAgentStatusMock` is invoked as `disabled` when non-SentinelOne alert', () => { | ||
render(false); | ||
|
||
expect(useGetSentinelOneAgentStatusMock).toHaveBeenCalledWith([''], { | ||
enabled: false, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters