MCPcopy Create free account
hub / github.com/coder/aibridge / TestCopilot_InjectAuthHeader

Function TestCopilot_InjectAuthHeader

provider/copilot_test.go:55–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestCopilot_InjectAuthHeader(t *testing.T) {
56 t.Parallel()
57
58 // Copilot uses per-user key passed in the Authorization header,
59 // so InjectAuthHeader should not modify any headers.
60 provider := NewCopilot(config.Copilot{})
61
62 t.Run("ExistingHeaders_Unchanged", func(t *testing.T) {
63 t.Parallel()
64
65 headers := http.Header{}
66 headers.Set("Authorization", "Bearer user-token")
67 headers.Set("X-Custom-Header", "custom-value")
68
69 provider.InjectAuthHeader(&headers)
70
71 assert.Equal(t, "Bearer user-token", headers.Get("Authorization"),
72 "Authorization header should remain unchanged")
73 assert.Equal(t, "custom-value", headers.Get("X-Custom-Header"),
74 "other headers should remain unchanged")
75 })
76
77 t.Run("EmptyHeaders_NoneAdded", func(t *testing.T) {
78 t.Parallel()
79
80 headers := http.Header{}
81
82 provider.InjectAuthHeader(&headers)
83
84 assert.Empty(t, headers, "no headers should be added")
85 })
86}
87
88func TestCopilot_CreateInterceptor(t *testing.T) {
89 t.Parallel()

Callers

nothing calls this directly

Calls 3

InjectAuthHeaderMethod · 0.95
NewCopilotFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected