refact(action): Make ActionSet behave as a set instead of a list

This switches the implementation of an ActionSet from a slice to a map
to ensure the elements in an ActionSet are unique. This allows for other
packages to perform set operations such as a union or difference without
needing to account for duplicates.
This commit is contained in:
Timothy Messier committed 2023-12-04 16:20:29 +00:00
1 parent bee45dc486
commit c52caae345
52 files changed
+1401 -274

No files matched your search

@@ -225,6 +225,9 @@ func TestList(t *testing.T) {
cmpopts.SortSlices(func(a, b *authmethods.AuthMethod) bool {
return a.Name < b.Name
}),
cmpopts.SortSlices(func(a, b string) bool {
return a < b
}),
),
)
@@ -251,6 +254,9 @@ func TestList(t *testing.T) {
cmpopts.SortSlices(func(a, b *authmethods.AuthMethod) bool {
return a.Name < b.Name
}),
cmpopts.SortSlices(func(a, b string) bool {
return a < b
}),
),
)
@@ -274,6 +280,9 @@ func TestList(t *testing.T) {
cmpopts.SortSlices(func(a, b *authmethods.AuthMethod) bool {
return a.Name < b.Name
}),
cmpopts.SortSlices(func(a, b string) bool {
return a < b
}),
),
)
@@ -281,7 +290,14 @@ func TestList(t *testing.T) {
authmethods.WithFilter(`"/item/attributes/client_id"=="client-id"`))
require.NoError(err)
require.Len(result.Items, 1)
assert.Empty(cmp.Diff(oidcAM.Item, result.Items[0], cmpopts.IgnoreUnexported(authmethods.AuthMethod{})))
assert.Empty(cmp.Diff(
oidcAM.Item,
result.Items[0],
cmpopts.IgnoreUnexported(authmethods.AuthMethod{}),
cmpopts.SortSlices(func(a, b string) bool {
return a < b
}),
))
result, err = amClient.List(tc.Context(), global,
authmethods.WithFilter(`"/item/attributes/min_login_name_length"==3`))
@@ -295,6 +311,9 @@ func TestList(t *testing.T) {
cmpopts.SortSlices(func(a, b *authmethods.AuthMethod) bool {
return a.Name < b.Name
}),
cmpopts.SortSlices(func(a, b string) bool {
return a < b
}),
),
)
@@ -302,7 +321,14 @@ func TestList(t *testing.T) {
authmethods.WithFilter(`"/item/attributes/min_password_length"==10`))
require.NoError(err)
require.Len(result.Items, 1)
assert.Empty(cmp.Diff(pwAM.Item, result.Items[0], cmpopts.IgnoreUnexported(authmethods.AuthMethod{})))
assert.Empty(cmp.Diff(
pwAM.Item,
result.Items[0],
cmpopts.IgnoreUnexported(authmethods.AuthMethod{}),
cmpopts.SortSlices(func(a, b string) bool {
return a < b
}),
))
}
func TestCustomMethods(t *testing.T) {