Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: node_js
node_js:
- "6"
- "5"
- "4"
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ exports.register = (server, config, next) => {
value.options.validateFunc = (request, session, callback) => {
const method = _.get(server.methods, validateFn);
if (!method) {
const msg = `could not find validate method ${validateFn} in server.methods`;
server.log(['error', 'hapi-strategy-loader'], msg);
return;
const err = new Error(`could not find validate method ${validateFn} in server.methods`);
server.log(['error', 'hapi-strategy-loader'], err);
return callback(err);
}
method(request, session, callback);
};
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "plugin to configure auth strategies for a hapi server",
"main": "index.js",
"scripts": {
"test": "lab -e test",
"test": "lab -e test --leaks",
"lint": "eslint ."
},
"repository": {
Expand All @@ -20,9 +20,9 @@
"devDependencies": {
"bell": "^7.7.2",
"code": "^2.1.0",
"eslint": "^3.4.0",
"eslint": "^3.9.1",
"eslint-config-firstandthird": "^3.0.2",
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-import": "^2.1.0",
"hapi": "^13.4.1",
"hapi-auth-cookie": "^6.1.1",
"hoek": "^4.0.0",
Expand Down
14 changes: 10 additions & 4 deletions test/server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,12 @@ lab.test('log and throw error if a method is not available', (done) => {
}
});
server.route({
method: 'GET', path: '/resource', handler: (request, reply) => {
method: 'GET',
path: '/resource',
handler: (request, reply) => {
code.expect(request.auth.isAuthenticated).to.not.equal(true);
code.expect(request.auth.error).to.exist;
code.expect(request.auth.error.data).to.include('gorbachev');
done();
reply(request.auth.error);
}
});
server.inject('/login/valid', (res) => {
Expand All @@ -271,7 +273,11 @@ lab.test('log and throw error if a method is not available', (done) => {
code.expect(header.length).to.equal(1);
code.expect(header[0]).to.contain('Max-Age=60');
const cookie = header[0].match(/(?:[^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)\s*=\s*(?:([^\x00-\x20\"\,\;\\\x7F]*))/);
server.inject({ method: 'GET', url: '/resource', headers: { cookie: `${mainCookie}=${cookie[1]}` } }, (res2) => {});
server.inject({ method: 'GET', url: '/resource', headers: { cookie: `${mainCookie}=${cookie[1]}` } }, (response2) => {
code.expect(response2.result.statusCode).to.equal(401);
code.expect(response2.result.message).to.include('Invalid cookie');
done();
});
});
});
});