Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -37,6 +37,7 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
actionTypeId: .servicenow-sir
config:
apiUrl: https://example.service-now.com/
isLegacy: false
secrets:
username: testuser
password: passwordkeystorevalue
Expand All @@ -45,6 +46,9 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
Config defines information for the connector type.

`apiUrl`:: An address that corresponds to *URL*.
`isLegacy`:: A boolean that indicates if the connector should use the Table API (legacy) or the Import Set API.

Note: If `isLegacy` is set to false the Elastic application should be installed in ServiceNow.

Secrets defines sensitive information for the connector type.

Expand Down
4 changes: 4 additions & 0 deletions docs/management/connectors/action-types/servicenow.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
actionTypeId: .servicenow
config:
apiUrl: https://example.service-now.com/
isLegacy: false
secrets:
username: testuser
password: passwordkeystorevalue
Expand All @@ -45,6 +46,9 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
Config defines information for the connector type.

`apiUrl`:: An address that corresponds to *URL*.
`isLegacy`:: A boolean that indicates if the connector should use the Table API (legacy) or the Import Set API.

Note: If `isLegacy` is set to false the Elastic application should be installed in ServiceNow.

Secrets defines sensitive information for the connector type.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const ExternalIncidentServiceConfigurationBase = {

export const ExternalIncidentServiceConfiguration = {
...ExternalIncidentServiceConfigurationBase,
isLegacy: schema.boolean({ defaultValue: false }),
isLegacy: schema.boolean({ defaultValue: true }),
};

export const ExternalIncidentServiceConfigurationBaseSchema = schema.object(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,5 +414,43 @@ describe('ServiceNowActionConnectorFields renders', () => {
.includes(errorMessage)
).toBeTruthy();
});

test('should set the isLegacy to false when creating a connector', async () => {
const newConnector = { ...usesTableApiConnector, config: {}, secrets: {} };
const editActionConfig = jest.fn();

mountWithIntl(
<ServiceNowConnectorFields
// @ts-expect-error
action={newConnector}
errors={{ apiUrl: [], username: [], password: [] }}
editActionConfig={editActionConfig}
editActionSecrets={() => {}}
readOnly={false}
setCallbacks={setCallbacks}
isEdit={false}
/>
);

expect(editActionConfig).toHaveBeenCalledWith('isLegacy', false);
});

test('it should set the legacy attribute if it is not undefined', async () => {
const editActionConfig = jest.fn();

mountWithIntl(
<ServiceNowConnectorFields
action={usesTableApiConnector}
errors={{ apiUrl: [], username: [], password: [] }}
editActionConfig={editActionConfig}
editActionSecrets={() => {}}
readOnly={false}
setCallbacks={setCallbacks}
isEdit={false}
/>
);

expect(editActionConfig).not.toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ServiceNowConnectorFields: React.FC<ActionConnectorFieldsProps<ServiceNowA
http,
notifications: { toasts },
} = useKibana().services;
const { apiUrl } = action.config;
const { apiUrl, isLegacy } = action.config;
const { username, password } = action.secrets;
const isOldConnector = isLegacyConnector(action);

Expand Down Expand Up @@ -123,6 +123,18 @@ const ServiceNowConnectorFields: React.FC<ActionConnectorFieldsProps<ServiceNowA
toasts,
]);

/**
* Defaults the isLegacy attribute to false
* if it is not defined. The isLegacy attribute
* will be undefined only at the creation of
* the connector.
*/
useEffect(() => {
if (isLegacy == null) {
editActionConfig('isLegacy', false);
}
});

return (
<>
{showUpdateConnector && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default function serviceNowITSMTest({ getService }: FtrProviderContext) {
connector_type_id: '.servicenow',
config: {
apiUrl: serviceNowSimulatorURL,
isLegacy: false,
},
secrets: mockServiceNow.secrets,
})
Expand Down Expand Up @@ -125,7 +126,7 @@ export default function serviceNowITSMTest({ getService }: FtrProviderContext) {
});
});

it('should set the isLegacy to false when not provided', async () => {
it('should set the isLegacy to true when not provided', async () => {
const { body: createdAction } = await supertest
.post('/api/actions/connector')
.set('kbn-xsrf', 'foo')
Expand All @@ -143,7 +144,7 @@ export default function serviceNowITSMTest({ getService }: FtrProviderContext) {
.get(`/api/actions/connector/${createdAction.id}`)
.expect(200);

expect(fetchedAction.config.isLegacy).to.be(false);
expect(fetchedAction.config.isLegacy).to.be(true);
});

it('should respond with a 400 Bad Request when creating a servicenow action with no apiUrl', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default function serviceNowSIRTest({ getService }: FtrProviderContext) {
connector_type_id: '.servicenow-sir',
config: {
apiUrl: serviceNowSimulatorURL,
isLegacy: false,
},
secrets: mockServiceNow.secrets,
})
Expand Down Expand Up @@ -129,7 +130,7 @@ export default function serviceNowSIRTest({ getService }: FtrProviderContext) {
});
});

it('should set the isLegacy to false when not provided', async () => {
it('should set the isLegacy to true when not provided', async () => {
const { body: createdAction } = await supertest
.post('/api/actions/connector')
.set('kbn-xsrf', 'foo')
Expand All @@ -147,7 +148,7 @@ export default function serviceNowSIRTest({ getService }: FtrProviderContext) {
.get(`/api/actions/connector/${createdAction.id}`)
.expect(200);

expect(fetchedAction.config.isLegacy).to.be(false);
expect(fetchedAction.config.isLegacy).to.be(true);
});

it('should respond with a 400 Bad Request when creating a servicenow action with no apiUrl', async () => {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/test/case_api_integration/common/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export const getServiceNowConnector = () => ({
},
config: {
apiUrl: 'http://some.non.existent.com',
isLegacy: false,
},
});

Expand Down Expand Up @@ -385,6 +386,7 @@ export const getServiceNowSIRConnector = () => ({
},
config: {
apiUrl: 'http://some.non.existent.com',
isLegacy: false,
},
});

Expand Down