summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2014-02-06 09:13:28 -0800
committerLance Stout <lancestout@gmail.com>2014-02-06 09:13:28 -0800
commit651915f31cc1f967df35ff016b6823312d84bf5e (patch)
tree3ced4cad2b1ea6f1dc9ccb74384731b84c1dae35
parentd9db1b84fe03ff92653afede1c2f1da4f0868fe4 (diff)
downloadslixmpp-651915f31cc1f967df35ff016b6823312d84bf5e.tar.gz
slixmpp-651915f31cc1f967df35ff016b6823312d84bf5e.tar.bz2
slixmpp-651915f31cc1f967df35ff016b6823312d84bf5e.tar.xz
slixmpp-651915f31cc1f967df35ff016b6823312d84bf5e.zip
Add test for wrong sender in IQ
-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)