fix: 导入 DramaBox 凭据后先核对个人信息
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from server.services.dramabox.app_api import account_from_bootstrap
|
||||
from server.services.dramabox.login import _credential_record
|
||||
|
||||
|
||||
@@ -35,6 +36,27 @@ def test_credential_file_is_one_json_document() -> None:
|
||||
raise AssertionError("不完整的凭据文件应被拒绝")
|
||||
|
||||
|
||||
def test_account_profile_must_match_the_credential() -> None:
|
||||
app = {"user_id": "88", "token": "Bearer old"}
|
||||
fresh = account_from_bootstrap(app, {"user": {"uid": "88", "token": "new", "nickname": "阿花", "isVip": 1}})
|
||||
assert fresh["token"] == "Bearer new"
|
||||
assert fresh["name"] == "阿花"
|
||||
assert fresh["vip"] is True
|
||||
try:
|
||||
account_from_bootstrap(app, {"user": {"uid": "99", "token": "new", "nickname": "别人"}})
|
||||
except RuntimeError as exc:
|
||||
assert "失效" in str(exc)
|
||||
else:
|
||||
raise AssertionError("用户编号不一致应视为未登录")
|
||||
try:
|
||||
account_from_bootstrap(app, {})
|
||||
except RuntimeError as exc:
|
||||
assert "失效" in str(exc)
|
||||
else:
|
||||
raise AssertionError("没有个人信息应视为未登录")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_credential_file_is_one_json_document()
|
||||
test_account_profile_must_match_the_credential()
|
||||
print("ok")
|
||||
|
||||
Reference in New Issue
Block a user