Comparing version 0.15.0 to 0.15.1
@@ -32,7 +32,7 @@ // Load modules | ||
Hawk.server.authenticate(request.raw.req, this.settings.getCredentialsFunc, { hostHeaderName: this.settings.hostHeaderName }, function (err, credentials, attributes) { | ||
Hawk.server.authenticate(request.raw.req, this.settings.getCredentialsFunc, { hostHeaderName: this.settings.hostHeaderName }, function (err, credentials, artifacts) { | ||
if (credentials) { | ||
credentials.authExt = attributes.ext; | ||
credentials.hash = attributes.hash; | ||
credentials.artifacts = artifacts; | ||
delete credentials.artifacts.credentials; // Needed to prevent utils.clone from creating a maximum call stack error | ||
} | ||
@@ -47,5 +47,54 @@ | ||
var isValid = Hawk.server.authenticatePayload(payload, credentials, credentials.hash, contentType); | ||
var isValid = Hawk.server.authenticatePayload(payload, credentials, credentials.artifacts.hash, contentType); | ||
return callback(isValid ? null : Boom.unauthorized('Payload is invalid')); | ||
}; | ||
internals.Scheme.prototype.responseHeader = function (request, callback) { | ||
var artifacts = Utils.clone(request.session.artifacts); | ||
artifacts.credentials = request.session; | ||
var options = { | ||
contentType: request.response._headers['Content-Type'] | ||
}; | ||
if (request.response._payload && | ||
request.response._payload.length) { | ||
options.payload = request.response._payload.join(''); | ||
var header = Hawk.server.header(artifacts, options); | ||
if (header) { | ||
request.response.header('Authorization', header); | ||
} | ||
return callback(!header ? Boom.internal('Problem creating hawk response authorization header.') : null); | ||
} | ||
if (request.response.variety === 'stream' && | ||
request.response.stream) { | ||
request.response.header('Trailer', 'Authorization'); | ||
var payload = ''; | ||
request.response.stream.on('data', function (chunk) { | ||
payload += chunk; | ||
}); | ||
request.response.stream.once('end', function (chunk) { | ||
payload += chunk; | ||
options.payload = payload; | ||
var header = Hawk.server.header(artifacts, options); | ||
if (header) { | ||
request.raw.res.addTrailers({ Authorization: header }); | ||
} | ||
}); | ||
} | ||
callback(); | ||
}; |
@@ -234,3 +234,3 @@ // Load modules | ||
if (config.payload === 'optional' && | ||
(!request.session.hash || | ||
(!request.session.artifacts.hash || | ||
typeof request.session._strategy.authenticatePayload !== 'function')) { | ||
@@ -245,2 +245,25 @@ | ||
}); | ||
}; | ||
internals.Auth.responseHeader = function (request, next) { | ||
if (!request.session || | ||
!request.session._strategy || | ||
typeof request.session._strategy.responseHeader !== 'function') { | ||
return next(); | ||
} | ||
if (!request.response || | ||
request.response.isBoom || | ||
request.response.varieties.error) { | ||
return next(); | ||
} | ||
request.session._strategy.responseHeader(request, function (err) { | ||
return next(err); | ||
}); | ||
}; |
@@ -115,2 +115,6 @@ // Load modules | ||
if (plugin.name === '?') { | ||
return new Error('Plugin name cannot be \'?\''); | ||
} | ||
if (!plugin.version) { | ||
@@ -142,3 +146,3 @@ return new Error('Plugin missing version'); | ||
internals.Pack.prototype._register = function (plugin, permissions, options, callback) { | ||
internals.Pack.prototype._register = function (plugin, permissions, options, callback, _dependencies) { | ||
@@ -151,8 +155,9 @@ var self = this; | ||
Utils.assert(callback, 'Missing callback'); | ||
Utils.assert(!this._env[plugin.name], 'Plugin already registered: ' + plugin.name); | ||
var invalid = this.validate(plugin); | ||
if (invalid) { | ||
return callback(invalid); | ||
} | ||
Utils.assert(!invalid, invalid && invalid.message); | ||
var dependencies = _dependencies || {}; | ||
// Setup environment | ||
@@ -197,2 +202,13 @@ | ||
return step(criteria, selection.index); | ||
}, | ||
dependency: function (deps) { | ||
dependencies[plugin.name] = dependencies[plugin.name] || []; | ||
deps = [].concat(deps); | ||
deps.forEach(function (dep) { | ||
if (!self._env[dep]) { | ||
dependencies[plugin.name].push(dep); | ||
} | ||
}); | ||
} | ||
@@ -209,5 +225,5 @@ }; | ||
if (permissions.state) { | ||
methods.state = function (name, options) { | ||
methods.state = function () { | ||
self._applySync(selection.servers, Server.prototype.state, [name, options]); | ||
self._applySync(selection.servers, Server.prototype.state, arguments); | ||
}; | ||
@@ -217,5 +233,5 @@ } | ||
if (permissions.helper) { | ||
methods.helper = function (name, method, options) { | ||
methods.helper = function () { | ||
self._applySync(selection.servers, Server.prototype.helper, [name, method, options]); | ||
self._applySync(selection.servers, Server.prototype.helper, arguments); | ||
}; | ||
@@ -229,5 +245,5 @@ } | ||
if (permissions.ext) { | ||
methods.ext = function (event, func) { | ||
methods.ext = function () { | ||
self._applySync(selection.servers, Server.prototype.ext, [event, func]); | ||
self._applySync(selection.servers, Server.prototype._ext, [arguments[0], arguments[1], arguments[2], plugin.name]); | ||
}; | ||
@@ -255,3 +271,12 @@ } | ||
plugin.register.call(null, root, options || {}, callback); | ||
plugin.register.call(null, root, options || {}, function (err) { | ||
if (!_dependencies && | ||
dependencies[plugin.name]) { | ||
Utils.assert(!dependencies[plugin.name].length, 'Plugin \'' + plugin.name + '\' missing dependencies: ' + dependencies[plugin.name].join(', ')); | ||
} | ||
callback(err); | ||
}); | ||
}; | ||
@@ -361,8 +386,17 @@ | ||
var dependencies = {}; | ||
Async.forEachSeries(registrations, function (item, next) { | ||
load(item, next); | ||
load(item, dependencies, next); | ||
}, | ||
function (err) { | ||
Object.keys(dependencies).forEach(function (deps) { | ||
dependencies[deps].forEach(function (dep) { | ||
Utils.assert(self._env[dep], 'Plugin \'' + deps + '\' missing dependencies: ' + dep); | ||
}); | ||
}); | ||
return callback(err); | ||
@@ -372,3 +406,3 @@ }); | ||
var load = function (item, next) { | ||
var load = function (item, dependencies, next) { | ||
@@ -385,18 +419,13 @@ var itemName = item.name; | ||
try { | ||
var mod = require(itemName); | ||
var pkg = require(Path.join(itemName, 'package.json')); | ||
var mod = require(itemName); // Will throw if require fails | ||
var pkg = require(Path.join(itemName, 'package.json')); | ||
plugin = { | ||
name: pkg.name, | ||
version: pkg.version, | ||
register: mod.register, | ||
path: itemName | ||
}; | ||
} | ||
catch (err) { | ||
return next(err); | ||
} | ||
plugin = { | ||
name: pkg.name, | ||
version: pkg.version, | ||
register: mod.register, | ||
path: itemName | ||
}; | ||
self._register(plugin, permissions, item.options, next); | ||
self._register(plugin, permissions, item.options, next, dependencies); | ||
}; | ||
@@ -403,0 +432,0 @@ |
@@ -6,4 +6,4 @@ // Load modules | ||
var Async = require('async'); | ||
var Boom = require('boom'); | ||
var Utils = require('./utils'); | ||
var Boom = require('boom'); | ||
var Payload = require('./payload'); | ||
@@ -15,2 +15,3 @@ var State = require('./state'); | ||
var Cached = require('./response/cached'); | ||
var Ext = require('./ext'); | ||
@@ -204,22 +205,2 @@ | ||
internals.Request.prototype._ext = function (event, callback) { | ||
var self = this; | ||
var handlers = this.server._ext[event]; // onRequest, onPreHandler, onPostHandler | ||
if (!handlers) { | ||
return callback(); | ||
} | ||
Async.forEachSeries(handlers, function (func, next) { | ||
func(self, next); | ||
}, | ||
function (err) { | ||
return callback(err); | ||
}); | ||
}; | ||
internals.Request.prototype._onRequestExt = function (callback) { | ||
@@ -234,3 +215,3 @@ | ||
this._ext('onRequest', function (err) { | ||
this.server._ext.invoke(this, 'onRequest', function (err) { | ||
@@ -280,4 +261,10 @@ // Undecorate request | ||
var ext = function (event) { return function (request, next) { self._ext(event, next); }; }; // Handler wrappers | ||
var ext = function (event) { | ||
return function (request, next) { | ||
self.server._ext.invoke(self, event, next); | ||
}; | ||
}; | ||
var funcs = [ | ||
@@ -296,3 +283,4 @@ // 'onRequest' in Server | ||
ext('onPostHandler'), // An error from here on will override any result set in handler() | ||
Validation.response | ||
Validation.response, | ||
Auth.responseHeader | ||
]; | ||
@@ -397,3 +385,3 @@ | ||
internals.Request.prototype._decorate = function (callback) { | ||
internals.Request.prototype._replyInterface = function (callback, withProperties) { | ||
@@ -412,3 +400,3 @@ var self = this; | ||
this.reply = function (result) { | ||
var reply = function (result) { | ||
@@ -420,4 +408,8 @@ Utils.assert(result instanceof Stream === false || !self._route.cache.isMode('server'), 'Cannot reply using a stream when caching enabled'); | ||
this.reply.send = function () { | ||
if (!withProperties) { | ||
return reply; | ||
} | ||
reply.send = function () { | ||
if (response === null) { | ||
@@ -430,3 +422,3 @@ response = Response.generate(null); | ||
if (!this._route.cache.isMode('server')) { | ||
this.reply.close = function () { | ||
reply.close = function () { | ||
@@ -439,3 +431,3 @@ process(); | ||
this.reply.stream = function (stream) { | ||
reply.stream = function (stream) { | ||
@@ -447,3 +439,3 @@ Utils.assert(stream instanceof Stream, 'request.reply.stream() requires a stream'); | ||
this.reply.payload = function (result) { | ||
reply.payload = function (result) { | ||
@@ -455,3 +447,3 @@ Utils.assert(result instanceof Stream === false, 'Must use request.reply.stream() with a Stream object'); | ||
this.reply.raw = function (result) { | ||
reply.raw = function (result) { | ||
@@ -462,3 +454,3 @@ response = Response.generate(new Response.Raw(self), process); | ||
this.reply.redirect = function (uri) { | ||
reply.redirect = function (uri) { | ||
@@ -472,3 +464,3 @@ response = Response.generate(new Response.Redirection(uri), process); | ||
this.reply.view = function (template, context, options) { | ||
reply.view = function (template, context, options) { | ||
@@ -480,2 +472,4 @@ var viewsManager = self._route.env.views || self.server.views; | ||
} | ||
return reply; | ||
}; | ||
@@ -565,2 +559,4 @@ | ||
var log = request.log.bind(request); | ||
var lookup = function () { | ||
@@ -570,9 +566,4 @@ | ||
var logFunc = function () { | ||
request._route.cache.getOrGenerate(request.url.path, log, generate, function (response, cached) { // request.url.path contains query | ||
return request.log.apply(request, arguments); | ||
}; | ||
request._route.cache.getOrGenerate(request.url.path, logFunc, generate, function (response, cached) { // request.url.path contains query | ||
if (cached && | ||
@@ -598,27 +589,45 @@ response instanceof Error === false) { | ||
// Decorate request with helper functions | ||
Ext.runProtected(log, 'handler', callback, function (run, next) { | ||
var timer = new Utils.Timer(); | ||
var timer = new Utils.Timer(); | ||
request._decorate(function (response) { | ||
var finalize = function (response) { | ||
// Check for Error result | ||
// Check for Error result | ||
if (response && | ||
(response.isBoom || response.varieties.error)) { | ||
if (response && | ||
(response.isBoom || response.varieties.error)) { | ||
request.log(['handler', 'result', 'error'], { msec: timer.elapsed() }); | ||
return callback(response); | ||
} | ||
request.log(['handler', 'result', 'error'], { msec: timer.elapsed() }); | ||
return next(response); | ||
} | ||
if (request._route.cache.rule.strict) { | ||
Utils.assert(response.varieties.cacheable, 'Attempted to cache non-cacheable item'); | ||
} | ||
if (request._route.cache.rule.strict) { | ||
Utils.assert(response.varieties.cacheable, 'Attempted to cache non-cacheable item'); | ||
} | ||
request.log(['handler', 'result'], { msec: timer.elapsed() }); | ||
return callback(null, response); | ||
}); | ||
request.log(['handler', 'result'], { msec: timer.elapsed() }); | ||
return next(null, response); | ||
}; | ||
// Execute handler | ||
// Execute handler | ||
request.route.handler.call(request, request); | ||
run(function () { | ||
switch (request.route.handler.length) { | ||
case 0: // function: () this: request this.reply + properties | ||
request.reply = request._replyInterface(finalize, true); | ||
request.route.handler.call(request); | ||
break; | ||
case 1: // function: (request) this: null request.reply + properties | ||
request.reply = request._replyInterface(finalize, true); | ||
request.route.handler.call(null, request); | ||
break; | ||
case 2: // function: (request, reply) this: null reply | ||
default: | ||
request.route.handler.call(null, request, request._replyInterface(finalize, false)); | ||
break; | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -625,0 +634,0 @@ }; |
@@ -6,3 +6,2 @@ // Load modules | ||
var Https = require('https'); | ||
var Domain = require('domain'); | ||
var Shot = require('shot'); | ||
@@ -17,2 +16,3 @@ var Boom = require('boom'); | ||
var Views = require('./views'); | ||
var Ext = require('./ext'); | ||
var Utils = require('./utils'); | ||
@@ -81,12 +81,4 @@ // Pack delayed required inline | ||
this._ext = { | ||
this._ext = new Ext(); | ||
// The following extension functions use the following signature: | ||
// function (request, next) { next(); } | ||
onRequest: null, // New request, before handing over to the router (allows changes to the request method, url, etc.) | ||
onPreHandler: null, // After validation and body parsing, before route handler | ||
onPostHandler: null // After route handler returns, before sending response | ||
}; | ||
// Set optional configuration | ||
@@ -166,9 +158,2 @@ // false -> null, true -> defaults, {} -> override defaults | ||
// Setup domain | ||
/* var domain = Domain.createDomain(); | ||
domain.add(req); | ||
domain.add(res); | ||
domain.enter(); | ||
*/ | ||
// Create request object | ||
@@ -304,9 +289,14 @@ | ||
internals.Server.prototype.ext = function (event, func) { | ||
internals.Server.prototype.ext = function () { | ||
Utils.assert(['onRequest', 'onPreHandler', 'onPostHandler'].indexOf(event) !== -1, 'Unknown event type: ' + event); | ||
this._ext[event] = (this._ext[event] || []).concat(func); | ||
return this._ext.add.apply(this._ext, arguments); | ||
}; | ||
internals.Server.prototype._ext = function () { | ||
return this._ext._add.apply(this._ext, arguments); | ||
}; | ||
// Add server route | ||
@@ -313,0 +303,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"homepage": "http://hapijs.com", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -43,9 +43,5 @@ "contributors": [ | ||
"devDependencies": { | ||
"mocha": "1.x.x", | ||
"chai": "1.x.x", | ||
"sinon": "1.x.x", | ||
"lab": "0.0.x", | ||
"handlebars": "1.0.x", | ||
"jade": "0.28.x", | ||
"blanket": "1.0.x", | ||
"travis-cov": "0.2.x", | ||
"complexity-report": "0.x.x" | ||
@@ -57,5 +53,3 @@ }, | ||
"scripts": { | ||
"test": "make test && make test-cov", | ||
"blanket": { "pattern": "//^((?!\/node_modules\/)(?!\/test\/helpers\/)(?!\/test\/unit\/)(?!\/test\/integration\/).)*$/ig", "onlyCwd": true, "data-cover-flags": { "branchTracking": true } }, | ||
"travis-cov": { "threshold": 100 } | ||
"test": "make test-cov" | ||
}, | ||
@@ -62,0 +56,0 @@ "licenses": [ |
@@ -12,3 +12,3 @@ <a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a> | ||
Current version: **0.15.0** | ||
Current version: **0.15.1** | ||
@@ -15,0 +15,0 @@ [![Build Status](https://secure.travis-ci.org/spumko/hapi.png)](http://travis-ci.org/spumko/hapi) |
// Load modules | ||
var Crypto = require('crypto'); | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Oz = require('oz'); | ||
var Hawk = require('hawk'); | ||
var Stream = require('stream'); | ||
var Hapi = require('../..'); | ||
@@ -17,3 +18,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -595,7 +600,34 @@ | ||
request.reply('Success'); | ||
request.reply.payload('Success').send(); | ||
}; | ||
var hawkErrorHandler = function (request) { | ||
request.reply.payload(new Error()).send(); | ||
}; | ||
var hawkStreamHandler = function (request) { | ||
var stream = new Stream(); | ||
stream.readable = true; | ||
stream.resume = function () { | ||
setTimeout(function () { | ||
stream.emit('data', 'hi'); | ||
}, 2); | ||
setTimeout(function () { | ||
stream.emit('end', ''); | ||
}, 5); | ||
}; | ||
request.reply.stream(stream).send(); | ||
}; | ||
server.route([ | ||
{ method: 'POST', path: '/hawk', handler: hawkHandler }, | ||
{ method: 'POST', path: '/hawkError', handler: hawkErrorHandler }, | ||
{ method: 'POST', path: '/hawkStream', handler: hawkStreamHandler }, | ||
{ method: 'POST', path: '/hawkOptional', handler: hawkHandler, config: { auth: { mode: 'optional' } } }, | ||
@@ -617,3 +649,3 @@ { method: 'POST', path: '/hawkScope', handler: hawkHandler, config: { auth: { scope: 'x' } } }, | ||
expect(res.result).to.exist; | ||
expect(res.statusCode).to.equal(200); | ||
expect(res.result).to.equal('Success'); | ||
@@ -630,3 +662,2 @@ done(); | ||
expect(res.result).to.exist; | ||
expect(res.result).to.equal('Success'); | ||
@@ -637,2 +668,92 @@ done(); | ||
it('includes authorization header in response when the response is a stream', function (done) { | ||
var request = { method: 'POST', url: '/hawkStream', headers: { authorization: hawkHeader('john', '/hawkStream'), host: '0.0.0.0:8080' } }; | ||
server.inject(request, function (res) { | ||
expect(res.statusCode).to.equal(200); | ||
expect(res.raw.res._trailer).to.contain('Hawk'); | ||
var attributes = Hawk.utils.parseAuthorizationHeader(res.raw.req.headers.authorization); | ||
var artifacts = { | ||
method: res.raw.req.method, | ||
host: res.raw.req.headers.host.split(':')[0], | ||
port: res.raw.req.headers.host.split(':')[1], | ||
resource: res.raw.req.url, | ||
ts: attributes.ts, | ||
nonce: attributes.nonce, | ||
ext: attributes.ext, | ||
mac: attributes.mac | ||
}; | ||
var options = { | ||
payload: res.payload | ||
}; | ||
getCredentials('john', function (err, cred) { | ||
artifacts.credentials = cred; | ||
var header = Hawk.server.header(artifacts, options); | ||
var trailerAuth = res.raw.res._trailer.split(':')[1]; | ||
trailerAuth = trailerAuth.substr(1, trailerAuth.lastIndexOf('"')); | ||
expect(res.headers.Trailer).to.contain('Authorization'); | ||
expect(header).to.equal(trailerAuth); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('includes valid authorization header in response when the response is text', function (done) { | ||
var request = { method: 'POST', url: '/hawk', headers: { authorization: hawkHeader('john', '/hawk'), host: '0.0.0.0:8080' } }; | ||
server.inject(request, function (res) { | ||
expect(res.headers.Authorization).to.contain('Hawk'); | ||
expect(res.statusCode).to.equal(200); | ||
var attributes = Hawk.utils.parseAuthorizationHeader(res.raw.req.headers.authorization); | ||
var artifacts = { | ||
method: res.raw.req.method, | ||
host: res.raw.req.headers.host.split(':')[0], | ||
port: res.raw.req.headers.host.split(':')[1], | ||
resource: res.raw.req.url, | ||
ts: attributes.ts, | ||
nonce: attributes.nonce, | ||
ext: attributes.ext, | ||
mac: attributes.mac | ||
}; | ||
var options = { | ||
payload: res.payload, | ||
contentType: res.headers['Content-Type'] | ||
}; | ||
getCredentials('john', function (err, cred) { | ||
artifacts.credentials = cred; | ||
var header = Hawk.server.header(artifacts, options); | ||
expect(header).to.equal(res.headers.Authorization); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('doesn\'t include authorization header in response when the response is an error', function (done) { | ||
var request = { method: 'POST', url: '/hawkError', headers: { authorization: hawkHeader('john', '/hawkError'), host: '0.0.0.0:8080' } }; | ||
server.inject(request, function (res) { | ||
expect(res.statusCode).to.equal(500); | ||
expect(res.headers.Authorization).to.not.exist; | ||
done(); | ||
}); | ||
}); | ||
it('returns an error on bad auth header', function (done) { | ||
@@ -639,0 +760,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Stream = require('stream'); | ||
@@ -15,3 +15,7 @@ var Hapi = require('../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -18,0 +22,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Http = require('http'); | ||
@@ -16,3 +16,7 @@ var Stream = require('stream'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -14,3 +14,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -17,0 +21,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -14,3 +14,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -17,0 +21,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Zlib = require('zlib'); | ||
@@ -16,3 +16,7 @@ var Request = require('request'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -14,3 +14,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -17,0 +21,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -14,3 +14,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -39,3 +43,3 @@ | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
pack.server('s1', server1, { labels: ['a', 'b'] }); | ||
@@ -104,3 +108,3 @@ pack.server('s2', server2, { labels: ['a', 'c'] }); | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
pack.server('s1', server1, { labels: ['a', 'b'] }); | ||
@@ -198,11 +202,10 @@ pack.server('s2', server2, { labels: ['a', 'test'] }); | ||
var server1 = new Hapi.Server(); | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
pack.server('s1', server1, { labels: ['a', 'b'] }); | ||
pack.allow({}).require('./pack/none', function (err) { | ||
expect(function () { | ||
expect(err).to.exist; | ||
expect(err.message).to.contain('Cannot find module'); | ||
done(); | ||
}); | ||
pack.allow({}).require('./pack/none', function (err) { }); | ||
}).to.throw('Cannot find module'); | ||
done(); | ||
}); | ||
@@ -213,11 +216,10 @@ | ||
var server1 = new Hapi.Server(); | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
pack.server('s1', server1, { labels: ['a', 'b'] }); | ||
pack.require('none', function (err) { | ||
expect(function () { | ||
expect(err).to.exist; | ||
expect(err.message).to.contain('Cannot find module'); | ||
done(); | ||
}); | ||
pack.require('none', function (err) { }); | ||
}).to.throw('Cannot find module'); | ||
done(); | ||
}); | ||
@@ -232,3 +234,3 @@ | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
pack.server('s1', server1, { labels: ['a', 'b'] }); | ||
@@ -260,9 +262,9 @@ pack.server('s2', server2, { labels: ['a', 'test'] }); | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
pack.register({ version: '0.0.0', register: function (pack, options, next) { next(); } }, function (err) { | ||
var pack = new Hapi.Pack(); | ||
expect(function () { | ||
expect(err).to.exist; | ||
expect(err.message).to.equal('Plugin missing name'); | ||
done(); | ||
}); | ||
pack.register({ version: '0.0.0', register: function (pack, options, next) { next(); } }, function (err) { }); | ||
}).to.throw('Plugin missing name'); | ||
done(); | ||
}); | ||
@@ -272,3 +274,3 @@ | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
var err = pack.validate({ version: '0.0.0', register: function (pack, options, next) { next(); } }); | ||
@@ -281,5 +283,15 @@ | ||
it('invalidates bad name', function (done) { | ||
var pack = new Hapi.Pack(); | ||
var err = pack.validate({ name: '?', version: '0.0.0', register: function (pack, options, next) { next(); } }); | ||
expect(err).to.exist; | ||
expect(err.message).to.equal('Plugin name cannot be \'?\''); | ||
done(); | ||
}); | ||
it('invalidates missing version', function (done) { | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
var err = pack.validate({ name: 'test', register: function (pack, options, next) { next(); } }); | ||
@@ -294,3 +306,3 @@ | ||
var pack = new Hapi.Pack({ a: 1 }); | ||
var pack = new Hapi.Pack(); | ||
var err = pack.validate({ name: 'test', version: '0.0.0' }); | ||
@@ -334,2 +346,84 @@ | ||
}); | ||
it('adds multiple ext functions with dependencies', function (done) { | ||
var server1 = new Hapi.Server(); | ||
var server2 = new Hapi.Server(); | ||
var server3 = new Hapi.Server(); | ||
var pack = new Hapi.Pack(); | ||
pack.server('s1', server1, { labels: ['a', 'b'] }); | ||
pack.server('s2', server2, { labels: ['a', 'c'] }); | ||
pack.server('s3', server3, { labels: ['c', 'b'] }); | ||
var handler = function () { | ||
return this.reply(this.plugins.deps); | ||
}; | ||
server1.route({ method: 'GET', path: '/', handler: handler }); | ||
server2.route({ method: 'GET', path: '/', handler: handler }); | ||
server3.route({ method: 'GET', path: '/', handler: handler }); | ||
pack.allow({ ext: true }).require(['./pack/--deps1', './pack/--deps2', './pack/--deps3'], function (err) { | ||
expect(err).to.not.exist; | ||
server1.inject({ method: 'GET', url: '/' }, function (res) { | ||
expect(res.result).to.equal('|2|1|') | ||
server2.inject({ method: 'GET', url: '/' }, function (res) { | ||
expect(res.result).to.equal('|3|1|') | ||
server3.inject({ method: 'GET', url: '/' }, function (res) { | ||
expect(res.result).to.equal('|3|2|') | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
it('fails to require single plugin with dependencies', function (done) { | ||
var server = new Hapi.Server(); | ||
expect(function () { | ||
server.plugin.allow({ ext: true }).require('./pack/--deps1', function (err) { }); | ||
}).to.throw('Plugin \'--deps1\' missing dependencies: --deps2'); | ||
done(); | ||
}); | ||
it('fails to register single plugin with dependencies', function (done) { | ||
var plugin = { | ||
name: 'test', | ||
version: '3.0.0', | ||
register: function (pack, options, next) { | ||
pack.dependency('none'); | ||
next(); | ||
} | ||
}; | ||
var server = new Hapi.Server(); | ||
expect(function () { | ||
server.plugin.allow({ ext: true }).register(plugin, function (err) { }); | ||
}).to.throw('Plugin \'test\' missing dependencies: none'); | ||
done(); | ||
}); | ||
it('fails to require multiple plugin with dependencies', function (done) { | ||
var server = new Hapi.Server(); | ||
expect(function () { | ||
server.plugin.allow({ ext: true }).require(['./pack/--deps1', './pack/--deps3'], function (err) { }); | ||
}).to.throw('Plugin \'--deps1\' missing dependencies: --deps2'); | ||
done(); | ||
}); | ||
}); |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Request = require('request'); | ||
@@ -20,3 +20,7 @@ var Fs = require('fs'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -23,0 +27,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -14,3 +14,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -17,0 +21,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Fs = require('fs'); | ||
@@ -16,3 +16,7 @@ var Request = require('request'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -22,22 +26,64 @@ | ||
before(startServer); | ||
var server = null; | ||
function startServer (done) { | ||
before(function (done) { | ||
var routeCache = { | ||
expiresIn: 500 | ||
}; | ||
// Define backend handlers | ||
var config = { | ||
cache: { | ||
engine: 'memory', | ||
host: '127.0.0.1', | ||
port: 6379 | ||
} | ||
}; | ||
var mapUriWithError = function (request, callback) { | ||
var dummyServer = new Hapi.Server('0.0.0.0', 0); | ||
dummyServer.route([ | ||
return callback(new Error('myerror')); | ||
} | ||
var profile = function () { | ||
this.reply({ | ||
'id': 'fa0dbda9b1b', | ||
'name': 'John Doe' | ||
}); | ||
} | ||
var activeItem = function () { | ||
this.reply({ | ||
'id': '55cf687663', | ||
'name': 'Active Item' | ||
}); | ||
} | ||
var item = function () { | ||
this.reply.payload({ | ||
'id': '55cf687663', | ||
'name': 'Item' | ||
}).created('http://google.com').send(); | ||
} | ||
var echoPostBody = function () { | ||
this.reply(this.payload); | ||
} | ||
var unauthorized = function () { | ||
this.reply(Hapi.error.unauthorized('Not authorized')); | ||
} | ||
var postResponseWithError = function (request) { | ||
request.reply(Hapi.error.forbidden('Forbidden')); | ||
} | ||
var postResponse = function (request, settings, response, payload) { | ||
request.reply.payload(payload).type(response.headers['content-type']).send(); | ||
} | ||
var streamHandler = function () { | ||
this.reply('success'); | ||
} | ||
var backendServer = new Hapi.Server(0); | ||
backendServer.route([ | ||
{ method: 'GET', path: '/profile', handler: profile }, | ||
@@ -54,22 +100,22 @@ { method: 'GET', path: '/item', handler: activeItem }, | ||
return callback(null, dummyServer.settings.uri + request.path, request.query); | ||
return callback(null, backendServer.settings.uri + request.path + (request.url.search || '')); | ||
}; | ||
server = new Hapi.Server('0.0.0.0', 0, config); | ||
backendServer.start(function () { | ||
dummyServer.start(function () { | ||
var backendPort = backendServer.settings.port; | ||
var routeCache = { expiresIn: 500 }; | ||
var dummyPort = dummyServer.settings.port; | ||
server = new Hapi.Server(0, { cache: { engine: 'memory' } }); | ||
server.route([ | ||
{ method: 'GET', path: '/profile', handler: { proxy: { host: '127.0.0.1', port: dummyPort, xforward: true, passThrough: true } } }, | ||
{ method: 'GET', path: '/item', handler: { proxy: { host: '127.0.0.1', port: dummyPort } }, config: { cache: routeCache } }, | ||
{ method: 'GET', path: '/unauthorized', handler: { proxy: { host: '127.0.0.1', port: dummyPort } }, config: { cache: routeCache } }, | ||
{ method: 'POST', path: '/item', handler: { proxy: { host: '127.0.0.1', port: dummyPort } } }, | ||
{ method: 'POST', path: '/notfound', handler: { proxy: { host: '127.0.0.1', port: dummyPort } } }, | ||
{ method: 'GET', path: '/proxyerror', handler: { proxy: { host: '127.0.0.1', port: dummyPort } }, config: { cache: routeCache } }, | ||
{ method: 'GET', path: '/postResponseError', handler: { proxy: { host: '127.0.0.1', port: dummyPort, postResponse: postResponseWithError } }, config: { cache: routeCache } }, | ||
{ method: 'GET', path: '/errorResponse', handler: { proxy: { host: '127.0.0.1', port: dummyPort } }, config: { cache: routeCache } }, | ||
{ method: 'GET', path: '/profile', handler: { proxy: { host: 'localhost', port: backendPort, xforward: true, passThrough: true } } }, | ||
{ method: 'GET', path: '/item', handler: { proxy: { host: 'localhost', port: backendPort } }, config: { cache: routeCache } }, | ||
{ method: 'GET', path: '/unauthorized', handler: { proxy: { host: 'localhost', port: backendPort } }, config: { cache: routeCache } }, | ||
{ method: 'POST', path: '/item', handler: { proxy: { host: 'localhost', port: backendPort } } }, | ||
{ method: 'POST', path: '/notfound', handler: { proxy: { host: 'localhost', port: backendPort } } }, | ||
{ method: 'GET', path: '/proxyerror', handler: { proxy: { host: 'localhost', port: backendPort } }, config: { cache: routeCache } }, | ||
{ method: 'GET', path: '/postResponseError', handler: { proxy: { host: 'localhost', port: backendPort, postResponse: postResponseWithError } }, config: { cache: routeCache } }, | ||
{ method: 'GET', path: '/errorResponse', handler: { proxy: { host: 'localhost', port: backendPort } }, config: { cache: routeCache } }, | ||
{ method: 'POST', path: '/echo', handler: { proxy: { mapUri: mapUri } } }, | ||
{ method: 'POST', path: '/file', handler: { proxy: { host: '127.0.0.1', port: dummyPort } }, config: { payload: 'stream' } }, | ||
{ method: 'POST', path: '/file', handler: { proxy: { host: 'localhost', port: backendPort } }, config: { payload: 'stream' } }, | ||
{ method: 'GET', path: '/maperror', handler: { proxy: { mapUri: mapUriWithError } } } | ||
@@ -83,58 +129,4 @@ ]); | ||
}); | ||
} | ||
}); | ||
function mapUriWithError (request, callback) { | ||
return callback(new Error('myerror')); | ||
} | ||
function profile (request) { | ||
request.reply({ | ||
'id': 'fa0dbda9b1b', | ||
'name': 'John Doe' | ||
}); | ||
} | ||
function activeItem (request) { | ||
request.reply({ | ||
'id': '55cf687663', | ||
'name': 'Active Item' | ||
}); | ||
} | ||
function item (request) { | ||
request.reply.payload({ | ||
'id': '55cf687663', | ||
'name': 'Item' | ||
}).created('http://google.com').send(); | ||
} | ||
function echoPostBody (request) { | ||
request.reply(request.payload); | ||
} | ||
function unauthorized (request) { | ||
request.reply(Hapi.error.unauthorized('Not authorized')); | ||
} | ||
function postResponseWithError (request) { | ||
request.reply(Hapi.error.forbidden('Forbidden')); | ||
} | ||
function postResponse (request, settings, response, payload) { | ||
request.reply.payload(payload).type(response.headers['content-type']).send(); | ||
} | ||
function streamHandler (request) { | ||
request.reply('success'); | ||
} | ||
function makeRequest (options, callback) { | ||
@@ -141,0 +133,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
var Request = require('../../lib/request'); | ||
@@ -14,3 +15,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -161,2 +166,145 @@ | ||
}); | ||
it('returns 500 on handler exception (same tick)', function (done) { | ||
var server = new Hapi.Server(); | ||
var handler = function (request) { | ||
var x = a.b.c; | ||
}; | ||
server.route({ method: 'GET', path: '/domain', handler: handler }); | ||
server.inject({ method: 'GET', url: '/domain' }, function (res) { | ||
expect(res.statusCode).to.equal(500); | ||
done(); | ||
}); | ||
}); | ||
it('returns 500 on handler exception (next tick)', function (done) { | ||
var server = new Hapi.Server(); | ||
var handler = function (request) { | ||
setTimeout(function () { | ||
var x = a.b.c; | ||
}, 1); | ||
}; | ||
server.route({ method: 'GET', path: '/domain', handler: handler }); | ||
server.inject({ method: 'GET', url: '/domain' }, function (res) { | ||
expect(res.statusCode).to.equal(500); | ||
done(); | ||
}); | ||
}); | ||
it('ignores second call to reply()', function (done) { | ||
var server = new Hapi.Server(); | ||
var handler = function () { | ||
var reply = this.reply; | ||
reply('123'); | ||
reply('456'); | ||
}; | ||
server.route({ method: 'GET', path: '/domain', handler: handler }); | ||
server.inject({ method: 'GET', url: '/domain' }, function (res) { | ||
expect(res.result).to.equal('123'); | ||
done(); | ||
}); | ||
}); | ||
it('returns 500 on ext method exception (same tick)', function (done) { | ||
var server = new Hapi.Server(); | ||
server.ext('onRequest', function (request, next) { | ||
var x = a.b.c; | ||
}); | ||
var handler = function () { | ||
this.reply('neven gonna happen'); | ||
}; | ||
server.route({ method: 'GET', path: '/domain', handler: handler }); | ||
server.inject({ method: 'GET', url: '/domain' }, function (res) { | ||
expect(res.statusCode).to.equal(500); | ||
done(); | ||
}); | ||
}); | ||
it('invokes handler with no arguments', function (done) { | ||
var server = new Hapi.Server(); | ||
var handler = function () { | ||
expect(this instanceof Request).to.equal(true); | ||
expect(arguments.length).to.equal(0); | ||
this.reply('ok'); | ||
}; | ||
server.route({ method: 'GET', path: '/', handler: handler }); | ||
server.inject({ method: 'GET', url: '/' }, function (res) { | ||
expect(res.result).to.equal('ok'); | ||
done(); | ||
}); | ||
}); | ||
it('invokes handler with 1 arguments', function (done) { | ||
var server = new Hapi.Server(); | ||
var handler = function (request) { | ||
expect(this instanceof Request).to.equal(false); | ||
expect(arguments.length).to.equal(1); | ||
request.reply('ok'); | ||
}; | ||
server.route({ method: 'GET', path: '/', handler: handler }); | ||
server.inject({ method: 'GET', url: '/' }, function (res) { | ||
expect(res.result).to.equal('ok'); | ||
done(); | ||
}); | ||
}); | ||
it('invokes handler with 3 arguments', function (done) { | ||
var server = new Hapi.Server(); | ||
var handler = function (request, reply) { | ||
expect(this instanceof Request).to.equal(false); | ||
expect(arguments.length).to.equal(2); | ||
expect(reply.send).to.not.exist; | ||
reply('ok'); | ||
}; | ||
server.route({ method: 'GET', path: '/', handler: handler }); | ||
server.inject({ method: 'GET', url: '/' }, function (res) { | ||
expect(res.result).to.equal('ok'); | ||
done(); | ||
}); | ||
}); | ||
}); |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Async = require('async'); | ||
@@ -16,3 +16,7 @@ var Hapi = require('../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -14,3 +14,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -17,0 +21,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Net = require('net'); | ||
@@ -15,3 +15,7 @@ var Hapi = require('../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -21,6 +25,5 @@ | ||
var server = Hapi.createServer(0); | ||
it('won\'t stop until all connections are closed', function (done) { | ||
it('won\t stop until all connections are closed', function (done) { | ||
var server = Hapi.createServer(0); | ||
server.start(function () { | ||
@@ -32,2 +35,3 @@ | ||
socket1.connect(server.settings.port, server.settings.host, function () { | ||
socket2.connect(server.settings.port, server.settings.host, function () { | ||
@@ -49,2 +53,2 @@ | ||
}); | ||
}); | ||
}); |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Http = require('http'); | ||
@@ -17,3 +17,7 @@ var Stream = require('stream'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -20,0 +24,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Oz = require('oz'); | ||
@@ -16,3 +16,7 @@ var Hapi = require('../../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Oz = require('oz'); | ||
@@ -16,3 +16,7 @@ var Hapi = require('../../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Shot = require('shot'); | ||
@@ -17,3 +17,7 @@ var Hapi = require('../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -20,0 +24,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Shot = require('shot'); | ||
@@ -16,3 +16,7 @@ var Hapi = require('../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../../..'); | ||
@@ -14,3 +14,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -17,0 +21,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../../..'); | ||
@@ -15,3 +15,7 @@ var Views = require('../../../lib/views'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -18,0 +22,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -16,3 +16,7 @@ var Route = require('../../lib/route'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -15,3 +15,7 @@ var Schema = require('../../lib/schema'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -18,0 +22,0 @@ var S = Hapi.types.String, |
// Load modules | ||
var Lab = require('lab'); | ||
var Https = require('https'); | ||
var Chai = require('chai'); | ||
var Hapi = require('../..'); | ||
@@ -15,3 +15,7 @@ | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -18,0 +22,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Iron = require('iron'); | ||
@@ -17,3 +17,7 @@ var Hapi = require('../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -20,0 +24,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -15,3 +15,7 @@ var Package = require('../../package.json'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -18,0 +22,0 @@ |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Querystring = require('querystring'); | ||
@@ -16,3 +16,7 @@ var Hapi = require('../..'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -19,0 +23,0 @@ var S = Hapi.types.String, |
// Load modules | ||
var Chai = require('chai'); | ||
var Lab = require('lab'); | ||
var Hapi = require('../..'); | ||
@@ -15,3 +15,7 @@ var Views = require('../../lib/views'); | ||
var expect = Chai.expect; | ||
var expect = Lab.expect; | ||
var before = Lab.before; | ||
var after = Lab.after; | ||
var describe = Lab.experiment; | ||
var it = Lab.test; | ||
@@ -34,3 +38,3 @@ | ||
}); | ||
it('should work and not throw with valid (no layouts)', function (done) { | ||
@@ -122,3 +126,3 @@ | ||
}); | ||
it('should load partials and render them EVEN if viewsPath has trailing slash', function (done) { | ||
@@ -143,3 +147,3 @@ | ||
}); | ||
it('should skip loading partial if engine does not have registerPartial method', function (done) { | ||
@@ -171,14 +175,11 @@ | ||
before(function () { | ||
var options = { | ||
views: { | ||
path: viewsPath | ||
} | ||
}; | ||
var options = { | ||
views: { | ||
path: viewsPath | ||
} | ||
}; | ||
internals._handlerServer = new Hapi.Server(options); | ||
internals._handlerServer.route({ method: 'GET', path: '/{param}', handler: { view: 'valid/handler' } }); | ||
internals._handlerServer = new Hapi.Server(options); | ||
internals._handlerServer.route({ method: 'GET', path: '/{param}', handler: { view: 'valid/handler' } }); | ||
}); | ||
it('handles routes to views', function (done) { | ||
@@ -185,0 +186,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
767689
4
166
13040