feat(admin/master): provider+master CRUD, token mgmt, logs APIs

This commit is contained in:
zenfun
2025-12-18 16:21:46 +08:00
parent b2d2df18c5
commit a61eff27e7
12 changed files with 1374 additions and 8 deletions

View File

@@ -66,3 +66,29 @@ func TestSyncProvider_WritesSnapshotAndRouting(t *testing.T) {
t.Fatalf("expected provider id 42 in routing set %q", routeKey)
}
}
func TestSyncKey_WritesTokenID(t *testing.T) {
mr := miniredis.RunT(t)
rdb := redis.NewClient(&redis.Options{Addr: mr.Addr()})
svc := NewSyncService(rdb)
k := &model.Key{
TokenHash: "hash",
MasterID: 1,
IssuedAtEpoch: 1,
Status: "active",
Group: "default",
Scopes: "chat:write",
DefaultNamespace: "default",
Namespaces: "default",
}
k.ID = 123
if err := svc.SyncKey(k); err != nil {
t.Fatalf("SyncKey: %v", err)
}
if got := mr.HGet("auth:token:hash", "id"); got != "123" {
t.Fatalf("expected auth:token:hash.id=123, got %q", got)
}
}