Skip to content

Commit 641927e

Browse files
committed
fix: use strictEqual
1 parent a70883a commit 641927e

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

test/index.test.js

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ function makeRequests (t, end, fastify, userAgentHeaderMatcher, pkce, discoveryH
4545
}
4646

4747
if (discoveryHostOptions.error) {
48-
t.assert.deepStrictEqual(err.message, 'Problem calling discovery endpoint. See innerError for details.')
49-
t.assert.deepStrictEqual(err.innerError.code, 'ETIMEDOUT')
48+
t.assert.strictEqual(err.message, 'Problem calling discovery endpoint. See innerError for details.')
49+
t.assert.strictEqual(err.innerError.code, 'ETIMEDOUT')
5050
discoveryScope?.done()
5151
end()
5252
return
5353
}
5454

5555
if (discoveryHostOptions.noToken) {
5656
// Let simple-oauth2 configuration fail instead
57-
t.assert.deepStrictEqual(err.message, 'Invalid options provided to simple-oauth2 "auth.tokenHost" is required')
57+
t.assert.strictEqual(err.message, 'Invalid options provided to simple-oauth2 "auth.tokenHost" is required')
5858
discoveryScope?.done()
5959
end()
6060
return
@@ -68,14 +68,14 @@ function makeRequests (t, end, fastify, userAgentHeaderMatcher, pkce, discoveryH
6868
}, function (err, responseStart) {
6969
t.assert.ifError(err)
7070

71-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
71+
t.assert.strictEqual(responseStart.statusCode, 302)
7272

7373
const { searchParams } = new URL(responseStart.headers.location)
7474
const [state, codeChallengeMethod, codeChallenge] = ['state', 'code_challenge_method', 'code_challenge'].map(k => searchParams.get(k))
7575

7676
t.assert.ok(state)
7777
if (pkce) {
78-
t.assert.deepStrictEqual(codeChallengeMethod, pkce, 'pkce method must match')
78+
t.assert.strictEqual(codeChallengeMethod, pkce, 'pkce method must match')
7979
t.assert.ok(codeChallenge, 'code challenge is present')
8080
}
8181

@@ -172,7 +172,7 @@ function makeRequests (t, end, fastify, userAgentHeaderMatcher, pkce, discoveryH
172172
}, function (err, responseEnd) {
173173
t.assert.ifError(err)
174174

175-
t.assert.deepStrictEqual(responseEnd.statusCode, 200)
175+
t.assert.strictEqual(responseEnd.statusCode, 200)
176176
t.assert.deepStrictEqual(JSON.parse(responseEnd.payload), RESPONSE_BODY_REFRESHED)
177177

178178
githubScope.done()
@@ -345,8 +345,8 @@ test('fastify-oauth2', async t => {
345345
}, function (err, responseEnd) {
346346
t.assert.ifError(err)
347347

348-
t.assert.deepStrictEqual(responseEnd.statusCode, 400)
349-
t.assert.deepStrictEqual(responseEnd.payload, 'Invalid state')
348+
t.assert.strictEqual(responseEnd.statusCode, 400)
349+
t.assert.strictEqual(responseEnd.payload, 'Invalid state')
350350

351351
end()
352352
})
@@ -538,7 +538,7 @@ test('fastify-oauth2', async t => {
538538
try {
539539
await this.githubOAuth2.userinfo('a try without a discovery option')
540540
} catch (error) {
541-
t.assert.deepStrictEqual(
541+
t.assert.strictEqual(
542542
error.message,
543543
'userinfo can not be used without discovery',
544544
'error signals to user that they should use discovery for this to work'
@@ -624,18 +624,18 @@ test('fastify-oauth2', async t => {
624624
try {
625625
await this.githubOAuth2.userinfo(refreshResult.token, { method: 'PUT' })
626626
} catch (error) {
627-
t.assert.deepStrictEqual(error.message, 'userinfo methods supported are only GET and POST', 'should not work for other methods')
627+
t.assert.strictEqual(error.message, 'userinfo methods supported are only GET and POST', 'should not work for other methods')
628628
}
629629

630630
try {
631631
await this.githubOAuth2.userinfo(refreshResult.token, { method: 'GET', via: 'body' })
632632
} catch (error) {
633-
t.assert.deepStrictEqual(error.message, 'body is supported only with POST', 'should report incompatible combo')
633+
t.assert.strictEqual(error.message, 'body is supported only with POST', 'should report incompatible combo')
634634
}
635635

636636
const userinfo = await this.githubOAuth2.userinfo(refreshResult.token, { params: { a: 1 } })
637637

638-
t.assert.deepStrictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
638+
t.assert.strictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
639639

640640
return { ...refreshResult.token, expires_at: undefined }
641641
})
@@ -669,7 +669,7 @@ test('fastify-oauth2', async t => {
669669
const refreshResult = await this.githubOAuth2.getNewAccessTokenUsingRefreshToken(result.token)
670670

671671
const userinfo = await this.githubOAuth2.userinfo(refreshResult.token, { method: 'POST', params: { a: 1 } })
672-
t.assert.deepStrictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
672+
t.assert.strictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
673673

674674
return { ...refreshResult.token, expires_at: undefined }
675675
})
@@ -708,7 +708,7 @@ test('fastify-oauth2', async t => {
708708
const refreshResult = await this.githubOAuth2.getNewAccessTokenUsingRefreshToken(result.token)
709709

710710
const userinfo = await this.githubOAuth2.userinfo(refreshResult.token, { method: 'POST', via: 'body', params: { a: 1 } })
711-
t.assert.deepStrictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
711+
t.assert.strictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
712712

713713
return { ...refreshResult.token, expires_at: undefined }
714714
})
@@ -749,7 +749,7 @@ test('fastify-oauth2', async t => {
749749
await new Promise((resolve) => {
750750
this.githubOAuth2.userinfo(refreshResult.token, {}, (err, userinfo) => {
751751
t.assert.ifError(err)
752-
t.assert.deepStrictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
752+
t.assert.strictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
753753
resolve()
754754
})
755755
})
@@ -787,7 +787,7 @@ test('fastify-oauth2', async t => {
787787
await new Promise((resolve) => {
788788
this.githubOAuth2.userinfo(refreshResult.token, (err, userinfo) => {
789789
t.assert.ifError(err)
790-
t.assert.deepStrictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
790+
t.assert.strictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
791791
resolve()
792792
})
793793
})
@@ -825,7 +825,7 @@ test('fastify-oauth2', async t => {
825825
await new Promise((resolve) => {
826826
this.githubOAuth2.userinfo(refreshResult.token, {}, (err, userinfo) => {
827827
t.assert.ifError(err)
828-
t.assert.deepStrictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
828+
t.assert.strictEqual(userinfo.sub, 'github.subjectid', 'should match an id')
829829
resolve()
830830
})
831831
})
@@ -862,7 +862,7 @@ test('fastify-oauth2', async t => {
862862
const refreshResult = await this.githubOAuth2.getNewAccessTokenUsingRefreshToken(result.token)
863863
await new Promise((resolve) => {
864864
this.githubOAuth2.userinfo(123456789, (err) => {
865-
t.assert.deepStrictEqual(err.message,
865+
t.assert.strictEqual(err.message,
866866
'you should provide token object containing access_token or access_token as string directly',
867867
'should match error message')
868868
resolve()
@@ -901,7 +901,7 @@ test('fastify-oauth2', async t => {
901901
const refreshResult = await this.githubOAuth2.getNewAccessTokenUsingRefreshToken(result.token)
902902
await new Promise((resolve) => {
903903
this.githubOAuth2.userinfo({ access_token: 123456789 }, (err) => {
904-
t.assert.deepStrictEqual(err.message, 'access_token should be string', 'message for nested access token format matched')
904+
t.assert.strictEqual(err.message, 'access_token should be string', 'message for nested access token format matched')
905905
resolve()
906906
})
907907
})
@@ -939,7 +939,7 @@ test('fastify-oauth2', async t => {
939939
const refreshResult = await this.githubOAuth2.getNewAccessTokenUsingRefreshToken(result.token)
940940
await new Promise((resolve) => {
941941
this.githubOAuth2.userinfo(refreshResult.token.access_token, (err) => {
942-
t.assert.deepStrictEqual(err.message,
942+
t.assert.strictEqual(err.message,
943943
'Problem calling userinfo endpoint. See innerError for details.',
944944
'should match start of the error message'
945945
)
@@ -1564,7 +1564,7 @@ test('options.callbackUriParams', (t, end) => {
15641564
}, function (err, responseStart) {
15651565
t.assert.ifError(err)
15661566

1567-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
1567+
t.assert.strictEqual(responseStart.statusCode, 302)
15681568
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&access_type=offline&redirect_uri=%2Fcallback&scope=notifications&state=(.*)/)
15691569
t.assert.ok(matched)
15701570
end()
@@ -1684,7 +1684,7 @@ test('generateAuthorizationUri redirect with request object', (t, end) => {
16841684
query: { code: 'generated_code' }
16851685
}, function (err, responseStart) {
16861686
t.assert.ifError(err)
1687-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
1687+
t.assert.strictEqual(responseStart.statusCode, 302)
16881688
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=notifications&state=generated_code/)
16891689
t.assert.ok(matched)
16901690
end()
@@ -1730,7 +1730,7 @@ test('generateAuthorizationUri redirect with request object and callback', (t, e
17301730
query: { code: 'generated_code' }
17311731
}, function (err, responseStart) {
17321732
t.assert.ifError(err)
1733-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
1733+
t.assert.strictEqual(responseStart.statusCode, 302)
17341734
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=notifications&state=generated_code/)
17351735
t.assert.ok(matched)
17361736
end()
@@ -2045,7 +2045,7 @@ test('preset configuration generate-callback-uri-params', async t => {
20452045
}, function (err, responseStart) {
20462046
t.assert.ifError(err)
20472047

2048-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2048+
t.assert.strictEqual(responseStart.statusCode, 302)
20492049
const matched = responseStart.headers.location.match(/https:\/\/appleid\.apple\.com\/auth\/authorize\?response_type=code&client_id=my-client-id&response_mode=form_post&redirect_uri=%2Fcallback&scope=email&state=(.*)/)
20502050
t.assert.ok(matched)
20512051
end()
@@ -2084,7 +2084,7 @@ test('preset configuration generate-callback-uri-params', async t => {
20842084
}, function (err, responseStart) {
20852085
t.assert.ifError(err)
20862086

2087-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2087+
t.assert.strictEqual(responseStart.statusCode, 302)
20882088
const matched = responseStart.headers.location.match(/https:\/\/appleid\.apple\.com\/auth\/authorize\?response_type=code&client_id=my-client-id&response_mode=form_post&redirect_uri=%2Fcallback&scope=name&state=(.*)/)
20892089
t.assert.ok(matched)
20902090
end()
@@ -2123,7 +2123,7 @@ test('preset configuration generate-callback-uri-params', async t => {
21232123
}, function (err, responseStart) {
21242124
t.assert.ifError(err)
21252125

2126-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2126+
t.assert.strictEqual(responseStart.statusCode, 302)
21272127
const matched = responseStart.headers.location.match(/https:\/\/appleid\.apple\.com\/auth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=&state=(.*)/)
21282128
t.assert.ok(matched)
21292129
end()
@@ -2154,9 +2154,9 @@ test('preset configuration generate-callback-uri-params', t => {
21542154

21552155
for (const configName of presetConfigs) {
21562156
t.assert.ok(fastifyOauth2[configName])
2157-
t.assert.deepStrictEqual(typeof fastifyOauth2[configName].tokenHost, 'string')
2158-
t.assert.deepStrictEqual(typeof fastifyOauth2[configName].tokenPath, 'string')
2159-
t.assert.deepStrictEqual(typeof fastifyOauth2[configName].authorizePath, 'string')
2157+
t.assert.strictEqual(typeof fastifyOauth2[configName].tokenHost, 'string')
2158+
t.assert.strictEqual(typeof fastifyOauth2[configName].tokenPath, 'string')
2159+
t.assert.strictEqual(typeof fastifyOauth2[configName].authorizePath, 'string')
21602160
}
21612161
})
21622162

@@ -2202,7 +2202,7 @@ test('revoke token for gitlab with callback', (t, end) => {
22022202
url: '/'
22032203
}, function (err, responseStart) {
22042204
t.assert.ifError(err, 'No error should be thrown')
2205-
t.assert.deepStrictEqual(responseStart.statusCode, 200)
2205+
t.assert.strictEqual(responseStart.statusCode, 200)
22062206
gitlabRevoke.done()
22072207

22082208
end()
@@ -2253,7 +2253,7 @@ test('revoke token for gitlab promisify', (t, end) => {
22532253
url: '/'
22542254
}, function (err, responseStart) {
22552255
t.assert.ifError(err, 'No error should be thrown')
2256-
t.assert.deepStrictEqual(responseStart.statusCode, 200)
2256+
t.assert.strictEqual(responseStart.statusCode, 200)
22572257
gitlabRevoke.done()
22582258

22592259
end()
@@ -2307,7 +2307,7 @@ test('revoke all token for gitlab promisify', (t, end) => {
23072307
url: '/'
23082308
}, function (err, responseStart) {
23092309
t.assert.ifError(err, 'No error should be thrown')
2310-
t.assert.deepStrictEqual(responseStart.statusCode, 200)
2310+
t.assert.strictEqual(responseStart.statusCode, 200)
23112311
gitlabRevoke.done()
23122312

23132313
end()
@@ -2360,7 +2360,7 @@ test('revoke all token for linkedin callback', (t, end) => {
23602360
url: '/'
23612361
}, function (err, responseStart) {
23622362
t.assert.ifError(err, 'No error should be thrown')
2363-
t.assert.deepStrictEqual(responseStart.statusCode, 200)
2363+
t.assert.strictEqual(responseStart.statusCode, 200)
23642364
gitlabRevoke.done()
23652365

23662366
end()
@@ -2403,7 +2403,7 @@ test('options.generateStateFunction', async t => {
24032403
query: { code: 'generated_code' }
24042404
}, function (err, responseStart) {
24052405
t.assert.ifError(err)
2406-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2406+
t.assert.strictEqual(responseStart.statusCode, 302)
24072407
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=notifications&state=generated_code/)
24082408
t.assert.ok(matched)
24092409
end()
@@ -2474,7 +2474,7 @@ test('options.generateStateFunction', async t => {
24742474
headers: { foo: 'foo' }
24752475
}, function (err, responseStart) {
24762476
t.assert.ifError(err)
2477-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2477+
t.assert.strictEqual(responseStart.statusCode, 302)
24782478
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=notifications&state=1e864fbd840212c1ed9ce60175d373f3a48681b2/)
24792479
t.assert.ok(matched)
24802480
end()
@@ -2496,7 +2496,7 @@ test('options.generateStateFunction', async t => {
24962496
},
24972497
callbackUri: '/callback',
24982498
generateStateFunction: function (request) {
2499-
t.assert.deepStrictEqual(this, fastify)
2499+
t.assert.strictEqual(this, fastify)
25002500
return request.query.code
25012501
},
25022502
checkStateFunction: () => true,
@@ -2516,7 +2516,7 @@ test('options.generateStateFunction', async t => {
25162516
query: { code: 'generated_code' }
25172517
}, function (err, responseStart) {
25182518
t.assert.ifError(err)
2519-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2519+
t.assert.strictEqual(responseStart.statusCode, 302)
25202520
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=notifications&state=generated_code/)
25212521
t.assert.ok(matched)
25222522
end()
@@ -2556,7 +2556,7 @@ test('options.generateStateFunction', async t => {
25562556
query: { code: 'generated_code' }
25572557
}, function (err, responseStart) {
25582558
t.assert.ifError(err)
2559-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2559+
t.assert.strictEqual(responseStart.statusCode, 302)
25602560
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=notifications&state=generated_code/)
25612561
t.assert.ok(matched)
25622562
end()
@@ -2596,7 +2596,7 @@ test('options.generateStateFunction', async t => {
25962596
query: { code: 'generated_code' }
25972597
}, function (err, responseStart) {
25982598
t.assert.ifError(err)
2599-
t.assert.deepStrictEqual(responseStart.statusCode, 302)
2599+
t.assert.strictEqual(responseStart.statusCode, 302)
26002600
const matched = responseStart.headers.location.match(/https:\/\/github\.com\/login\/oauth\/authorize\?response_type=code&client_id=my-client-id&redirect_uri=%2Fcallback&scope=notifications&state=generated_code/)
26012601
t.assert.ok(matched)
26022602
end()
@@ -2638,8 +2638,8 @@ test('options.generateStateFunction', async t => {
26382638
query: { code: 'generated_code' }
26392639
}, function (err, responseStart) {
26402640
t.assert.ifError(err)
2641-
t.assert.deepStrictEqual(responseStart.statusCode, 500)
2642-
t.assert.deepStrictEqual(responseStart.body, 'generate state failed')
2641+
t.assert.strictEqual(responseStart.statusCode, 500)
2642+
t.assert.strictEqual(responseStart.body, 'generate state failed')
26432643
end()
26442644
})
26452645
})
@@ -2673,8 +2673,8 @@ test('options.generateStateFunction', async t => {
26732673
query: { code: 'generated_code' }
26742674
}, function (err, responseStart) {
26752675
t.assert.ifError(err)
2676-
t.assert.deepStrictEqual(responseStart.statusCode, 500)
2677-
t.assert.deepStrictEqual(responseStart.body, 'generate state failed')
2676+
t.assert.strictEqual(responseStart.statusCode, 500)
2677+
t.assert.strictEqual(responseStart.body, 'generate state failed')
26782678
end()
26792679
})
26802680
})
@@ -2720,7 +2720,7 @@ test('options.checkStateFunction', async t => {
27202720
return request.query.code
27212721
},
27222722
checkStateFunction: function () {
2723-
t.assert.deepStrictEqual(this, fastify)
2723+
t.assert.strictEqual(this, fastify)
27242724
return true
27252725
},
27262726
scope: ['notifications']
@@ -2874,8 +2874,8 @@ test('options.checkStateFunction', async t => {
28742874
}, function (err, responseEnd) {
28752875
t.assert.ifError(err)
28762876

2877-
t.assert.deepStrictEqual(responseEnd.statusCode, 400)
2878-
t.assert.deepStrictEqual(responseEnd.payload, 'Invalid state')
2877+
t.assert.strictEqual(responseEnd.statusCode, 400)
2878+
t.assert.strictEqual(responseEnd.payload, 'Invalid state')
28792879

28802880
end()
28812881
})
@@ -2921,8 +2921,8 @@ test('options.checkStateFunction', async t => {
29212921
}, function (err, responseEnd) {
29222922
t.assert.ifError(err)
29232923

2924-
t.assert.deepStrictEqual(responseEnd.statusCode, 400)
2925-
t.assert.deepStrictEqual(responseEnd.payload, 'state is invalid')
2924+
t.assert.strictEqual(responseEnd.statusCode, 400)
2925+
t.assert.strictEqual(responseEnd.payload, 'state is invalid')
29262926

29272927
end()
29282928
})
@@ -2984,8 +2984,8 @@ test('options.redirectStateCookieName', async (t) => {
29842984
function (err, responseEnd) {
29852985
t.assert.ifError(err)
29862986

2987-
t.assert.deepStrictEqual(responseEnd.statusCode, 302)
2988-
t.assert.deepStrictEqual(responseEnd.cookies[0].name, 'custom-redirect-state')
2987+
t.assert.strictEqual(responseEnd.statusCode, 302)
2988+
t.assert.strictEqual(responseEnd.cookies[0].name, 'custom-redirect-state')
29892989
t.assert.ok(typeof responseEnd.cookies[0].value === 'string')
29902990

29912991
end()
@@ -3048,8 +3048,8 @@ test('options.verifierCookieName', async (t) => {
30483048
function (err, responseEnd) {
30493049
t.assert.ifError(err)
30503050

3051-
t.assert.deepStrictEqual(responseEnd.statusCode, 302)
3052-
t.assert.deepStrictEqual(responseEnd.cookies[1].name, 'custom-verifier')
3051+
t.assert.strictEqual(responseEnd.statusCode, 302)
3052+
t.assert.strictEqual(responseEnd.cookies[1].name, 'custom-verifier')
30533053
t.assert.ok(typeof responseEnd.cookies[1].value === 'string')
30543054

30553055
end()

0 commit comments

Comments
 (0)