Skip to content

Commit

Permalink
Upgrades Hapi to 14.2.0
Browse files Browse the repository at this point in the history
As of Node 6, crypto.pbkdf emits a deprecation warning when the digest isn't explicily set. Under certain conditions we are seeing this warning from Hapi's dependency Iron. Iron resolved this issue as of 4.0.4, which was introduced into Hapi as of 14.0.0.

Node deprecation: nodejs/node@8e8959d
Iron's resolution: hapijs/iron@9e0a1ef

As of Hapi v9, they have removed three build-in plugins from the core which we rely on inert (files and directories), vision (view templates), and h2o2 (proxy). hapijs/hapi#2682

Signed-off-by: Tyler Smalley <[email protected]>
  • Loading branch information
Tyler Smalley committed Sep 19, 2016
1 parent 85234ed commit 4feeff1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 18 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@
"glob-all": "3.0.1",
"good-squeeze": "2.1.0",
"gridster": "0.5.6",
"hapi": "8.8.1",
"h2o2": "5.1.1",
"hapi": "14.2.0",
"highland": "2.7.2",
"httpolyglot": "0.1.1",
"imports-loader": "0.6.4",
"inert": "4.0.2",
"jade": "1.11.0",
"jade-loader": "0.7.1",
"joi": "6.6.1",
Expand Down Expand Up @@ -154,6 +156,7 @@
"trunc-text": "1.0.2",
"url-loader": "0.5.6",
"validate-npm-package-name": "2.2.2",
"vision": "4.1.0",
"webpack": "1.12.15",
"webpack-directory-name-as-main": "1.0.0",
"whatwg-fetch": "0.9.0",
Expand Down
3 changes: 3 additions & 0 deletions src/cli/cluster/base_path_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { readFileSync } from 'fs';

import Config from '../../server/config/config';
import setupConnection from '../../server/http/setup_connection';
import registerHapiPlugins from '../../server/http/register_hapi_plugins';
import setupLogging from '../../server/logging';
import { DEV_SSL_CERT_PATH } from '../dev_ssl';

Expand Down Expand Up @@ -44,6 +45,8 @@ export default class BasePathProxy {

setupLogging(null, this.server, config);
setupConnection(null, this.server, config);
registerHapiPlugins(null, this.server, config);

this.setupRoutes();
}

Expand Down
23 changes: 9 additions & 14 deletions src/core_plugins/elasticsearch/lib/__tests__/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ describe('plugins/elasticsearch', function () {
return kbnServer.close();
});

function testRoute(options) {
function testRoute(options, statusCode = 200) {
if (typeof options.payload === 'object') {
options.payload = JSON.stringify(options.payload);
}

const statusCode = options.statusCode || 200;
describe(format('%s %s', options.method, options.url), function () {
it('should should return ' + statusCode, function (done) {
kbnTestServer.makeRequest(kbnServer, options, function (res) {
Expand All @@ -62,21 +61,18 @@ describe('plugins/elasticsearch', function () {

testRoute({
method: 'POST',
url: '/elasticsearch/.kibana',
statusCode: 405
});
url: '/elasticsearch/.kibana'
}, 405);

testRoute({
method: 'PUT',
url: '/elasticsearch/.kibana',
statusCode: 405
});
url: '/elasticsearch/.kibana'
}, 405);

testRoute({
method: 'DELETE',
url: '/elasticsearch/.kibana',
statusCode: 405
});
url: '/elasticsearch/.kibana'
}, 405);

testRoute({
method: 'GET',
Expand All @@ -86,9 +82,8 @@ describe('plugins/elasticsearch', function () {
testRoute({
method: 'POST',
url: '/elasticsearch/.kibana/_bulk',
payload: '{}',
statusCode: 400
});
payload: '{}'
}, 400);

testRoute({
method: 'POST',
Expand Down
5 changes: 4 additions & 1 deletion src/optimize/lazy/lazy_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import Boom from 'boom';
import { Server } from 'hapi';
import { fromNode } from 'bluebird';

import registerHapiPlugins from '../../server/http/register_hapi_plugins';

module.exports = class LazyServer {
constructor(host, port, optimizer) {
this.optimizer = optimizer;
this.server = new Server();

registerHapiPlugins(null, this.server);

this.server.connection({
host: host,
port: port
Expand Down
5 changes: 4 additions & 1 deletion src/server/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import _ from 'lodash';
import fs from 'fs';
import Boom from 'boom';
import Hapi from 'hapi';
import HapiTemplates from 'vision';
import HapiStaticFiles from 'inert';
import HapiProxy from 'h2o2';
import getDefaultRoute from './get_default_route';
import versionCheckMixin from './version_check';

module.exports = async function (kbnServer, server, config) {


server = kbnServer.server = new Hapi.Server();

const shortUrlLookup = require('./short_url_lookup')(server);
await kbnServer.mixin(require('./register_hapi_plugins'));
await kbnServer.mixin(require('./setup_connection'));

// provide a simple way to expose static directories
Expand Down
16 changes: 16 additions & 0 deletions src/server/http/register_hapi_plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import HapiTemplates from 'vision';
import HapiStaticFiles from 'inert';
import HapiProxy from 'h2o2';
import { fromNode } from 'bluebird';

const plugins = [HapiTemplates, HapiStaticFiles, HapiProxy];

async function registerPlugins(server) {
await fromNode(cb => {
server.register(plugins, cb);
});
}

export default function (kbnServer, server, config) {
registerPlugins(server);
}
1 change: 0 additions & 1 deletion src/server/kbn_server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Hapi from 'hapi';
import { constant, once, compact, flatten } from 'lodash';
import { promisify, resolve, fromNode } from 'bluebird';
import { isWorker } from 'cluster';
Expand Down

0 comments on commit 4feeff1

Please sign in to comment.