Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements. Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate. Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable. Refs: Versioned dependencies U1/U3; feature/dependency-workspace
63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
package app
|
||
|
||
// EXT-18 AdminProvider 正负例:admin 主体 → true;非 admin / 空 actor(scoped
|
||
// host)→ false;store 查询失败 → false(fail-closed)。
|
||
|
||
import (
|
||
"testing"
|
||
|
||
"git-ssh.u1680832.nyat.app/weichen/Agent-System-Backend.git/internal/store"
|
||
)
|
||
|
||
func TestExt18AdminProviderPositive(t *testing.T) {
|
||
st, err := store.OpenSQLite(t.TempDir() + "/t.db")
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if err := st.CreateAccount("boss", "Boss", "pw", true); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
h := inprocHost{caps: hostcaps{st: st}, pluginID: "tst", owner: "boss", actor: "boss"}
|
||
if !h.IsAdmin() {
|
||
t.Fatal("admin 主体应返回 true")
|
||
}
|
||
}
|
||
|
||
func TestExt18AdminProviderNegative(t *testing.T) {
|
||
st, err := store.OpenSQLite(t.TempDir() + "/t.db")
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if err := st.CreateAccount("user", "User", "pw", false); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
h := inprocHost{caps: hostcaps{st: st}, pluginID: "tst", owner: "user", actor: "user"}
|
||
if h.IsAdmin() {
|
||
t.Fatal("非 admin 主体应返回 false")
|
||
}
|
||
}
|
||
|
||
func TestExt18AdminProviderEmptyActor(t *testing.T) {
|
||
st, err := store.OpenSQLite(t.TempDir() + "/t.db")
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if err := st.CreateAccount("boss", "Boss", "pw", true); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
h := inprocHost{caps: hostcaps{st: st}, pluginID: "tst", owner: "boss", actor: ""} // scoped host(无 dispatch)
|
||
if h.IsAdmin() {
|
||
t.Fatal("空 actor(非 dispatch 上下文)恒 false")
|
||
}
|
||
}
|
||
|
||
func TestExt18RequestHostProjectIDField(t *testing.T) {
|
||
// 编译期断言:Request 有 HostProjectID 字段。
|
||
_ = ""
|
||
var r struct{ HostProjectID string }
|
||
r.HostProjectID = "proj-1"
|
||
if r.HostProjectID != "proj-1" {
|
||
t.Fatal("字段赋值失败")
|
||
}
|
||
}
|