|
9 | 9 |
|
10 | 10 | ghcontext "github.com/github/github-mcp-server/pkg/context" |
11 | 11 | "github.com/github/github-mcp-server/pkg/github" |
| 12 | + "github.com/github/github-mcp-server/pkg/http/oauth" |
12 | 13 | "github.com/github/github-mcp-server/pkg/inventory" |
13 | 14 | "github.com/github/github-mcp-server/pkg/utils" |
14 | 15 | "github.com/stretchr/testify/assert" |
@@ -44,6 +45,39 @@ func TestRunHTTPServerRejectsInvalidStaticTools(t *testing.T) { |
44 | 45 | } |
45 | 46 | } |
46 | 47 |
|
| 48 | +func TestNewOAuthConfig(t *testing.T) { |
| 49 | + tests := []struct { |
| 50 | + name string |
| 51 | + authorizationServer string |
| 52 | + }{ |
| 53 | + { |
| 54 | + name: "unset preserves host-derived authorization server", |
| 55 | + }, |
| 56 | + { |
| 57 | + name: "explicit override is propagated", |
| 58 | + authorizationServer: "https://oauth-proxy.example.com", |
| 59 | + }, |
| 60 | + } |
| 61 | + |
| 62 | + for _, tt := range tests { |
| 63 | + t.Run(tt.name, func(t *testing.T) { |
| 64 | + cfg := newOAuthConfig(ServerConfig{ |
| 65 | + BaseURL: "https://mcp.example.com", |
| 66 | + ResourcePath: "/mcp", |
| 67 | + TrustProxyHeaders: true, |
| 68 | + AuthorizationServer: tt.authorizationServer, |
| 69 | + }) |
| 70 | + |
| 71 | + assert.Equal(t, &oauth.Config{ |
| 72 | + BaseURL: "https://mcp.example.com", |
| 73 | + ResourcePath: "/mcp", |
| 74 | + TrustProxyHeaders: true, |
| 75 | + AuthorizationServer: tt.authorizationServer, |
| 76 | + }, cfg) |
| 77 | + }) |
| 78 | + } |
| 79 | +} |
| 80 | + |
47 | 81 | func TestInitGlobalToolScopeMapUsesHost(t *testing.T) { |
48 | 82 | tests := []struct { |
49 | 83 | name string |
|
0 commit comments