Fix: Double encoding of URLs when using data proxy (#98494)

fix: unescape raw path and set to req path
This commit is contained in:
Syerikjan Kh
2025-01-07 10:27:34 -05:00
committed by GitHub
parent 44e65c5bc9
commit b7809b7350
2 changed files with 22 additions and 2 deletions
+14
View File
@@ -119,6 +119,10 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
Path: "api/rbac-restricted",
ReqAction: "test-app.settings:read",
},
{
Path: "encodedPath",
URL: "http://encoded.com",
},
}
ds := &datasources.DataSource{
@@ -235,6 +239,16 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
assert.Equal(t, "https://example.com/api/v1/some-route/", req.URL.String())
})
t.Run("When matching proxy path is already encoded", func(t *testing.T) {
ctx, req := setUp()
proxy, err := setupDSProxyTest(t, ctx, ds, routes, "/our%20devices")
require.NoError(t, err)
proxy.matchedRoute = routes[9]
ApplyRoute(proxy.ctx.Req.Context(), req, proxy.proxyPath, proxy.matchedRoute, dsInfo, proxy.cfg)
assert.Equal(t, "http://encoded.com/our%20devices", req.URL.String())
})
t.Run("Validating request", func(t *testing.T) {
t.Run("plugin route with valid role", func(t *testing.T) {
ctx, _ := setUp()