summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-09-18 17:49:52 +0900
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-11-26 16:29:19 +0000
commit4847f834bd8f6a1168851b0918c080fc0e6c13b8 (patch)
tree7b3fee45bf53ca1e9f07835a9f82cb3731309dfd /tests
parent53191ff1cfb25036da84efbd3d171dc1c64e82ac (diff)
downloadslixmpp-4847f834bd8f6a1168851b0918c080fc0e6c13b8.tar.gz
slixmpp-4847f834bd8f6a1168851b0918c080fc0e6c13b8.tar.bz2
slixmpp-4847f834bd8f6a1168851b0918c080fc0e6c13b8.tar.xz
slixmpp-4847f834bd8f6a1168851b0918c080fc0e6c13b8.zip
Add a plugin for XEP-0380: Explicit Message Encryption.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stanza_xep_0380.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0380.py b/tests/test_stanza_xep_0380.py
new file mode 100644
index 00000000..9ed349bf
--- /dev/null
+++ b/tests/test_stanza_xep_0380.py
@@ -0,0 +1,37 @@
+import unittest
+from slixmpp import Message
+from slixmpp.test import SlixTest
+import slixmpp.plugins.xep_0380 as xep_0380
+from slixmpp.xmlstream import register_stanza_plugin
+
+
+class TestEME(SlixTest):
+
+ def setUp(self):
+ register_stanza_plugin(Message, xep_0380.stanza.Encryption)
+
+ def testCreateEME(self):
+ """Testing creating EME."""
+
+ xmlstring = """
+ <message>
+ <encryption xmlns="urn:xmpp:eme:0" namespace="%s"%s />
+ </message>
+ """
+
+ msg = self.Message()
+ self.check(msg, "<message />")
+
+ msg['eme']['namespace'] = 'urn:xmpp:otr:0'
+ self.check(msg, xmlstring % ('urn:xmpp:otr:0', ''))
+
+ msg['eme']['namespace'] = 'urn:xmpp:openpgp:0'
+ self.check(msg, xmlstring % ('urn:xmpp:openpgp:0', ''))
+
+ msg['eme']['name'] = 'OX'
+ self.check(msg, xmlstring % ('urn:xmpp:openpgp:0', ' name="OX"'))
+
+ del msg['eme']
+ self.check(msg, "<message />")
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestEME)