aboutsummaryrefslogtreecommitdiff
path: root/python/tests
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2019-06-22 17:06:02 +0000
committerMatthew Hodgson <matthew@matrix.org>2019-06-22 17:06:02 +0000
commitae38f2c5a0db711ef573276bc745ee2384a197fa (patch)
tree6029aafbda99fe85c3fac43db2646b446d564917 /python/tests
parent25662564d415b9d5486f1915c9d46e5851b058d0 (diff)
parent61175c969b1de3ecd8c25478c69d6d1883dfa211 (diff)
Merge branch 'python/unicode_decode_errors' into 'master'
Python unicode decode errors when decrypting. See merge request matrix-org/olm!4
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/group_session_test.py14
-rw-r--r--python/tests/pk_test.py8
-rw-r--r--python/tests/session_test.py9
3 files changed, 31 insertions, 0 deletions
diff --git a/python/tests/group_session_test.py b/python/tests/group_session_test.py
index c17e84f..4632a60 100644
--- a/python/tests/group_session_test.py
+++ b/python/tests/group_session_test.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import pytest
from olm import InboundGroupSession, OlmGroupSessionError, OutboundGroupSession
@@ -112,3 +113,16 @@ class TestClass(object):
outbound = OutboundGroupSession()
inbound = InboundGroupSession(outbound.session_key)
del inbound
+
+ def test_invalid_unicode_decrypt(self):
+ outbound = OutboundGroupSession()
+ inbound = InboundGroupSession(outbound.session_key)
+
+ text = outbound.encrypt(b"\xed")
+ plaintext, _ = inbound.decrypt(text)
+
+ print(plaintext)
+ assert plaintext == u"�"
+
+ plaintext, _ = inbound.decrypt(text, "ignore")
+ assert plaintext == ""
diff --git a/python/tests/pk_test.py b/python/tests/pk_test.py
index fe3b4b6..ef87465 100644
--- a/python/tests/pk_test.py
+++ b/python/tests/pk_test.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import pytest
from olm import (PkDecryption, PkDecryptionError, PkEncryption, PkSigning,
@@ -55,3 +56,10 @@ class TestClass(object):
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"�"
diff --git a/python/tests/session_test.py b/python/tests/session_test.py
index ab1c38b..b856585 100644
--- a/python/tests/session_test.py
+++ b/python/tests/session_test.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import pytest
from olm import (Account, InboundSession, OlmMessage, OlmPreKeyMessage,
@@ -141,3 +142,11 @@ class TestClass(object):
new_message = new_session.encrypt(plaintext)
assert bob_session.matches(new_message) is False
+
+ def test_invalid_unicode_decrypt(self):
+ alice, bob, session = self._create_session()
+ message = session.encrypt(b"\xed")
+
+ bob_session = InboundSession(bob, message)
+ plaintext = bob_session.decrypt(message)
+ assert plaintext == u"�"