Skip to content

Commit 5f60a59

Browse files
committed
Add missing callback tests
1 parent c220e9e commit 5f60a59

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

test/handler/handler.js

+32-7
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,34 @@ describe('handler', () => {
123123
})
124124
})
125125

126-
describe('missing provider', () => {
126+
describe('missing provider + missing callback', () => {
127127
;['express', 'koa', 'hapi', 'fastify', 'node', 'aws', 'azure', 'gcloud', 'vercel'].forEach((handler) => {
128128
describe(handler, () => {
129129
before(async () => {
130-
client = await Client({test: 'handlers', handler, config})
130+
client = await Client({
131+
test: 'handlers',
132+
handler,
133+
config: {
134+
defaults: {origin: config.defaults.origin}, // no callback!
135+
oauth2: config.oauth2
136+
}
137+
})
131138
})
132139

133140
after(async () => {
134141
await client.close()
135142
})
136143

137-
it('/connect - misconfigured provider', async () => {
144+
it('/connect - missing provider', async () => {
145+
t.equal(config.defaults.dynamic, undefined)
146+
var {body: {response}} = await request({
147+
url: client.url('/connect/oauth5'),
148+
cookie: {},
149+
})
150+
t.deepEqual(response, {error: 'Grant: missing or misconfigured provider'})
151+
})
152+
153+
it('/connect - unsupported oauth version', async () => {
138154
var {body: {response}} = await request({
139155
url: client.url('/connect/oauth2'),
140156
qs: {oauth: 5},
@@ -143,13 +159,22 @@ describe('handler', () => {
143159
t.deepEqual(response, {error: 'Grant: missing or misconfigured provider'})
144160
})
145161

146-
it('/connect - missing provider', async () => {
147-
t.equal(config.defaults.dynamic, undefined)
162+
it('/connect - authorize error', async () => {
148163
var {body: {response}} = await request({
149-
url: client.url('/connect/oauth5'),
164+
url: client.url('/connect/oauth2'),
165+
qs: {authorize_url: provider.url('/authorize_error_message')},
150166
cookie: {},
151167
})
152-
t.deepEqual(response, {error: 'Grant: missing or misconfigured provider'})
168+
t.deepEqual(response, {error: {message: 'invalid'}})
169+
})
170+
171+
it('/connect - access error', async () => {
172+
var {body: {response}} = await request({
173+
url: client.url('/connect/oauth2'),
174+
qs: {access_url: provider.url('/access_error_status')},
175+
cookie: {},
176+
})
177+
t.deepEqual(response, {error: {invalid: 'access_url'}})
153178
})
154179

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

0 commit comments

Comments
 (0)