Commit 7610d571 by Carl Bergquist Committed by GitHub

Provisioning: Use proxy as default access mode in provisioning (#24669)

fixes #24591
fixes #19501
parent 2f22781c
......@@ -94,6 +94,10 @@ func validateDefaultUniqueness(datasources []*configs) error {
ds.OrgID = 1
}
if ds.Access == "" {
ds.Access = "proxy"
}
if ds.IsDefault {
defaultCount[ds.OrgID] = defaultCount[ds.OrgID] + 1
if defaultCount[ds.OrgID] > 1 {
......
......@@ -21,6 +21,7 @@ var (
versionZero = "testdata/version-0"
brokenYaml = "testdata/broken-yaml"
multipleOrgsWithDefault = "testdata/multiple-org-default"
withoutDefaults = "testdata/appliedDefaults"
fakeRepo *fakeRepository
)
......@@ -35,6 +36,18 @@ func TestDatasourceAsConfig(t *testing.T) {
bus.AddHandler("test", mockGet)
bus.AddHandler("test", mockGetAll)
Convey("apply default values when missing", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(withoutDefaults)
if err != nil {
t.Fatalf("applyChanges return an error %v", err)
}
So(len(fakeRepo.inserted), ShouldEqual, 1)
So(fakeRepo.inserted[0].OrgId, ShouldEqual, 1)
So(fakeRepo.inserted[0].Access, ShouldEqual, "proxy")
})
Convey("One configured datasource", func() {
Convey("no datasource in database", func() {
dc := newDatasourceProvisioner(logger)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment