@@ -20,6 +20,8 @@ import (
20
20
)
21
21
22
22
// TestOAuth2BearerTokenSecurityBoundaries tests RFC 6750 security boundaries
23
+ //
24
+ //nolint:tparallel,paralleltest // Subtests share a DB; run sequentially to avoid Windows DB cleanup flake.
23
25
func TestOAuth2BearerTokenSecurityBoundaries (t * testing.T ) {
24
26
t .Parallel ()
25
27
@@ -41,8 +43,6 @@ func TestOAuth2BearerTokenSecurityBoundaries(t *testing.T) {
41
43
})
42
44
43
45
t .Run ("TokenIsolation" , func (t * testing.T ) {
44
- t .Parallel ()
45
-
46
46
// Create middleware
47
47
middleware := httpmw .ExtractAPIKeyMW (httpmw.ExtractAPIKeyConfig {
48
48
DB : db ,
@@ -78,8 +78,6 @@ func TestOAuth2BearerTokenSecurityBoundaries(t *testing.T) {
78
78
})
79
79
80
80
t .Run ("CrossTokenAttempts" , func (t * testing.T ) {
81
- t .Parallel ()
82
-
83
81
middleware := httpmw .ExtractAPIKeyMW (httpmw.ExtractAPIKeyConfig {
84
82
DB : db ,
85
83
})
@@ -101,8 +99,6 @@ func TestOAuth2BearerTokenSecurityBoundaries(t *testing.T) {
101
99
})
102
100
103
101
t .Run ("TimingAttackResistance" , func (t * testing.T ) {
104
- t .Parallel ()
105
-
106
102
middleware := httpmw .ExtractAPIKeyMW (httpmw.ExtractAPIKeyConfig {
107
103
DB : db ,
108
104
})
@@ -150,6 +146,8 @@ func TestOAuth2BearerTokenSecurityBoundaries(t *testing.T) {
150
146
}
151
147
152
148
// TestOAuth2BearerTokenMalformedHeaders tests handling of malformed Bearer headers per RFC 6750
149
+ //
150
+ //nolint:tparallel,paralleltest // Subtests share a DB; run sequentially to avoid Windows DB cleanup flake.
153
151
func TestOAuth2BearerTokenMalformedHeaders (t * testing.T ) {
154
152
t .Parallel ()
155
153
@@ -215,8 +213,6 @@ func TestOAuth2BearerTokenMalformedHeaders(t *testing.T) {
215
213
216
214
for _ , test := range tests {
217
215
t .Run (test .name , func (t * testing.T ) {
218
- t .Parallel ()
219
-
220
216
req := httptest .NewRequest ("GET" , "/test" , nil )
221
217
req .Header .Set ("Authorization" , test .authHeader )
222
218
rec := httptest .NewRecorder ()
@@ -234,6 +230,8 @@ func TestOAuth2BearerTokenMalformedHeaders(t *testing.T) {
234
230
}
235
231
236
232
// TestOAuth2BearerTokenPrecedence tests token extraction precedence per RFC 6750
233
+ //
234
+ //nolint:tparallel,paralleltest // Subtests share a DB; run sequentially to avoid Windows DB cleanup flake.
237
235
func TestOAuth2BearerTokenPrecedence (t * testing.T ) {
238
236
t .Parallel ()
239
237
@@ -257,8 +255,6 @@ func TestOAuth2BearerTokenPrecedence(t *testing.T) {
257
255
}))
258
256
259
257
t .Run ("CookieTakesPrecedenceOverBearer" , func (t * testing.T ) {
260
- t .Parallel ()
261
-
262
258
req := httptest .NewRequest ("GET" , "/test" , nil )
263
259
// Set both cookie and Bearer header - cookie should take precedence
264
260
req .AddCookie (& http.Cookie {
@@ -274,8 +270,6 @@ func TestOAuth2BearerTokenPrecedence(t *testing.T) {
274
270
})
275
271
276
272
t .Run ("QueryParameterTakesPrecedenceOverBearer" , func (t * testing.T ) {
277
- t .Parallel ()
278
-
279
273
// Set both query parameter and Bearer header - query should take precedence
280
274
u , _ := url .Parse ("/test" )
281
275
q := u .Query ()
@@ -292,8 +286,6 @@ func TestOAuth2BearerTokenPrecedence(t *testing.T) {
292
286
})
293
287
294
288
t .Run ("BearerHeaderFallback" , func (t * testing.T ) {
295
- t .Parallel ()
296
-
297
289
// Only set Bearer header - should be used as fallback
298
290
req := httptest .NewRequest ("GET" , "/test" , nil )
299
291
req .Header .Set ("Authorization" , "Bearer " + validToken )
@@ -305,8 +297,6 @@ func TestOAuth2BearerTokenPrecedence(t *testing.T) {
305
297
})
306
298
307
299
t .Run ("AccessTokenQueryParameterFallback" , func (t * testing.T ) {
308
- t .Parallel ()
309
-
310
300
// Only set access_token query parameter - should be used as fallback
311
301
u , _ := url .Parse ("/test" )
312
302
q := u .Query ()
@@ -322,8 +312,6 @@ func TestOAuth2BearerTokenPrecedence(t *testing.T) {
322
312
})
323
313
324
314
t .Run ("MultipleAuthMethodsShouldNotConflict" , func (t * testing.T ) {
325
- t .Parallel ()
326
-
327
315
// RFC 6750 says clients shouldn't send tokens in multiple ways,
328
316
// but if they do, we should handle it gracefully by using precedence
329
317
u , _ := url .Parse ("/test" )
@@ -348,6 +336,8 @@ func TestOAuth2BearerTokenPrecedence(t *testing.T) {
348
336
}
349
337
350
338
// TestOAuth2WWWAuthenticateCompliance tests WWW-Authenticate header compliance with RFC 6750
339
+ //
340
+ //nolint:tparallel,paralleltest // Subtests share a DB; run sequentially to avoid Windows DB cleanup flake.
351
341
func TestOAuth2WWWAuthenticateCompliance (t * testing.T ) {
352
342
t .Parallel ()
353
343
@@ -363,8 +353,6 @@ func TestOAuth2WWWAuthenticateCompliance(t *testing.T) {
363
353
}))
364
354
365
355
t .Run ("UnauthorizedResponse" , func (t * testing.T ) {
366
- t .Parallel ()
367
-
368
356
req := httptest .NewRequest ("GET" , "/test" , nil )
369
357
req .Header .Set ("Authorization" , "Bearer invalid-token" )
370
358
rec := httptest .NewRecorder ()
@@ -383,8 +371,6 @@ func TestOAuth2WWWAuthenticateCompliance(t *testing.T) {
383
371
})
384
372
385
373
t .Run ("ExpiredTokenResponse" , func (t * testing.T ) {
386
- t .Parallel ()
387
-
388
374
// Create an expired API key
389
375
_ , expiredToken := dbgen .APIKey (t , db , database.APIKey {
390
376
UserID : user .ID ,
@@ -406,8 +392,6 @@ func TestOAuth2WWWAuthenticateCompliance(t *testing.T) {
406
392
})
407
393
408
394
t .Run ("InsufficientScopeResponse" , func (t * testing.T ) {
409
- t .Parallel ()
410
-
411
395
// For this test, we'll test with an invalid token to trigger the middleware's
412
396
// error handling which does set WWW-Authenticate headers for 403 responses
413
397
// In practice, insufficient scope errors would be handled by RBAC middleware
0 commit comments