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

Function TestOK

coderd/rbac/acl/updatevalidator_test.go:18–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestOK(t *testing.T) {
19 t.Parallel()
20
21 db, _ := dbtestutil.NewDB(t)
22 o := dbgen.Organization(t, db, database.Organization{})
23 g := dbgen.Group(t, db, database.Group{OrganizationID: o.ID})
24 u := dbgen.User(t, db, database.User{})
25 ctx := testutil.Context(t, testutil.WaitShort)
26
27 update := codersdk.UpdateWorkspaceACL{
28 UserRoles: map[string]codersdk.WorkspaceRole{
29 u.ID.String(): codersdk.WorkspaceRoleAdmin,
30 // An unknown ID is allowed if and only if the specified role is either
31 // codersdk.WorkspaceRoleDeleted or codersdk.TemplateRoleDeleted.
32 uuid.NewString(): codersdk.WorkspaceRoleDeleted,
33 },
34 GroupRoles: map[string]codersdk.WorkspaceRole{
35 g.ID.String(): codersdk.WorkspaceRoleAdmin,
36 // An unknown ID is allowed if and only if the specified role is either
37 // codersdk.WorkspaceRoleDeleted or codersdk.TemplateRoleDeleted.
38 uuid.NewString(): codersdk.WorkspaceRoleDeleted,
39 },
40 }
41 errors := acl.Validate(ctx, db, coderd.WorkspaceACLUpdateValidator(update))
42 require.Empty(t, errors)
43}
44
45func TestDeniesUnknownIDs(t *testing.T) {
46 t.Parallel()

Callers

nothing calls this directly

Calls 9

NewDBFunction · 0.92
OrganizationFunction · 0.92
GroupFunction · 0.92
UserFunction · 0.92
ContextFunction · 0.92
ValidateFunction · 0.92
StringMethod · 0.45
EmptyMethod · 0.45

Tested by

no test coverage detected