hapi-auth-cookie
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "hapi-auth-cookie", | ||
"description": "Cookie authentication plugin", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -16,3 +16,3 @@ "repository": "git://github.com/spumko/hapi-auth-cookie", | ||
"engines": { | ||
"node": "0.10.x" | ||
"node": ">=0.10.22" | ||
}, | ||
@@ -24,6 +24,6 @@ "dependencies": { | ||
"peerDependencies": { | ||
"hapi": "2.x.x" | ||
"hapi": ">=2.x.x" | ||
}, | ||
"devDependencies": { | ||
"hapi": "2.x.x", | ||
"hapi": "3.x.x", | ||
"lab": "1.x.x" | ||
@@ -30,0 +30,0 @@ }, |
@@ -189,2 +189,55 @@ // Load modules | ||
it('errors in validation function', function (done) { | ||
var server = new Hapi.Server(); | ||
server.pack.require('../', function (err) { | ||
expect(err).to.not.exist; | ||
server.auth.strategy('default', 'cookie', { | ||
password: 'password', | ||
ttl: 60 * 1000, | ||
cookie: 'special', | ||
clearInvalid: true, | ||
validateFunc: function (session, callback) { return callback(new Error('boom')); } | ||
}); | ||
server.route({ | ||
method: 'GET', path: '/login/{user}', | ||
config: { | ||
auth: { mode: 'try' }, | ||
handler: function (request, reply) { | ||
request.auth.session.set({ user: request.params.user }); | ||
return reply(request.params.user); | ||
} | ||
} | ||
}); | ||
server.route({ | ||
method: 'GET', path: '/resource', handler: function (request, reply) { | ||
expect(request.auth.credentials.user).to.equal('steve'); | ||
return reply('resource'); | ||
}, | ||
config: { auth: true } | ||
}); | ||
server.inject('/login/steve', function (res) { | ||
expect(res.result).to.equal('steve'); | ||
var header = res.headers['set-cookie']; | ||
expect(header.length).to.equal(1); | ||
expect(header[0]).to.contain('Max-Age=60'); | ||
var cookie = header[0].match(/(?:[^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)\s*=\s*(?:([^\x00-\x20\"\,\;\\\x7F]*))/); | ||
server.inject({ method: 'GET', url: '/resource', headers: { cookie: 'special=' + cookie[1] } }, function (res) { | ||
expect(res.statusCode).to.equal(401); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('redirection', function (done) { | ||
@@ -191,0 +244,0 @@ |
Sorry, the diff of this file is not supported yet
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
27044
428