feat: complete pet SOP governance workflow

This commit is contained in:
Eric 1549169735@qq.com
2026-08-08 22:58:35 +08:00
parent 97a76250f7
commit 4b240499c2
85 changed files with 1316 additions and 269 deletions

View 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)
}
})
}
}