From f19fd76c25f7b6b428cd3ffba378301ab8203832 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 1 Sep 2026 16:58:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(smoke):=20=E6=89=8B=E5=8A=A8=E8=A7=A3?= =?UTF-8?q?=E6=9E=90Set-Cookie=E2=80=94=E2=80=94cookiejar=E5=9C=A8http?= =?UTF-8?q?=E4=B8=8B=E6=8B=92=E5=AD=98Secure=20cookie=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=80=81=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/smoke/run_smoke.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/deploy/smoke/run_smoke.py b/deploy/smoke/run_smoke.py index c35764a..fcc2476 100644 --- a/deploy/smoke/run_smoke.py +++ b/deploy/smoke/run_smoke.py @@ -89,13 +89,17 @@ def main(): break if login_case and os.environ.get("SMOKE_PASS"): status, text, headers, err = req(opener, base, login_case, None, verify_ssl) - # 从 cookiejar 提取会话名 + # 手动解析 Set-Cookie(cookiejar 在 http:// 下会拒绝带 Secure 属性的 cookie) names = [] - for ck in cj: - names.append("%s=%s" % (ck.name, ck.value)) - session_cookie = "; ".join(names) - if status != 200: - print("[LOGIN-FAIL] 登录用例返回 %s,后续需登录的用例将跳过: %s" % (status, (err or text[:100]))) + if headers is not None: + for hv in headers.get_all("Set-Cookie", []): + pair = hv.split(";", 1)[0].strip() + if "=" in pair: + names.append(pair) + session_cookie = "; ".join(names) if names else None + if status != 200 or not session_cookie: + print("[LOGIN-FAIL] 登录用例返回 %s cookie=%s,后续需登录的用例将跳过: %s" + % (status, bool(session_cookie), (err or text[:100]))) passed, failed, skipped = [], [], [] for c in cases: