Created
August 21, 2014 14:07
-
-
Save molekilla/126c85344be1177e10b8 to your computer and use it in GitHub Desktop.
hapi-bearer-token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*globals expect:true*/ | |
var Hapi = require('hapi'); | |
var server = require('./../../../lib/hapi'); | |
describe("Users controller", function() { | |
it("should return HTTP 401 when no bearer header auth is found", function(done) { | |
server.inject({ method: 'POST', url: '/api/v1/users' }, function (res) { | |
expect(res.statusCode).toBe(401); | |
done(); | |
}); | |
}); | |
it("should return HTTP 500 when bearer code is a mismatch", function(done) { | |
server.inject({ method: 'POST', url: '/api/v1/users', headers: { authorization: "Bearer abc" } }, function (res) { | |
expect(res.statusCode).toBe(500); | |
done(); | |
}); | |
}); | |
it("should return HTTP 200 for /api/v1/users", function(done) { | |
server.inject({ method: 'POST', url: '/api/v1/users', headers: { authorization: "Bearer a1b2c3" } }, function (res) { | |
expect(res.statusCode).toBe(201); | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment