chore: Allow RecordingAuthorizer to record multiple rbac authz calls (#6024)

* chore: Allow RecordingAuthorizer to record multiple rbac authz calls

Prior iteration only recorded the last call. This is required for
more comprehensive testing
This commit is contained in:
Steven Masley
2023-02-03 13:03:46 -06:00
committed by GitHub
parent 571f5d0e02
commit b359dbbd8b
9 changed files with 720 additions and 53 deletions

View File

@ -1,5 +1,25 @@
package slice
// New is a convenience method for creating []T.
func New[T any](items ...T) []T {
return items
}
// SameElements returns true if the 2 lists have the same elements in any
// order.
func SameElements[T comparable](a []T, b []T) bool {
if len(a) != len(b) {
return false
}
for _, element := range a {
if !Contains(b, element) {
return false
}
}
return true
}
func ContainsCompare[T any](haystack []T, needle T, equal func(a, b T) bool) bool {
for _, hay := range haystack {
if equal(needle, hay) {