Skip to content

Commit

Permalink
feat: add more test cover
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jun 16, 2023
1 parent 6c89e3a commit bab1e20
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
exclude = docs
max-line-length = 88
max-line-length = 588
52 changes: 52 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,55 @@ def test_roundtrip():
decrypted = decrypt(encrypted[4:])
assert isinstance(decrypted, str)
assert d == decrypted


def test_decrypt_real_device():
input = (
b"\xd0\xf2\x81\xf8\x8b\xff\x9a\xf7\xd5\xef\x94\xb6\xd1\xb4\xc0\x9f"
b"\xec\x95\xe6\x8f\xe1\x87\xe8\xca\xf0\x8b\xa9\xda\xad\xf2\x84\xe1"
b"\x93\xb1\x8b\xa9\x98\xb6\x86\xa8\x9a\xba\xf8\x8d\xe4\x88\xec\xcc"
b"\xfe\xcf\xff\xce\xfe\xcb\xeb\xb9\xdc\xb0\x9e\xaf\x99\xac\x95\xa6"
b"\x9e\xbc\x90\xb2\xda\xad\xf2\x84\xe1\x93\xb1\x8b\xa9\x98\xb6\x86"
b"\xa4\x88\xaa\xc7\xa8\xcc\xa9\xc5\xe7\xdd\xff\xba\xea\xde\xee\xc6"
b"\x93\xc0\xe9\xcb\xe7\xc5\xa1\xc4\xb2\xdb\xb8\xdd\x94\xf0\xd2\xe8"
b"\xca\xf2\xc2\xf2\xc4\xf6\xc5\xf4\xb1\x80\xb4\x8d\xb4\xf6\xb7\xf4"
b"\xc0\x84\xb0\xf2\xb1\x86\xc3\x85\xc6\x82\xb6\xf4\xc4\xf3\xc6\xf7"
b"\xcf\xfe\xbb\x8d\xbe\x87\xb4\xf2\xc0\xe2\xce\xec\x83\xe6\x8b\xc2"
b"\xa6\x84\xbe\x9c\xae\xe8\xd1\xe3\xd2\xe7\xa1\x90\xd4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"\xce\xaa\xf5\x9a\xfc\x9a\xb8\x82\xb2\x9e\xbc\xdf\xb7\xde\xb2\xd6"
b"\xa4\xc1\xaf\x8d\xb7\xec\x97\xb5\xdc\xb8\x9a\xa0\x82\xb2\x82\xa0"
b"\x8c\xae\xdd\xa9\xc8\xbc\xd9\xfb\xc1\xf0\xdc\xfe\x9f\xf3\x9a\xfb"
b"\x88\xaa\x90\xb2\xe8\x87\xea\x88\xe1\x84\xa6\x8a\xa8\xc7\xa9\xf6"
b"\x82\xeb\x86\xe3\xc1\xfb\xcf\xf8\xc8\xe4\xc6\xa8\xcd\xb5\xc1\x9e"
b"\xff\x9c\xe8\x81\xee\x80\xa2\x98\xe3\xc1\xb5\xcc\xbc\xd9\xfb\xc1"
b"\xec\xdd\xa0\xdd\xf1\x8a\xa8\xc1\xa5\x87\xbd\x9f\xaf\x9e\xbc\x90"
b"\xb2\xc1\xb5\xd4\xa0\xc5\xe7\xdd\xec\xc0\xe2\x83\xef\x86\xe7\x94"
b"\xb6\x8c\xae\xe3\x82\xe5\x8c\xef\xcd\xe1\xc3\xac\xc2\x9d\xe9\x80"
b"\xed\x88\xaa\x90\xa1\x96\xa2\x8e\xac\xc2\xa7\xdf\xab\xf4\x95\xf6"
b"\x82\xeb\x84\xea\xc8\xf2\x89\xab\xdf\xa6\xd6\xb3\x91\xab\x86\xb7"
b"\xca\xb7\xea\xc6\xe4\x87\xef\x86\xea\x8e\xd1\xbf\xca\xa7\x85\xbf"
b"\x8d\xa1\x83\xed\x99\xfa\xa5\xd6\xa2\xc3\xb7\xd2\xf0\xca\xfa\xd6"
b"\xf4\x91\xe3\x91\xce\xad\xc2\xa6\xc3\xe1\xdb\xeb\x96\xeb\x96"
)
decrypted = decrypt(input)
assert (
decrypted == '{"system":{"get_sysinfo":{"sw_ver":"1.0.2 Build 210105'
' Rel.165938","hw_ver":"1.0","model":"EP40(US)","deviceId":"8006231E1499BAC4D4BC7EFCD4B075181E6393F2","oemId":"2F9215F1DCBF7DC17F80E2B0CACD47FC","hwId":"B3B7B05B758C3EDA8F9C69FECDBA2111","rssi":-40,"latitude_i":297852,"longitude_i":-954073,"alias":"TP-LINK_Smart'
' Plug_004F","status":"new","mic_type":"IOT.SMARTPLUGSWITCH","feature":"TIM","mac":"E8:48:B8:1E:00:4F","updating":0,"led_off":0,"children":[{"id":"00","state":1,"alias":"Zombie","on_time":470,"next_action":{"type":-1}},{"id":"01","state":1,"alias":"Magic","on_time":174,"next_action":{"type":-1}}],"child_num":2,"ntc_state":0,"err_code":0}}}'
)

0 comments on commit bab1e20

Please sign in to comment.