Add authorized actions output on resources (#870)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2021-01-20 10:53:01 -05:00
1 parent ec6151d174
commit dcb15cffbd
93 files changed
+2475 -1038

No files matched your search

+3 -3
View File
@@ -108,11 +108,11 @@ func (a Type) String() string {
}[a]
}
// Actions stores a slice of action types
type Actions []Type
// ActionSet stores a slice of action types
type ActionSet []Type
// Strings converts Actions into a slice of the actions' string equivalents
func (a Actions) Strings() []string {
func (a ActionSet) Strings() []string {
if a == nil {
return nil
}
+4 -4
View File
@@ -87,22 +87,22 @@ func TestAction(t *testing.T) {
func TestActionStrings(t *testing.T) {
tests := []struct {
name string
actions Actions
actions ActionSet
want []string
}{
{
name: "basic test",
actions: Actions{Read, AuthorizeSession},
actions: ActionSet{Read, AuthorizeSession},
want: []string{"read", "authorize-session"},
},
{
name: "reverse test to check ordering",
actions: Actions{AuthorizeSession, Read},
actions: ActionSet{AuthorizeSession, Read},
want: []string{"authorize-session", "read"},
},
{
name: "another test",
actions: Actions{Delete, AddGrants},
actions: ActionSet{Delete, AddGrants},
want: []string{"delete", "add-grants"},
},
}