fix(smoke): 手动解析Set-Cookie——cookiejar在http下拒存Secure cookie导致登录态丢失
This commit is contained in:
parent
b86b39e051
commit
f19fd76c25
@ -89,13 +89,17 @@ def main():
|
|||||||
break
|
break
|
||||||
if login_case and os.environ.get("SMOKE_PASS"):
|
if login_case and os.environ.get("SMOKE_PASS"):
|
||||||
status, text, headers, err = req(opener, base, login_case, None, verify_ssl)
|
status, text, headers, err = req(opener, base, login_case, None, verify_ssl)
|
||||||
# 从 cookiejar 提取会话名
|
# 手动解析 Set-Cookie(cookiejar 在 http:// 下会拒绝带 Secure 属性的 cookie)
|
||||||
names = []
|
names = []
|
||||||
for ck in cj:
|
if headers is not None:
|
||||||
names.append("%s=%s" % (ck.name, ck.value))
|
for hv in headers.get_all("Set-Cookie", []):
|
||||||
session_cookie = "; ".join(names)
|
pair = hv.split(";", 1)[0].strip()
|
||||||
if status != 200:
|
if "=" in pair:
|
||||||
print("[LOGIN-FAIL] 登录用例返回 %s,后续需登录的用例将跳过: %s" % (status, (err or text[:100])))
|
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 = [], [], []
|
passed, failed, skipped = [], [], []
|
||||||
for c in cases:
|
for c in cases:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user