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("""
ABC=DEFGH
"""))
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("""
=ABCDEFGH
"""))
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("""
ABCD?EFGH
"""))
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)