自动化:迁移通用 Cookie 单值回退读取
This commit is contained in:
1 parent
04e1aab2e8
commit
0cd4109014
3 files changed
+27
-3
No files matched your search
@@ -114,7 +114,8 @@ app shell / routes
|
||||
- 已完成阶段 2 后续切片:`internal/renewal/scheduler.go` 已改用 `RenewalRuntimeAccount` 窄模型及按账号重读接口,只解密 Cookie、续期 metadata 和启用状态,不再把登录密码/用户名带入续期调度器;
|
||||
- 已完成阶段 2 后续切片:`internal/automation/account_tasks.go` 的 Session 阻断指纹已改用 `GetCookieRuntimeData`,只读取 Cookie 与 metadata,不再解密完整账号详情;
|
||||
- 已完成阶段 2 后续切片:`internal/automation/center.go` 的确认发货流程已改用 `GetCookieRuntimeData`,只读取 Cookie 与 metadata,保留凭证锁、Cookie Jar 和重试行为;
|
||||
- 下一最小工作项:将 `internal/automation/center.go` 的通用 `cookieValue` 回退读取迁移到已有的单值 `GetValue` 接口,继续清除完整详情读取;
|
||||
- 已完成阶段 2 后续切片:`internal/automation/center.go` 的通用 `cookieValue` 回退读取已迁移到 `GetValue`,Automation 生产代码不再直接读取完整账号详情;
|
||||
- 下一最小工作项:为 `internal/engine/account.go` 的登录态检查流程建立 Cookie/metadata 窄读取,先处理 `tryLoginStatusCheck`,不改变重试和续期行为;
|
||||
- 随后工作项:再处理 Engine、Automation 等明确需要平台凭证的流程,统一使用按账号 ID 过滤的单值凭证接口;
|
||||
- 禁止跳过当前入口直接开始 Engine、Automation 或 DB 的大规模拆分。
|
||||
|
||||
|
||||
@@ -1154,11 +1154,11 @@ func (c *Center) cookieValue(ctx context.Context, cookieID string) (string, erro
|
||||
if c.cookieSrc != nil {
|
||||
return c.cookieSrc(ctx, cookieID)
|
||||
}
|
||||
d, err := c.store.Cookies.GetDetails(ctx, cookieID)
|
||||
value, err := c.store.Cookies.GetValue(ctx, cookieID) // value 是只读取账号 Cookie 明文的单值结果,不会展开完整账号详情。
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return d.Value, nil
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func (c *Center) markEventFacts(ctx context.Context, task Task) error {
|
||||
|
||||
@@ -1317,3 +1317,26 @@ func TestReviewRequestCounterFailureMovesCompletedActionToNeedsReview(t *testing
|
||||
t.Fatalf("status=%q message=%q", status, message)
|
||||
}
|
||||
}
|
||||
|
||||
// TestCookieValueFallbackUsesSingleValueQuery 验证订单详情补全的 Cookie 回退不会读取登录密码等完整账号字段。
|
||||
func TestCookieValueFallbackUsesSingleValueQuery(t *testing.T) {
|
||||
t.Setenv("XIANYU_DATA_KEY", "cookie-value-fallback-key")
|
||||
// store 是当前测试使用的 SQLite repository 聚合器。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// ctx 是测试数据库操作共用的上下文。
|
||||
ctx := context.Background()
|
||||
// corruptErr 表示写入故意损坏的登录密码失败的原因。
|
||||
if _, corruptErr := store.DB.ExecContext(ctx,
|
||||
`UPDATE cookies SET username=?,password=? WHERE id=?`,
|
||||
"fallback-user", "not-a-password-ciphertext", "cid"); corruptErr != nil {
|
||||
t.Fatalf("corrupt password: %v", corruptErr)
|
||||
}
|
||||
// center 是待验证 Cookie 回退读取逻辑的自动化中心。
|
||||
center := New(store, nil, nil)
|
||||
// value 是单值查询返回的 Cookie 明文。
|
||||
value, valueErr := center.cookieValue(ctx, "cid")
|
||||
if valueErr != nil || value != "unb=123; _m_h5_tk=tk_1;" {
|
||||
t.Fatalf("cookieValue value=%q err=%v", value, valueErr)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user