(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestListCustomRoles(t *testing.T) { |
| 20 | t.Parallel() |
| 21 | |
| 22 | t.Run("Organizations", func(t *testing.T) { |
| 23 | t.Parallel() |
| 24 | |
| 25 | client, db := coderdtest.NewWithDatabase(t, nil) |
| 26 | owner := coderdtest.CreateFirstUser(t, client) |
| 27 | |
| 28 | const roleName = "random_role" |
| 29 | dbgen.CustomRole(t, db, database.CustomRole{ |
| 30 | Name: roleName, |
| 31 | DisplayName: "Random Role", |
| 32 | OrganizationID: uuid.NullUUID{ |
| 33 | UUID: owner.OrganizationID, |
| 34 | Valid: true, |
| 35 | }, |
| 36 | SitePermissions: nil, |
| 37 | OrgPermissions: []database.CustomRolePermission{ |
| 38 | { |
| 39 | Negate: false, |
| 40 | ResourceType: rbac.ResourceWorkspace.Type, |
| 41 | Action: policy.ActionRead, |
| 42 | }, |
| 43 | }, |
| 44 | UserPermissions: nil, |
| 45 | }) |
| 46 | |
| 47 | ctx := testutil.Context(t, testutil.WaitShort) |
| 48 | roles, err := client.ListOrganizationRoles(ctx, owner.OrganizationID) |
| 49 | require.NoError(t, err) |
| 50 | |
| 51 | found := slices.ContainsFunc(roles, func(element codersdk.AssignableRoles) bool { |
| 52 | return element.Name == roleName && element.OrganizationID == owner.OrganizationID.String() |
| 53 | }) |
| 54 | require.Truef(t, found, "custom organization role listed") |
| 55 | }) |
| 56 | } |
nothing calls this directly
no test coverage detected