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

Function TestIsOrgRole

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

Source from the content-addressed store, hash-verified

1334}
1335
1336func TestIsOrgRole(t *testing.T) {
1337 t.Parallel()
1338 randomUUID, err := uuid.Parse("cad8c09d-c099-4ec7-9263-7d52b1a3997a")
1339 require.NoError(t, err)
1340
1341 testCases := []struct {
1342 Identifier rbac.RoleIdentifier
1343 OrgRole bool
1344 OrgID uuid.UUID
1345 }{
1346 // Not org roles
1347 {Identifier: rbac.RoleOwner()},
1348 {Identifier: rbac.RoleMember()},
1349 {Identifier: rbac.RoleAuditor()},
1350 {
1351 Identifier: rbac.RoleIdentifier{},
1352 OrgRole: false,
1353 },
1354
1355 // Org roles
1356 {
1357 Identifier: rbac.ScopedRoleOrgAdmin(randomUUID),
1358 OrgRole: true,
1359 OrgID: randomUUID,
1360 },
1361 {
1362 Identifier: rbac.ScopedRoleOrgMember(randomUUID),
1363 OrgRole: true,
1364 OrgID: randomUUID,
1365 },
1366 }
1367
1368 // nolint:paralleltest
1369 for _, c := range testCases {
1370 t.Run(c.Identifier.String(), func(t *testing.T) {
1371 t.Parallel()
1372 ok := c.Identifier.IsOrgRole()
1373 require.Equal(t, c.OrgRole, ok, "match expected org role")
1374 require.Equal(t, c.OrgID, c.Identifier.OrganizationID, "match expected org id")
1375 })
1376 }
1377}
1378
1379func TestListRoles(t *testing.T) {
1380 t.Parallel()

Callers

nothing calls this directly

Calls 10

RoleOwnerFunction · 0.92
RoleMemberFunction · 0.92
RoleAuditorFunction · 0.92
ScopedRoleOrgAdminFunction · 0.92
ScopedRoleOrgMemberFunction · 0.92
IsOrgRoleMethod · 0.80
ParseMethod · 0.65
RunMethod · 0.65
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected