summaryrefslogtreecommitdiff
path: root/tests/test_stream_presence.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-10-25 12:52:32 -0400
committerLance Stout <lancestout@gmail.com>2010-10-25 12:52:32 -0400
commitac330b5c6c7a24eda0e91d4fc70414cfff014545 (patch)
tree1c4b5eb35d2c1de806abf72f43de8baf3e9ed3cc /tests/test_stream_presence.py
parent46ffa8e9fe02b355426eb1b044dbdd8fffe20549 (diff)
downloadslixmpp-ac330b5c6c7a24eda0e91d4fc70414cfff014545.tar.gz
slixmpp-ac330b5c6c7a24eda0e91d4fc70414cfff014545.tar.bz2
slixmpp-ac330b5c6c7a24eda0e91d4fc70414cfff014545.tar.xz
slixmpp-ac330b5c6c7a24eda0e91d4fc70414cfff014545.zip
Fixed bug in presence subscription handling.
Subscription requests and responses were not setting the correct 'to' attribute.
Diffstat (limited to 'tests/test_stream_presence.py')
-rw-r--r--tests/test_stream_presence.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py
index 135d8eed..994d4e17 100644
--- a/tests/test_stream_presence.py
+++ b/tests/test_stream_presence.py
@@ -82,5 +82,47 @@ class TestStreamPresence(SleekTest):
self.assertEqual(events, ['got_offline'],
"Got offline incorrectly triggered: %s" % events)
+ def testAutoAuthorizeAndSubscribe(self):
+ """
+ Test auto authorizing and auto subscribing
+ to subscription requests.
+ """
+
+ events = set()
+
+ def presence_subscribe(p):
+ events.add('presence_subscribe')
+
+ def changed_subscription(p):
+ events.add('changed_subscription')
+
+ self.stream_start(jid='tester@localhost')
+
+ self.xmpp.add_event_handler('changed_subscription',
+ changed_subscription)
+ self.xmpp.add_event_handler('presence_subscribe',
+ presence_subscribe)
+
+ # With these settings we should accept a subscription
+ # and request a subscription in return.
+ self.xmpp.auto_authorize = True
+ self.xmpp.auto_subscribe = True
+
+ self.stream_recv("""
+ <presence from="user@localhost" type="subscribe" />
+ """)
+
+ self.stream_send_presence("""
+ <presence to="user@localhost" type="subscribed" />
+ """)
+
+ self.stream_send_presence("""
+ <presence to="user@localhost" type="subscribe" />
+ """)
+
+ expected = set(('presence_subscribe', 'changed_subscription'))
+ self.assertEqual(events, expected,
+ "Incorrect events triggered: %s" % events)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPresence)