fix(weibo): 识别支付域登录失效
This commit is contained in:
@@ -205,6 +205,22 @@ def test_refresh_marks_payment_access_failure(db, current_user):
|
||||
assert "触发微博账号风控" in account.ck_check_message
|
||||
|
||||
|
||||
def test_refresh_marks_payment_login_expiry_as_invalid(db, current_user):
|
||||
account_out = import_cookies(
|
||||
WeiboCookieImport(text="SCF=a; SUB=b", tag=""),
|
||||
db=db,
|
||||
current=current_user,
|
||||
).accounts[0]
|
||||
account = db.query(WeiboAccount).filter(WeiboAccount.id == account_out.id).one()
|
||||
StubWeiboClient.payment_error = WeiboAuthError("支付域 retcode=6102")
|
||||
|
||||
with pytest.raises(WeiboAuthError, match="6102"):
|
||||
weibo_service.refresh_weibo_account(db, account)
|
||||
|
||||
assert account.ck_check_status == "invalid"
|
||||
assert "6102" in account.ck_check_message
|
||||
|
||||
|
||||
def test_list_accounts_returns_parallel_page_shape(db, current_user):
|
||||
assert (
|
||||
import_cookies(
|
||||
|
||||
@@ -17,6 +17,7 @@ from core.weibo import (
|
||||
WeiboExchangeUncertainError,
|
||||
WeiboHomeSnapshot,
|
||||
WeiboRechargeError,
|
||||
WeiboTransportError,
|
||||
extract_bind_raw_url,
|
||||
normalize_weibo_cookie,
|
||||
)
|
||||
@@ -50,7 +51,7 @@ class FakeResponse:
|
||||
|
||||
def json(self):
|
||||
if not isinstance(self.payload, dict):
|
||||
raise TypeError("not json")
|
||||
raise requests.exceptions.JSONDecodeError("not json", self.text, 0)
|
||||
return self.payload
|
||||
|
||||
|
||||
@@ -155,6 +156,30 @@ def test_fetch_home_keeps_trace_id_for_other_api_error():
|
||||
client.fetch_home()
|
||||
|
||||
|
||||
def test_fetch_home_treats_sina_login_redirect_as_auth_error():
|
||||
session = FakeSession(
|
||||
[
|
||||
(
|
||||
"<html><head><meta http-equiv='refresh' "
|
||||
"content=\"0; url='https://vipclub.weibo.com/aj/vmember/"
|
||||
"gfsupport?retcode=6102'\"></head></html>"
|
||||
)
|
||||
]
|
||||
)
|
||||
client = WeiboClient("SUB=expired", session=session)
|
||||
|
||||
with pytest.raises(WeiboAuthError, match="重新登录微博"):
|
||||
client.fetch_home()
|
||||
|
||||
|
||||
def test_fetch_home_reports_non_json_endpoint_path():
|
||||
session = FakeSession(["<html><body>gateway error</body></html>"])
|
||||
client = WeiboClient("SUB=test", session=session)
|
||||
|
||||
with pytest.raises(WeiboTransportError, match="/aj/mall/home"):
|
||||
client.fetch_home()
|
||||
|
||||
|
||||
def test_generate_bind_scheme_posts_account_type_without_weibo_cookie():
|
||||
session = FakeSession(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user