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

@@ -67,13 +67,13 @@ func TestFetchActionSetForId(t *testing.T) {
{
name: "no match",
id: "zip",
avail: action.ActionSet{action.Read, action.Update},
avail: action.NewActionSet(action.Read, action.Update),
},
{
name: "disjoint match",
id: "ttcp_bar",
avail: action.ActionSet{action.Delete, action.AddGrants, action.Read, action.RemoveHostSets},
allowed: action.ActionSet{action.Delete, action.Read},
avail: action.NewActionSet(action.Delete, action.AddGrants, action.Read, action.RemoveHostSets),
allowed: action.NewActionSet(action.Delete, action.Read),
},
{
name: "different type",
@@ -84,8 +84,8 @@ func TestFetchActionSetForId(t *testing.T) {
name: "type match",
id: "anything",
typeOverride: resource.Role,
avail: action.ActionSet{action.Read, action.AddGrants},
allowed: action.ActionSet{action.AddGrants},
avail: action.NewActionSet(action.Read, action.AddGrants),
allowed: action.NewActionSet(action.AddGrants),
},
}
for _, tt := range cases {