Files
Agent-System-Backend/pkg/extension/resource_authz_v2_test.go
T
weichen bff6820e5f
ci / vet-and-test (pull_request) Successful in 42s
Add EXT-19 account lister host capability
Why: 方案 r1 U3/KTD2——RDM 成员管理需最小账号目录(owner+有效态+分页);此前无公开能力,下游只能盲加成员字符串。
Evidence: 红(AccountLister 未定义编译红);绿:surface 棘轮 2.11.0 + TestInprocHostListAccounts(排序/游标/limit 钳制/真实 store);go test ./... 全绿。
Impact: 公开面 AccountEntry{Owner,Valid}+AccountLister(游标分页,limit 1-200 缺省 50);inprocHost 实现(users 表,无姓名/联系方式下发);既有 EXT-8b 版本断言放宽为下限。
Refs: 方案 r1 U3/KTD2;Dev#477/#180 identity CLI
2026-10-12 13:46:15 +00:00

36 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package extension
// EXT-8b 资源级授权契约红测(方案 r1 U9 首切片):
// 1. 公开面新增 ResourceAuthzQuery / ResourceAuthorizerV2 /
// Registry.RegisterResourceAuthorizerV2(surface 棘轮须同步 surface.txt);
// 2. SurfaceVersion 升至 2.10.0-experimental;
// 3. compiledRegistry(声明式扩展)对 V2 一律拒绝(无宿主进程内代码,
// fail-closed——与 V1 同款语义)。
import (
"encoding/json"
"strings"
"testing"
)
func TestResourceAuthzV2SurfacePresent(t *testing.T) {
if SurfaceVersion < "2.10.0" {
t.Fatalf("SurfaceVersion 应 ≥2.10.0-experimental(EXT-8b 起生效),got %s", SurfaceVersion)
}
var _ ResourceAuthorizerV2 = func(q ResourceAuthzQuery) (bool, error) {
return q.Actor != "" && q.Action != "" && q.ResourceType != "" && q.ResourceID != "", nil
}
// 查询六要素字段存在且可构造(字段名即契约)。
q := ResourceAuthzQuery{Actor: "u1", Action: "download", ResourceType: "artifact",
ResourceID: "a1", Owner: "u2", ProjectID: "p1"}
b, err := json.Marshal(q)
if err != nil {
t.Fatal(err)
}
for _, want := range []string{`"actor":"u1"`, `"action":"download"`, `"resourceType":"artifact"`,
`"resourceId":"a1"`, `"owner":"u2"`, `"projectId":"p1"`} {
if !strings.Contains(string(b), want) {
t.Fatalf("查询字段序列化缺 %s: %s", want, b)
}
}
}