2021-04-14 09:31:27 -05:00
|
|
|
package accesscontrol
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2021-04-27 11:22:18 -05:00
|
|
|
func TestConcatPermissions(t *testing.T) {
|
2021-04-23 08:44:42 -05:00
|
|
|
perms1 := []Permission{
|
|
|
|
{
|
|
|
|
Action: "test",
|
|
|
|
Scope: "test:*",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action: "test1",
|
|
|
|
Scope: "test1:*",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
perms2 := []Permission{
|
|
|
|
{
|
|
|
|
Action: "test1",
|
|
|
|
Scope: "*",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
expected := []Permission{
|
|
|
|
{
|
|
|
|
Action: "test",
|
|
|
|
Scope: "test:*",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action: "test1",
|
|
|
|
Scope: "test1:*",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action: "test1",
|
|
|
|
Scope: "*",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-04-27 11:22:18 -05:00
|
|
|
perms := ConcatPermissions(perms1, perms2)
|
2021-04-23 08:44:42 -05:00
|
|
|
assert.ElementsMatch(t, perms, expected)
|
|
|
|
}
|