MCPcopy Index your code
hub / github.com/github/github-mcp-server / TestBuildResourceMetadataURL

Function TestBuildResourceMetadataURL

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

Source from the content-addressed store, hash-verified

258}
259
260func TestBuildResourceMetadataURL(t *testing.T) {
261 t.Parallel()
262
263 tests := []struct {
264 name string
265 cfg *Config
266 setupRequest func() *http.Request
267 resourcePath string
268 expectedURL string
269 }{
270 {
271 name: "root path",
272 cfg: &Config{},
273 setupRequest: func() *http.Request {
274 req := httptest.NewRequest(http.MethodGet, "/", nil)
275 req.Host = "api.example.com"
276 return req
277 },
278 resourcePath: "/",
279 expectedURL: "http://api.example.com/.well-known/oauth-protected-resource",
280 },
281 {
282 name: "resource path preserves trailing slash",
283 cfg: &Config{},
284 setupRequest: func() *http.Request {
285 req := httptest.NewRequest(http.MethodGet, "/mcp/", nil)
286 req.Host = "api.example.com"
287 return req
288 },
289 resourcePath: "/mcp/",
290 expectedURL: "http://api.example.com/.well-known/oauth-protected-resource/mcp/",
291 },
292 {
293 name: "with custom resource path",
294 cfg: &Config{},
295 setupRequest: func() *http.Request {
296 req := httptest.NewRequest(http.MethodGet, "/mcp", nil)
297 req.Host = "api.example.com"
298 return req
299 },
300 resourcePath: "/mcp",
301 expectedURL: "http://api.example.com/.well-known/oauth-protected-resource/mcp",
302 },
303 {
304 name: "with base URL config",
305 cfg: &Config{
306 BaseURL: "https://custom.example.com",
307 },
308 setupRequest: func() *http.Request {
309 req := httptest.NewRequest(http.MethodGet, "/mcp", nil)
310 req.Host = "api.example.com"
311 return req
312 },
313 resourcePath: "/mcp",
314 expectedURL: "https://custom.example.com/.well-known/oauth-protected-resource/mcp",
315 },
316 {
317 name: "with forwarded headers ignored by default",

Callers

nothing calls this directly

Calls 1

BuildResourceMetadataURLFunction · 0.85

Tested by

no test coverage detected