[Telepathy-commits] [telepathy-gabble/master] Add a test for ListChannels() crashing given a dtube

Will Thompson will.thompson at collabora.co.uk
Tue Jan 20 23:26:16 PST 2009


---
 tests/twisted/Makefile.am                     |    1 +
 tests/twisted/tubes/crash-on-list-channels.py |   67 +++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/tubes/crash-on-list-channels.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 2a06e65..907d404 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -39,6 +39,7 @@ TWISTED_TESTS = \
 	text/test-text.py \
 	tubes/muc-presence.py \
 	tubes/close-muc-with-closed-tube.py \
+	tubes/crash-on-list-channels.py \
 	tubes/test-get-available-tubes.py \
 	tubes/accept-muc-stream-tube-ibb.py \
 	tubes/accept-private-stream-tube.py \
diff --git a/tests/twisted/tubes/crash-on-list-channels.py b/tests/twisted/tubes/crash-on-list-channels.py
new file mode 100644
index 0000000..7989136
--- /dev/null
+++ b/tests/twisted/tubes/crash-on-list-channels.py
@@ -0,0 +1,67 @@
+"""
+Regression test for a bug where calling ListChannels with an open old-skool
+DBus tube asserted.
+"""
+
+import dbus
+
+from servicetest import call_async, EventPattern, watch_tube_signals
+from gabbletest import exec_test, acknowledge_iq, sync_stream
+
+from twisted.words.xish import domish, xpath
+
+TUBES = 'org.freedesktop.Telepathy.Channel.Type.Tubes'
+NS_TUBES = 'http://telepathy.freedesktop.org/xmpp/tubes'
+
+jid = 'explosions at in.the.sky'
+
+def test(q, bus, conn, stream):
+    conn.Connect()
+    _, roster_event = q.expect_many(
+        EventPattern('dbus-signal', signal='StatusChanged', args=[0, 1]),
+        EventPattern('stream-iq', query_ns='jabber:iq:roster'))
+
+    roster = roster_event.stanza
+    roster['type'] = 'result'
+    item = roster_event.query.addElement('item')
+    item['jid'] = jid
+    item['subscription'] = 'both'
+    stream.send(roster)
+
+    presence = domish.Element(('jabber:client', 'presence'))
+    presence['from'] = '%s/Bob' % jid
+    presence['to'] = 'test at localhost/Resource'
+    c = presence.addElement('c')
+    c['xmlns'] = 'http://jabber.org/protocol/caps'
+    c['node'] = 'http://example.com/ICantBelieveItsNotTelepathy'
+    c['ver'] = '1.2.3'
+    stream.send(presence)
+
+    event = q.expect('stream-iq', iq_type='get',
+        query_ns='http://jabber.org/protocol/disco#info',
+        to=('%s/Bob' % jid))
+    result = event.stanza
+    result['type'] = 'result'
+    assert event.query['node'] == \
+        'http://example.com/ICantBelieveItsNotTelepathy#1.2.3'
+    feature = event.query.addElement('feature')
+    feature['var'] = NS_TUBES
+    stream.send(result)
+
+    sync_stream(q, stream)
+
+    h = conn.RequestHandles(1, [jid])[0]
+    tubes_path = conn.RequestChannel(TUBES, 1, h, True)
+
+    tubes_chan = bus.get_object(conn.bus_name, tubes_path)
+    tubes_iface = dbus.Interface(tubes_chan, TUBES)
+
+    tubes_iface.OfferDBusTube('bong.hits', dbus.Dictionary({}, signature='sv'))
+
+    conn.ListChannels()
+
+    call_async(q, conn, 'Disconnect')
+    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+if __name__ == '__main__':
+    exec_test(test)
-- 
1.5.6.5




More information about the Telepathy-commits mailing list