mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 09:52:35 +08:00
Data sources: Don't fail if URL doesn't specify protocol (#24497)
This commit is contained in:
@ -567,7 +567,25 @@ func TestNewDataSourceProxy_InvalidURL(t *testing.T) {
|
||||
plugin := plugins.DataSourcePlugin{}
|
||||
_, err := NewDataSourceProxy(&ds, &plugin, &ctx, "api/method", &cfg)
|
||||
require.Error(t, err)
|
||||
assert.True(t, strings.HasPrefix(err.Error(), `Validation of URL "://host/root" failed`))
|
||||
assert.True(t, strings.HasPrefix(err.Error(), `Validation of data source URL "://host/root" failed`))
|
||||
}
|
||||
|
||||
func TestNewDataSourceProxy_ProtocolLessURL(t *testing.T) {
|
||||
ctx := models.ReqContext{
|
||||
Context: &macaron.Context{
|
||||
Req: macaron.Request{},
|
||||
},
|
||||
SignedInUser: &models.SignedInUser{OrgRole: models.ROLE_EDITOR},
|
||||
}
|
||||
ds := models.DataSource{
|
||||
Type: "test",
|
||||
Url: "127.0.01:5432",
|
||||
}
|
||||
cfg := setting.Cfg{}
|
||||
plugin := plugins.DataSourcePlugin{}
|
||||
_, err := NewDataSourceProxy(&ds, &plugin, &ctx, "api/method", &cfg)
|
||||
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
type CloseNotifierResponseRecorder struct {
|
||||
|
Reference in New Issue
Block a user