From abe61a83c6440f386649fb12e61186a9dc5e9387 Mon Sep 17 00:00:00 2001 From: adcoelho Date: Wed, 28 Jun 2023 10:54:01 +0200 Subject: [PATCH 1/3] Schema validation for params in cases find. Updated documentation. Tests --- x-pack/plugins/cases/common/api/cases/case.ts | 12 +++- .../plugins/cases/common/constants/index.ts | 3 + .../plugins/cases/docs/openapi/bundled.json | 11 ++-- .../plugins/cases/docs/openapi/bundled.yaml | 6 +- .../paths/s@{spaceid}@api@cases@_find.yaml | 7 ++- .../cases/server/client/cases/find.test.ts | 37 ++++++++++++- .../tests/common/cases/find_cases.ts | 55 +++++++++++++------ 7 files changed, 103 insertions(+), 28 deletions(-) diff --git a/x-pack/plugins/cases/common/api/cases/case.ts b/x-pack/plugins/cases/common/api/cases/case.ts index 8f1e7a1264166..61c31e9cff515 100644 --- a/x-pack/plugins/cases/common/api/cases/case.ts +++ b/x-pack/plugins/cases/common/api/cases/case.ts @@ -13,6 +13,12 @@ import { CommentRt } from './comment'; import { CasesStatusResponseRt, CaseStatusRt } from './status'; import { CaseConnectorRt } from '../connectors/connector'; import { CaseAssigneesRt } from './assignee'; +import { + MAX_ASSIGNEES_FILTER_LENGTH, + MAX_REPORTERS_FILTER_LENGTH, + MAX_TAGS_FILTER_LENGTH, +} from '../../constants'; +import { limitedArraySchema } from '../../schema'; export const AttachmentTotalsRt = rt.strict({ alerts: rt.number, @@ -207,7 +213,7 @@ export const CasesFindRequestRt = rt.exact( /** * Tags to filter by */ - tags: rt.union([rt.array(rt.string), rt.string]), + tags: rt.union([limitedArraySchema(rt.string, 0, MAX_TAGS_FILTER_LENGTH), rt.string]), /** * The status of the case (open, closed, in-progress) */ @@ -219,11 +225,11 @@ export const CasesFindRequestRt = rt.exact( /** * The uids of the user profiles to filter by */ - assignees: rt.union([rt.array(rt.string), rt.string]), + assignees: rt.union([limitedArraySchema(rt.string, 0, MAX_ASSIGNEES_FILTER_LENGTH), rt.string]), /** * The reporters to filter by */ - reporters: rt.union([rt.array(rt.string), rt.string]), + reporters: rt.union([limitedArraySchema(rt.string, 0, MAX_REPORTERS_FILTER_LENGTH), rt.string]), /** * Operator to use for the `search` field */ diff --git a/x-pack/plugins/cases/common/constants/index.ts b/x-pack/plugins/cases/common/constants/index.ts index 1a49de004e73f..24365cdc625e8 100644 --- a/x-pack/plugins/cases/common/constants/index.ts +++ b/x-pack/plugins/cases/common/constants/index.ts @@ -106,6 +106,9 @@ export const MAX_CONCURRENT_SEARCHES = 10 as const; export const MAX_BULK_GET_CASES = 1000 as const; export const MAX_COMMENTS_PER_PAGE = 100 as const; 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; /** * Validation diff --git a/x-pack/plugins/cases/docs/openapi/bundled.json b/x-pack/plugins/cases/docs/openapi/bundled.json index 78ba5444f40aa..a367593d6b89e 100644 --- a/x-pack/plugins/cases/docs/openapi/bundled.json +++ b/x-pack/plugins/cases/docs/openapi/bundled.json @@ -221,7 +221,7 @@ { "name": "assignees", "in": "query", - "description": "Filters the returned cases by assignees. Valid values are `none` or unique identifiers for the user profiles. These identifiers can be found by using the suggest user profile API.", + "description": "Filters the returned cases by assignees. Valid values are `none` or unique identifiers for the user profiles. These identifiers can be found by using the suggest user profile API.\n", "schema": { "oneOf": [ { @@ -231,7 +231,8 @@ "type": "array", "items": { "type": "string" - } + }, + "maximum": 100 } ] } @@ -296,7 +297,8 @@ "type": "array", "items": { "type": "string" - } + }, + "maximum": 100 } ] }, @@ -375,7 +377,8 @@ "type": "array", "items": { "type": "string" - } + }, + "maximum": 100 } ] }, diff --git a/x-pack/plugins/cases/docs/openapi/bundled.yaml b/x-pack/plugins/cases/docs/openapi/bundled.yaml index 405cf4fb689f0..dfb37c895902d 100644 --- a/x-pack/plugins/cases/docs/openapi/bundled.yaml +++ b/x-pack/plugins/cases/docs/openapi/bundled.yaml @@ -133,13 +133,15 @@ paths: - $ref: '#/components/parameters/space_id' - name: assignees in: query - description: Filters the returned cases by assignees. Valid values are `none` or unique identifiers for the user profiles. These identifiers can be found by using the suggest user profile API. + description: | + Filters the returned cases by assignees. Valid values are `none` or unique identifiers for the user profiles. These identifiers can be found by using the suggest user profile API. schema: oneOf: - type: string - type: array items: type: string + maximum: 100 - name: category in: query description: Filters the returned cases by category. Limited to 100 categories. @@ -176,6 +178,7 @@ paths: - type: array items: type: string + maximum: 100 example: elastic - name: search in: query @@ -222,6 +225,7 @@ paths: - type: array items: type: string + maximum: 100 example: tag-1 - name: to in: query diff --git a/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml b/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml index e04fbfe020c9f..09c28446def69 100644 --- a/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml +++ b/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml @@ -11,13 +11,16 @@ get: - $ref: '../components/parameters/space_id.yaml' - name: assignees in: query - description: Filters the returned cases by assignees. Valid values are `none` or unique identifiers for the user profiles. These identifiers can be found by using the suggest user profile API. + description: > + Filters the returned cases by assignees. Valid values are `none` or unique identifiers for the user profiles. + These identifiers can be found by using the suggest user profile API. schema: oneOf: - type: string - type: array items: type: string + maximum: 100 - name: category in: query description: Filters the returned cases by category. Limited to 100 categories. @@ -59,6 +62,7 @@ get: - type: array items: type: string + maximum: 100 example: elastic - name: search in: query @@ -105,6 +109,7 @@ get: - type: array items: type: string + maximum: 100 example: tag-1 - name: to in: query diff --git a/x-pack/plugins/cases/server/client/cases/find.test.ts b/x-pack/plugins/cases/server/client/cases/find.test.ts index 968f111b58516..b89b255f8da14 100644 --- a/x-pack/plugins/cases/server/client/cases/find.test.ts +++ b/x-pack/plugins/cases/server/client/cases/find.test.ts @@ -8,7 +8,12 @@ import { v1 as uuidv1 } from 'uuid'; import type { Case } from '../../../common/api'; -import { MAX_CATEGORY_FILTER_LENGTH } from '../../../common/constants'; +import { + MAX_ASSIGNEES_FILTER_LENGTH, + MAX_CATEGORY_FILTER_LENGTH, + MAX_REPORTERS_FILTER_LENGTH, + MAX_TAGS_FILTER_LENGTH, +} from '../../../common/constants'; import { flattenCaseSavedObject } from '../../common/utils'; import { mockCases } from '../../mocks'; import { createCasesClientMockArgs, createCasesClientMockFindRequest } from '../mocks'; @@ -114,5 +119,35 @@ describe('find', () => { `Error: Too many categories provided. The maximum allowed is ${MAX_CATEGORY_FILTER_LENGTH}` ); }); + + it(`throws an error when the tags array has ${MAX_TAGS_FILTER_LENGTH} items`, async () => { + const tags = Array(MAX_TAGS_FILTER_LENGTH + 1).fill('foobar'); + + const findRequest = createCasesClientMockFindRequest({ tags }); + + await expect(find(findRequest, clientArgs)).rejects.toThrowErrorMatchingInlineSnapshot( + `"Failed to find cases: {\\"search\\":\\"\\",\\"searchFields\\":[\\"title\\",\\"description\\"],\\"severity\\":\\"low\\",\\"assignees\\":[],\\"reporters\\":[],\\"status\\":\\"open\\",\\"tags\\":[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"],\\"owner\\":[],\\"sortField\\":\\"createdAt\\",\\"sortOrder\\":\\"desc\\"}: Error: array must be of length <= 100,Invalid value \\"[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"]\\" supplied to \\"tags\\""` + ); + }); + + it(`throws an error when the assignees array has ${MAX_ASSIGNEES_FILTER_LENGTH} items`, async () => { + const assignees = Array(MAX_ASSIGNEES_FILTER_LENGTH + 1).fill('foobar'); + + const findRequest = createCasesClientMockFindRequest({ assignees }); + + await expect(find(findRequest, clientArgs)).rejects.toThrowErrorMatchingInlineSnapshot( + `"Failed to find cases: {\\"search\\":\\"\\",\\"searchFields\\":[\\"title\\",\\"description\\"],\\"severity\\":\\"low\\",\\"assignees\\":[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"],\\"reporters\\":[],\\"status\\":\\"open\\",\\"tags\\":[],\\"owner\\":[],\\"sortField\\":\\"createdAt\\",\\"sortOrder\\":\\"desc\\"}: Error: array must be of length <= 100,Invalid value \\"[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"]\\" supplied to \\"assignees\\""` + ); + }); + + it(`throws an error when the reporters array has ${MAX_REPORTERS_FILTER_LENGTH} items`, async () => { + const reporters = Array(MAX_REPORTERS_FILTER_LENGTH + 1).fill('foobar'); + + const findRequest = createCasesClientMockFindRequest({ reporters }); + + await expect(find(findRequest, clientArgs)).rejects.toThrowErrorMatchingInlineSnapshot( + `"Failed to find cases: {\\"search\\":\\"\\",\\"searchFields\\":[\\"title\\",\\"description\\"],\\"severity\\":\\"low\\",\\"assignees\\":[],\\"reporters\\":[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"],\\"status\\":\\"open\\",\\"tags\\":[],\\"owner\\":[],\\"sortField\\":\\"createdAt\\",\\"sortOrder\\":\\"desc\\"}: Error: array must be of length <= 100,Invalid value \\"[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"]\\" supplied to \\"reporters\\""` + ); + }); }); }); diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts index 00bdaa5b25f0b..6875bc043a6c5 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts @@ -8,7 +8,13 @@ import { v1 as uuidv1 } from 'uuid'; import expect from '@kbn/expect'; -import { CASES_URL, MAX_CATEGORY_FILTER_LENGTH } from '@kbn/cases-plugin/common/constants'; +import { + CASES_URL, + MAX_ASSIGNEES_FILTER_LENGTH, + MAX_CATEGORY_FILTER_LENGTH, + MAX_REPORTERS_FILTER_LENGTH, + MAX_TAGS_FILTER_LENGTH, +} from '@kbn/cases-plugin/common/constants'; import { Case, CaseSeverity, CaseStatuses, CommentType } from '@kbn/cases-plugin/common/api'; import { ALERTING_CASES_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; @@ -307,20 +313,6 @@ export default ({ getService }: FtrProviderContext): void => { }); }); - it('unhappy path - 400s when bad query supplied', async () => { - await findCases({ supertest, query: { perPage: true }, expectedHttpCode: 400 }); - }); - - for (const field of ['owner', 'tags', 'severity', 'status']) { - it(`should return a 400 when attempting to query a keyword field [${field}] when using a wildcard query`, async () => { - await findCases({ - supertest, - query: { searchFields: [field], search: 'some search string*' }, - expectedHttpCode: 400, - }); - }); - } - it('sorts by severity', async () => { const case4 = await createCase(supertest, { ...postCaseReq, @@ -349,10 +341,37 @@ export default ({ getService }: FtrProviderContext): void => { }); }); - it('unhappy path - 400s when more than the maximum category fields are supplied', async () => { - const category = Array(MAX_CATEGORY_FILTER_LENGTH + 1).fill('foobar'); + describe('errors', () => { + it('unhappy path - 400s when bad query supplied', async () => { + await findCases({ supertest, query: { perPage: true }, expectedHttpCode: 400 }); + }); + + for (const field of ['owner', 'tags', 'severity', 'status']) { + it(`should return a 400 when attempting to query a keyword field [${field}] when using a wildcard query`, async () => { + await findCases({ + supertest, + query: { searchFields: [field], search: 'some search string*' }, + expectedHttpCode: 400, + }); + }); + } - await findCases({ supertest, query: { category }, expectedHttpCode: 400 }); + for (const scenario of [ + { fieldName: 'category', sizeLimit: MAX_CATEGORY_FILTER_LENGTH }, + { fieldName: 'tags', sizeLimit: MAX_TAGS_FILTER_LENGTH }, + { fieldName: 'assignees', sizeLimit: MAX_ASSIGNEES_FILTER_LENGTH }, + { fieldName: 'reporters', sizeLimit: MAX_REPORTERS_FILTER_LENGTH }, + ]) { + it(`unhappy path - 400s when the field ${scenario.fieldName} exceeds the size limit`, async () => { + const value = Array(scenario.sizeLimit + 1).fill('foobar'); + + await findCases({ + supertest, + query: { [scenario.fieldName]: value }, + expectedHttpCode: 400, + }); + }); + } }); describe('search and searchField', () => { From 16c1fad68aa6233cf75b435dfacc2bc4054ba7df Mon Sep 17 00:00:00 2001 From: adcoelho Date: Wed, 28 Jun 2023 15:03:29 +0200 Subject: [PATCH 2/3] Addressing PR comments. --- .../plugins/cases/server/client/cases/find.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/cases/server/client/cases/find.test.ts b/x-pack/plugins/cases/server/client/cases/find.test.ts index b89b255f8da14..76e15425ecef5 100644 --- a/x-pack/plugins/cases/server/client/cases/find.test.ts +++ b/x-pack/plugins/cases/server/client/cases/find.test.ts @@ -125,8 +125,8 @@ describe('find', () => { const findRequest = createCasesClientMockFindRequest({ tags }); - await expect(find(findRequest, clientArgs)).rejects.toThrowErrorMatchingInlineSnapshot( - `"Failed to find cases: {\\"search\\":\\"\\",\\"searchFields\\":[\\"title\\",\\"description\\"],\\"severity\\":\\"low\\",\\"assignees\\":[],\\"reporters\\":[],\\"status\\":\\"open\\",\\"tags\\":[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"],\\"owner\\":[],\\"sortField\\":\\"createdAt\\",\\"sortOrder\\":\\"desc\\"}: Error: array must be of length <= 100,Invalid value \\"[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"]\\" supplied to \\"tags\\""` + await expect(find(findRequest, clientArgs)).rejects.toThrowError( + 'Error: array must be of length <= 100' ); }); @@ -135,8 +135,8 @@ describe('find', () => { const findRequest = createCasesClientMockFindRequest({ assignees }); - await expect(find(findRequest, clientArgs)).rejects.toThrowErrorMatchingInlineSnapshot( - `"Failed to find cases: {\\"search\\":\\"\\",\\"searchFields\\":[\\"title\\",\\"description\\"],\\"severity\\":\\"low\\",\\"assignees\\":[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"],\\"reporters\\":[],\\"status\\":\\"open\\",\\"tags\\":[],\\"owner\\":[],\\"sortField\\":\\"createdAt\\",\\"sortOrder\\":\\"desc\\"}: Error: array must be of length <= 100,Invalid value \\"[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"]\\" supplied to \\"assignees\\""` + await expect(find(findRequest, clientArgs)).rejects.toThrowError( + 'Error: array must be of length <= 100' ); }); @@ -145,8 +145,8 @@ describe('find', () => { const findRequest = createCasesClientMockFindRequest({ reporters }); - await expect(find(findRequest, clientArgs)).rejects.toThrowErrorMatchingInlineSnapshot( - `"Failed to find cases: {\\"search\\":\\"\\",\\"searchFields\\":[\\"title\\",\\"description\\"],\\"severity\\":\\"low\\",\\"assignees\\":[],\\"reporters\\":[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"],\\"status\\":\\"open\\",\\"tags\\":[],\\"owner\\":[],\\"sortField\\":\\"createdAt\\",\\"sortOrder\\":\\"desc\\"}: Error: array must be of length <= 100,Invalid value \\"[\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\",\\"foobar\\"]\\" supplied to \\"reporters\\""` + await expect(find(findRequest, clientArgs)).rejects.toThrowError( + 'Error: array must be of length <= 100' ); }); }); From bd2a0006f7d854846f4c7b5d80d22ed201e1992a Mon Sep 17 00:00:00 2001 From: adcoelho Date: Thu, 29 Jun 2023 09:31:31 +0200 Subject: [PATCH 3/3] Update tests and documentation. --- x-pack/plugins/cases/common/api/cases/case.ts | 12 +++++++++--- x-pack/plugins/cases/docs/openapi/bundled.json | 6 +++--- x-pack/plugins/cases/docs/openapi/bundled.yaml | 6 +++--- .../openapi/paths/s@{spaceid}@api@cases@_find.yaml | 6 +++--- .../plugins/cases/server/client/cases/find.test.ts | 6 +++--- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/cases/common/api/cases/case.ts b/x-pack/plugins/cases/common/api/cases/case.ts index 61c31e9cff515..acfca22e70498 100644 --- a/x-pack/plugins/cases/common/api/cases/case.ts +++ b/x-pack/plugins/cases/common/api/cases/case.ts @@ -213,7 +213,7 @@ export const CasesFindRequestRt = rt.exact( /** * Tags to filter by */ - tags: rt.union([limitedArraySchema(rt.string, 0, MAX_TAGS_FILTER_LENGTH), rt.string]), + tags: rt.union([limitedArraySchema(rt.string, 0, MAX_TAGS_FILTER_LENGTH, 'tags'), rt.string]), /** * The status of the case (open, closed, in-progress) */ @@ -225,11 +225,17 @@ export const CasesFindRequestRt = rt.exact( /** * The uids of the user profiles to filter by */ - assignees: rt.union([limitedArraySchema(rt.string, 0, MAX_ASSIGNEES_FILTER_LENGTH), rt.string]), + assignees: rt.union([ + limitedArraySchema(rt.string, 0, MAX_ASSIGNEES_FILTER_LENGTH, 'assignees'), + rt.string, + ]), /** * The reporters to filter by */ - reporters: rt.union([limitedArraySchema(rt.string, 0, MAX_REPORTERS_FILTER_LENGTH), rt.string]), + reporters: rt.union([ + limitedArraySchema(rt.string, 0, MAX_REPORTERS_FILTER_LENGTH, 'reporters'), + rt.string, + ]), /** * Operator to use for the `search` field */ diff --git a/x-pack/plugins/cases/docs/openapi/bundled.json b/x-pack/plugins/cases/docs/openapi/bundled.json index a367593d6b89e..2ccef20d760a1 100644 --- a/x-pack/plugins/cases/docs/openapi/bundled.json +++ b/x-pack/plugins/cases/docs/openapi/bundled.json @@ -232,7 +232,7 @@ "items": { "type": "string" }, - "maximum": 100 + "maxItems": 100 } ] } @@ -298,7 +298,7 @@ "items": { "type": "string" }, - "maximum": 100 + "maxItems": 100 } ] }, @@ -378,7 +378,7 @@ "items": { "type": "string" }, - "maximum": 100 + "maxItems": 100 } ] }, diff --git a/x-pack/plugins/cases/docs/openapi/bundled.yaml b/x-pack/plugins/cases/docs/openapi/bundled.yaml index dfb37c895902d..30ca1177c1390 100644 --- a/x-pack/plugins/cases/docs/openapi/bundled.yaml +++ b/x-pack/plugins/cases/docs/openapi/bundled.yaml @@ -141,7 +141,7 @@ paths: - type: array items: type: string - maximum: 100 + maxItems: 100 - name: category in: query description: Filters the returned cases by category. Limited to 100 categories. @@ -178,7 +178,7 @@ paths: - type: array items: type: string - maximum: 100 + maxItems: 100 example: elastic - name: search in: query @@ -225,7 +225,7 @@ paths: - type: array items: type: string - maximum: 100 + maxItems: 100 example: tag-1 - name: to in: query diff --git a/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml b/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml index 09c28446def69..d02399d081f33 100644 --- a/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml +++ b/x-pack/plugins/cases/docs/openapi/paths/s@{spaceid}@api@cases@_find.yaml @@ -20,7 +20,7 @@ get: - type: array items: type: string - maximum: 100 + maxItems: 100 - name: category in: query description: Filters the returned cases by category. Limited to 100 categories. @@ -62,7 +62,7 @@ get: - type: array items: type: string - maximum: 100 + maxItems: 100 example: elastic - name: search in: query @@ -109,7 +109,7 @@ get: - type: array items: type: string - maximum: 100 + maxItems: 100 example: tag-1 - name: to in: query diff --git a/x-pack/plugins/cases/server/client/cases/find.test.ts b/x-pack/plugins/cases/server/client/cases/find.test.ts index 76e15425ecef5..b7d9d9117ad7e 100644 --- a/x-pack/plugins/cases/server/client/cases/find.test.ts +++ b/x-pack/plugins/cases/server/client/cases/find.test.ts @@ -126,7 +126,7 @@ describe('find', () => { const findRequest = createCasesClientMockFindRequest({ tags }); await expect(find(findRequest, clientArgs)).rejects.toThrowError( - 'Error: array must be of length <= 100' + `Error: The length of the field tags is too long. Array must be of length <= ${MAX_TAGS_FILTER_LENGTH}` ); }); @@ -136,7 +136,7 @@ describe('find', () => { const findRequest = createCasesClientMockFindRequest({ assignees }); await expect(find(findRequest, clientArgs)).rejects.toThrowError( - 'Error: array must be of length <= 100' + `Error: The length of the field assignees is too long. Array must be of length <= ${MAX_ASSIGNEES_FILTER_LENGTH}` ); }); @@ -146,7 +146,7 @@ describe('find', () => { const findRequest = createCasesClientMockFindRequest({ reporters }); await expect(find(findRequest, clientArgs)).rejects.toThrowError( - 'Error: array must be of length <= 100' + `Error: The length of the field reporters is too long. Array must be of length <= ${MAX_REPORTERS_FILTER_LENGTH}.` ); }); });