summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream_handlers.py53
1 files changed, 53 insertions, 0 deletions
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)