mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Security Solution][Exceptions] - Fix operator logic for large value lists (#99490)
### Summary Logic for operators was off, this fix adds unit tests to ensure this bug is not hit again and updates logic
This commit is contained in:
parent
f669addb40
commit
ebe85665a9
3 changed files with 77 additions and 1 deletions
|
@ -228,6 +228,7 @@ describe('BuilderEntryItem', () => {
|
|||
test('it renders field values correctly when operator is "isInListOperator"', () => {
|
||||
wrapper = mount(
|
||||
<BuilderEntryItem
|
||||
allowLargeValueLists
|
||||
autocompleteService={autocompleteStartMock}
|
||||
entry={{
|
||||
correspondingKeywordField: undefined,
|
||||
|
@ -264,6 +265,7 @@ describe('BuilderEntryItem', () => {
|
|||
test('it renders field values correctly when operator is "isNotInListOperator"', () => {
|
||||
wrapper = mount(
|
||||
<BuilderEntryItem
|
||||
allowLargeValueLists
|
||||
autocompleteService={autocompleteStartMock}
|
||||
entry={{
|
||||
correspondingKeywordField: undefined,
|
||||
|
|
|
@ -193,7 +193,7 @@ export const BuilderEntryItem: React.FC<EntryItemProps> = ({
|
|||
entry,
|
||||
listType,
|
||||
entry.field != null && entry.field.type === 'boolean',
|
||||
isFirst && !allowLargeValueLists
|
||||
isFirst && allowLargeValueLists
|
||||
);
|
||||
const comboBox = (
|
||||
<OperatorComponent
|
||||
|
|
|
@ -120,6 +120,80 @@ describe('ExceptionBuilderComponent', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('it displays "is in list" operators if "allowLargeValueLists" is true', async () => {
|
||||
wrapper = mount(
|
||||
<EuiThemeProvider>
|
||||
<ExceptionBuilderComponent
|
||||
allowLargeValueLists={true}
|
||||
autocompleteService={autocompleteStartMock}
|
||||
exceptionListItems={[
|
||||
{
|
||||
...getExceptionListItemSchemaMock(),
|
||||
entries: [
|
||||
{ ...getEntryMatchAnyMock(), field: getField('ip').name, value: ['some ip'] },
|
||||
],
|
||||
},
|
||||
]}
|
||||
httpService={mockKibanaHttpService}
|
||||
indexPatterns={{
|
||||
fields,
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
}}
|
||||
isAndDisabled={false}
|
||||
isNestedDisabled={false}
|
||||
isOrDisabled={false}
|
||||
listId="list_id"
|
||||
listNamespaceType="single"
|
||||
listType="detection"
|
||||
ruleName="Test rule"
|
||||
onChange={jest.fn()}
|
||||
/>
|
||||
</EuiThemeProvider>
|
||||
);
|
||||
|
||||
expect(
|
||||
wrapper.find('[data-test-subj="operatorAutocompleteComboBox"]').at(0).prop('options')
|
||||
).toEqual(expect.arrayContaining([{ label: 'is in list' }, { label: 'is not in list' }]));
|
||||
});
|
||||
|
||||
test('it does not display "is in list" operators if "allowLargeValueLists" is false', async () => {
|
||||
wrapper = mount(
|
||||
<EuiThemeProvider>
|
||||
<ExceptionBuilderComponent
|
||||
allowLargeValueLists={false}
|
||||
autocompleteService={autocompleteStartMock}
|
||||
exceptionListItems={[
|
||||
{
|
||||
...getExceptionListItemSchemaMock(),
|
||||
entries: [
|
||||
{ ...getEntryMatchAnyMock(), field: getField('ip').name, value: ['some ip'] },
|
||||
],
|
||||
},
|
||||
]}
|
||||
httpService={mockKibanaHttpService}
|
||||
indexPatterns={{
|
||||
fields,
|
||||
id: '1234',
|
||||
title: 'logstash-*',
|
||||
}}
|
||||
isAndDisabled={false}
|
||||
isNestedDisabled={false}
|
||||
isOrDisabled={false}
|
||||
listId="list_id"
|
||||
listNamespaceType="single"
|
||||
listType="detection"
|
||||
ruleName="Test rule"
|
||||
onChange={jest.fn()}
|
||||
/>
|
||||
</EuiThemeProvider>
|
||||
);
|
||||
|
||||
expect(
|
||||
wrapper.find('[data-test-subj="operatorAutocompleteComboBox"]').at(0).prop('options')
|
||||
).not.toEqual(expect.arrayContaining([{ label: 'is in list' }, { label: 'is not in list' }]));
|
||||
});
|
||||
|
||||
test('it displays "or", "and" and "add nested button" enabled', () => {
|
||||
wrapper = mount(
|
||||
<EuiThemeProvider>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue