mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
[Connectors][ServiceNow] Default isLegacy
to true for API consumers (#115367)
This commit is contained in:
parent
800cfb504c
commit
43e0043fcb
8 changed files with 68 additions and 6 deletions
|
@ -37,6 +37,7 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
|
||||||
actionTypeId: .servicenow-sir
|
actionTypeId: .servicenow-sir
|
||||||
config:
|
config:
|
||||||
apiUrl: https://example.service-now.com/
|
apiUrl: https://example.service-now.com/
|
||||||
|
isLegacy: false
|
||||||
secrets:
|
secrets:
|
||||||
username: testuser
|
username: testuser
|
||||||
password: passwordkeystorevalue
|
password: passwordkeystorevalue
|
||||||
|
@ -45,6 +46,9 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
|
||||||
Config defines information for the connector type.
|
Config defines information for the connector type.
|
||||||
|
|
||||||
`apiUrl`:: An address that corresponds to *URL*.
|
`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.
|
Secrets defines sensitive information for the connector type.
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
|
||||||
actionTypeId: .servicenow
|
actionTypeId: .servicenow
|
||||||
config:
|
config:
|
||||||
apiUrl: https://example.service-now.com/
|
apiUrl: https://example.service-now.com/
|
||||||
|
isLegacy: false
|
||||||
secrets:
|
secrets:
|
||||||
username: testuser
|
username: testuser
|
||||||
password: passwordkeystorevalue
|
password: passwordkeystorevalue
|
||||||
|
@ -45,6 +46,9 @@ Use the <<action-settings, Action configuration settings>> to customize connecto
|
||||||
Config defines information for the connector type.
|
Config defines information for the connector type.
|
||||||
|
|
||||||
`apiUrl`:: An address that corresponds to *URL*.
|
`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.
|
Secrets defines sensitive information for the connector type.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const ExternalIncidentServiceConfigurationBase = {
|
||||||
|
|
||||||
export const ExternalIncidentServiceConfiguration = {
|
export const ExternalIncidentServiceConfiguration = {
|
||||||
...ExternalIncidentServiceConfigurationBase,
|
...ExternalIncidentServiceConfigurationBase,
|
||||||
isLegacy: schema.boolean({ defaultValue: false }),
|
isLegacy: schema.boolean({ defaultValue: true }),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ExternalIncidentServiceConfigurationBaseSchema = schema.object(
|
export const ExternalIncidentServiceConfigurationBaseSchema = schema.object(
|
||||||
|
|
|
@ -414,5 +414,43 @@ describe('ServiceNowActionConnectorFields renders', () => {
|
||||||
.includes(errorMessage)
|
.includes(errorMessage)
|
||||||
).toBeTruthy();
|
).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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ const ServiceNowConnectorFields: React.FC<ActionConnectorFieldsProps<ServiceNowA
|
||||||
http,
|
http,
|
||||||
notifications: { toasts },
|
notifications: { toasts },
|
||||||
} = useKibana().services;
|
} = useKibana().services;
|
||||||
const { apiUrl } = action.config;
|
const { apiUrl, isLegacy } = action.config;
|
||||||
const { username, password } = action.secrets;
|
const { username, password } = action.secrets;
|
||||||
const isOldConnector = isLegacyConnector(action);
|
const isOldConnector = isLegacyConnector(action);
|
||||||
|
|
||||||
|
@ -123,6 +123,18 @@ const ServiceNowConnectorFields: React.FC<ActionConnectorFieldsProps<ServiceNowA
|
||||||
toasts,
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{showUpdateConnector && (
|
{showUpdateConnector && (
|
||||||
|
|
|
@ -91,6 +91,7 @@ export default function serviceNowITSMTest({ getService }: FtrProviderContext) {
|
||||||
connector_type_id: '.servicenow',
|
connector_type_id: '.servicenow',
|
||||||
config: {
|
config: {
|
||||||
apiUrl: serviceNowSimulatorURL,
|
apiUrl: serviceNowSimulatorURL,
|
||||||
|
isLegacy: false,
|
||||||
},
|
},
|
||||||
secrets: mockServiceNow.secrets,
|
secrets: mockServiceNow.secrets,
|
||||||
})
|
})
|
||||||
|
@ -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
|
const { body: createdAction } = await supertest
|
||||||
.post('/api/actions/connector')
|
.post('/api/actions/connector')
|
||||||
.set('kbn-xsrf', 'foo')
|
.set('kbn-xsrf', 'foo')
|
||||||
|
@ -143,7 +144,7 @@ export default function serviceNowITSMTest({ getService }: FtrProviderContext) {
|
||||||
.get(`/api/actions/connector/${createdAction.id}`)
|
.get(`/api/actions/connector/${createdAction.id}`)
|
||||||
.expect(200);
|
.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 () => {
|
it('should respond with a 400 Bad Request when creating a servicenow action with no apiUrl', async () => {
|
||||||
|
|
|
@ -95,6 +95,7 @@ export default function serviceNowSIRTest({ getService }: FtrProviderContext) {
|
||||||
connector_type_id: '.servicenow-sir',
|
connector_type_id: '.servicenow-sir',
|
||||||
config: {
|
config: {
|
||||||
apiUrl: serviceNowSimulatorURL,
|
apiUrl: serviceNowSimulatorURL,
|
||||||
|
isLegacy: false,
|
||||||
},
|
},
|
||||||
secrets: mockServiceNow.secrets,
|
secrets: mockServiceNow.secrets,
|
||||||
})
|
})
|
||||||
|
@ -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
|
const { body: createdAction } = await supertest
|
||||||
.post('/api/actions/connector')
|
.post('/api/actions/connector')
|
||||||
.set('kbn-xsrf', 'foo')
|
.set('kbn-xsrf', 'foo')
|
||||||
|
@ -147,7 +148,7 @@ export default function serviceNowSIRTest({ getService }: FtrProviderContext) {
|
||||||
.get(`/api/actions/connector/${createdAction.id}`)
|
.get(`/api/actions/connector/${createdAction.id}`)
|
||||||
.expect(200);
|
.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 () => {
|
it('should respond with a 400 Bad Request when creating a servicenow action with no apiUrl', async () => {
|
||||||
|
|
|
@ -329,6 +329,7 @@ export const getServiceNowConnector = () => ({
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
apiUrl: 'http://some.non.existent.com',
|
apiUrl: 'http://some.non.existent.com',
|
||||||
|
isLegacy: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -385,6 +386,7 @@ export const getServiceNowSIRConnector = () => ({
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
apiUrl: 'http://some.non.existent.com',
|
apiUrl: 'http://some.non.existent.com',
|
||||||
|
isLegacy: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue