feat: implement legacy config auth storage and core api

This commit is contained in:
OpenClaw Agent
2026-09-21 13:02:34 +08:00
parent 83695cea81
commit 79070af15d
6 changed files with 600 additions and 26 deletions
+20
View File
@@ -0,0 +1,20 @@
package auth
import "testing"
func TestParseRules(t *testing.T) {
m, err := ParseRules([]string{"::r|admin:secret:rw:private:d"})
if err != nil {
t.Fatal(err)
}
if !m.Guest.Mask.HasRead() || m.Guest.Mask.HasWrite() {
t.Fatal("guest mask")
}
a := m.Accounts["admin"]
if a == nil || !a.Mask.HasWrite() || a.Mask.HasDelete() {
t.Fatal("admin mask")
}
if got := a.MaskFor("private/x"); !got.HasDelete() {
t.Fatalf("subrule=%v", got)
}
}