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:
parent
2727e2503f
commit
943a8508a6
@ -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.WriteRune(' ')
|
||||
query.WriteString(sqlID)
|
||||
|
@ -117,6 +117,18 @@ func TestFilter_Datasources(t *testing.T) {
|
||||
expectedDataSources: []string{"ds:3", "ds:7", "ds:8"},
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user