tests: XEP-0454
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
b52540e49f
commit
14a6c7801d
1 changed files with 35 additions and 0 deletions
35
tests/test_xep_0454.py
Normal file
35
tests/test_xep_0454.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue