mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
remove HAPI plugins registration from legacy (#94262)
* remove HAPI plugins registration from legacy * remove duplicate legacy integration tests
This commit is contained in:
parent
066e47e9ea
commit
00fcc2d3d0
6 changed files with 3 additions and 106 deletions
|
@ -115,7 +115,6 @@
|
|||
"@hapi/hoek": "^9.1.1",
|
||||
"@hapi/inert": "^6.0.3",
|
||||
"@hapi/podium": "^4.1.1",
|
||||
"@hapi/vision": "^6.0.1",
|
||||
"@hapi/wreck": "^17.1.0",
|
||||
"@kbn/ace": "link:packages/kbn-ace",
|
||||
"@kbn/analytics": "link:packages/kbn-analytics",
|
||||
|
|
|
@ -9,15 +9,10 @@
|
|||
import { format } from 'url';
|
||||
import Boom from '@hapi/boom';
|
||||
|
||||
import { registerHapiPlugins } from './register_hapi_plugins';
|
||||
import { setupBasePathProvider } from './setup_base_path_provider';
|
||||
|
||||
export default async function (kbnServer, server) {
|
||||
server = kbnServer.server;
|
||||
|
||||
setupBasePathProvider(kbnServer);
|
||||
|
||||
await registerHapiPlugins(server);
|
||||
const getBasePath = (request) => kbnServer.newPlatform.setup.core.http.basePath.get(request);
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
|
@ -27,8 +22,8 @@ export default async function (kbnServer, server) {
|
|||
if (path === '/' || path.charAt(path.length - 1) !== '/') {
|
||||
throw Boom.notFound();
|
||||
}
|
||||
|
||||
const pathPrefix = req.getBasePath() ? `${req.getBasePath()}/` : '';
|
||||
const basePath = getBasePath(req);
|
||||
const pathPrefix = basePath ? `${basePath}/` : '';
|
||||
return h
|
||||
.redirect(
|
||||
format({
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* 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 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as kbnTestServer from '../../../../core/test_helpers/kbn_server';
|
||||
|
||||
let root;
|
||||
beforeAll(async () => {
|
||||
root = kbnTestServer.createRoot({
|
||||
server: { maxPayloadBytes: 100 },
|
||||
migrations: { skip: true },
|
||||
plugins: { initialize: false },
|
||||
});
|
||||
|
||||
await root.setup();
|
||||
await root.start();
|
||||
|
||||
kbnTestServer.getKbnServer(root).server.route({
|
||||
path: '/payload_size_check/test/route',
|
||||
method: 'POST',
|
||||
config: { payload: { maxBytes: 200 } },
|
||||
handler: (req) => req.payload.data.slice(0, 5),
|
||||
});
|
||||
}, 30000);
|
||||
|
||||
afterAll(async () => await root.shutdown());
|
||||
|
||||
test('accepts payload with a size larger than default but smaller than route config allows', async () => {
|
||||
await kbnTestServer.request
|
||||
.post(root, '/payload_size_check/test/route')
|
||||
.send({
|
||||
data: Array(150).fill('+').join(''),
|
||||
})
|
||||
.expect(200, '+++++');
|
||||
});
|
||||
|
||||
test('fails with 413 if payload size is larger than default and route config allows', async () => {
|
||||
await kbnTestServer.request
|
||||
.post(root, '/payload_size_check/test/route')
|
||||
.send({
|
||||
data: Array(250).fill('+').join(''),
|
||||
})
|
||||
.expect(413, {
|
||||
statusCode: 413,
|
||||
error: 'Request Entity Too Large',
|
||||
message: 'Payload content length greater than maximum allowed: 200',
|
||||
});
|
||||
});
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* 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 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import HapiTemplates from '@hapi/vision';
|
||||
import HapiStaticFiles from '@hapi/inert';
|
||||
import HapiProxy from '@hapi/h2o2';
|
||||
|
||||
const plugins = [HapiTemplates, HapiStaticFiles, HapiProxy];
|
||||
|
||||
async function registerPlugins(server) {
|
||||
return await server.register(plugins);
|
||||
}
|
||||
|
||||
export function registerHapiPlugins(server) {
|
||||
registerPlugins(server);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* 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 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export function setupBasePathProvider(kbnServer) {
|
||||
kbnServer.server.decorate('request', 'getBasePath', function () {
|
||||
const request = this;
|
||||
return kbnServer.newPlatform.setup.core.http.basePath.get(request);
|
||||
});
|
||||
}
|
10
yarn.lock
10
yarn.lock
|
@ -2016,16 +2016,6 @@
|
|||
dependencies:
|
||||
"@hapi/hoek" "9.x.x"
|
||||
|
||||
"@hapi/vision@^6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/vision/-/vision-6.0.1.tgz#976c3575be56d3cb5b472ddcfe0b7403778706fd"
|
||||
integrity sha512-xv4PwmhbXCLzDfojZ7l4+P/YynBhMInV8GtLPH4gB74prhwOl8lGcJxxK8V9rf1aMH/vonM5yVGd9FuoA9sT0A==
|
||||
dependencies:
|
||||
"@hapi/boom" "9.x.x"
|
||||
"@hapi/bounce" "2.x.x"
|
||||
"@hapi/hoek" "9.x.x"
|
||||
"@hapi/validate" "1.x.x"
|
||||
|
||||
"@hapi/wreck@17.x.x", "@hapi/wreck@^17.0.0", "@hapi/wreck@^17.1.0":
|
||||
version "17.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/wreck/-/wreck-17.1.0.tgz#fbdc380c6f3fa1f8052dc612b2d3b6ce3e88dbec"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue