summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsetup.py1
-rw-r--r--tests/test_stream_handlers.py53
2 files changed, 54 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index d9041af5..c89b0b09 100755
--- a/setup.py
+++ b/setup.py
@@ -42,6 +42,7 @@ CLASSIFIERS = [ 'Intended Audience :: Developers',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
+ 'Programming Language :: Python :: 3.3',
'Topic :: Software Development :: Libraries :: Python Modules',
]
diff --git a/tests/test_stream_handlers.py b/tests/test_stream_handlers.py
index ef46da6a..0208cd16 100644
--- a/tests/test_stream_handlers.py
+++ b/tests/test_stream_handlers.py
@@ -1,4 +1,5 @@
import time
+import threading
import unittest
from sleekxmpp.test import SleekTest
@@ -226,5 +227,57 @@ class TestHandlers(SleekTest):
</message>
""")
+ def testWrongSender(self):
+ """
+ Test that using the wrong sender JID in a IQ result
+ doesn't trigger handlers.
+ """
+
+ events = []
+
+ def run_test():
+ # Check that Iq was sent by waiter_handler
+ iq = self.Iq()
+ iq['id'] = 'test'
+ iq['to'] = 'tester@sleekxmpp.com/test'
+ iq['type'] = 'set'
+ iq['query'] = 'test'
+ result = iq.send()
+ events.append(result['from'].full)
+
+ t = threading.Thread(name="sender_test", target=run_test)
+ t.start()
+
+ self.recv("""
+ <iq id="test" from="evil@sleekxmpp.com/bad" type="result">
+ <query xmlns="test" />
+ </iq>
+ """)
+ self.recv("""
+ <iq id="test" from="evil2@sleekxmpp.com" type="result">
+ <query xmlns="test" />
+ </iq>
+ """)
+ self.recv("""
+ <iq id="test" from="evil.com" type="result">
+ <query xmlns="test" />
+ </iq>
+ """)
+
+ # Now for a good one
+ self.recv("""
+ <iq id="test" from="tester@sleekxmpp.com/test" type="result">
+ <query xmlns="test" />
+ </iq>
+ """)
+
+ t.join()
+
+ time.sleep(0.1)
+
+ self.assertEqual(events, ['tester@sleekxmpp.com/test'], "Did not timeout on bad sender")
+
+
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestHandlers)