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

Function TestChatACLDisabled

coderd/database/modelmethods_internal_test.go:147–183  ·  view source on GitHub ↗

nolint:tparallel,paralleltest

(t *testing.T)

Source from the content-addressed store, hash-verified

145
146//nolint:tparallel,paralleltest
147func TestChatACLDisabled(t *testing.T) {
148 uid := uuid.NewString()
149 gid := uuid.NewString()
150
151 chat := Chat{
152 ID: uuid.New(),
153 OrganizationID: uuid.New(),
154 OwnerID: uuid.New(),
155 UserACL: ChatACL{
156 uid: ChatACLEntry{Permissions: []policy.Action{policy.ActionRead}},
157 },
158 GroupACL: ChatACL{
159 gid: ChatACLEntry{Permissions: []policy.Action{policy.ActionRead}},
160 },
161 }
162
163 t.Run("ACLsOmittedWhenDisabled", func(t *testing.T) {
164 rbac.SetChatACLDisabled(true)
165 t.Cleanup(func() { rbac.SetChatACLDisabled(false) })
166
167 obj := chat.RBACObject()
168
169 require.Empty(t, obj.ACLUserList, "user ACLs should be empty when disabled")
170 require.Empty(t, obj.ACLGroupList, "group ACLs should be empty when disabled")
171 })
172
173 t.Run("ACLsIncludedWhenEnabled", func(t *testing.T) {
174 rbac.SetChatACLDisabled(false)
175
176 obj := chat.RBACObject()
177
178 require.NotEmpty(t, obj.ACLUserList, "user ACLs should be present when enabled")
179 require.NotEmpty(t, obj.ACLGroupList, "group ACLs should be present when enabled")
180 require.Contains(t, obj.ACLUserList, uid)
181 require.Contains(t, obj.ACLGroupList, gid)
182 })
183}
184
185//nolint:tparallel,paralleltest
186func TestWorkspaceACLDisabled(t *testing.T) {

Callers

nothing calls this directly

Calls 8

RBACObjectMethod · 0.95
SetChatACLDisabledFunction · 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