diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-11-05 01:45:06 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-11-05 01:45:06 +0100 |
commit | 2a8202e74846d191a321cca1202175af9db6107d (patch) | |
tree | a6f455caf07da1186851f343a237a4c4e4484f46 /python/tests/account_test.py | |
parent | 8efa0ec17d8c262f9c3fd7603e8074f74a053708 (diff) |
Diffstat (limited to 'python/tests/account_test.py')
-rw-r--r-- | python/tests/account_test.py | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/python/tests/account_test.py b/python/tests/account_test.py deleted file mode 100644 index f3b71eb..0000000 --- a/python/tests/account_test.py +++ /dev/null @@ -1,114 +0,0 @@ -from builtins import int - -import pytest - -from olm import Account, OlmAccountError, OlmVerifyError, ed25519_verify -from olm._compat import to_bytes - - -class TestClass(object): - def test_to_bytes(self): - assert isinstance(to_bytes("a"), bytes) - assert isinstance(to_bytes(u"a"), bytes) - assert isinstance(to_bytes(b"a"), bytes) - assert isinstance(to_bytes(r"a"), bytes) - with pytest.raises(TypeError): - to_bytes(0) - - def test_account_creation(self): - alice = Account() - assert alice.identity_keys - assert len(alice.identity_keys) == 2 - - def test_account_pickle(self): - alice = Account() - pickle = alice.pickle() - assert (alice.identity_keys == Account.from_pickle(pickle) - .identity_keys) - - def test_invalid_unpickle(self): - with pytest.raises(ValueError): - Account.from_pickle(b"") - - def test_passphrase_pickle(self): - alice = Account() - passphrase = "It's a secret to everybody" - pickle = alice.pickle(passphrase) - assert (alice.identity_keys == Account.from_pickle( - pickle, passphrase).identity_keys) - - def test_wrong_passphrase_pickle(self): - alice = Account() - passphrase = "It's a secret to everybody" - pickle = alice.pickle(passphrase) - - with pytest.raises(OlmAccountError): - Account.from_pickle(pickle, "") - - def test_one_time_keys(self): - alice = Account() - alice.generate_one_time_keys(10) - one_time_keys = alice.one_time_keys - assert one_time_keys - assert len(one_time_keys["curve25519"]) == 10 - - def test_max_one_time_keys(self): - alice = Account() - assert isinstance(alice.max_one_time_keys, int) - - def test_publish_one_time_keys(self): - alice = Account() - alice.generate_one_time_keys(10) - one_time_keys = alice.one_time_keys - - assert one_time_keys - assert len(one_time_keys["curve25519"]) == 10 - - alice.mark_keys_as_published() - assert not alice.one_time_keys["curve25519"] - - def test_clear(self): - alice = Account() - del alice - - def test_valid_signature(self): - message = "It's a secret to everybody" - alice = Account() - - signature = alice.sign(message) - signing_key = alice.identity_keys["ed25519"] - - assert signature - assert signing_key - - ed25519_verify(signing_key, message, signature) - - def test_invalid_signature(self): - message = "It's a secret to everybody" - alice = Account() - bob = Account() - - signature = alice.sign(message) - signing_key = bob.identity_keys["ed25519"] - - assert signature - assert signing_key - - with pytest.raises(OlmVerifyError): - ed25519_verify(signing_key, message, signature) - - def test_signature_verification_twice(self): - message = "It's a secret to everybody" - alice = Account() - - signature = alice.sign(message) - signing_key = alice.identity_keys["ed25519"] - - assert signature - assert signing_key - - ed25519_verify(signing_key, message, signature) - assert signature == alice.sign(message) - - ed25519_verify(signing_key, message, signature) - assert signature == alice.sign(message) |