|
|
|
|
@ -42,6 +42,17 @@ func TestReduce(t *testing.T) { |
|
|
|
|
"teams:write": {"teams:id:1"}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "specific permissions with repeated scope", |
|
|
|
|
ps: []Permission{ |
|
|
|
|
{Action: "teams:read", Scope: "teams:id:1"}, |
|
|
|
|
{Action: "teams:read", Scope: "teams:id:2"}, |
|
|
|
|
{Action: "teams:read", Scope: "teams:id:1"}, |
|
|
|
|
}, |
|
|
|
|
want: map[string][]string{ |
|
|
|
|
"teams:read": {"teams:id:1", "teams:id:2"}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "wildcard permission", |
|
|
|
|
ps: []Permission{ |
|
|
|
|
@ -88,6 +99,16 @@ func TestReduce(t *testing.T) { |
|
|
|
|
"dashboards:read": {"*"}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "non-wilcard scopes with * in them", |
|
|
|
|
ps: []Permission{ |
|
|
|
|
{Action: "dashboards:read", Scope: "dashboards:uid:123"}, |
|
|
|
|
{Action: "dashboards:read", Scope: "dashboards:uid:1*"}, |
|
|
|
|
}, |
|
|
|
|
want: map[string][]string{ |
|
|
|
|
"dashboards:read": {"dashboards:uid:123", "dashboards:uid:1*"}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
for _, tt := range tests { |
|
|
|
|
t.Run(tt.name, func(t *testing.T) { |
|
|
|
|
|