Data proxy: Fix encoded characters in URL path should be proxied encoded (#30597)
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>
This commit is contained in:
committed by
GitHub
parent
68b05b8aaa
commit
c0edf88f9f
+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