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 authored and jbudz committed Nov 28, 2016
1 parent cc0a682 commit 5810d6f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@
"good-squeeze": "2.1.0",
"gridster": "0.5.6",
"grunt-run": "0.6.0",
"hapi": "8.8.1",
"h2o2": "5.1.1",
"hapi": "14.2.0",
"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 @@ -134,6 +136,7 @@
"style-loader": "0.12.3",
"tar": "2.2.0",
"url-loader": "0.5.6",
"vision": "4.1.0",
"webpack": "1.12.15",
"webpack-directory-name-as-main": "1.0.0",
"whatwg-fetch": "0.9.0",
Expand Down
5 changes: 4 additions & 1 deletion src/optimize/lazy/LazyServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
let { Server } = require('hapi');
let { fromNode } = require('bluebird');
let Boom = require('boom');

let registerHapiPlugins = require('../../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
23 changes: 9 additions & 14 deletions src/plugins/elasticsearch/lib/__tests__/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ describe('plugins/elasticsearch', function () {
});


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 Down Expand Up @@ -61,21 +60,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 @@ -85,9 +81,8 @@ describe('plugins/elasticsearch', function () {
testRoute({
method: 'POST',
url: '/elasticsearch/.kibana/_bulk',
payload: '{}',
statusCode: 400
});
payload: '{}'
}, 400);

testRoute({
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions src/server/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = function (kbnServer, server, config) {
server = kbnServer.server = new Hapi.Server();

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

// Create a new connection
let connectionOptions = {
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);
}

0 comments on commit 5810d6f

Please sign in to comment.