docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批: 已推库 16 个文件 + 本批剩余文件)。 校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0); 全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
This commit is contained in:
1 parent
91e8d7a029
commit
074ffc4ebf
73 files changed
+2529
-2529
No files matched your search
@@ -1,9 +1,9 @@
|
||||
package gateway
|
||||
|
||||
// Exercises the weixin-iLink scan-login admin endpoints (design/08 §4). The
|
||||
// adapter is registered through a wrapper that embeds adapter.PlatformAdapter —
|
||||
// mirroring cmd/cyrene's namedAdapter — so these tests also cover the reflection
|
||||
// unwrap the gateway uses to reach the concrete *weixin_ilink.Adapter.
|
||||
// 演练 weixin-iLink 扫码登录管理端点(design/08 §4)。适配器
|
||||
// 经由一个内嵌 adapter.PlatformAdapter 的包装器注册 —— 仿照
|
||||
// 仿照 cmd/cyrene 的 namedAdapter —— 因此这些测试也覆盖网关
|
||||
// 用来抵达具体 *weixin_ilink.Adapter 的反射拆包。
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/plugins/channels/weixin_ilink"
|
||||
)
|
||||
|
||||
// gatewayWeixinWrap embeds adapter.PlatformAdapter the way cmd/cyrene's namedAdapter
|
||||
// does, so the gateway's reflection-based unwrap (asWeixinLoginAdmin) is exercised.
|
||||
// gatewayWeixinWrap 按 cmd/cyrene 的 namedAdapter 的方式内嵌
|
||||
// adapter.PlatformAdapter,从而演练网关基于反射的拆包(asWeixinLoginAdmin)。
|
||||
type gatewayWeixinWrap struct {
|
||||
adapter.PlatformAdapter
|
||||
name string
|
||||
@@ -34,7 +34,7 @@ type gatewayWeixinWrap struct {
|
||||
|
||||
func (w *gatewayWeixinWrap) Name() string { return w.name }
|
||||
|
||||
// fakeWeixinChannels is a minimal ChannelConfigStore for the persist-on-confirm path.
|
||||
// fakeWeixinChannels 是供「确认即持久化」路径用的最小 ChannelConfigStore。
|
||||
type fakeWeixinChannels struct {
|
||||
path string
|
||||
data map[string][]config.ChannelAccount
|
||||
@@ -50,8 +50,8 @@ func (f *fakeWeixinChannels) Reload(platform string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// weixinLoginServer answers the scan-login surface: a fixed QR and an immediate
|
||||
// confirmed status (so the background poll confirms within a poll interval).
|
||||
// weixinLoginServer 应答扫码登录表面:固定的二维码与立即
|
||||
// 确认的状态(使后台轮询在一个轮询周期内确认)。
|
||||
func weixinLoginServer(t *testing.T) *httptest.Server {
|
||||
t.Helper()
|
||||
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -75,8 +75,8 @@ func weixinLoginServer(t *testing.T) *httptest.Server {
|
||||
return srv
|
||||
}
|
||||
|
||||
// newWeixinGateway wires a registry whose weixin channel wraps a real adapter, and
|
||||
// returns the httptest URL + an owner JWT. channels may be nil (no persist test).
|
||||
// newWeixinGateway 接线一个注册表,其 weixin 渠道包装真实适配器,
|
||||
// 并返回 httptest URL + owner JWT。channels 可为 nil(不做持久化测试)。
|
||||
func newWeixinGateway(t *testing.T, name string, channels ChannelConfigStore) (string, string) {
|
||||
t.Helper()
|
||||
wsrv := weixinLoginServer(t)
|
||||
@@ -101,8 +101,8 @@ func newWeixinGateway(t *testing.T, name string, channels ChannelConfigStore) (s
|
||||
return ts.URL, tok
|
||||
}
|
||||
|
||||
// newWeixinGatewayPresetToken builds a gateway whose weixin adapter already holds a
|
||||
// token, so login endpoints report confirmed without any network.
|
||||
// newWeixinGatewayPresetToken 构建一个网关,其 weixin 适配器已持有
|
||||
// token,因此登录端点无需任何网络就报告已确认。
|
||||
func newWeixinGatewayPresetToken(t *testing.T, name string) (string, string) {
|
||||
t.Helper()
|
||||
wa, err := weixin_ilink.New(
|
||||
@@ -122,8 +122,8 @@ func newWeixinGatewayPresetToken(t *testing.T, name string) (string, string) {
|
||||
return ts.URL, tok
|
||||
}
|
||||
|
||||
// weixinLoginWaitingServer answers the QR but keeps the status "wait" (never
|
||||
// confirms), so the panel polls a login that is still in progress.
|
||||
// weixinLoginWaitingServer 应答二维码但状态一直是 "wait"(永不
|
||||
// 确认),因此面板轮询的是一个仍在进行中的登录。
|
||||
func weixinLoginWaitingServer(t *testing.T) *httptest.Server {
|
||||
t.Helper()
|
||||
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -144,7 +144,7 @@ func weixinLoginWaitingServer(t *testing.T) *httptest.Server {
|
||||
return srv
|
||||
}
|
||||
|
||||
// newWeixinGatewayWaiting wires a weixin adapter whose status poll never confirms.
|
||||
// newWeixinGatewayWaiting 接线一个 weixin 适配器,其状态轮询永不确认。
|
||||
func newWeixinGatewayWaiting(t *testing.T, name string) (string, string) {
|
||||
t.Helper()
|
||||
wsrv := weixinLoginWaitingServer(t)
|
||||
@@ -229,7 +229,7 @@ func TestAdminWeixinLoginStatus_ConfirmPersists(t *testing.T) {
|
||||
}
|
||||
base, tok := newWeixinGateway(t, "weixin-ilink:conf0", chs)
|
||||
|
||||
// Trigger the QR, then poll until the background login confirms and persists.
|
||||
// 触发二维码,然后轮询直到后台登录确认并持久化。
|
||||
if resp, body := doReq(t, http.MethodGet, base+"/api/v1/admin/channels/weixin-ilink/login-qr?accountId=conf0", nil, tok); resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("login-qr status = %d, body=%s", resp.StatusCode, body)
|
||||
}
|
||||
@@ -333,12 +333,12 @@ func TestAdminWeixinLogin_NonWeixinNotImplemented(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// ownerRegCall records one RegisterChannelOwner invocation.
|
||||
// ownerRegCall 记录一次 RegisterChannelOwner 调用。
|
||||
type ownerRegCall struct {
|
||||
platform, accountID string
|
||||
}
|
||||
|
||||
// captureOwnerRegistrar records whitelist registrations for the weixin confirm path.
|
||||
// captureOwnerRegistrar 记录 weixin 确认路径的白名单登记。
|
||||
type captureOwnerRegistrar struct {
|
||||
calls []ownerRegCall
|
||||
}
|
||||
@@ -348,10 +348,10 @@ func (c *captureOwnerRegistrar) RegisterChannelOwner(_ context.Context, platform
|
||||
return nil
|
||||
}
|
||||
|
||||
// TestPersistWeixinConfirmed_RegistersOwner verifies that once a scan-login
|
||||
// confirmation persists the channels.json credentials, the bound owner id is
|
||||
// handed to the OwnerRegistrar as (weixin-ilink, ilink_user_id), and that an empty
|
||||
// owner id skips the registration entirely.
|
||||
// TestPersistWeixinConfirmed_RegistersOwner 验证:一旦扫码登录确认
|
||||
// 把凭据持久化进 channels.json,被绑定的主人 id 就会以
|
||||
// (weixin-ilink, ilink_user_id) 交给 OwnerRegistrar,而空
|
||||
// 主人 id 会完全跳过该登记。
|
||||
func TestPersistWeixinConfirmed_RegistersOwner(t *testing.T) {
|
||||
t.Parallel()
|
||||
path := filepath.Join(t.TempDir(), "channels.json")
|
||||
@@ -375,8 +375,8 @@ func TestPersistWeixinConfirmed_RegistersOwner(t *testing.T) {
|
||||
t.Fatalf("registrar calls = %+v, want [weixin-ilink/o-1]", reg.calls)
|
||||
}
|
||||
|
||||
// An empty owner id (a confirmed bind that yields no bound user) must not
|
||||
// register anything.
|
||||
// 空的主人 id(一次确认了但没有产出绑定用户的绑定)绝不
|
||||
// 登记任何内容。
|
||||
if err := s.persistWeixinConfirmed(context.Background(), "weixin-ilink", "conf0", "tok-y", "bot-y", ""); err != nil {
|
||||
t.Fatalf("persistWeixinConfirmed(no owner): %v", err)
|
||||
}
|
||||
@@ -385,8 +385,8 @@ func TestPersistWeixinConfirmed_RegistersOwner(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestNew_WiresOwnerRegistrar verifies the composition point: Deps.OwnerRegistrar
|
||||
// is threaded onto the Server so the weixin confirm flow has a live registrar.
|
||||
// TestNew_WiresOwnerRegistrar 验证组合点:Deps.OwnerRegistrar
|
||||
// 被串到 Server 上,使 weixin 确认流程有活的 registrar。
|
||||
func TestNew_WiresOwnerRegistrar(t *testing.T) {
|
||||
t.Parallel()
|
||||
reg := &captureOwnerRegistrar{}
|
||||
|
||||
Reference in new issue
Block a user