package auth_test import ( "encoding/json" "net/http" "net/http/httptest" "testing" "github.com/mathiasbq/hyperguild/ingestion/internal/auth" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestProtectedResourceHandler(t *testing.T) { h := auth.ProtectedResourceHandler("https://brain-mcp.d-ma.be", "https://auth.d-ma.be") req := httptest.NewRequest(http.MethodGet, "/.well-known/oauth-protected-resource", nil) rr := httptest.NewRecorder() h(rr, req) assert.Equal(t, http.StatusOK, rr.Code) assert.Equal(t, "application/json", rr.Header().Get("Content-Type")) var body map[string]any require.NoError(t, json.Unmarshal(rr.Body.Bytes(), &body)) assert.Equal(t, "https://brain-mcp.d-ma.be", body["resource"]) servers := body["authorization_servers"].([]any) assert.Equal(t, "https://auth.d-ma.be", servers[0]) }