mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 06:12:20 +08:00
RBAC: remove redundant role name field from plugin role registrations (#58166)
* RBAC: Remove name from role registration * Inline accesscontrol service * test fix * use fmt Co-Authored-By: marefr <marcus.efraimsson@gmail.com> Co-authored-by: marefr <marcus.efraimsson@gmail.com>
This commit is contained in:
@ -24,8 +24,7 @@ func TestToRegistrations(t *testing.T) {
|
||||
regs: []plugins.RoleRegistration{
|
||||
{
|
||||
Role: plugins.Role{
|
||||
Name: "test:name",
|
||||
DisplayName: "Test",
|
||||
Name: "Tester",
|
||||
Description: "Test",
|
||||
Permissions: []plugins.Permission{
|
||||
{Action: "test:action"},
|
||||
@ -36,7 +35,7 @@ func TestToRegistrations(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Role: plugins.Role{
|
||||
Name: "test:name",
|
||||
Name: "Admin Validator",
|
||||
Permissions: []plugins.Permission{},
|
||||
},
|
||||
},
|
||||
@ -45,10 +44,10 @@ func TestToRegistrations(t *testing.T) {
|
||||
{
|
||||
Role: ac.RoleDTO{
|
||||
Version: 1,
|
||||
Name: "test:name",
|
||||
DisplayName: "Test",
|
||||
Name: ac.PluginRolePrefix + "plugin-id:tester",
|
||||
DisplayName: "Tester",
|
||||
Description: "Test",
|
||||
Group: "PluginName",
|
||||
Group: "Plugin Name",
|
||||
Permissions: []ac.Permission{
|
||||
{Action: "test:action"},
|
||||
{Action: "test:action", Scope: "test:scope"},
|
||||
@ -60,8 +59,9 @@ func TestToRegistrations(t *testing.T) {
|
||||
{
|
||||
Role: ac.RoleDTO{
|
||||
Version: 1,
|
||||
Name: "test:name",
|
||||
Group: "PluginName",
|
||||
Name: ac.PluginRolePrefix + "plugin-id:admin-validator",
|
||||
DisplayName: "Admin Validator",
|
||||
Group: "Plugin Name",
|
||||
Permissions: []ac.Permission{},
|
||||
OrgID: ac.GlobalOrgID,
|
||||
},
|
||||
@ -71,7 +71,7 @@ func TestToRegistrations(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := ToRegistrations("PluginName", tt.regs)
|
||||
got := ToRegistrations("plugin-id", "Plugin Name", tt.regs)
|
||||
require.Equal(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user