(t *testing.T)
| 665 | } |
| 666 | |
| 667 | func TestPRMEndpoint(t *testing.T) { |
| 668 | ctx, cancel := context.WithCancel(context.Background()) |
| 669 | defer cancel() |
| 670 | |
| 671 | // Setup telemetry and logging |
| 672 | otelShutdown, err := telemetry.SetupOTel(ctx, "0.0.0", "", false, "", "toolbox") |
| 673 | if err != nil { |
| 674 | t.Fatalf("unexpected error: %s", err) |
| 675 | } |
| 676 | defer func() { |
| 677 | if err := otelShutdown(ctx); err != nil { |
| 678 | t.Fatalf("unexpected error shutting down otel: %s", err) |
| 679 | } |
| 680 | }() |
| 681 | |
| 682 | testLogger, err := log.NewStdLogger(os.Stdout, os.Stderr, "info") |
| 683 | if err != nil { |
| 684 | t.Fatalf("unexpected error: %s", err) |
| 685 | } |
| 686 | ctx = util.WithLogger(ctx, testLogger) |
| 687 | |
| 688 | instrumentation, err := telemetry.CreateTelemetryInstrumentation("0.0.0") |
| 689 | if err != nil { |
| 690 | t.Fatalf("unexpected error: %s", err) |
| 691 | } |
| 692 | ctx = util.WithInstrumentation(ctx, instrumentation) |
| 693 | |
| 694 | // Create a mock OIDC server to bypass JWKS discovery during init |
| 695 | mockOIDC := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 696 | if r.URL.Path == "/.well-known/openid-configuration" { |
| 697 | w.Header().Set("Content-Type", "application/json") |
| 698 | fmt.Fprintf(w, `{"issuer": "http://%s", "jwks_uri": "http://%s/jwks"}`, r.Host, r.Host) |
| 699 | return |
| 700 | } |
| 701 | if r.URL.Path == "/jwks" { |
| 702 | w.Header().Set("Content-Type", "application/json") |
| 703 | fmt.Fprint(w, `{"keys": []}`) |
| 704 | return |
| 705 | } |
| 706 | w.WriteHeader(http.StatusNotFound) |
| 707 | })) |
| 708 | defer mockOIDC.Close() |
| 709 | |
| 710 | // Configure the server |
| 711 | addr, port := "127.0.0.1", 5003 |
| 712 | cfg := server.ServerConfig{ |
| 713 | Version: "0.0.0", |
| 714 | Address: addr, |
| 715 | Port: port, |
| 716 | ToolboxUrl: "https://my-toolbox.example.com", |
| 717 | AllowedHosts: []string{"*"}, |
| 718 | AuthServiceConfigs: map[string]auth.AuthServiceConfig{ |
| 719 | "generic1": generic.Config{ |
| 720 | Name: "generic1", |
| 721 | Type: generic.AuthServiceType, |
| 722 | McpEnabled: true, |
| 723 | AuthorizationServer: mockOIDC.URL, // Injecting the mock server URL here |
| 724 | ScopesRequired: []string{"read", "write"}, |
nothing calls this directly
no test coverage detected