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

Method AssertActorID

coderd/coderdtest/authorize.go:240–259  ·  view source on GitHub ↗
(t *testing.T, id string, did ...ActionObjectPair)

Source from the content-addressed store, hash-verified

238}
239
240func (r *RecordingAuthorizer) AssertActorID(t *testing.T, id string, did ...ActionObjectPair) {
241 r.Lock()
242 defer r.Unlock()
243 ptr := 0
244 for i, call := range r.Called {
245 if ptr == len(did) {
246 // Finished all assertions
247 return
248 }
249 if call.Actor.ID == id {
250 action, object := did[ptr].Action, did[ptr].Object
251 assert.Equalf(t, action, call.Action, "assert action %d", ptr)
252 assert.Equalf(t, object, call.Object, "assert object %d", ptr)
253 r.Called[i].asserted = true
254 ptr++
255 }
256 }
257
258 assert.Equalf(t, len(did), ptr, "assert actor: didn't find all actions, %d missing actions", len(did)-ptr)
259}
260
261// recordAuthorize is the internal method that records the Authorize() call.
262func (r *RecordingAuthorizer) recordAuthorize(subject rbac.Subject, action policy.Action, object rbac.Object, authzErr error) {

Callers 2

AssertActorMethod · 0.95
TestCacheRBACFunction · 0.80

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1

TestCacheRBACFunction · 0.64