Skip to content

Commit

Permalink
Add missing callback tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simov committed Nov 26, 2023
1 parent c220e9e commit 5f60a59
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions test/handler/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,34 @@ describe('handler', () => {
})
})

describe('missing provider', () => {
describe('missing provider + missing callback', () => {
;['express', 'koa', 'hapi', 'fastify', 'node', 'aws', 'azure', 'gcloud', 'vercel'].forEach((handler) => {
describe(handler, () => {
before(async () => {
client = await Client({test: 'handlers', handler, config})
client = await Client({
test: 'handlers',
handler,
config: {
defaults: {origin: config.defaults.origin}, // no callback!
oauth2: config.oauth2
}
})
})

after(async () => {
await client.close()
})

it('/connect - misconfigured provider', async () => {
it('/connect - missing provider', async () => {
t.equal(config.defaults.dynamic, undefined)
var {body: {response}} = await request({
url: client.url('/connect/oauth5'),
cookie: {},
})
t.deepEqual(response, {error: 'Grant: missing or misconfigured provider'})
})

it('/connect - unsupported oauth version', async () => {
var {body: {response}} = await request({
url: client.url('/connect/oauth2'),
qs: {oauth: 5},
Expand All @@ -143,13 +159,22 @@ describe('handler', () => {
t.deepEqual(response, {error: 'Grant: missing or misconfigured provider'})
})

it('/connect - missing provider', async () => {
t.equal(config.defaults.dynamic, undefined)
it('/connect - authorize error', async () => {
var {body: {response}} = await request({
url: client.url('/connect/oauth5'),
url: client.url('/connect/oauth2'),
qs: {authorize_url: provider.url('/authorize_error_message')},
cookie: {},
})
t.deepEqual(response, {error: 'Grant: missing or misconfigured provider'})
t.deepEqual(response, {error: {message: 'invalid'}})
})

it('/connect - access error', async () => {
var {body: {response}} = await request({
url: client.url('/connect/oauth2'),
qs: {access_url: provider.url('/access_error_status')},
cookie: {},
})
t.deepEqual(response, {error: {invalid: 'access_url'}})
})

it('/callback - missing session', async () => {
Expand Down

0 comments on commit 5f60a59

Please sign in to comment.