feat: complete pet SOP governance workflow
This commit is contained in:
24
internal/auth/permissions_test.go
Normal file
24
internal/auth/permissions_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package auth
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHasPermission(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
permissions []string
|
||||
permission string
|
||||
want bool
|
||||
}{
|
||||
{name: "exact", permissions: []string{"sop.view"}, permission: "sop.view", want: true},
|
||||
{name: "wildcard", permissions: []string{"*"}, permission: "sop.publish", want: true},
|
||||
{name: "denied", permissions: []string{"sop.view"}, permission: "sop.publish", want: false},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
principal := Principal{Permissions: test.permissions}
|
||||
if got := HasPermission(principal, test.permission); got != test.want {
|
||||
t.Fatalf("HasPermission() = %v, want %v", got, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user