mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Handle case where there are no matching ids for all actions passed to (#46646)
This commit is contained in:
@@ -69,6 +69,10 @@ func Filter(user *models.SignedInUser, sqlID, prefix string, actions ...string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return denyQuery, nil
|
||||||
|
}
|
||||||
|
|
||||||
query := strings.Builder{}
|
query := strings.Builder{}
|
||||||
query.WriteRune(' ')
|
query.WriteRune(' ')
|
||||||
query.WriteString(sqlID)
|
query.WriteString(sqlID)
|
||||||
|
|||||||
@@ -117,6 +117,18 @@ func TestFilter_Datasources(t *testing.T) {
|
|||||||
expectedDataSources: []string{"ds:3", "ds:7", "ds:8"},
|
expectedDataSources: []string{"ds:3", "ds:7", "ds:8"},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "expect no data sources when scopes does not match",
|
||||||
|
sqlID: "data_source.id",
|
||||||
|
prefix: "datasources",
|
||||||
|
actions: []string{"datasources:read", "datasources:write"},
|
||||||
|
permissions: map[string][]string{
|
||||||
|
"datasources:read": {"datasources:id:3", "datasources:id:7", "datasources:id:8"},
|
||||||
|
"datasources:write": {"datasources:id:10"},
|
||||||
|
},
|
||||||
|
expectedDataSources: []string{},
|
||||||
|
expectErr: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// set sqlIDAcceptList before running tests
|
// set sqlIDAcceptList before running tests
|
||||||
|
|||||||
Reference in New Issue
Block a user