def test_unencrypted_import(self, tempdir): device_id = "DEVICEID" file = path.join(tempdir, "keys_file") with open(file, "w") as f: f.write("{}") alice_store = DefaultStore("alice", device_id, tempdir, "") alice = Olm("alice", device_id, alice_store) with pytest.raises(EncryptionError): alice.import_keys(file, "pass")
def test_invalid_json_schema(self, tempdir): device_id = "DEVICEID" file = path.join(tempdir, "keys_file") payload = {"sessions": [{"algorithm": "test"}]} encrypt_and_save(json.dumps(payload).encode(), file, "pass", count=10) alice_store = DefaultStore("alice", device_id, tempdir, "") alice = Olm("alice", device_id, alice_store) with pytest.raises(EncryptionError): alice.import_keys(file, "pass")
def store(tempdir): store = DefaultStore("ephemeral", "DEVICEID", tempdir) account = OlmAccount() store.save_account(account) return store