/
githubmirror
/
grafana
Обзор
Документация
Войти
/
githubmirror
/
grafana
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
pkg/plugins/pluginscdn/url_constructor_test.go
34 строки
1 KB
Giuseppe Guerra
Plugins: Allow loading panel plugins from a CDN (#59096)
27 янв 2023, 17:08
Не верифицирован
27 янв 2023, 17:08
af1e2d6
Код
Авторство
О чём код?
package pluginscdn import ( "testing" "github.com/stretchr/testify/require" ) func TestURLConstructor_StringURLFor(t *testing.T) { uc := URLConstructor{ cdnURLTemplate: "https://the.cdn/{id}/{version}/{assetPath}", pluginID: "the-plugin", pluginVersion: "0.1", } type tc struct { name string path string exp string } for _, c := range []tc{ {"simple", "file.txt", "https://the.cdn/the-plugin/0.1/file.txt"}, {"multiple", "some/path/to/file.txt", "https://the.cdn/the-plugin/0.1/some/path/to/file.txt"}, {"path traversal", "some/../to/file.txt", "https://the.cdn/the-plugin/0.1/to/file.txt"}, {"above root", "../../../../../file.txt", "https://the.cdn/the-plugin/0.1/file.txt"}, {"multiple slashes", "some/////file.txt", "https://the.cdn/the-plugin/0.1/some/file.txt"}, {"dots", "some/././././file.txt", "https://the.cdn/the-plugin/0.1/some/file.txt"}, } { t.Run(c.name, func(t *testing.T) { u, err := uc.StringPath(c.path) require.NoError(t, err) require.Equal(t, c.exp, u) }) } }