MCPcopy Create free account
hub / github.com/coder/coder / TestExtractBearerToken

Function TestExtractBearerToken

aibridge/utils/auth_test.go:11–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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()

Callers

nothing calls this directly

Calls 3

ExtractBearerTokenFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected