mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 02:42:22 +08:00
Plugins: Preserve trailing slash in plugin proxy (#86859)
* Plugins: Preserve trailing slash in plugin proxy * enable toggle by default
This commit is contained in:

committed by
GitHub

parent
17f03882d4
commit
fe3e5917f1
@ -316,10 +316,16 @@ func TestPluginProxyRoutes(t *testing.T) {
|
||||
Method: "GET",
|
||||
URL: "http://localhost/api/v2/instances",
|
||||
},
|
||||
{
|
||||
Path: "/mypath/*",
|
||||
Method: "GET",
|
||||
URL: "https://example.com/api/v1/",
|
||||
},
|
||||
}
|
||||
|
||||
tcs := []struct {
|
||||
proxyPath string
|
||||
withFeatures []any
|
||||
expectedURLPath string
|
||||
expectedStatus int
|
||||
}{
|
||||
@ -362,6 +368,17 @@ func TestPluginProxyRoutes(t *testing.T) {
|
||||
expectedURLPath: "/api/v2/instances/instance-one",
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
{
|
||||
proxyPath: "/mypath/some-route/",
|
||||
expectedURLPath: "/api/v1/some-route",
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
{
|
||||
proxyPath: "/mypath/some-route/",
|
||||
withFeatures: []any{featuremgmt.FlagPluginProxyPreserveTrailingSlash},
|
||||
expectedURLPath: "/api/v1/some-route/",
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
@ -404,7 +421,7 @@ func TestPluginProxyRoutes(t *testing.T) {
|
||||
SecureJSONData: map[string][]byte{},
|
||||
}
|
||||
cfg := &setting.Cfg{}
|
||||
proxy, err := NewPluginProxy(ps, testRoutes, ctx, tc.proxyPath, cfg, secretsService, tracing.InitializeTracerForTest(), &http.Transport{}, acimpl.ProvideAccessControl(featuremgmt.WithFeatures()), featuremgmt.WithFeatures())
|
||||
proxy, err := NewPluginProxy(ps, testRoutes, ctx, tc.proxyPath, cfg, secretsService, tracing.InitializeTracerForTest(), &http.Transport{}, acimpl.ProvideAccessControl(featuremgmt.WithFeatures()), featuremgmt.WithFeatures(tc.withFeatures...))
|
||||
require.NoError(t, err)
|
||||
proxy.HandleRequest()
|
||||
|
||||
|
Reference in New Issue
Block a user