-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps][Connectors] Add support of additional fields for Servic…
…eNow ITSM and SecOps (#184023) ## Summary This PR adds support for additional fields for the ServiceNow ITSM and SecOps connector. The additional fields will not be available to the recovered action. <img width="607" alt="Screenshot 2024-05-27 at 6 29 26 PM" src="https://github.com/elastic/kibana/assets/7871006/7d397d7b-2b0b-4399-8d3a-0725ad04a10d"> ## Testing Verify that: 1. Existing rules with ITSM and SecOps configured continue working as expected. 2. Can create rules with an ITSM action and set some additional fields supported by ITSM. You can find the available in the Elastic transformation map inside ServiceNow. 3. The "additional fields" verification in the UI is working as expected. 4. The "additional fields" are not shown when you set a recovered action. Fixes: #183609 ### 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 ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ## Release notes Pass any field to ServiceNow using the ServiceNow ITSM and SecOps connectors with a JSON field called "additional fields". --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
ad646ca
commit 75f3af5
Showing
41 changed files
with
1,174 additions
and
52 deletions.
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
x-pack/plugins/actions/server/integration_tests/__snapshots__/connector_types.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/stack_connectors/common/servicenow/constants.ts
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,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const MAX_ADDITIONAL_FIELDS_LENGTH = 20; |
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
91 changes: 91 additions & 0 deletions
91
...plugins/stack_connectors/public/connector_types/lib/servicenow/additional_fields.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,91 @@ | ||
/* | ||
* 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 { render, screen, waitFor } from '@testing-library/react'; | ||
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; | ||
import { AdditionalFields } from './additional_fields'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
describe('Credentials', () => { | ||
const onChange = jest.fn(); | ||
const value = JSON.stringify({ foo: 'test' }); | ||
const props = { value, errors: [], onChange }; | ||
|
||
it('renders the additional fields correctly', async () => { | ||
render( | ||
<IntlProvider locale="en"> | ||
<AdditionalFields {...props} /> | ||
</IntlProvider> | ||
); | ||
|
||
expect(await screen.findByTestId('additionalFields')).toBeInTheDocument(); | ||
}); | ||
|
||
it('sets the value correctly', async () => { | ||
render( | ||
<IntlProvider locale="en"> | ||
<AdditionalFields {...props} /> | ||
</IntlProvider> | ||
); | ||
|
||
expect(await screen.findByText(value)).toBeInTheDocument(); | ||
}); | ||
|
||
/** | ||
* Test for the intermediate release process | ||
*/ | ||
it('does not show the component if the value is undefined', async () => { | ||
render( | ||
<IntlProvider locale="en"> | ||
<AdditionalFields {...props} value={undefined} /> | ||
</IntlProvider> | ||
); | ||
|
||
expect(screen.queryByTestId('additional_fieldsJsonEditor')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('changes the value correctly', async () => { | ||
const newValue = JSON.stringify({ bar: 'test' }); | ||
|
||
render( | ||
<IntlProvider locale="en"> | ||
<AdditionalFields {...props} /> | ||
</IntlProvider> | ||
); | ||
|
||
const editor = await screen.findByTestId('additional_fieldsJsonEditor'); | ||
|
||
userEvent.clear(editor); | ||
userEvent.paste(editor, newValue); | ||
|
||
await waitFor(() => { | ||
expect(onChange).toHaveBeenCalledWith(newValue); | ||
}); | ||
|
||
expect(await screen.findByText(newValue)).toBeInTheDocument(); | ||
}); | ||
|
||
it('updating wth an empty string sets its value to null', async () => { | ||
const newValue = JSON.stringify({ bar: 'test' }); | ||
|
||
render( | ||
<IntlProvider locale="en"> | ||
<AdditionalFields {...props} /> | ||
</IntlProvider> | ||
); | ||
|
||
const editor = await screen.findByTestId('additional_fieldsJsonEditor'); | ||
|
||
userEvent.paste(editor, newValue); | ||
userEvent.clear(editor); | ||
|
||
await waitFor(() => { | ||
expect(onChange).toHaveBeenCalledWith(null); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.