summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0047.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-02-02 19:19:50 +0100
committerLance Stout <lancestout@gmail.com>2012-02-02 19:19:50 +0100
commit4665c5cf1acf22bd3988682c2942ce0c50d897c4 (patch)
tree6f8c052fbc529e5302878d811d4c969d2d5fc74d /tests/test_stanza_xep_0047.py
parentbd52a5e6c12237e1ab4ceaf0d5933f3e5109800e (diff)
downloadslixmpp-4665c5cf1acf22bd3988682c2942ce0c50d897c4.tar.gz
slixmpp-4665c5cf1acf22bd3988682c2942ce0c50d897c4.tar.bz2
slixmpp-4665c5cf1acf22bd3988682c2942ce0c50d897c4.tar.xz
slixmpp-4665c5cf1acf22bd3988682c2942ce0c50d897c4.zip
Fix data stanza based on test results.
Diffstat (limited to 'tests/test_stanza_xep_0047.py')
-rw-r--r--tests/test_stanza_xep_0047.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0047.py b/tests/test_stanza_xep_0047.py
new file mode 100644
index 00000000..1b212529
--- /dev/null
+++ b/tests/test_stanza_xep_0047.py
@@ -0,0 +1,77 @@
+from sleekxmpp.test import *
+from sleekxmpp.plugins.xep_0047 import Data
+
+
+class TestIBB(SleekTest):
+
+ def setUp(self):
+ register_stanza_plugin(Iq, Data)
+
+ def testInvalidBase64MidEqual(self):
+ """
+ Test detecting invalid base64 data with = inside the
+ character data instead of at the end.
+ """
+ iq = Iq(xml=ET.fromstring("""
+ <iq type="set" id="0" to="tester@localhost">
+ <data xmlns="http://jabber.org/protocol/ibb" seq="0">
+ ABC=DEFGH
+ </data>
+ </iq>
+ """))
+
+ errored = False
+
+ try:
+ data = iq['ibb_data']['data']
+ except XMPPError:
+ errored = True
+
+ self.assertTrue(errored, "ABC=DEFGH did not raise base64 error")
+
+ def testInvalidBase64PrefixEqual(self):
+ """
+ Test detecting invalid base64 data with = as a prefix
+ to the character data.
+ """
+ iq = Iq(xml=ET.fromstring("""
+ <iq type="set" id="0" to="tester@localhost">
+ <data xmlns="http://jabber.org/protocol/ibb" seq="0">
+ =ABCDEFGH
+ </data>
+ </iq>
+ """))
+
+ errored = False
+
+ try:
+ data = iq['ibb_data']['data']
+ except XMPPError:
+ errored = True
+
+ self.assertTrue(errored, "=ABCDEFGH did not raise base64 error")
+
+ def testInvalidBase64Alphabet(self):
+ """
+ Test detecting invalid base64 data with characters
+ outside of the base64 alphabet.
+ """
+ iq = Iq(xml=ET.fromstring("""
+ <iq type="set" id="0" to="tester@localhost">
+ <data xmlns="http://jabber.org/protocol/ibb" seq="0">
+ ABCD?EFGH
+ </data>
+ </iq>
+ """))
+
+ errored = False
+
+ try:
+ data = iq['ibb_data']['data']
+ except XMPPError:
+ errored = True
+
+ self.assertTrue(errored, "ABCD?EFGH did not raise base64 error")
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestIBB)