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
@@ -104,6 +104,10 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
URL: "http://www.test.com",
|
||||
Body: []byte(`{ "url": "{{.JsonData.dynamicUrl}}", "secret": "{{.SecureJsonData.key}}" }`),
|
||||
},
|
||||
{
|
||||
Path: "mypath",
|
||||
URL: "https://example.com/api/v1/",
|
||||
},
|
||||
}
|
||||
|
||||
ds := &datasources.DataSource{
|
||||
@@ -209,6 +213,16 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
require.Equal(t, `{ "url": "https://dynamic.grafana.com", "secret": "123" }`, string(content))
|
||||
})
|
||||
|
||||
t.Run("When matching route path ending with a slash", func(t *testing.T) {
|
||||
ctx, req := setUp()
|
||||
proxy, err := setupDSProxyTest(t, ctx, ds, routes, "mypath/some-route/")
|
||||
require.NoError(t, err)
|
||||
proxy.matchedRoute = routes[6]
|
||||
ApplyRoute(proxy.ctx.Req.Context(), req, proxy.proxyPath, proxy.matchedRoute, dsInfo, proxy.cfg)
|
||||
|
||||
assert.Equal(t, "https://example.com/api/v1/some-route/", req.URL.String())
|
||||
})
|
||||
|
||||
t.Run("Validating request", func(t *testing.T) {
|
||||
t.Run("plugin route with valid role", func(t *testing.T) {
|
||||
ctx, _ := setUp()
|
||||
|
||||
Reference in New Issue
Block a user