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

Function TestDeniesUnknownIDs

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

Source from the content-addressed store, hash-verified

43}
44
45func TestDeniesUnknownIDs(t *testing.T) {
46 t.Parallel()
47
48 db, _ := dbtestutil.NewDB(t)
49 ctx := testutil.Context(t, testutil.WaitShort)
50
51 update := codersdk.UpdateWorkspaceACL{
52 UserRoles: map[string]codersdk.WorkspaceRole{
53 uuid.NewString(): codersdk.WorkspaceRoleAdmin,
54 },
55 GroupRoles: map[string]codersdk.WorkspaceRole{
56 uuid.NewString(): codersdk.WorkspaceRoleAdmin,
57 },
58 }
59 errors := acl.Validate(ctx, db, coderd.WorkspaceACLUpdateValidator(update))
60 require.Len(t, errors, 2)
61 require.Equal(t, errors[0].Field, "group_roles")
62 require.ErrorContains(t, errors[0], "does not exist")
63 require.Equal(t, errors[1].Field, "user_roles")
64 require.ErrorContains(t, errors[1], "does not exist")
65}
66
67func TestDeniesUnknownRolesAndInvalidIDs(t *testing.T) {
68 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewDBFunction · 0.92
ContextFunction · 0.92
ValidateFunction · 0.92
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected