Skip to content

Commit a2f9831

Browse files
authored
test: run tests in parallel (#1009)
1 parent a2c0f38 commit a2f9831

17 files changed

+333
-85
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ linters:
2929
- nolintlint
3030
- canonicalheader
3131

32-
# deprecated
33-
- exportloopref
34-
3532
issues:
3633
exclude-rules:
3734
- path: _test\.go

authorization_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ var AuthTestData = []AuthorizationTestData{
167167
}
168168

169169
func TestAuthorizeMultipleAuthorizationHeader(t *testing.T) {
170+
t.Parallel()
171+
170172
for _, testdata := range AuthTestData {
171173
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
172174
r.Header.Add("Authorization", testdata.validEmpty)
@@ -181,6 +183,8 @@ func TestAuthorizeMultipleAuthorizationHeader(t *testing.T) {
181183
}
182184

183185
func TestAuthorizeAuthorizationHeaderTooShort(t *testing.T) {
186+
t.Parallel()
187+
184188
for _, testdata := range AuthTestData {
185189
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
186190
r.Header.Add("Authorization", "Bearer x")
@@ -194,6 +198,8 @@ func TestAuthorizeAuthorizationHeaderTooShort(t *testing.T) {
194198
}
195199

196200
func TestAuthorizeAuthorizationHeaderNoBearer(t *testing.T) {
201+
t.Parallel()
202+
197203
for _, testdata := range AuthTestData {
198204
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
199205
r.Header.Add("Authorization", "Greater "+testdata.validEmpty)
@@ -207,6 +213,8 @@ func TestAuthorizeAuthorizationHeaderNoBearer(t *testing.T) {
207213
}
208214

209215
func TestAuthorizeAuthorizationHeaderInvalidAlg(t *testing.T) {
216+
t.Parallel()
217+
210218
for _, testdata := range AuthTestData {
211219
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
212220
r.Header.Add("Authorization", bearerPrefix+createDummyNoneSignedJWT())
@@ -221,6 +229,8 @@ func TestAuthorizeAuthorizationHeaderInvalidAlg(t *testing.T) {
221229
}
222230

223231
func TestAuthorizeAuthorizationHeaderInvalidKey(t *testing.T) {
232+
t.Parallel()
233+
224234
for _, testdata := range AuthTestData {
225235
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
226236
r.Header.Add("Authorization", bearerPrefix+testdata.validEmpty)
@@ -235,6 +245,8 @@ func TestAuthorizeAuthorizationHeaderInvalidKey(t *testing.T) {
235245
}
236246

237247
func TestAuthorizeAuthorizationHeaderInvalidSignature(t *testing.T) {
248+
t.Parallel()
249+
238250
for _, testdata := range AuthTestData {
239251
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
240252
r.Header.Add("Authorization", bearerPrefix+testdata.validEmpty[:len(testdata.validEmpty)-8]+"12345678")
@@ -249,6 +261,8 @@ func TestAuthorizeAuthorizationHeaderInvalidSignature(t *testing.T) {
249261
}
250262

251263
func TestAuthorizeAuthorizationHeaderNoContent(t *testing.T) {
264+
t.Parallel()
265+
252266
for _, testdata := range AuthTestData {
253267
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
254268
r.Header.Add("Authorization", bearerPrefix+testdata.validEmpty)
@@ -263,6 +277,8 @@ func TestAuthorizeAuthorizationHeaderNoContent(t *testing.T) {
263277
}
264278

265279
func TestAuthorizeAuthorizationHeader(t *testing.T) {
280+
t.Parallel()
281+
266282
for _, testdata := range AuthTestData {
267283
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
268284
r.Header.Add("Authorization", bearerPrefix+testdata.valid)
@@ -277,6 +293,8 @@ func TestAuthorizeAuthorizationHeader(t *testing.T) {
277293
}
278294

279295
func TestAuthorizeAuthorizationHeaderWithCert(t *testing.T) {
296+
t.Parallel()
297+
280298
for _, testdata := range AuthTestData {
281299
if testdata.validForCert != "" {
282300
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
@@ -293,6 +311,8 @@ func TestAuthorizeAuthorizationHeaderWithCert(t *testing.T) {
293311
}
294312

295313
func TestAuthorizeAuthorizationHeaderNamespaced(t *testing.T) {
314+
t.Parallel()
315+
296316
for _, testdata := range AuthTestData {
297317
if testdata.validNamespaced != "" {
298318
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
@@ -309,6 +329,8 @@ func TestAuthorizeAuthorizationHeaderNamespaced(t *testing.T) {
309329
}
310330

311331
func TestAuthorizeAuthorizationHeaderWrongAlgorithm(t *testing.T) {
332+
t.Parallel()
333+
312334
for idx, testdata := range AuthTestData {
313335
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
314336
r.Header.Add("Authorization", bearerPrefix+testdata.valid)
@@ -324,6 +346,8 @@ func TestAuthorizeAuthorizationHeaderWrongAlgorithm(t *testing.T) {
324346
}
325347

326348
func TestAuthorizeAuthorizationQueryTooShort(t *testing.T) {
349+
t.Parallel()
350+
327351
for _, testdata := range AuthTestData {
328352
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
329353
query := r.URL.Query()
@@ -339,6 +363,8 @@ func TestAuthorizeAuthorizationQueryTooShort(t *testing.T) {
339363
}
340364

341365
func TestAuthorizeAuthorizationQueryInvalidAlg(t *testing.T) {
366+
t.Parallel()
367+
342368
for _, testdata := range AuthTestData {
343369
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
344370
query := r.URL.Query()
@@ -355,6 +381,8 @@ func TestAuthorizeAuthorizationQueryInvalidAlg(t *testing.T) {
355381
}
356382

357383
func TestAuthorizeAuthorizationQueryInvalidKey(t *testing.T) {
384+
t.Parallel()
385+
358386
for _, testdata := range AuthTestData {
359387
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
360388
query := r.URL.Query()
@@ -371,6 +399,8 @@ func TestAuthorizeAuthorizationQueryInvalidKey(t *testing.T) {
371399
}
372400

373401
func TestAuthorizeAuthorizationQueryInvalidSignature(t *testing.T) {
402+
t.Parallel()
403+
374404
for _, testdata := range AuthTestData {
375405
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
376406
query := r.URL.Query()
@@ -387,6 +417,8 @@ func TestAuthorizeAuthorizationQueryInvalidSignature(t *testing.T) {
387417
}
388418

389419
func TestAuthorizeAuthorizationQueryNoContent(t *testing.T) {
420+
t.Parallel()
421+
390422
for _, testdata := range AuthTestData {
391423
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
392424
query := r.URL.Query()
@@ -403,6 +435,8 @@ func TestAuthorizeAuthorizationQueryNoContent(t *testing.T) {
403435
}
404436

405437
func TestAuthorizeAuthorizationQuery(t *testing.T) {
438+
t.Parallel()
439+
406440
for _, testdata := range AuthTestData {
407441
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
408442
query := r.URL.Query()
@@ -419,6 +453,8 @@ func TestAuthorizeAuthorizationQuery(t *testing.T) {
419453
}
420454

421455
func TestAuthorizeAuthorizationQueryNamespaced(t *testing.T) {
456+
t.Parallel()
457+
422458
for _, testdata := range AuthTestData {
423459
if testdata.validNamespaced != "" {
424460
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
@@ -437,6 +473,8 @@ func TestAuthorizeAuthorizationQueryNamespaced(t *testing.T) {
437473
}
438474

439475
func TestAuthorizeAuthorizationQueryRsaWithCert(t *testing.T) {
476+
t.Parallel()
477+
440478
for _, testdata := range AuthTestData {
441479
if testdata.validForCert != "" {
442480
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
@@ -455,6 +493,8 @@ func TestAuthorizeAuthorizationQueryRsaWithCert(t *testing.T) {
455493
}
456494

457495
func TestAuthorizeAuthorizationQueryWrongAlgorithm(t *testing.T) {
496+
t.Parallel()
497+
458498
for idx, testdata := range AuthTestData {
459499
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
460500
query := r.URL.Query()
@@ -472,6 +512,8 @@ func TestAuthorizeAuthorizationQueryWrongAlgorithm(t *testing.T) {
472512
}
473513

474514
func TestAuthorizeCookieInvalidAlg(t *testing.T) {
515+
t.Parallel()
516+
475517
for _, testdata := range AuthTestData {
476518
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
477519
r.AddCookie(&http.Cookie{Name: defaultCookieName, Value: createDummyNoneSignedJWT()})
@@ -485,6 +527,8 @@ func TestAuthorizeCookieInvalidAlg(t *testing.T) {
485527
}
486528

487529
func TestAuthorizeCookieInvalidKey(t *testing.T) {
530+
t.Parallel()
531+
488532
for _, testdata := range AuthTestData {
489533
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
490534
r.AddCookie(&http.Cookie{Name: defaultCookieName, Value: testdata.validEmpty})
@@ -499,6 +543,8 @@ func TestAuthorizeCookieInvalidKey(t *testing.T) {
499543
}
500544

501545
func TestAuthorizeCookieInvalidSignature(t *testing.T) {
546+
t.Parallel()
547+
502548
for _, testdata := range AuthTestData {
503549
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
504550
r.AddCookie(&http.Cookie{Name: defaultCookieName, Value: testdata.validEmpty[:len(testdata.validEmpty)-8] + "12345678"})
@@ -513,6 +559,8 @@ func TestAuthorizeCookieInvalidSignature(t *testing.T) {
513559
}
514560

515561
func TestAuthorizeCookieNoContent(t *testing.T) {
562+
t.Parallel()
563+
516564
for _, testdata := range AuthTestData {
517565
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
518566
r.AddCookie(&http.Cookie{Name: defaultCookieName, Value: testdata.validEmpty})
@@ -527,6 +575,8 @@ func TestAuthorizeCookieNoContent(t *testing.T) {
527575
}
528576

529577
func TestAuthorizeCookie(t *testing.T) {
578+
t.Parallel()
579+
530580
for _, testdata := range AuthTestData {
531581
r, _ := http.NewRequest(http.MethodGet, defaultHubURL, nil)
532582
r.AddCookie(&http.Cookie{Name: defaultCookieName, Value: testdata.valid})
@@ -541,6 +591,8 @@ func TestAuthorizeCookie(t *testing.T) {
541591
}
542592

543593
func TestAuthorizeCookieNoOriginNoReferer(t *testing.T) {
594+
t.Parallel()
595+
544596
for _, testdata := range AuthTestData {
545597
r, _ := http.NewRequest(http.MethodPost, defaultHubURL, nil)
546598
r.AddCookie(&http.Cookie{Name: defaultCookieName, Value: testdata.valid})
@@ -554,6 +606,8 @@ func TestAuthorizeCookieNoOriginNoReferer(t *testing.T) {
554606
}
555607

556608
func TestAuthorizeCookieOriginNotAllowed(t *testing.T) {
609+
t.Parallel()
610+
557611
for _, testdata := range AuthTestData {
558612
r, _ := http.NewRequest(http.MethodPost, defaultHubURL, nil)
559613
r.Header.Add("Origin", "http://example.com")
@@ -568,6 +622,8 @@ func TestAuthorizeCookieOriginNotAllowed(t *testing.T) {
568622
}
569623

570624
func TestAuthorizeCookieRefererNotAllowed(t *testing.T) {
625+
t.Parallel()
626+
571627
for _, testdata := range AuthTestData {
572628
r, _ := http.NewRequest(http.MethodPost, defaultHubURL, nil)
573629
r.Header.Add("Referer", "http://example.com/foo/bar")
@@ -582,6 +638,8 @@ func TestAuthorizeCookieRefererNotAllowed(t *testing.T) {
582638
}
583639

584640
func TestAuthorizeCookieInvalidReferer(t *testing.T) {
641+
t.Parallel()
642+
585643
for _, testdata := range AuthTestData {
586644
r, _ := http.NewRequest(http.MethodPost, defaultHubURL, nil)
587645
r.Header.Add("Referer", "http://192.168.0.%31/")
@@ -596,6 +654,8 @@ func TestAuthorizeCookieInvalidReferer(t *testing.T) {
596654
}
597655

598656
func TestAuthorizeCookieOriginHasPriority(t *testing.T) {
657+
t.Parallel()
658+
599659
for _, testdata := range AuthTestData {
600660
r, _ := http.NewRequest(http.MethodPost, defaultHubURL, nil)
601661
r.Header.Add("Origin", "http://example.net")
@@ -612,6 +672,8 @@ func TestAuthorizeCookieOriginHasPriority(t *testing.T) {
612672
}
613673

614674
func TestAuthorizeAllOriginsAllowed(t *testing.T) {
675+
t.Parallel()
676+
615677
for _, testdata := range AuthTestData {
616678
r, _ := http.NewRequest(http.MethodPost, defaultHubURL, nil)
617679
r.Header.Add("Origin", "http://example.com")
@@ -625,6 +687,8 @@ func TestAuthorizeAllOriginsAllowed(t *testing.T) {
625687
}
626688

627689
func TestAuthorizeCustomCookieName(t *testing.T) {
690+
t.Parallel()
691+
628692
for _, testdata := range AuthTestData {
629693
r, _ := http.NewRequest(http.MethodPost, defaultHubURL, nil)
630694
r.Header.Add("Origin", "http://example.com")
@@ -638,6 +702,8 @@ func TestAuthorizeCustomCookieName(t *testing.T) {
638702
}
639703

640704
func TestCanReceive(t *testing.T) {
705+
t.Parallel()
706+
641707
tss := &TopicSelectorStore{}
642708
assert.True(t, canReceive(tss, []string{"foo", "bar"}, []string{"foo", "bar"}))
643709
assert.True(t, canReceive(tss, []string{"foo", "bar"}, []string{"bar"}))
@@ -648,6 +714,8 @@ func TestCanReceive(t *testing.T) {
648714
}
649715

650716
func TestCanDispatch(t *testing.T) {
717+
t.Parallel()
718+
651719
tss := &TopicSelectorStore{}
652720
assert.True(t, canDispatch(tss, []string{"foo", "bar"}, []string{"foo", "bar"}))
653721
assert.True(t, canDispatch(tss, []string{"foo", "bar"}, []string{"*"}))

0 commit comments

Comments
 (0)