Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
For #258
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Sep 15, 2019
1 parent 61458a5 commit c52428a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions test/plugin.js
Expand Up @@ -60,7 +60,7 @@ describe('Plugin', () => {
return '';
};

it('calls through to handler on successful auth', async () => {
it('handles successful auth', async () => {

const server = Hapi.server();
await server.register(Hawk);
Expand All @@ -83,7 +83,7 @@ describe('Plugin', () => {
expect(res.result).to.equal('Success');
});

it('calls through to handler on failed optional auth', async () => {
it('handles failed optional auth', async () => {

const server = Hapi.server();
await server.register(Hawk);
Expand All @@ -105,6 +105,29 @@ describe('Plugin', () => {
expect(res.result).to.equal('Success');
});

it('handles successful auth (default strategy)', async () => {

const server = Hapi.server();
await server.register(Hawk);

server.auth.strategy('default', 'hawk', { getCredentialsFunc });
server.auth.default('default');
server.route({
method: 'POST',
path: '/hawk',
handler: function (request, h) {

return 'Success';
}
});

const request = { method: 'POST', url: 'http://example.com:8080/hawk', headers: { authorization: hawkHeader('john', '/hawk').header } };
const res = await server.inject(request);

expect(res.statusCode).to.equal(200);
expect(res.result).to.equal('Success');
});

it('includes authorization header in response when the response is a stream', async () => {

const server = Hapi.server();
Expand Down

0 comments on commit c52428a

Please sign in to comment.