diff --git a/src/core/server/http/http_server.mocks.ts b/src/core/server/http/http_server.mocks.ts index 81d756f47d760..c586cf6a9825f 100644 --- a/src/core/server/http/http_server.mocks.ts +++ b/src/core/server/http/http_server.mocks.ts @@ -28,12 +28,13 @@ import { LifecycleResponseFactory, RouteMethod, KibanaResponseFactory, + RouteValidationSpec, } from './router'; import { OnPreResponseToolkit } from './lifecycle/on_pre_response'; import { OnPostAuthToolkit } from './lifecycle/on_post_auth'; import { OnPreAuthToolkit } from './lifecycle/on_pre_auth'; -interface RequestFixtureOptions { +interface RequestFixtureOptions
{
headers?: Record ;
+ query?: RouteValidationSpec ({
path = '/path',
headers = { accept: 'something/html' },
params = {},
@@ -53,10 +59,11 @@ function createKibanaRequestMock({
method = 'get',
socket = new Socket(),
routeTags,
-}: RequestFixtureOptions = {}) {
+ validation = {},
+}: RequestFixtureOptions = {}) {
const queryString = stringify(query, { sort: false });
- return KibanaRequest.from(
+ return KibanaRequest.from (
createRawRequestMock({
headers,
params,
@@ -76,9 +83,9 @@ function createKibanaRequestMock({
},
}),
{
- params: schema.object({}, { allowUnknowns: true }),
- body: schema.object({}, { allowUnknowns: true }),
- query: schema.object({}, { allowUnknowns: true }),
+ params: validation.params || schema.any(),
+ body: validation.body || schema.any(),
+ query: validation.query || schema.any(),
}
);
}
;
+ body?: RouteValidationSpec;
+ };
}
-function createKibanaRequestMock({
+function createKibanaRequestMock