修正活动WSS会话guid一致性
This commit is contained in:
@@ -146,3 +146,37 @@ def test_activity_auth_frame_matches_latest_capture_layout():
|
||||
|
||||
# body 必须与 9.1 828 AUTH 同样以 TAIL_BYTES 收尾
|
||||
assert message.body[-len(TAIL_BYTES):] == TAIL_BYTES
|
||||
|
||||
|
||||
def test_activity_cookie_guid_is_replaced_by_launch_guid():
|
||||
old = "0a" + "1" * 30
|
||||
new = "0a" + "2" * 30
|
||||
cookie = f"udb_uid=1; guid={old}; x=y; guid={old}"
|
||||
|
||||
result = HuyaWssClient._cookie_with_guid(cookie, new)
|
||||
|
||||
assert result == f"udb_uid=1; guid={new}; x=y"
|
||||
|
||||
|
||||
def test_activity_auth_accepts_explicit_launch_guid_over_cookie_guid():
|
||||
async def build_frame():
|
||||
client = HuyaWssClient()
|
||||
client._activity_mode = True
|
||||
client.ws = type("FakeWs", (), {"send": AsyncMock()})()
|
||||
await client.send_auth(
|
||||
1199664135026,
|
||||
"guid=" + "0a" * 16 + "; udb_cred=" + "x" * 300,
|
||||
sequence=0x1D000109,
|
||||
guid="0b" * 16,
|
||||
)
|
||||
return client.ws.send.call_args.args[0]
|
||||
|
||||
message = WssMessage.decode(asyncio.run(build_frame()))
|
||||
stream = TafInputStream(message.body[: -len(TAIL_BYTES)])
|
||||
assert stream.read_head() == (3, TafType.ZERO)
|
||||
stream.read_int64(0)
|
||||
stream.read_string(1)
|
||||
assert stream.read_head() == (2, TafType.STRING4)
|
||||
cookie_len = int.from_bytes(stream.buf.read(4), "big")
|
||||
stream.buf.read(cookie_len)
|
||||
assert stream.read_string(3) == "0b" * 16
|
||||
|
||||
Reference in New Issue
Block a user