Fix encoded characters in URL path should be proxied as encoded in the data proxy.
Fixes #26870
Fixes #31438
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit c0edf88f9f)
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
co-authored by
Marcus Efraimsson
parent
30b91296ad
commit
3c8daef653
+24
-24
@@ -7,28 +7,28 @@ import (
|
||||
)
|
||||
|
||||
func TestDataProxy(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
origPath string
|
||||
proxyPath string
|
||||
exp string
|
||||
}{
|
||||
{
|
||||
"Should append trailing slash to proxy path if original path has a trailing slash",
|
||||
"/api/datasources/proxy/6/api/v1/query_range/",
|
||||
"api/v1/query_range/",
|
||||
"api/v1/query_range/",
|
||||
},
|
||||
{
|
||||
"Should not append trailing slash to proxy path if original path doesn't have a trailing slash",
|
||||
"/api/datasources/proxy/6/api/v1/query_range",
|
||||
"api/v1/query_range",
|
||||
"api/v1/query_range",
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
assert.Equal(t, tc.exp, ensureProxyPathTrailingSlash(tc.origPath, tc.proxyPath))
|
||||
})
|
||||
}
|
||||
t.Run("extractProxyPath", func(t *testing.T) {
|
||||
testCases := []struct {
|
||||
originalRawPath string
|
||||
exp string
|
||||
}{
|
||||
{
|
||||
"/api/datasources/proxy/1",
|
||||
"",
|
||||
},
|
||||
{
|
||||
"/api/datasources/proxy/1/some/thing",
|
||||
"some/thing",
|
||||
},
|
||||
{
|
||||
"/api/datasources/proxy/54/api/services/afsd%2Fafsd/operations",
|
||||
"api/services/afsd%2Fafsd/operations",
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run("Given raw path, should extract expected proxy path", func(t *testing.T) {
|
||||
assert.Equal(t, tc.exp, extractProxyPath(tc.originalRawPath))
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user