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

Function TestWorkspaceACLDisabled

coderd/database/modelmethods_internal_test.go:186–222  ·  view source on GitHub ↗

nolint:tparallel,paralleltest

(t *testing.T)

Source from the content-addressed store, hash-verified

184
185//nolint:tparallel,paralleltest
186func TestWorkspaceACLDisabled(t *testing.T) {
187 uid := uuid.NewString()
188 gid := uuid.NewString()
189
190 ws := WorkspaceTable{
191 ID: uuid.New(),
192 OrganizationID: uuid.New(),
193 OwnerID: uuid.New(),
194 UserACL: WorkspaceACL{
195 uid: WorkspaceACLEntry{Permissions: []policy.Action{policy.ActionSSH}},
196 },
197 GroupACL: WorkspaceACL{
198 gid: WorkspaceACLEntry{Permissions: []policy.Action{policy.ActionSSH}},
199 },
200 }
201
202 t.Run("ACLsOmittedWhenDisabled", func(t *testing.T) {
203 rbac.SetWorkspaceACLDisabled(true)
204 t.Cleanup(func() { rbac.SetWorkspaceACLDisabled(false) })
205
206 obj := ws.RBACObject()
207
208 require.Empty(t, obj.ACLUserList, "user ACLs should be empty when disabled")
209 require.Empty(t, obj.ACLGroupList, "group ACLs should be empty when disabled")
210 })
211
212 t.Run("ACLsIncludedWhenEnabled", func(t *testing.T) {
213 rbac.SetWorkspaceACLDisabled(false)
214
215 obj := ws.RBACObject()
216
217 require.NotEmpty(t, obj.ACLUserList, "user ACLs should be present when enabled")
218 require.NotEmpty(t, obj.ACLGroupList, "group ACLs should be present when enabled")
219 require.Contains(t, obj.ACLUserList, uid)
220 require.Contains(t, obj.ACLGroupList, gid)
221 })
222}
223
224// Helpers
225func requirePermission(t *testing.T, s rbac.Scope, resource string, action policy.Action) {

Callers

nothing calls this directly

Calls 8

RBACObjectMethod · 0.95
SetWorkspaceACLDisabledFunction · 0.92
NotEmptyMethod · 0.80
NewMethod · 0.65
RunMethod · 0.65
CleanupMethod · 0.65
EmptyMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected