summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0380.py
blob: 9ed349bf7c0628d39657208fb9e78aa87e541782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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)