mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Cases] Guardrails getConnectors API (#161282)
Connected to https://github.com/elastic/kibana/issues/146945 ## Summary | Description | Limit | Done? | Documented? | ------------- | ---- | :---: | ---- | | Total number of supported connectors returned | 1000 | ✅ | Yes | ### Checklist Delete any items that are not applicable to this PR. - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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 ### Release Notes The getConnectors API will now limit the number of supported connectors returned to 1000.
This commit is contained in:
parent
715a578344
commit
2774812001
6 changed files with 23 additions and 6 deletions
|
@ -111,6 +111,7 @@ export const MAX_CATEGORY_FILTER_LENGTH = 100 as const;
|
|||
export const MAX_TAGS_FILTER_LENGTH = 100 as const;
|
||||
export const MAX_ASSIGNEES_FILTER_LENGTH = 100 as const;
|
||||
export const MAX_REPORTERS_FILTER_LENGTH = 100 as const;
|
||||
export const MAX_SUPPORTED_CONNECTORS_RETURNED = 1000 as const;
|
||||
|
||||
/**
|
||||
* Validation
|
||||
|
|
|
@ -1800,7 +1800,8 @@
|
|||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"maxItems": 1000
|
||||
},
|
||||
"examples": {
|
||||
"findConnectorResponse": {
|
||||
|
|
|
@ -1106,6 +1106,7 @@ paths:
|
|||
type: string
|
||||
referencedByCount:
|
||||
type: integer
|
||||
maxItems: 1000
|
||||
examples:
|
||||
findConnectorResponse:
|
||||
$ref: '#/components/examples/find_connector_response'
|
||||
|
|
|
@ -14,10 +14,11 @@ get:
|
|||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
$ref: '../components/schemas/connector_response_properties.yaml'
|
||||
maxItems: 1000
|
||||
examples:
|
||||
findConnectorResponse:
|
||||
$ref: '../components/examples/find_connector_response.yaml'
|
||||
|
|
|
@ -10,6 +10,7 @@ import { actionsClientMock } from '@kbn/actions-plugin/server/mocks';
|
|||
import type { CasesClientArgs } from '../types';
|
||||
import { getConnectors, get, update } from './client';
|
||||
import { createCasesClientInternalMock, createCasesClientMockArgs } from '../mocks';
|
||||
import { MAX_SUPPORTED_CONNECTORS_RETURNED } from '../../../common/constants';
|
||||
|
||||
describe('client', () => {
|
||||
const clientArgs = createCasesClientMockArgs();
|
||||
|
@ -219,6 +220,15 @@ describe('client', () => {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('limits connectors returned to 1000', async () => {
|
||||
actionsClient.listTypes.mockImplementation(async () => actionTypes.slice(0, 1));
|
||||
actionsClient.getAll.mockImplementation(async () =>
|
||||
Array(MAX_SUPPORTED_CONNECTORS_RETURNED + 1).fill(connectors[0])
|
||||
);
|
||||
|
||||
expect((await getConnectors(args)).length).toEqual(MAX_SUPPORTED_CONNECTORS_RETURNED);
|
||||
});
|
||||
});
|
||||
|
||||
describe('get', () => {
|
||||
|
|
|
@ -30,7 +30,10 @@ import {
|
|||
} from '../../../common/types/api';
|
||||
import type { ConnectorMappings, ConnectorMappingResponse } from '../../../common/api';
|
||||
import { FindActionConnectorResponseRt, decodeWithExcessOrThrow } from '../../../common/api';
|
||||
import { MAX_CONCURRENT_SEARCHES } from '../../../common/constants';
|
||||
import {
|
||||
MAX_CONCURRENT_SEARCHES,
|
||||
MAX_SUPPORTED_CONNECTORS_RETURNED,
|
||||
} from '../../../common/constants';
|
||||
import { createCaseError } from '../../common/error';
|
||||
import type { CasesClientInternal } from '../client_internal';
|
||||
import type { CasesClientArgs } from '../types';
|
||||
|
@ -207,9 +210,9 @@ export async function getConnectors({
|
|||
return types;
|
||||
}, {} as Record<string, ActionType>);
|
||||
|
||||
const res = (await actionsClient.getAll()).filter((action) =>
|
||||
isConnectorSupported(action, actionTypes)
|
||||
);
|
||||
const res = (await actionsClient.getAll())
|
||||
.filter((action) => isConnectorSupported(action, actionTypes))
|
||||
.slice(0, MAX_SUPPORTED_CONNECTORS_RETURNED);
|
||||
|
||||
return decodeOrThrow(FindActionConnectorResponseRt)(res);
|
||||
} catch (error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue