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)
| 214 | // When marking authz calls as asserted, it will mark the first matching |
| 215 | // calls first. |
| 216 | func (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. |