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: