Test / test (push) Failing after 25m47s
Go port of the read path of pybyd 0.0.75 (the client behind jkaberg/hass-byd-vehicle): the bangcle white-box AES envelope, the signing/checkcode layer, login, vehicle list, and realtime readings. Scraping runs on a cron schedule rather than per Prometheus request because each reading wakes the car's T-Box and drains the traction battery; /metrics serves the last result. Every numeric field of the realtime payload becomes a gauge, so the exporter does not need a hand-maintained field list that goes stale when BYD changes the payload. Tests pin the wire format against pybyd byte-for-byte and drive the client end to end against a fake cloud that speaks the real protocol. Co-Authored-By: Claude Opus 5 <[email protected]>
21 lines
938 B
Python
21 lines
938 B
Python
#!/usr/bin/env python3
|
|
"""Regenerate the Go test vectors in crypto_test.go from the reference client.
|
|
|
|
pip install --target=/tmp/pybydenv pybyd==0.0.75 cryptography
|
|
PYTHONPATH=/tmp/pybydenv python3 gen_fixtures.py
|
|
|
|
If the Go tests fail after a pybyd upgrade, run this: BYD rotating the bangcle
|
|
tables is the likely cause, and bangcle_tables.bin needs replacing too
|
|
(pybyd/data/bangcle_tables.bin inside the wheel).
|
|
"""
|
|
from pybyd._crypto.bangcle import BangcleCodec
|
|
from pybyd._crypto.hashing import md5_hex, pwd_login_key, sha1_mixed, compute_checkcode
|
|
|
|
c = BangcleCodec()
|
|
for p in ["", "hello", '{"functionType":"pwdLogin"}', "ünïcodé ✓"]:
|
|
print(f"{p!r} -> {c.encode_envelope(p)}")
|
|
print("md5Hex(hunter2) ", md5_hex("hunter2"))
|
|
print("pwdLoginKey(hunter2) ", pwd_login_key("hunter2"))
|
|
print("sha1Mixed(abc) ", sha1_mixed("abc"))
|
|
print("checkcode ", compute_checkcode({"zeta": "1", "alpha": "2"}))
|