@fastify/bearer-auth
Advanced tools
Comparing version 10.0.0 to 10.0.1
{ | ||
"name": "@fastify/bearer-auth", | ||
"version": "10.0.0", | ||
"version": "10.0.1", | ||
"description": "An authentication plugin for Fastify", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"test:typescript": "tsd", | ||
"test:unit": "tap" | ||
"test:unit": "c8 --100 node --test" | ||
}, | ||
@@ -38,5 +38,5 @@ "precommit": [ | ||
"@types/node": "^22.0.0", | ||
"fastify": "^5.0.0-alpha.4", | ||
"c8": "^10.1.2", | ||
"fastify": "^5.0.0", | ||
"standard": "^17.1.0", | ||
"tap": "^18.7.2", | ||
"tsd": "^0.31.0" | ||
@@ -43,0 +43,0 @@ }, |
'use strict' | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const stream = require('node:stream') | ||
@@ -32,4 +32,4 @@ const Fastify = require('fastify') | ||
t.ok(fastify.verifyBearerAuth) | ||
t.ok(fastify.verifyBearerAuthFactory) | ||
t.assert.ok(fastify.verifyBearerAuth) | ||
t.assert.ok(fastify.verifyBearerAuthFactory) | ||
@@ -47,6 +47,6 @@ const response = await fastify.inject({ | ||
t.equal(failure.level, 20) | ||
t.equal(failure.msg, 'unauthorized: invalid authorization header') | ||
t.assert.strictEqual(failure.level, 20) | ||
t.assert.strictEqual(failure.msg, 'unauthorized: invalid authorization header') | ||
t.equal(response.statusCode, 401) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
}) | ||
@@ -63,4 +63,4 @@ | ||
} catch (err) { | ||
t.equal(err.message, `fastify.log does not have level '${invalidLogLevel}'`) | ||
t.assert.strictEqual(err.message, `fastify.log does not have level '${invalidLogLevel}'`) | ||
} | ||
}) |
'use strict' | ||
const tap = require('tap') | ||
const test = tap.test | ||
const { test } = require('node:test') | ||
const fastify = require('fastify')() | ||
@@ -10,22 +9,25 @@ const plugin = require('../') | ||
test('verifyBearerAuth', (t) => { | ||
test('verifyBearerAuth', async (t) => { | ||
t.plan(1) | ||
fastify.ready(() => { | ||
t.ok(fastify.verifyBearerAuth) | ||
}) | ||
await fastify.ready() | ||
t.assert.ok(fastify.verifyBearerAuth) | ||
}) | ||
test('verifyBearerAuthFactory', (t) => { | ||
test('verifyBearerAuthFactory', async (t) => { | ||
t.plan(1) | ||
fastify.ready(() => { | ||
t.ok(fastify.verifyBearerAuthFactory) | ||
}) | ||
await fastify.ready() | ||
t.assert.ok(fastify.verifyBearerAuthFactory) | ||
}) | ||
test('verifyBearerAuthFactory', (t) => { | ||
t.plan(1) | ||
fastify.ready(() => { | ||
const keys = { keys: new Set([123456]) } | ||
t.throws(() => fastify.verifyBearerAuthFactory(keys), /keys has to contain only string entries/) | ||
}) | ||
test('verifyBearerAuthFactory', async (t) => { | ||
t.plan(2) | ||
await fastify.ready() | ||
const keys = { keys: new Set([123456]) } | ||
await t.assert.rejects( | ||
async () => fastify.verifyBearerAuthFactory(keys), | ||
(err) => { | ||
t.assert.strictEqual(err.message, 'options.keys has to contain only string entries') | ||
return true | ||
} | ||
) | ||
}) |
'use strict' | ||
const tap = require('tap') | ||
const test = tap.test | ||
const { test } = require('node:test') | ||
const fastify = require('fastify')() | ||
@@ -14,5 +13,5 @@ const plugin = require('../') | ||
test('success route succeeds', (t) => { | ||
test('success route succeeds', async (t) => { | ||
t.plan(2) | ||
fastify.inject({ | ||
const response = await fastify.inject({ | ||
method: 'GET', | ||
@@ -23,13 +22,10 @@ url: '/test', | ||
} | ||
}).then(response => { | ||
t.equal(response.statusCode, 200) | ||
t.same(JSON.parse(response.body), { hello: 'world' }) | ||
}).catch(err => { | ||
t.error(err) | ||
}) | ||
t.assert.strictEqual(response.statusCode, 200) | ||
t.assert.deepStrictEqual(JSON.parse(response.body), { hello: 'world' }) | ||
}) | ||
test('invalid key route fails correctly', (t) => { | ||
test('invalid key route fails correctly', async (t) => { | ||
t.plan(2) | ||
fastify.inject({ | ||
const response = await fastify.inject({ | ||
method: 'GET', | ||
@@ -40,13 +36,10 @@ url: '/test', | ||
} | ||
}).then(response => { | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /invalid authorization header/) | ||
}).catch(err => { | ||
t.error(err) | ||
}) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'invalid authorization header') | ||
}) | ||
test('missing space between bearerType and key fails correctly', (t) => { | ||
test('missing space between bearerType and key fails correctly', async (t) => { | ||
t.plan(2) | ||
fastify.inject({ | ||
const response = await fastify.inject({ | ||
method: 'GET', | ||
@@ -57,23 +50,15 @@ url: '/test', | ||
} | ||
}).then(response => { | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /invalid authorization header/) | ||
}).catch(err => { | ||
t.error(err) | ||
}) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'invalid authorization header') | ||
}) | ||
test('missing header route fails correctly', (t) => { | ||
test('missing header route fails correctly', async (t) => { | ||
t.plan(2) | ||
fastify.inject({ method: 'GET', url: '/test' }).then(response => { | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /missing authorization header/) | ||
}).catch(err => { | ||
t.error(err) | ||
}) | ||
const response = await fastify.inject({ method: 'GET', url: '/test' }) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'missing authorization header') | ||
}) | ||
test('integration with @fastify/auth', async (t) => { | ||
t.plan(3) | ||
const fastify = require('fastify')() | ||
@@ -103,10 +88,10 @@ await fastify.register(plugin, { addHook: false, keys: new Set(['123456']) }) | ||
t.test('anonymous should pass', async (t) => { | ||
await test('anonymous should pass', async (t) => { | ||
t.plan(2) | ||
const res = await fastify.inject({ method: 'GET', url: '/anonymous' }) | ||
t.equal(res.statusCode, 200) | ||
t.match(JSON.parse(res.body).hello, 'world') | ||
t.assert.strictEqual(res.statusCode, 200) | ||
t.assert.strictEqual(JSON.parse(res.body).hello, 'world') | ||
}) | ||
t.test('bearer auth should pass', async (t) => { | ||
await test('bearer auth should pass', async (t) => { | ||
t.plan(2) | ||
@@ -120,7 +105,7 @@ const res = await fastify.inject({ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.match(JSON.parse(res.body).hello, 'world') | ||
t.assert.strictEqual(res.statusCode, 200) | ||
t.assert.strictEqual(JSON.parse(res.body).hello, 'world') | ||
}) | ||
t.test('bearer auth should fail, so fastify.auth fails', async (t) => { | ||
await test('bearer auth should fail, so fastify.auth fails', async (t) => { | ||
t.plan(2) | ||
@@ -134,4 +119,4 @@ const res = await fastify.inject({ | ||
}) | ||
t.equal(res.statusCode, 401) | ||
t.match(JSON.parse(res.body).error, /Unauthorized/) | ||
t.assert.strictEqual(res.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(res.body).error, 'Unauthorized') | ||
}) | ||
@@ -141,4 +126,2 @@ }) | ||
test('integration with @fastify/auth; not the last auth option', async (t) => { | ||
t.plan(3) | ||
const fastify = require('fastify')() | ||
@@ -165,3 +148,3 @@ await fastify.register(plugin, { addHook: false, keys: new Set(['123456']) }) | ||
t.test('bearer auth should pass so fastify.auth should pass', async (t) => { | ||
await test('bearer auth should pass so fastify.auth should pass', async (t) => { | ||
t.plan(2) | ||
@@ -175,7 +158,7 @@ const res = await fastify.inject({ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.match(JSON.parse(res.body).hello, 'world') | ||
t.assert.strictEqual(res.statusCode, 200) | ||
t.assert.strictEqual(JSON.parse(res.body).hello, 'world') | ||
}) | ||
t.test('bearer should fail but fastify.auth should pass', async (t) => { | ||
await test('bearer should fail but fastify.auth should pass', async (t) => { | ||
t.plan(2) | ||
@@ -189,7 +172,7 @@ const res = await fastify.inject({ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.match(JSON.parse(res.body).hello, 'world') | ||
t.assert.strictEqual(res.statusCode, 200) | ||
t.assert.strictEqual(JSON.parse(res.body).hello, 'world') | ||
}) | ||
t.test('bearer should fail but fastify.auth should pass', async (t) => { | ||
await test('bearer should fail but fastify.auth should pass', async (t) => { | ||
t.plan(2) | ||
@@ -201,5 +184,5 @@ const res = await fastify.inject({ | ||
}) | ||
t.equal(res.statusCode, 200) | ||
t.match(JSON.parse(res.body).hello, 'world') | ||
t.assert.strictEqual(res.statusCode, 200) | ||
t.assert.strictEqual(JSON.parse(res.body).hello, 'world') | ||
}) | ||
}) |
'use strict' | ||
const tap = require('tap') | ||
const test = tap.test | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
const plugin = require('../') | ||
const { FST_BEARER_AUTH_INVALID_SPEC } = require('../lib/errors') | ||
test('throws FST_BEARER_AUTH_INVALID_SPEC when invalid value for specCompliance was used', async (t) => { | ||
t.plan(1) | ||
t.plan(2) | ||
const fastify = Fastify() | ||
t.rejects(async () => fastify.register(plugin, { keys: new Set(['123456']), specCompliance: 'invalid' }), new FST_BEARER_AUTH_INVALID_SPEC()) | ||
await t.assert.rejects( | ||
async () => fastify.register(plugin, { keys: new Set(['123456']), specCompliance: 'invalid' }), | ||
(err) => { | ||
t.assert.strictEqual(err.name, 'FastifyError') | ||
return true | ||
} | ||
) | ||
}) |
'use strict' | ||
const tap = require('tap') | ||
const test = tap.test | ||
const { test } = require('node:test') | ||
const fastify = require('fastify')() | ||
@@ -25,4 +24,4 @@ const plugin = require('../') | ||
t.equal(response.statusCode, 200) | ||
t.same(JSON.parse(response.body), { hello: 'world' }) | ||
t.assert.strictEqual(response.statusCode, 200) | ||
t.assert.deepStrictEqual(JSON.parse(response.body), { hello: 'world' }) | ||
}) | ||
@@ -41,4 +40,4 @@ | ||
t.equal(response.statusCode, 200) | ||
t.same(JSON.parse(response.body), { hello: 'world' }) | ||
t.assert.strictEqual(response.statusCode, 200) | ||
t.assert.deepStrictEqual(JSON.parse(response.body), { hello: 'world' }) | ||
}) | ||
@@ -57,4 +56,4 @@ | ||
t.equal(response.statusCode, 200) | ||
t.same(JSON.parse(response.body), { hello: 'world' }) | ||
t.assert.strictEqual(response.statusCode, 200) | ||
t.assert.deepStrictEqual(JSON.parse(response.body), { hello: 'world' }) | ||
}) | ||
@@ -72,4 +71,4 @@ | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /invalid authorization header/) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'invalid authorization header') | ||
}) | ||
@@ -87,4 +86,4 @@ | ||
}) | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /invalid authorization header/) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'invalid authorization header') | ||
}) |
'use strict' | ||
const tap = require('tap') | ||
const test = tap.test | ||
const { test } = require('node:test') | ||
const fastify = require('fastify')() | ||
@@ -25,4 +24,4 @@ const plugin = require('../') | ||
t.equal(response.statusCode, 200) | ||
t.same(JSON.parse(response.body), { hello: 'world' }) | ||
t.assert.strictEqual(response.statusCode, 200) | ||
t.assert.deepStrictEqual(JSON.parse(response.body), { hello: 'world' }) | ||
}) | ||
@@ -41,4 +40,4 @@ | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /invalid authorization header/) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'invalid authorization header') | ||
}) | ||
@@ -57,4 +56,4 @@ | ||
t.equal(response.statusCode, 200) | ||
t.same(JSON.parse(response.body), { hello: 'world' }) | ||
t.assert.strictEqual(response.statusCode, 200) | ||
t.assert.deepStrictEqual(JSON.parse(response.body), { hello: 'world' }) | ||
}) | ||
@@ -72,4 +71,4 @@ | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /invalid authorization header/) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'invalid authorization header') | ||
}) | ||
@@ -87,4 +86,4 @@ | ||
}) | ||
t.equal(response.statusCode, 401) | ||
t.match(JSON.parse(response.body).error, /invalid authorization header/) | ||
t.assert.strictEqual(response.statusCode, 401) | ||
t.assert.strictEqual(JSON.parse(response.body).error, 'invalid authorization header') | ||
}) |
'use strict' | ||
const test = require('tap').test | ||
const { test } = require('node:test') | ||
const noop = () => { } | ||
@@ -22,4 +22,4 @@ const verifyBearerAuthFactory = require('../lib/verify-bearer-auth-factory') | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /missing authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'missing authorization header') | ||
} | ||
@@ -45,10 +45,10 @@ | ||
function header (key, value) { | ||
t.ok(key) | ||
t.ok(value) | ||
t.equal(key, 'content-type') | ||
t.equal(value, CUSTOM_CONTENT_TYPE) | ||
t.assert.ok(key) | ||
t.assert.ok(value) | ||
t.assert.strictEqual(key, 'content-type') | ||
t.assert.strictEqual(value, CUSTOM_CONTENT_TYPE) | ||
} | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /missing authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'missing authorization header') | ||
} | ||
@@ -73,4 +73,4 @@ | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -95,4 +95,4 @@ | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -121,4 +121,4 @@ | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -145,4 +145,4 @@ | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -169,4 +169,4 @@ | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -193,3 +193,3 @@ | ||
function send (body) { | ||
t.fail('should not happen') | ||
t.assert.ifError(body) | ||
} | ||
@@ -199,3 +199,3 @@ | ||
hook(request, response, () => { | ||
t.pass() | ||
t.assert.ok(true) | ||
}) | ||
@@ -221,3 +221,3 @@ }) | ||
function send (body) { | ||
t.fail('should not happen') | ||
t.assert.ifError(body) | ||
} | ||
@@ -227,3 +227,3 @@ | ||
hook(request, response, () => { | ||
t.pass() | ||
t.assert.ok(true) | ||
}) | ||
@@ -247,4 +247,4 @@ }) | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -271,3 +271,3 @@ | ||
function send (body) { | ||
t.fail('should not happen') | ||
t.assert.ifError(body) | ||
} | ||
@@ -277,3 +277,3 @@ | ||
hook(request, response, () => { | ||
t.pass() | ||
t.assert.ok(true) | ||
}) | ||
@@ -285,3 +285,3 @@ }) | ||
const auth = function (val) { | ||
t.equal(val, key, 'wrong argument') | ||
t.assert.strictEqual(val, key, 'wrong argument') | ||
return Promise.resolve(true) | ||
@@ -301,3 +301,3 @@ } | ||
function send (body) { | ||
t.fail('should not happen') | ||
t.assert.ifError('should not happen') | ||
} | ||
@@ -307,3 +307,3 @@ | ||
hook(request, response, () => { | ||
t.pass() | ||
t.assert.ok(true) | ||
}) | ||
@@ -315,3 +315,3 @@ }) | ||
const auth = function (val) { | ||
t.equal(val, key, 'wrong argument') | ||
t.assert.strictEqual(val, key, 'wrong argument') | ||
return true | ||
@@ -331,3 +331,3 @@ } | ||
function send (body) { | ||
t.fail('should not happen') | ||
t.assert.ifError('should not happen') | ||
} | ||
@@ -337,3 +337,3 @@ | ||
hook(request, response, () => { | ||
t.pass() | ||
t.assert.ok(true) | ||
}) | ||
@@ -357,4 +357,4 @@ }) | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -364,3 +364,3 @@ | ||
hook(request, response, () => { | ||
t.fail('should not accept') | ||
t.assert.ifError('should not accept') | ||
}) | ||
@@ -385,10 +385,10 @@ }) | ||
function header (key, value) { | ||
t.ok(key) | ||
t.ok(value) | ||
t.equal(key, 'content-type') | ||
t.equal(value, CUSTOM_CONTENT_TYPE) | ||
t.assert.ok(key) | ||
t.assert.ok(value) | ||
t.assert.strictEqual(key, 'content-type') | ||
t.assert.strictEqual(value, CUSTOM_CONTENT_TYPE) | ||
} | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -411,4 +411,4 @@ | ||
const auth = function (val, req) { | ||
t.equal(req, request) | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(req, request) | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return false | ||
@@ -419,3 +419,3 @@ } | ||
code: (status) => { | ||
t.equal(401, status) | ||
t.assert.strictEqual(401, status) | ||
return response | ||
@@ -427,4 +427,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -442,3 +442,3 @@ | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return Promise.resolve(false) | ||
@@ -455,3 +455,3 @@ } | ||
code: (status) => { | ||
t.equal(401, status) | ||
t.assert.strictEqual(401, status) | ||
return response | ||
@@ -463,4 +463,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /invalid authorization header/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'invalid authorization header') | ||
} | ||
@@ -478,3 +478,3 @@ | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
throw Error('failing') | ||
@@ -491,3 +491,3 @@ } | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -499,4 +499,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /failing/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'failing') | ||
} | ||
@@ -514,3 +514,3 @@ | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return Promise.reject(Error('failing')) | ||
@@ -527,3 +527,3 @@ } | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -535,4 +535,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /failing/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'failing') | ||
} | ||
@@ -542,3 +542,3 @@ | ||
hook(request, response, () => { | ||
t.fail('should not accept') | ||
t.assert.ifError('should not accept') | ||
}) | ||
@@ -551,3 +551,3 @@ }) | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return Promise.reject('failing') // eslint-disable-line | ||
@@ -564,3 +564,3 @@ } | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -572,4 +572,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /failing/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'failing') | ||
} | ||
@@ -579,3 +579,3 @@ | ||
hook(request, response, () => { | ||
t.fail('should not accept') | ||
t.assert.ifError('should not accept') | ||
}) | ||
@@ -595,3 +595,3 @@ }) | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -603,4 +603,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /foo!/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'foo!') | ||
} | ||
@@ -611,3 +611,3 @@ | ||
if (err) { | ||
t.pass(err) | ||
t.assert.ok(err) | ||
} | ||
@@ -622,3 +622,3 @@ throw new Error('foo!') | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return 'foobar' | ||
@@ -635,3 +635,3 @@ } | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -643,4 +643,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /internal server error/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'internal server error') | ||
} | ||
@@ -650,3 +650,3 @@ | ||
hook(request, response, () => { | ||
t.fail('should not accept') | ||
t.assert.ifError('should not accept') | ||
}) | ||
@@ -659,3 +659,3 @@ }) | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return Promise.resolve('abcde') | ||
@@ -672,3 +672,3 @@ } | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -680,4 +680,4 @@ }, | ||
function send (body) { | ||
t.ok(body.error) | ||
t.match(body.error, /internal server error/) | ||
t.assert.ok(body.error) | ||
t.assert.strictEqual(body.error, 'internal server error') | ||
} | ||
@@ -687,3 +687,3 @@ | ||
hook(request, response, () => { | ||
t.fail('should not accept') | ||
t.assert.ifError('should not accept') | ||
}) | ||
@@ -696,3 +696,3 @@ }) | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return 'foobar' | ||
@@ -709,3 +709,3 @@ } | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -717,4 +717,4 @@ } | ||
hook(request, response, (err) => { | ||
t.ok(err) | ||
t.match(err.message, /internal server error/) | ||
t.assert.ok(err) | ||
t.assert.strictEqual(err.message, 'internal server error') | ||
}) | ||
@@ -727,3 +727,3 @@ }) | ||
const auth = function (val) { | ||
t.equal(val, 'abcdefg', 'wrong argument') | ||
t.assert.strictEqual(val, 'abcdefg', 'wrong argument') | ||
return Promise.reject(Error('failing')) | ||
@@ -740,3 +740,3 @@ } | ||
code: (status) => { | ||
t.equal(500, status) | ||
t.assert.strictEqual(500, status) | ||
return response | ||
@@ -748,4 +748,4 @@ } | ||
hook(request, response, (err) => { | ||
t.ok(err) | ||
t.match(err.message, /failing/) | ||
t.assert.ok(err) | ||
t.assert.strictEqual(err.message, 'failing') | ||
}) | ||
@@ -769,3 +769,3 @@ }) | ||
function send (body) { | ||
t.fail('should not happen') | ||
t.assert.ifError(body) | ||
} | ||
@@ -775,3 +775,3 @@ | ||
hook(request, response, () => { | ||
t.pass() | ||
t.assert.ok(true) | ||
}) | ||
@@ -783,3 +783,3 @@ }) | ||
t.throws(() => verifyBearerAuthFactory({ keys: true })) | ||
t.assert.throws(() => verifyBearerAuthFactory({ keys: true })) | ||
}) |
48723
22
1299