[telepathy-gabble/master] test-fallback-socks5-proxy.py: test new proxy querying policy

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Thu Nov 26 05:57:41 PST 2009


Proxy queries are sent when creating the 1-1 D-Bus tube now.
---
 tests/twisted/test-fallback-socks5-proxy.py |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/tests/twisted/test-fallback-socks5-proxy.py b/tests/twisted/test-fallback-socks5-proxy.py
index 73a98f7..3b74b18 100644
--- a/tests/twisted/test-fallback-socks5-proxy.py
+++ b/tests/twisted/test-fallback-socks5-proxy.py
@@ -12,12 +12,14 @@ from bytestream import create_from_si_offer, BytestreamS5B
 def test(q, bus, conn, stream):
     conn.Connect()
 
-    _, e1, e2 = q.expect_many(
-        EventPattern('dbus-signal', signal='StatusChanged',
-            args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]),
+    proxy_query_events = [
         EventPattern('stream-iq', to='fallback1-proxy.localhost', iq_type='get', query_ns=ns.BYTESTREAMS),
-        EventPattern('stream-iq', to='fallback2-proxy.localhost', iq_type='get', query_ns=ns.BYTESTREAMS),
-        )
+        EventPattern('stream-iq', to='fallback2-proxy.localhost', iq_type='get', query_ns=ns.BYTESTREAMS)]
+
+    q.forbid_events(proxy_query_events)
+
+    q.expect('dbus-signal', signal='StatusChanged',
+            args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
 
     proxy_port = {'fallback1-proxy.localhost': '12345', 'fallback2-proxy.localhost': '6789'}
 
@@ -30,9 +32,6 @@ def test(q, bus, conn, stream):
                 elem('streamhost', jid=jid, host='127.0.0.1', port=port)()))
         stream.send(reply)
 
-    send_socks5_reply(e1.stanza)
-    send_socks5_reply(e2.stanza)
-
     # Offer a private D-Bus tube just to check if the proxy is present in the
     # SOCKS5 offer
 
@@ -48,11 +47,19 @@ def test(q, bus, conn, stream):
     stream.send(make_caps_disco_reply(stream, disco_event.stanza, [ns.TUBES]))
     sync_stream(q, stream)
 
+    q.unforbid_events(proxy_query_events)
+
     path, props = conn.Requests.CreateChannel({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_DBUS_TUBE,
         cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
         cs.TARGET_ID: 'alice at localhost',
         cs.DBUS_TUBE_SERVICE_NAME: 'com.example.TestCase'})
 
+    # Proxy queries are send when creating the channel
+    e1, e2 = q.expect_many(*proxy_query_events)
+
+    send_socks5_reply(e1.stanza)
+    send_socks5_reply(e2.stanza)
+
     tube_chan = bus.get_object(conn.bus_name, path)
     dbus_tube_iface = dbus.Interface(tube_chan, cs.CHANNEL_TYPE_DBUS_TUBE)
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list