MCPcopy
hub / github.com/github/github-mcp-server / TestNewAuthHandler

Function TestNewAuthHandler

pkg/http/oauth/oauth_test.go:21–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestNewAuthHandler(t *testing.T) {
22 t.Parallel()
23
24 dotcomHost, err := utils.NewAPIHost("https://api.github.com")
25 require.NoError(t, err)
26
27 tests := []struct {
28 name string
29 cfg *Config
30 expectedAuthServer string
31 expectedResourcePath string
32 }{
33 {
34 name: "custom authorization server",
35 cfg: &Config{
36 AuthorizationServer: "https://custom.example.com/oauth",
37 },
38 expectedAuthServer: "https://custom.example.com/oauth",
39 expectedResourcePath: "",
40 },
41 {
42 name: "custom base URL and resource path",
43 cfg: &Config{
44 BaseURL: "https://example.com",
45 ResourcePath: "/mcp",
46 },
47 expectedAuthServer: "",
48 expectedResourcePath: "/mcp",
49 },
50 }
51
52 for _, tc := range tests {
53 t.Run(tc.name, func(t *testing.T) {
54 t.Parallel()
55
56 handler, err := NewAuthHandler(tc.cfg, dotcomHost)
57 require.NoError(t, err)
58 require.NotNil(t, handler)
59
60 assert.Equal(t, tc.expectedAuthServer, handler.cfg.AuthorizationServer)
61 assert.Equal(t, tc.expectedResourcePath, handler.cfg.ResourcePath)
62 })
63 }
64}
65
66func TestGetEffectiveHostAndScheme(t *testing.T) {
67 t.Parallel()

Callers

nothing calls this directly

Calls 2

NewAPIHostFunction · 0.92
NewAuthHandlerFunction · 0.85

Tested by

no test coverage detected