summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2022-03-18 15:15:24 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2022-03-19 10:31:34 +0100
commit14a6c7801d8ecaabe69a1e28a26fb0755b5ee9dd (patch)
tree6fc98876884e6dfc20c44e9b6f0461cbc4d00667 /tests
parentb52540e49f4b314640086f8f5845924af68150b2 (diff)
downloadslixmpp-14a6c7801d8ecaabe69a1e28a26fb0755b5ee9dd.tar.gz
slixmpp-14a6c7801d8ecaabe69a1e28a26fb0755b5ee9dd.tar.bz2
slixmpp-14a6c7801d8ecaabe69a1e28a26fb0755b5ee9dd.tar.xz
slixmpp-14a6c7801d8ecaabe69a1e28a26fb0755b5ee9dd.zip
tests: XEP-0454
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xep_0454.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_xep_0454.py b/tests/test_xep_0454.py
new file mode 100644
index 00000000..3d0860a9
--- /dev/null
+++ b/tests/test_xep_0454.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# vim:fenc=utf-8 et ts=4 sts=4 sw=4
+#
+# Copyright © 2022 Maxime “pep” Buquet <pep@bouah.net>
+#
+# Distributed under terms of the GPLv3+ license.
+
+"""
+ Tests for XEP-0454 (OMEMO Media Sharing) plugin.
+"""
+
+import unittest
+from io import BytesIO
+from slixmpp.test import SlixTest
+from slixmpp.plugins.xep_0454 import XEP_0454
+
+
+class TestMediaSharing(SlixTest):
+
+ def testEncryptDecryptSmall(self):
+ plain = b'qwertyuiop'
+ ciphertext, fragment = XEP_0454.encrypt(input_file=BytesIO(plain))
+ result = XEP_0454.decrypt(BytesIO(ciphertext), fragment)
+
+ self.assertEqual(plain, result)
+
+ def testEncryptDecrypt(self):
+ plain = b'a' * 4096 + b'qwertyuiop'
+ ciphertext, fragment = XEP_0454.encrypt(input_file=BytesIO(plain))
+ result = XEP_0454.decrypt(BytesIO(ciphertext), fragment)
+
+ self.assertEqual(plain, result)
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestMediaSharing)