MCPcopy Index your code
hub / github.com/authorizerdev/authorizer / bootRESTGateway

Function bootRESTGateway

internal/integration_tests/rest_errors_test.go:31–58  ·  view source on GitHub ↗

bootRESTGateway boots the gRPC server + grpc-gateway over an httptest server, mirroring the production wiring (the gateway mounted under the gin router at v1/*). It uses the fully-wired service from initTestSetup so auth-bearing methods (Profile, Logout, etc.) have real Token/Storage providers rathe

(t *testing.T)

Source from the content-addressed store, hash-verified

29// methods (Profile, Logout, etc.) have real Token/Storage providers rather
30// than nil stubs. Returns the base URL.
31func bootRESTGateway(t *testing.T) string {
32 t.Helper()
33 cfg := getTestConfig()
34 cfg.ClientID = "test-client"
35
36 s := initTestSetup(t, cfg)
37
38 grpcSrv, err := grpcsrv.New(":0", &grpcsrv.Dependencies{
39 Log: s.Logger,
40 Config: cfg,
41 ServiceProvider: s.ServiceProvider,
42 TokenProvider: s.TokenProvider,
43 })
44 require.NoError(t, err)
45
46 ctx, cancel := context.WithCancel(context.Background())
47 t.Cleanup(cancel)
48 gw, cleanup, err := gateway.Handler(ctx, grpcSrv.GRPCServer())
49 require.NoError(t, err)
50 t.Cleanup(cleanup)
51
52 gin.SetMode(gin.TestMode)
53 r := gin.New()
54 r.Any("/v1/*path", gin.WrapH(gw))
55 ts := httptest.NewServer(r)
56 t.Cleanup(ts.Close)
57 return ts.URL
58}
59
60// decodeErrorEnvelope reads the standard REST error envelope.
61type errorEnvelope struct {

Calls 5

NewFunction · 0.92
HandlerFunction · 0.92
getTestConfigFunction · 0.85
initTestSetupFunction · 0.85
GRPCServerMethod · 0.80

Tested by

no test coverage detected