forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps][Cases] Make deprecated APIs internal in serverless (ela…
…stic#198378) ## Summary Fixes: elastic#198407 ### Checklist Delete any items that are not applicable to this PR. - [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 ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)
- Loading branch information
Showing
18 changed files
with
481 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
x-pack/plugins/cases/server/routes/api/cases/get_case.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { createCasesClientMock } from '../../../client/mocks'; | ||
import { getCaseRoute } from './get_case'; | ||
import { httpServerMock, loggingSystemMock } from '@kbn/core/server/mocks'; | ||
|
||
describe('getCaseRoute', () => { | ||
const casesClientMock = createCasesClientMock(); | ||
const logger = loggingSystemMock.createLogger(); | ||
const response = httpServerMock.createResponseFactory(); | ||
const kibanaVersion = '8.17'; | ||
const context = { cases: { getCasesClient: jest.fn().mockResolvedValue(casesClientMock) } }; | ||
|
||
it('throws a bad request if the includeComments is set in serverless', async () => { | ||
const router = getCaseRoute({ isServerless: true }); | ||
const request = httpServerMock.createKibanaRequest({ | ||
path: '/api/cases/{case_id}/?includeComments=true', | ||
query: { includeComments: true }, | ||
params: { case_id: 'foo' }, | ||
}); | ||
|
||
await expect( | ||
// @ts-expect-error: no need to create the context | ||
router.handler({ response, request, logger, kibanaVersion, context }) | ||
).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"Failed to retrieve case in route case id: foo | ||
include comments: true: Error: includeComments is not supported" | ||
`); | ||
}); | ||
|
||
it('does not throw a bad request if the includeComments is set in non-serverless', async () => { | ||
const router = getCaseRoute({ isServerless: false }); | ||
const request = httpServerMock.createKibanaRequest({ | ||
path: '/api/cases/{case_id}/?includeComments=true', | ||
query: { includeComments: true }, | ||
params: { case_id: 'foo' }, | ||
}); | ||
|
||
await expect( | ||
// @ts-expect-error: no need to create the context | ||
router.handler({ response, request, logger, kibanaVersion, context }) | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
it('does not throw a bad request if the includeComments is not set in serverless', async () => { | ||
const router = getCaseRoute({ isServerless: true }); | ||
const request = httpServerMock.createKibanaRequest({ | ||
path: '/api/cases/{case_id}', | ||
params: { case_id: 'foo' }, | ||
}); | ||
|
||
await expect( | ||
// @ts-expect-error: no need to create the context | ||
router.handler({ response, request, logger, kibanaVersion, context }) | ||
).resolves.not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/cases/server/routes/api/comments/get_all_comment.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getAllCommentsRoute } from './get_all_comment'; | ||
|
||
describe('getAllCommentsRoute', () => { | ||
it('marks the endpoint internal in serverless', async () => { | ||
const router = getAllCommentsRoute({ isServerless: true }); | ||
|
||
expect(router.routerOptions?.access).toBe('internal'); | ||
}); | ||
|
||
it('marks the endpoint public in non-serverless', async () => { | ||
const router = getAllCommentsRoute({ isServerless: false }); | ||
|
||
expect(router.routerOptions?.access).toBe('public'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/cases/server/routes/api/stats/get_status.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getStatusRoute } from './get_status'; | ||
|
||
describe('getStatusRoute', () => { | ||
it('marks the endpoint internal in serverless', async () => { | ||
const router = getStatusRoute({ isServerless: true }); | ||
|
||
expect(router.routerOptions?.access).toBe('internal'); | ||
}); | ||
|
||
it('marks the endpoint public in non-serverless', async () => { | ||
const router = getStatusRoute({ isServerless: false }); | ||
|
||
expect(router.routerOptions?.access).toBe('public'); | ||
}); | ||
}); |
Oops, something went wrong.