mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Conflicts: # x-pack/plugins/cases/server/connectors/case/index.test.ts # x-pack/plugins/cases/server/connectors/case/schema.ts Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
b7f9a41f48
commit
68e8ba4024
2 changed files with 79 additions and 3 deletions
|
@ -171,6 +171,34 @@ describe('case connector', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: 'servicenow-sir',
|
||||
params: {
|
||||
subAction: 'create',
|
||||
subActionParams: {
|
||||
title: 'Case from case connector!!',
|
||||
tags: ['case', 'connector'],
|
||||
description: 'Yo fields!!',
|
||||
connector: {
|
||||
id: 'servicenow-sir',
|
||||
name: 'Servicenow SIR',
|
||||
type: '.servicenow-sir',
|
||||
fields: {
|
||||
destIp: true,
|
||||
sourceIp: true,
|
||||
malwareHash: true,
|
||||
malwareUrl: true,
|
||||
category: 'ddos',
|
||||
subcategory: '15',
|
||||
priority: '1',
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
syncAlerts: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: 'none',
|
||||
params: {
|
||||
|
@ -474,7 +502,7 @@ describe('case connector', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('succeeds when servicenow fields are valid', () => {
|
||||
it('succeeds when servicenow ITSM fields are valid', () => {
|
||||
const params: Record<string, unknown> = {
|
||||
subAction: 'update',
|
||||
subActionParams: {
|
||||
|
@ -508,6 +536,42 @@ describe('case connector', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('succeeds when servicenow SIR fields are valid', () => {
|
||||
const params: Record<string, unknown> = {
|
||||
subAction: 'update',
|
||||
subActionParams: {
|
||||
id: 'case-id',
|
||||
version: '123',
|
||||
connector: {
|
||||
id: 'servicenow-sir',
|
||||
name: 'Servicenow SIR',
|
||||
type: '.servicenow-sir',
|
||||
fields: {
|
||||
destIp: true,
|
||||
sourceIp: true,
|
||||
malwareHash: true,
|
||||
malwareUrl: true,
|
||||
category: 'ddos',
|
||||
subcategory: '15',
|
||||
priority: '1',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(validateParams(caseActionType, params)).toEqual({
|
||||
...params,
|
||||
subActionParams: {
|
||||
description: null,
|
||||
tags: null,
|
||||
title: null,
|
||||
status: null,
|
||||
settings: null,
|
||||
...(params.subActionParams as Record<string, unknown>),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('set fields to null if they are missing', () => {
|
||||
const params: Record<string, unknown> = {
|
||||
subAction: 'update',
|
||||
|
|
|
@ -56,7 +56,7 @@ const ResilientFieldsSchema = schema.object({
|
|||
severityCode: schema.nullable(schema.string()),
|
||||
});
|
||||
|
||||
const ServiceNowFieldsSchema = schema.object({
|
||||
const ServiceNowITSMFieldsSchema = schema.object({
|
||||
impact: schema.nullable(schema.string()),
|
||||
severity: schema.nullable(schema.string()),
|
||||
urgency: schema.nullable(schema.string()),
|
||||
|
@ -64,11 +64,22 @@ const ServiceNowFieldsSchema = schema.object({
|
|||
subcategory: schema.nullable(schema.string()),
|
||||
});
|
||||
|
||||
const ServiceNowSIRFieldsSchema = schema.object({
|
||||
destIp: schema.nullable(schema.boolean()),
|
||||
sourceIp: schema.nullable(schema.boolean()),
|
||||
malwareHash: schema.nullable(schema.boolean()),
|
||||
malwareUrl: schema.nullable(schema.boolean()),
|
||||
priority: schema.nullable(schema.string()),
|
||||
category: schema.nullable(schema.string()),
|
||||
subcategory: schema.nullable(schema.string()),
|
||||
});
|
||||
|
||||
const NoneFieldsSchema = schema.nullable(schema.object({}));
|
||||
|
||||
const ReducedConnectorFieldsSchema: { [x: string]: any } = {
|
||||
'.jira': JiraFieldsSchema,
|
||||
'.resilient': ResilientFieldsSchema,
|
||||
'.servicenow-sir': ServiceNowSIRFieldsSchema,
|
||||
};
|
||||
|
||||
export const ConnectorProps = {
|
||||
|
@ -78,6 +89,7 @@ export const ConnectorProps = {
|
|||
schema.literal('.servicenow'),
|
||||
schema.literal('.jira'),
|
||||
schema.literal('.resilient'),
|
||||
schema.literal('.servicenow-sir'),
|
||||
schema.literal('.none'),
|
||||
]),
|
||||
// Chain of conditional schemes
|
||||
|
@ -92,7 +104,7 @@ export const ConnectorProps = {
|
|||
schema.conditional(
|
||||
schema.siblingRef('type'),
|
||||
'.servicenow',
|
||||
ServiceNowFieldsSchema,
|
||||
ServiceNowITSMFieldsSchema,
|
||||
NoneFieldsSchema
|
||||
)
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue