MCPcopy Index your code
hub / github.com/coder/coder / TestListRoles

Function TestListRoles

coderd/rbac/roles_test.go:1379–1416  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1377}
1378
1379func TestListRoles(t *testing.T) {
1380 t.Parallel()
1381
1382 siteRoles := rbac.SiteBuiltInRoles()
1383 siteRoleNames := make([]string, 0, len(siteRoles))
1384 for _, role := range siteRoles {
1385 siteRoleNames = append(siteRoleNames, role.Identifier.Name)
1386 }
1387
1388 // If this test is ever failing, just update the list to the roles
1389 // expected from the builtin set.
1390 // Always use constant strings, as if the names change, we need to write
1391 // a SQL migration to change the name on the backend.
1392 require.ElementsMatch(t, []string{
1393 "owner",
1394 "member",
1395 "auditor",
1396 "template-admin",
1397 "user-admin",
1398 },
1399 siteRoleNames)
1400 orgID := uuid.New()
1401 orgRoles := rbac.OrganizationRoles(orgID)
1402 orgRoleNames := make([]string, 0, len(orgRoles))
1403 for _, role := range orgRoles {
1404 orgRoleNames = append(orgRoleNames, role.Identifier.String())
1405 }
1406
1407 require.ElementsMatch(t, []string{
1408 fmt.Sprintf("organization-admin:%s", orgID.String()),
1409 fmt.Sprintf("organization-auditor:%s", orgID.String()),
1410 fmt.Sprintf("organization-user-admin:%s", orgID.String()),
1411 fmt.Sprintf("organization-template-admin:%s", orgID.String()),
1412 fmt.Sprintf("organization-workspace-creation-ban:%s", orgID.String()),
1413 fmt.Sprintf("agents-access:%s", orgID.String()),
1414 },
1415 orgRoleNames)
1416}
1417
1418func TestChangeSet(t *testing.T) {
1419 t.Parallel()

Callers

nothing calls this directly

Calls 4

SiteBuiltInRolesFunction · 0.92
OrganizationRolesFunction · 0.92
NewMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected