企业微信
This commit is contained in:
1 parent
46ac70f4c5
commit
a9fc852abb
33 files changed
+4875
-106
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import base64
|
||||
|
||||
from app.services.wecom_crypto import decrypt_wecom_aes, encrypt_wecom_aes, sha1_hex
|
||||
|
||||
|
||||
def test_wecom_aes_roundtrip():
|
||||
corp_id = 'ww1234567890abcdef'
|
||||
aes_key_b64 = base64.b64encode(b'0' * 32).decode('ascii').rstrip('=')
|
||||
xml = '<xml><MsgType><![CDATA[event]]></MsgType></xml>'
|
||||
cipher = encrypt_wecom_aes(xml, aes_key_b64, corp_id)
|
||||
plain = decrypt_wecom_aes(cipher, aes_key_b64, corp_id)
|
||||
assert plain == xml
|
||||
|
||||
|
||||
def test_wecom_msg_signature():
|
||||
token = 'hxops-token'
|
||||
ts = '123'
|
||||
nonce = 'abc'
|
||||
encrypt = 'cipher-text'
|
||||
sig = sha1_hex([token, ts, nonce, encrypt])
|
||||
assert sha1_hex([token, ts, nonce, encrypt]) == sig
|
||||
Reference in new issue
Block a user