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

Method AssertOutOfOrder

coderd/coderdtest/authorize.go:216–232  ·  view source on GitHub ↗

AssertOutOfOrder asserts that the given actor performed the given action on the given objects. It does not care about the order of the calls. When marking authz calls as asserted, it will mark the first matching calls first.

(t *testing.T, actor rbac.Subject, did ...ActionObjectPair)

Source from the content-addressed store, hash-verified

214// When marking authz calls as asserted, it will mark the first matching
215// calls first.
216func (r *RecordingAuthorizer) AssertOutOfOrder(t *testing.T, actor rbac.Subject, did ...ActionObjectPair) {
217 r.Lock()
218 defer r.Unlock()
219
220 for _, do := range did {
221 found := false
222 // Find the first non-asserted call that matches the actor, action, and object.
223 for i, call := range r.Called {
224 if !call.asserted && call.Actor.Equal(actor) && call.Action == do.Action && call.Object.Equal(do.Object) {
225 r.Called[i].asserted = true
226 found = true
227 break
228 }
229 }
230 require.True(t, found, "assertion missing: %s %s %s", actor, do.Action, do.Object)
231 }
232}
233
234// AssertActor asserts in order. If the order of authz calls does not match,
235// this will fail.

Callers 3

TestAuthzRecorderFunction · 0.95
SubtestWithDBMethod · 0.95
AssertCheckedMethod · 0.80

Calls 3

LockMethod · 0.45
UnlockMethod · 0.45
EqualMethod · 0.45

Tested by 2

TestAuthzRecorderFunction · 0.76
SubtestWithDBMethod · 0.76