Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ingest pipelines] add community id processor #103863

Merged
merged 23 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
93811b5
wip: community_id processor
sabarasaba Jun 30, 2021
8ba5838
fix up validation conditions for fields
sabarasaba Jun 30, 2021
9892aaf
add tests
sabarasaba Jul 1, 2021
0eedfa0
Merge branch 'master' into add_comunity_id_processor
kibanamachine Jul 5, 2021
137721e
Fix layout and tests
sabarasaba Jul 5, 2021
8b477b0
Fix copy and validations
sabarasaba Jul 6, 2021
633851b
Remove unused prop
sabarasaba Jul 6, 2021
e810727
Merge branch 'master' into add_comunity_id_processor
sabarasaba Jul 13, 2021
ba46932
fix test matchers
sabarasaba Jul 13, 2021
c5ef54e
lowercase copy
sabarasaba Jul 13, 2021
bd74071
Convert hardcoded values to variables
sabarasaba Jul 13, 2021
26c6933
Remove extra dollar sign
sabarasaba Jul 13, 2021
ee6d096
fix copy variable
sabarasaba Jul 13, 2021
40eecaa
Update x-pack/plugins/ingest_pipelines/public/application/components/…
sabarasaba Jul 16, 2021
d9906cc
Update x-pack/plugins/ingest_pipelines/public/application/components/…
sabarasaba Jul 16, 2021
64b70f9
Update x-pack/plugins/ingest_pipelines/public/application/components/…
sabarasaba Jul 16, 2021
19d500f
Update x-pack/plugins/ingest_pipelines/public/application/components/…
sabarasaba Jul 16, 2021
0dabf68
Update x-pack/plugins/ingest_pipelines/public/application/components/…
sabarasaba Jul 16, 2021
db098dc
Merge branch 'master' into add_comunity_id_processor
kibanamachine Jul 16, 2021
7e399a3
No need to whitelist known fields
sabarasaba Jul 16, 2021
77d00ea
CR changes
sabarasaba Jul 19, 2021
8497055
Merge branch 'master' into add_comunity_id_processor
kibanamachine Jul 19, 2021
9be5b0e
Merge branch 'master' into add_comunity_id_processor
kibanamachine Jul 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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 { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';

const COMMUNITY_ID_TYPE = 'community_id';

describe('Processor: Community id', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;

beforeAll(() => {
jest.useFakeTimers();
});

afterAll(() => {
jest.useRealTimers();
});

beforeEach(async () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
value: {
processors: [],
},
onFlyoutOpen: jest.fn(),
onUpdate,
});
});

testBed.component.update();

// Open flyout to add new processor
testBed.actions.addProcessor();
// Add type (the other fields are not visible until a type is selected)
await testBed.actions.addProcessorType(COMMUNITY_ID_TYPE);
});

test('can submit if no fields are filled', async () => {
const {
actions: { saveNewProcessor },
form,
} = testBed;

// Click submit button with no fields filled
await saveNewProcessor();

// Expect no form errors
expect(form.getErrorsMessages()).toHaveLength(0);
});

test('allows to set either iana_number or transport', async () => {
const { find, form } = testBed;

expect(find('ianaField.input').exists()).toBe(true);
expect(find('transportField.input').exists()).toBe(true);

form.setInputValue('ianaField.input', 'iana_number');
expect(find('transportField.input').props().disabled).toBe(true);

form.setInputValue('ianaField.input', '');
form.setInputValue('transportField.input', 'transport');
expect(find('ianaField.input').props().disabled).toBe(true);
});

test('allows optional parameters to be set', async () => {
const {
actions: { saveNewProcessor },
form,
} = testBed;

form.toggleEuiSwitch('ignoreMissingSwitch.input');
form.toggleEuiSwitch('ignoreFailureSwitch.input');
form.setInputValue('sourceIpField.input', 'source.ip');
form.setInputValue('sourcePortField.input', 'source.port');
form.setInputValue('targetField.input', 'target_field');
form.setInputValue('destinationIpField.input', 'destination.ip');
form.setInputValue('destinationPortField.input', 'destination.port');
form.setInputValue('icmpTypeField.input', 'icmp_type');
form.setInputValue('icmpCodeField.input', 'icmp_code');
form.setInputValue('ianaField.input', 'iana');
form.setInputValue('seedField.input', '10');

// Save the field with new changes
await saveNewProcessor();

const processors = getProcessorValue(onUpdate, COMMUNITY_ID_TYPE);
expect(processors[0][COMMUNITY_ID_TYPE]).toEqual({
ignore_failure: true,
ignore_missing: false,
target_field: 'target_field',
source_ip: 'source.ip',
source_port: 'source.port',
destination_ip: 'destination.ip',
destination_port: 'destination.port',
icmp_type: 'icmp_type',
icmp_code: 'icmp_code',
iana_number: 'iana',
seed: 10,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,13 @@ type TestSubject =
| 'fieldsValueField.input'
| 'saltValueField.input'
| 'methodsValueField'
| 'sourceIpField.input'
| 'sourcePortField.input'
| 'destinationIpField.input'
| 'destinationPortField.input'
| 'icmpTypeField.input'
| 'icmpCodeField.input'
| 'ianaField.input'
| 'transportField.input'
| 'seedField.input'
| 'trimSwitch.input';
Loading