(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestExtractBearerToken(t *testing.T) { |
| 12 | t.Parallel() |
| 13 | |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | input string |
| 17 | expected string |
| 18 | }{ |
| 19 | { |
| 20 | name: "Empty", |
| 21 | input: "", |
| 22 | expected: "", |
| 23 | }, |
| 24 | { |
| 25 | name: "Whitespace", |
| 26 | input: " ", |
| 27 | expected: "", |
| 28 | }, |
| 29 | { |
| 30 | name: "InvalidFormat", |
| 31 | input: "some-token", |
| 32 | expected: "", |
| 33 | }, |
| 34 | { |
| 35 | name: "BearerOnly", |
| 36 | input: "Bearer", |
| 37 | expected: "", |
| 38 | }, |
| 39 | { |
| 40 | name: "Valid", |
| 41 | input: "Bearer my-secret-token", |
| 42 | expected: "my-secret-token", |
| 43 | }, |
| 44 | { |
| 45 | name: "BearerMixedCase", |
| 46 | input: "BeArEr my-secret-token", |
| 47 | expected: "my-secret-token", |
| 48 | }, |
| 49 | { |
| 50 | name: "LeadingWhitespace", |
| 51 | input: " Bearer my-secret-token", |
| 52 | expected: "my-secret-token", |
| 53 | }, |
| 54 | { |
| 55 | name: "TrailingWhitespace", |
| 56 | input: "Bearer my-secret-token ", |
| 57 | expected: "my-secret-token", |
| 58 | }, |
| 59 | { |
| 60 | name: "TooManyParts", |
| 61 | input: "Bearer token extra", |
| 62 | expected: "", |
| 63 | }, |
| 64 | } |
| 65 | |
| 66 | for _, tt := range tests { |
| 67 | t.Run(tt.name, func(t *testing.T) { |
| 68 | t.Parallel() |
nothing calls this directly
no test coverage detected