mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
chore: create type for unique role names (#13506)
* chore: create type for unique role names Using `string` was confusing when something should be combined with org context, and when not to. Naming this new name, "RoleIdentifier"
This commit is contained in:
@ -35,7 +35,7 @@ func TestUpsertCustomRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
canAssignRole := rbac.Role{
|
||||
Name: "can-assign",
|
||||
Identifier: rbac.RoleIdentifier{Name: "can-assign"},
|
||||
DisplayName: "",
|
||||
Site: rbac.Permissions(map[string][]policy.Action{
|
||||
rbac.ResourceAssignRole.Type: {policy.ActionRead, policy.ActionCreate},
|
||||
@ -51,7 +51,7 @@ func TestUpsertCustomRoles(t *testing.T) {
|
||||
all = append(all, t)
|
||||
case rbac.ExpandableRoles:
|
||||
all = append(all, must(t.Expand())...)
|
||||
case string:
|
||||
case rbac.RoleIdentifier:
|
||||
all = append(all, must(rbac.RoleByName(t)))
|
||||
default:
|
||||
panic("unknown type")
|
||||
@ -80,7 +80,7 @@ func TestUpsertCustomRoles(t *testing.T) {
|
||||
{
|
||||
// No roles, so no assign role
|
||||
name: "no-roles",
|
||||
subject: rbac.RoleNames([]string{}),
|
||||
subject: rbac.RoleIdentifiers{},
|
||||
errorContains: "forbidden",
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user