aboutsummaryrefslogtreecommitdiff
path: root/python/tests/pk_test.py
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-05 01:45:06 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-05 01:45:06 +0100
commit2a8202e74846d191a321cca1202175af9db6107d (patch)
treea6f455caf07da1186851f343a237a4c4e4484f46 /python/tests/pk_test.py
parent8efa0ec17d8c262f9c3fd7603e8074f74a053708 (diff)
Convert to sibs projectHEADmaster
Diffstat (limited to 'python/tests/pk_test.py')
-rw-r--r--python/tests/pk_test.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/python/tests/pk_test.py b/python/tests/pk_test.py
deleted file mode 100644
index ef87465..0000000
--- a/python/tests/pk_test.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- coding: utf-8 -*-
-import pytest
-
-from olm import (PkDecryption, PkDecryptionError, PkEncryption, PkSigning,
- ed25519_verify)
-
-
-class TestClass(object):
- def test_invalid_encryption(self):
- with pytest.raises(ValueError):
- PkEncryption("")
-
- def test_decrytion(self):
- decryption = PkDecryption()
- encryption = PkEncryption(decryption.public_key)
- plaintext = "It's a secret to everybody."
- message = encryption.encrypt(plaintext)
- decrypted_plaintext = decryption.decrypt(message)
- isinstance(decrypted_plaintext, str)
- assert plaintext == decrypted_plaintext
-
- def test_invalid_decrytion(self):
- decryption = PkDecryption()
- encryption = PkEncryption(decryption.public_key)
- plaintext = "It's a secret to everybody."
- message = encryption.encrypt(plaintext)
- message.ephemeral_key = "?"
- with pytest.raises(PkDecryptionError):
- decryption.decrypt(message)
-
- def test_pickling(self):
- decryption = PkDecryption()
- encryption = PkEncryption(decryption.public_key)
- plaintext = "It's a secret to everybody."
- message = encryption.encrypt(plaintext)
-
- pickle = decryption.pickle()
- unpickled = PkDecryption.from_pickle(pickle)
- decrypted_plaintext = unpickled.decrypt(message)
- assert plaintext == decrypted_plaintext
-
- def test_invalid_unpickling(self):
- with pytest.raises(ValueError):
- PkDecryption.from_pickle("")
-
- def test_invalid_pass_pickling(self):
- decryption = PkDecryption()
- pickle = decryption.pickle("Secret")
-
- with pytest.raises(PkDecryptionError):
- PkDecryption.from_pickle(pickle, "Not secret")
-
- def test_signing(self):
- seed = PkSigning.generate_seed()
- signing = PkSigning(seed)
- message = "This statement is true"
- signature = signing.sign(message)
- ed25519_verify(signing.public_key, message, signature)
-
- def test_invalid_unicode_decrypt(self):
- decryption = PkDecryption()
- encryption = PkEncryption(decryption.public_key)
- message = encryption.encrypt(b"\xed")
- plaintext = decryption.decrypt(message)
- assert plaintext == u"�"