Files
AskaEth 074ffc4ebf
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled
docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批:
已推库 16 个文件 + 本批剩余文件)。
校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0);
全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
2026-10-03 22:28:25 +08:00

37 lines
1.1 KiB
Go

package gateway
import (
"net/http"
"strings"
"testing"
"git.yeij.top/AskaEth/Cyrene_v2/internal/auth"
)
// TestAdminMissingStoreWritesHonest501 为尚无后端存储的端点锁定 B5
// 红线:它们必须返回 501 not_implemented 并附说明性
// 消息,绝不编造成功。创建用户没有可持久化的用户表/登录,
// 而 IoT 没有场景/规则模型或存储。
func TestAdminMissingStoreWritesHonest501(t *testing.T) {
t.Parallel()
srv, ts, jwt := buildEnv(t, cfgDefault(), Deps{})
_ = srv
tok := signAny(t, jwt, "acct", auth.RoleOwner)
cases := []string{
"/api/v1/admin/users",
"/api/v1/admin/iot/scenarios",
"/api/v1/admin/iot/rules",
}
for _, path := range cases {
resp, body := doReq(t, http.MethodPost, ts.URL+path, map[string]any{"name": "x"}, tok)
if resp.StatusCode != http.StatusNotImplemented {
t.Fatalf("%s status = %d, want 501 (body=%s)", path, resp.StatusCode, body)
}
wantErrorShape(t, body)
if !strings.Contains(string(body), "not_implemented") {
t.Fatalf("%s body = %s, want not_implemented code", path, body)
}
}
}