nolint:tparallel,paralleltest
(t *testing.T)
| 184 | |
| 185 | //nolint:tparallel,paralleltest |
| 186 | func 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 |
| 225 | func requirePermission(t *testing.T, s rbac.Scope, resource string, action policy.Action) { |
nothing calls this directly
no test coverage detected