Add support for bearer auth (#1488) (#1490)

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2021-07-13 09:40:06 +02:00
committed by GitHub
parent 2f0aeec108
commit ea2c8d2d4d
6 changed files with 65 additions and 3 deletions

View File

@ -1421,3 +1421,30 @@ test('Disable prototype poisoning protection', t => {
t.error(err)
})
})
test('Bearer auth', t => {
t.plan(3)
function handler (req, res) {
t.match(req.headers, {
authorization: 'Bearer Zm9vOmJhcg=='
})
res.setHeader('Content-Type', 'application/json;utf=8')
res.end(JSON.stringify({ hello: 'world' }))
}
buildServer(handler, ({ port }, server) => {
const client = new Client({
node: `http://localhost:${port}`,
auth: {
bearer: 'Zm9vOmJhcg=='
}
})
client.info((err, { body }) => {
t.error(err)
t.same(body, { hello: 'world' })
server.stop()
})
})
})