RBAC: Reject plugin registrations without a name (#81719)
* RBAC: Reject plugin registrations without a name * Lint'
This commit is contained in:
@@ -85,34 +85,41 @@ func TestValidatePluginRole(t *testing.T) {
|
||||
role ac.RoleDTO
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
name: "empty display name",
|
||||
pluginID: "test-app",
|
||||
role: ac.RoleDTO{DisplayName: ""},
|
||||
wantErr: &ac.ErrorInvalidRole{},
|
||||
},
|
||||
{
|
||||
name: "empty",
|
||||
pluginID: "",
|
||||
role: ac.RoleDTO{Name: "plugins::"},
|
||||
role: ac.RoleDTO{Name: "plugins::reader", DisplayName: "Reader"},
|
||||
wantErr: ac.ErrPluginIDRequired,
|
||||
},
|
||||
{
|
||||
name: "invalid name",
|
||||
pluginID: "test-app",
|
||||
role: ac.RoleDTO{Name: "test-app:reader"},
|
||||
role: ac.RoleDTO{Name: "test-app:reader", DisplayName: "Reader"},
|
||||
wantErr: &ac.ErrorInvalidRole{},
|
||||
},
|
||||
{
|
||||
name: "invalid id in name",
|
||||
pluginID: "test-app",
|
||||
role: ac.RoleDTO{Name: "plugins:test-app2:reader"},
|
||||
role: ac.RoleDTO{Name: "plugins:test-app2:reader", DisplayName: "Reader"},
|
||||
wantErr: &ac.ErrorInvalidRole{},
|
||||
},
|
||||
{
|
||||
name: "valid name",
|
||||
pluginID: "test-app",
|
||||
role: ac.RoleDTO{Name: "plugins:test-app:reader"},
|
||||
role: ac.RoleDTO{Name: "plugins:test-app:reader", DisplayName: "Reader"},
|
||||
},
|
||||
{
|
||||
name: "invalid permission",
|
||||
pluginID: "test-app",
|
||||
role: ac.RoleDTO{
|
||||
Name: "plugins:test-app:reader",
|
||||
DisplayName: "Reader",
|
||||
Permissions: []ac.Permission{{Action: "invalidtest-app:read"}},
|
||||
},
|
||||
wantErr: &ac.ErrorInvalidRole{},
|
||||
@@ -121,7 +128,8 @@ func TestValidatePluginRole(t *testing.T) {
|
||||
name: "valid permissions",
|
||||
pluginID: "test-app",
|
||||
role: ac.RoleDTO{
|
||||
Name: "plugins:test-app:reader",
|
||||
Name: "plugins:test-app:reader",
|
||||
DisplayName: "Reader",
|
||||
Permissions: []ac.Permission{
|
||||
{Action: "plugins.app:access", Scope: "plugins:id:test-app"},
|
||||
{Action: "test-app:read"},
|
||||
@@ -133,7 +141,8 @@ func TestValidatePluginRole(t *testing.T) {
|
||||
name: "invalid permission targets other plugin",
|
||||
pluginID: "test-app",
|
||||
role: ac.RoleDTO{
|
||||
Name: "plugins:test-app:reader",
|
||||
Name: "plugins:test-app:reader",
|
||||
DisplayName: "Reader",
|
||||
Permissions: []ac.Permission{
|
||||
{Action: "plugins.app:access", Scope: "plugins:id:other-app"},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user