Skip to content

Commit

Permalink
fix tests directory
Browse files Browse the repository at this point in the history
in the future, it might be better to do not repeat tests/res 100 times
  • Loading branch information
ElDavoo authored Apr 1, 2024
1 parent e1a2bb7 commit db211e3
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/test_waencrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,49 @@

class Test_Encryption:
def test_encryption15(self):
key = KeyFactory.new("res/encrypted_backup.key")
key = KeyFactory.new("tests/res/encrypted_backup.key")
props = Props(wa_version="2.22.5.13", jid="67", features=[5,7,8,13,14,19,22,25,28,30,31,32,36,37], max_feature=37)
db = Database15(key=key, iv=bytes.fromhex("C395EE009CF8B68AC0EA760550F6559C"))
data = db.encrypt(key, props, zlib.compress(open("res/msgstore.db", 'rb').read(), 1, 15))
data = db.encrypt(key, props, zlib.compress(open("tests/res/msgstore.db", 'rb').read(), 1, 15))
new_check = sha512(data).digest()
with open("res/msgstore-new.db.crypt15", 'wb') as f:
with open("tests/res/msgstore-new.db.crypt15", 'wb') as f:
f.write(data)
with open("res/msgstore.db.crypt15", 'rb') as f:
with open("tests/res/msgstore.db.crypt15", 'rb') as f:
orig_check = sha512(f.read()).digest()
assert new_check == orig_check

def test_encryption14(self):
key = KeyFactory.new("res/key")
key = KeyFactory.new("tests/res/key")
props = Props(wa_version="2.22.5.13", jid="67", features=[5,7,8,13,14,19,22,25,28,30,31,32,36,37], max_feature=37)
db = Database14(key=key, iv=bytes.fromhex("EA53CEAE36ECAB50BC331AEB62491625"))
data = db.encrypt(key, props, zlib.compress(open("res/msgstore.db", 'rb').read(), 1, 15))
data = db.encrypt(key, props, zlib.compress(open("tests/res/msgstore.db", 'rb').read(), 1, 15))
new_check = sha512(data).digest()
with open("res/msgstore-new.db.crypt14", 'wb') as f:
with open("tests/res/msgstore-new.db.crypt14", 'wb') as f:
f.write(data)
with open("res/msgstore.db.crypt14", 'rb') as f:
with open("tests/res/msgstore.db.crypt14", 'rb') as f:
orig_check = sha512(f.read()).digest()
assert new_check == orig_check

def test_encryption14_noexpiry(self):
key = KeyFactory.new("res/key")
key = KeyFactory.new("tests/res/key")
props = Props(wa_version="2.22.5.13", jid="67", features=None)
db = Database14(key=key, iv=bytes.fromhex("EA53CEAE36ECAB50BC331AEB62491625"))
data = db.encrypt(key, props, zlib.compress(open("res/msgstore.db", 'rb').read(), 1, 15))
data = db.encrypt(key, props, zlib.compress(open("tests/res/msgstore.db", 'rb').read(), 1, 15))
new_check = sha512(data).digest()
with open("res/msgstore-new.db.crypt14", 'wb') as f:
with open("tests/res/msgstore-new.db.crypt14", 'wb') as f:
f.write(data)
with open("res/msgstore-noexpiry.db.crypt14", 'rb') as f:
with open("tests/res/msgstore-noexpiry.db.crypt14", 'rb') as f:
orig_check = sha512(f.read()).digest()
assert new_check == orig_check

def test_encryption12(self):
key = KeyFactory.new("res/key")
key = KeyFactory.new("tests/res/key")
props = Props(wa_version="2.22.5.13", jid="67", features=None)
db = Database12(key=key, iv=bytes.fromhex("F4E9A6DC0B6F0D8986AF6C7180F02356"))
data = db.encrypt(key, props, zlib.compress(open("res/msgstore.db", 'rb').read(), 1, 15))
data = db.encrypt(key, props, zlib.compress(open("tests/res/msgstore.db", 'rb').read(), 1, 15))
new_check = sha512(data).digest()
with open("res/msgstore-new.db.crypt12", 'wb') as f:
with open("tests/res/msgstore-new.db.crypt12", 'wb') as f:
f.write(data)
with open("res/msgstore.db.crypt12", 'rb') as f:
with open("tests/res/msgstore.db.crypt12", 'rb') as f:
orig_check = sha512(f.read()).digest()
assert new_check == orig_check

0 comments on commit db211e3

Please sign in to comment.