| 238 | } |
| 239 | |
| 240 | func (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. |
| 262 | func (r *RecordingAuthorizer) recordAuthorize(subject rbac.Subject, action policy.Action, object rbac.Object, authzErr error) { |