mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
f7305965a4
* AccessControl: Remove package variables for roles and grants Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Check for inheritance during role registration Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Moving back role definition to accessscontrol * Make settings reader role public Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Nits Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Forgot to update this * Account for declaration error * Fixing pkg/api init ossac * Account for error in tests * Update test to verify inheritance * Nits. * Place br inheritance behind a feature toggle * Parent -> Parents * Nit. Co-authored-by: Jguer <joao.guerreiro@grafana.com>
45 lines
594 B
Go
45 lines
594 B
Go
package accesscontrol
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestConcatPermissions(t *testing.T) {
|
|
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: "*",
|
|
},
|
|
}
|
|
|
|
perms := ConcatPermissions(perms1, perms2)
|
|
assert.ElementsMatch(t, perms, expected)
|
|
}
|