summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMaxime Buquet <pep@bouah.net>2022-03-21 17:01:40 +0100
committerMaxime Buquet <pep@bouah.net>2022-03-21 17:01:40 +0100
commit82ff68cfacf55aa1b79aa2f84f085ca346a75a74 (patch)
treedfc04e95d6c01c68d43b62d66d520c6cacf39a3c /tests
parentfcec6742cf3cc4d46793d7a72236a101cfa13ffd (diff)
parent28d44ecf74385e4adeaa03c9fa8b561b3ca4d9a0 (diff)
downloadslixmpp-82ff68cfacf55aa1b79aa2f84f085ca346a75a74.tar.gz
slixmpp-82ff68cfacf55aa1b79aa2f84f085ca346a75a74.tar.bz2
slixmpp-82ff68cfacf55aa1b79aa2f84f085ca346a75a74.tar.xz
slixmpp-82ff68cfacf55aa1b79aa2f84f085ca346a75a74.zip
Merge branch 'upload-encrypt' into 'master'
XEP-0454: OMEMO Media Sharing See merge request poezio/slixmpp!189
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xep_0454.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/test_xep_0454.py b/tests/test_xep_0454.py
new file mode 100644
index 00000000..8d43c7e3
--- /dev/null
+++ b/tests/test_xep_0454.py
@@ -0,0 +1,41 @@
+#!/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)
+
+ def testFormatURL(self):
+ url = 'https://foo.bar'
+ fragment = 'a' * 88
+ result = XEP_0454.format_url(url, fragment)
+ self.assertEqual('aesgcm://foo.bar#' + 'a' * 88, result)
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestMediaSharing)