mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 11:32:36 +08:00
Plugins: Handle app plugin proxy routes per request (#51835)
Fixes #47530
This commit is contained in:

committed by
GitHub

parent
5f80bf5297
commit
e6857bf17d
36
pkg/api/plugin_proxy_test.go
Normal file
36
pkg/api/plugin_proxy_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestExtractPluginProxyPath(t *testing.T) {
|
||||
testCases := []struct {
|
||||
originalRawPath string
|
||||
exp string
|
||||
}{
|
||||
{
|
||||
"/api/plugin-proxy/test",
|
||||
"",
|
||||
},
|
||||
{
|
||||
"/api/plugin-proxy/test/some/thing",
|
||||
"some/thing",
|
||||
},
|
||||
{
|
||||
"/api/plugin-proxy/test2/api/services/afsd%2Fafsd/operations",
|
||||
"api/services/afsd%2Fafsd/operations",
|
||||
},
|
||||
{
|
||||
"/api/plugin-proxy/cloudflare-app/with-token/api/v4/accounts",
|
||||
"with-token/api/v4/accounts",
|
||||
},
|
||||
}
|
||||
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