(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func 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 | |
| 66 | func TestGetEffectiveHostAndScheme(t *testing.T) { |
| 67 | t.Parallel() |
nothing calls this directly
no test coverage detected