fix: 登录写入安全 Cookie 时不再被当前 httpx 拒绝
This commit is contained in:
@@ -12,6 +12,7 @@ from euniv.client import (
|
||||
make_qr_payload,
|
||||
parse_uac,
|
||||
qr_data_uri,
|
||||
set_cookie,
|
||||
)
|
||||
from euniv.crypto import decrypt_secret
|
||||
from euniv.db import SessionLocal
|
||||
@@ -150,3 +151,17 @@ def test_qr_login_stores_scan_mark(monkeypatch) -> None:
|
||||
assert stored["ucs_token"] == "ucs-qr"
|
||||
assert stored["yxt_token"] == "yxt-qr"
|
||||
assert "secret" not in decrypt_secret(account.password_cipher)
|
||||
|
||||
|
||||
def test_secure_cookie_is_written_through_the_jar() -> None:
|
||||
client = EunivClient("6650000146", "secret-pass")
|
||||
try:
|
||||
set_cookie(client.client.cookies, "PORTALSSOCookie", "token", domain="zte.com.cn", path="/", secure=True)
|
||||
client.restore({"yxt_token": "learning-token", "ucs_token": "ucs", "ucs_account_id": "6650000146"})
|
||||
portal = [item for item in client.client.cookies.jar if item.name == "PORTALSSOCookie"]
|
||||
learning = [item for item in client.client.cookies.jar if item.name == "ELEARNING_00024"]
|
||||
assert portal and portal[0].secure is True
|
||||
assert len(learning) == 2
|
||||
assert all(item.secure for item in learning)
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
Reference in New Issue
Block a user