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:
Gabriel MABILLE
2022-11-15 09:51:40 +01:00
committed by GitHub
parent 80e80221b9
commit d999b5bda0
10 changed files with 37 additions and 48 deletions

View File

@ -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)
})
}