summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-03-15 16:36:42 -0400
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-17 18:03:07 +0100
commitc10809c97c20c1d3a55740f4e93eac26664b88a9 (patch)
tree7434ca1a55d2674d599901c80f31033828e954f4
parent4f67d0e00694967c31ab35ab6eec0a325bc19d5d (diff)
tube tests: remove all Chan.T.Tubes tests
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--tests/twisted/Makefile.am3
-rw-r--r--tests/twisted/tubes/accept-muc-dbus-tube.py12
-rw-r--r--tests/twisted/tubes/accept-muc-stream-tube.py70
-rw-r--r--tests/twisted/tubes/accept-private-dbus-tube.py59
-rw-r--r--tests/twisted/tubes/accept-private-stream-tube.py139
-rw-r--r--tests/twisted/tubes/check-create-tube-return.py24
-rw-r--r--tests/twisted/tubes/close-muc-with-closed-tube.py49
-rw-r--r--tests/twisted/tubes/crash-on-list-channels.py62
-rw-r--r--tests/twisted/tubes/ensure-si-tube.py66
-rw-r--r--tests/twisted/tubes/muc-presence.py19
-rw-r--r--tests/twisted/tubes/muctubeutil.py89
-rw-r--r--tests/twisted/tubes/offer-muc-dbus-tube.py227
-rw-r--r--tests/twisted/tubes/offer-muc-stream-tube.py218
-rw-r--r--tests/twisted/tubes/offer-no-caps.py22
-rw-r--r--tests/twisted/tubes/offer-private-dbus-tube.py126
-rw-r--r--tests/twisted/tubes/offer-private-stream-tube.py180
-rw-r--r--tests/twisted/tubes/test-get-available-tubes.py59
-rw-r--r--tests/twisted/tubes/test-socks5-muc.py24
-rw-r--r--tests/twisted/tubes/tubetestutil.py18
19 files changed, 270 insertions, 1196 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index f8457f7a9..f6e847bef 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -131,10 +131,8 @@ TWISTED_TUBE_TESTS = \
tubes/accept-private-stream-tube.py \
tubes/check-create-tube-return.py \
tubes/close-muc-with-closed-tube.py \
- tubes/crash-on-list-channels.py \
tubes/create-invalid-tube-channels.py \
tubes/ensure-si-tube.py \
- tubes/muc-presence.py \
tubes/offer-muc-dbus-tube.py \
tubes/offer-muc-stream-tube.py \
tubes/offer-no-caps.py \
@@ -275,7 +273,6 @@ TWISTED_OTHER_FILES = \
test-helper.py \
tls-cert.pem \
tls-key.pem \
- tubes/muctubeutil.py \
tubes/tubetestutil.py \
$(NULL)
diff --git a/tests/twisted/tubes/accept-muc-dbus-tube.py b/tests/twisted/tubes/accept-muc-dbus-tube.py
index fb841c3ca..782c79bc5 100644
--- a/tests/twisted/tubes/accept-muc-dbus-tube.py
+++ b/tests/twisted/tubes/accept-muc-dbus-tube.py
@@ -37,13 +37,13 @@ def test(q, bus, conn, stream, access_control):
parameter.addContent('bar')
stream.send(presence)
- # tubes channel is created
- event = q.expect('dbus-signal', signal='NewChannels')
- channels = event.args[0]
- path, props = channels[0]
-
# tube channel is created
- event = q.expect('dbus-signal', signal='NewChannels')
+ def new_chan_predicate(e):
+ path, props = e.args[0][0]
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
+
+ event = q.expect('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate)
channels = event.args[0]
path, props = channels[0]
diff --git a/tests/twisted/tubes/accept-muc-stream-tube.py b/tests/twisted/tubes/accept-muc-stream-tube.py
index 01e65fdb2..2729c51ab 100644
--- a/tests/twisted/tubes/accept-muc-stream-tube.py
+++ b/tests/twisted/tubes/accept-muc-stream-tube.py
@@ -49,8 +49,10 @@ def test(q, bus, conn, stream, bytestream_cls,
room_handle = handles[0]
# join the muc
- call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_ROOM,
- room_handle, True)
+ call_async(q, conn.Requests, 'CreateChannel', {
+ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+ cs.TARGET_HANDLE_TYPE: cs.HT_ROOM,
+ cs.TARGET_HANDLE: room_handle})
_, stream_event = q.expect_many(
EventPattern('dbus-signal', signal='MembersChanged',
@@ -70,7 +72,7 @@ def test(q, bus, conn, stream, bytestream_cls,
assert conn.InspectHandles(1, [3]) == ['chat@conf.localhost/bob']
bob_handle = 3
- event = q.expect('dbus-return', method='RequestChannel')
+ event = q.expect('dbus-return', method='CreateChannel')
# Bob offers a stream tube
stream_tube_id = 666
@@ -112,51 +114,13 @@ def test(q, bus, conn, stream, bytestream_cls,
path, props = channels[0]
assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT
- # tubes channel is automatically created
- event, new_event = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'))
-
- assert event.args[1] == cs.CHANNEL_TYPE_TUBES, event.args
- assert event.args[2] == cs.HT_ROOM
- assert event.args[3] == room_handle
-
- tubes_chan = bus.get_object(conn.bus_name, event.args[0])
- tubes_iface = dbus.Interface(tubes_chan, event.args[1])
-
- channel_props = tubes_chan.GetAll(cs.CHANNEL, dbus_interface=cs.PROPERTIES_IFACE)
- assert channel_props['TargetID'] == 'chat@conf.localhost', channel_props
- assert channel_props['Requested'] == False
- assert channel_props['InitiatorID'] == ''
- assert channel_props['InitiatorHandle'] == 0
-
- channels = new_event.args[0]
- assert len(channels) == 1
- path, props = channels[0]
- assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TUBES
-
- tubes_self_handle = tubes_chan.GetSelfHandle(dbus_interface=cs.CHANNEL_IFACE_GROUP)
-
- q.expect('dbus-signal', signal='NewTube',
- args=[stream_tube_id, bob_handle, 1, 'echo', sample_parameters, 0])
-
- expected_tube = (stream_tube_id, bob_handle, cs.TUBE_TYPE_STREAM, 'echo',
- sample_parameters, cs.TUBE_STATE_LOCAL_PENDING)
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assert tubes == [(
- stream_tube_id,
- bob_handle,
- 1, # Stream
- 'echo',
- sample_parameters,
- cs.TUBE_CHANNEL_STATE_LOCAL_PENDING
- )]
-
- assert len(tubes) == 1, unwrap(tubes)
- t.check_tube_in_tubes(expected_tube, tubes)
+ def new_chan_predicate(e):
+ path, props = e.args[0][0]
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
- # tube channel is also announced (new API)
- new_event = q.expect('dbus-signal', signal='NewChannels')
+ # tube channel is announced
+ new_event = q.expect('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate)
channels = new_event.args[0]
assert len(channels) == 1
@@ -176,17 +140,18 @@ def test(q, bus, conn, stream, bytestream_cls,
tube_chan = bus.get_object(conn.bus_name, path)
tube_props = tube_chan.GetAll(cs.CHANNEL_IFACE_TUBE, dbus_interface=cs.PROPERTIES_IFACE,
byte_arrays=True)
+ tube_iface = dbus.Interface(tube_chan, cs.CHANNEL_TYPE_STREAM_TUBE)
assert tube_props['Parameters'] == sample_parameters
assert tube_props['State'] == cs.TUBE_CHANNEL_STATE_LOCAL_PENDING
# Accept the tube
- call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id,
+ call_async(q, tube_iface, 'Accept',
address_type, access_control, access_control_param, byte_arrays=True)
accept_return_event, _ = q.expect_many(
- EventPattern('dbus-return', method='AcceptStreamTube'),
- EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[stream_tube_id, 2]))
+ EventPattern('dbus-return', method='Accept'),
+ EventPattern('dbus-signal', signal='TubeChannelStateChanged',
+ args=[2]))
address = accept_return_event.value[0]
@@ -260,8 +225,7 @@ def test(q, bus, conn, stream, bytestream_cls,
assertEquals(cs.CANCELLED, e.args[1])
# OK, we're done
- disconnect_conn(q, conn, stream,
- [EventPattern('dbus-signal', signal='TubeClosed', args=[stream_tube_id])])
+ disconnect_conn(q, conn, stream)
if __name__ == '__main__':
t.exec_stream_tube_test(test)
diff --git a/tests/twisted/tubes/accept-private-dbus-tube.py b/tests/twisted/tubes/accept-private-dbus-tube.py
index 82e81118c..dbbeb3bed 100644
--- a/tests/twisted/tubes/accept-private-dbus-tube.py
+++ b/tests/twisted/tubes/accept-private-dbus-tube.py
@@ -81,66 +81,21 @@ def test(q, bus, conn, stream, bytestream_cls, access_control):
# RequestChannel are the ones we wanted.
sync_dbus(bus, q, conn)
- # let's try to accept a D-Bus tube using the old API
- bytestream = bytestream_cls(stream, q, 'beta', bob_full_jid,
- 'test@localhost/Reource', True)
-
- last_tube_id += 1
- contact_offer_dbus_tube(bytestream, last_tube_id)
-
- # tubes channel is created
- event = q.expect('dbus-signal', signal='NewChannel')
-
bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['bob@localhost'])[0]
- t.check_NewChannel_signal(event.args, cs.CHANNEL_TYPE_TUBES, None,
- bob_handle, False)
-
- tubes_chan = bus.get_object(conn.bus_name, event.args[0])
- tubes_iface = dbus.Interface(tubes_chan, cs.CHANNEL_TYPE_TUBES)
-
- event = q.expect('dbus-signal', signal='NewTube')
- id = event.args[0]
- initiator = event.args[1]
- type = event.args[2]
- service = event.args[3]
- parameters = event.args[4]
- state = event.args[5]
-
- assertEquals (last_tube_id, id)
- initiator_jid = conn.InspectHandles(1, [initiator])[0]
- assert initiator_jid == 'bob@localhost'
- assert type == cs.TUBE_TYPE_DBUS
- assert service == 'com.example.TestCase2'
- assert parameters == {'login': 'TEST'}
- assert state == cs.TUBE_STATE_LOCAL_PENDING
-
- # accept the tube (old API)
- call_async(q, tubes_iface, 'AcceptDBusTube', id)
-
- event = q.expect('stream-iq', iq_type='result')
- bytestream.check_si_reply(event.stanza)
- tube = xpath.queryForNodes('/iq/si/tube[@xmlns="%s"]' % ns.TUBES,
- event.stanza)
- assert len(tube) == 1
-
- # Init the bytestream
- events, _ = bytestream.open_bytestream([EventPattern('dbus-return', method='AcceptDBusTube')],
- [EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[last_tube_id, 2])])
-
- return_event = events[0]
- address = return_event.value[0]
- assert len(address) > 0
-
- # OK, now let's try to accept a D-Bus tube using the new API
+ # let's try to accept a D-Bus tube using the new API
bytestream = bytestream_cls(stream, q, 'gamma', bob_full_jid,
self_full_jid, True)
last_tube_id += 1
contact_offer_dbus_tube(bytestream, last_tube_id)
- e = q.expect('dbus-signal', signal='NewChannels')
+ def new_chan_predicate(e):
+ path, props = e.args[0][0]
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
+
+ e = q.expect('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate)
channels = e.args[0]
assert len(channels) == 1
path, props = channels[0]
diff --git a/tests/twisted/tubes/accept-private-stream-tube.py b/tests/twisted/tubes/accept-private-stream-tube.py
index 58f3558ae..37ed1693d 100644
--- a/tests/twisted/tubes/accept-private-stream-tube.py
+++ b/tests/twisted/tubes/accept-private-stream-tube.py
@@ -24,54 +24,37 @@ bob_jid = 'bob@localhost/Bob'
stream_tube_id = 49
def receive_tube_offer(q, bus, conn, stream):
+ global stream_tube_id
message = domish.Element(('jabber:client', 'message'))
message['to'] = 'test@localhost/Resource'
message['from'] = bob_jid
tube_node = message.addElement((ns.TUBES, 'tube'))
tube_node['type'] = 'stream'
tube_node['service'] = 'http'
+ stream_tube_id += 1
tube_node['id'] = str(stream_tube_id)
stream.send(message)
- old_sig, new_sig = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
- chan_path = old_sig.args[0]
- assert old_sig.args[1] == cs.CHANNEL_TYPE_TUBES, old_sig.args[1]
- assert old_sig.args[2] == cs.HT_CONTACT
- bob_handle = old_sig.args[3]
- assert old_sig.args[2] == 1, old_sig.args[2] # Suppress_Handler
- assert len(new_sig.args) == 1
- assert len(new_sig.args[0]) == 1
- assert new_sig.args[0][0][0] == chan_path, new_sig.args[0][0]
- assert new_sig.args[0][0][1] is not None
-
- event = q.expect('dbus-signal', signal='NewTube')
-
- old_sig, new_sig = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
- new_chan_path = old_sig.args[0]
- assert new_chan_path != chan_path
- assert old_sig.args[1] == cs.CHANNEL_TYPE_STREAM_TUBE, old_sig.args[1]
- assert old_sig.args[2] == cs.HT_CONTACT
- bob_handle = old_sig.args[3]
- assert old_sig.args[2] == 1, old_sig.args[2] # Suppress_Handler
+ def new_chan_predicate(e):
+ path, props = e.args[0][0]
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
+
+ new_sig = q.expect('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate)
+
assert len(new_sig.args) == 1
assert len(new_sig.args[0]) == 1
- assert new_sig.args[0][0][0] == new_chan_path, new_sig.args[0][0]
- assert new_sig.args[0][0][1] is not None
- # create channel proxies
- tubes_chan = bus.get_object(conn.bus_name, chan_path)
- tubes_iface = dbus.Interface(tubes_chan, cs.CHANNEL_TYPE_TUBES)
+ path, props = new_sig.args[0][0]
+ assertEquals(cs.CHANNEL_TYPE_STREAM_TUBE, props[cs.CHANNEL_TYPE])
+ assertEquals(cs.HT_CONTACT, props[cs.TARGET_HANDLE_TYPE])
+ assertEquals(False, props[cs.REQUESTED])
- new_tube_chan = bus.get_object(conn.bus_name, new_chan_path)
+ # create channel proxies
+ new_tube_chan = bus.get_object(conn.bus_name, path)
new_tube_iface = dbus.Interface(new_tube_chan, cs.CHANNEL_TYPE_STREAM_TUBE)
- return (tubes_chan, tubes_iface, new_tube_chan, new_tube_iface)
+ return (new_tube_chan, new_tube_iface)
def expect_tube_activity(q, bus, conn, stream, bytestream_cls, address_type,
address, access_control, access_control_param):
@@ -157,20 +140,9 @@ def test(q, bus, conn, stream, bytestream_cls,
sync_dbus(bus, q, conn)
# Receive a tube offer from Bob
- (tubes_chan, tubes_iface, new_tube_chan, new_tube_iface) = \
+ (new_tube_chan, new_tube_iface) = \
receive_tube_offer(q, bus, conn, stream)
- # Try bad parameters on the old iface
- call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id+1, 2, 0, '',
- byte_arrays=True)
- q.expect('dbus-error', method='AcceptStreamTube')
- call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, 2, 1, '',
- byte_arrays=True)
- q.expect('dbus-error', method='AcceptStreamTube')
- call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, 20, 0, '',
- byte_arrays=True)
- q.expect('dbus-error', method='AcceptStreamTube')
-
# Try bad parameters on the new iface
call_async(q, new_tube_iface, 'Accept', 20, 0, '',
byte_arrays=True)
@@ -179,69 +151,8 @@ def test(q, bus, conn, stream, bytestream_cls,
byte_arrays=True)
q.expect('dbus-error', method='Accept')
- # Accept the tube with old iface
- call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, address_type,
- access_control, access_control_param, byte_arrays=True)
-
- accept_return_event, _ = q.expect_many(
- EventPattern('dbus-return', method='AcceptStreamTube'),
- EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[stream_tube_id, 2]))
-
- socket_address = accept_return_event.value[0]
-
- bytestream, conn_id = expect_tube_activity(q, bus, conn, stream, bytestream_cls,
- address_type, socket_address, access_control, access_control_param)
-
- tubes_chan.Close()
- bytestream.wait_bytestream_closed()
-
- # Receive a tube offer from Bob
- (tubes_chan, tubes_iface, new_tube_chan, new_tube_iface) = \
- receive_tube_offer(q, bus, conn, stream)
-
- # Accept the tube with old iface, and use UNIX sockets
- call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id,
- address_type, access_control, access_control_param, byte_arrays=True)
-
- accept_return_event, _ = q.expect_many(
- EventPattern('dbus-return', method='AcceptStreamTube'),
- EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[stream_tube_id, 2]))
-
- socket_address = accept_return_event.value[0]
-
- bytestream, conn_id = expect_tube_activity(q, bus, conn, stream, bytestream_cls,
- address_type, socket_address, access_control, access_control_param)
- tubes_chan.Close()
- bytestream.wait_bytestream_closed()
-
- # Receive a tube offer from Bob
- (tubes_chan, tubes_iface, new_tube_chan, new_tube_iface) = \
- receive_tube_offer(q, bus, conn, stream)
-
- # Accept the tube with new iface, and use IPv4
- call_async(q, new_tube_iface, 'Accept', address_type,
- access_control, access_control_param, byte_arrays=True)
-
- accept_return_event, _ = q.expect_many(
- EventPattern('dbus-return', method='Accept'),
- EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[stream_tube_id, 2]))
-
- socket_address = accept_return_event.value[0]
-
- bytestream, conn_id = expect_tube_activity(q, bus, conn, stream, bytestream_cls,
- address_type, socket_address, access_control, access_control_param)
- tubes_chan.Close()
- e, _ = bytestream.wait_bytestream_closed([
- EventPattern('dbus-signal', signal='ConnectionClosed'),
- EventPattern('socket-disconnected')])
- assertEquals(conn_id, e.args[0])
- assertEquals(cs.CANCELLED, e.args[1])
-
# Receive a tube offer from Bob
- (tubes_chan, tubes_iface, new_tube_chan, new_tube_iface) = \
+ (new_tube_chan, new_tube_iface) = \
receive_tube_offer(q, bus, conn, stream)
# Accept the tube with new iface, and use UNIX sockets
@@ -250,8 +161,8 @@ def test(q, bus, conn, stream, bytestream_cls,
accept_return_event, _ = q.expect_many(
EventPattern('dbus-return', method='Accept'),
- EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[stream_tube_id, 2]))
+ EventPattern('dbus-signal', signal='TubeChannelStateChanged',
+ args=[2]))
socket_address = accept_return_event.value[0]
@@ -274,16 +185,10 @@ def test(q, bus, conn, stream, bytestream_cls,
assertEquals(conn_id, e.args[0])
assertEquals(cs.CONNECTION_REFUSED, e.args[1])
- tubes_chan.Close()
-
- # Receive a tube offer from Bob
- (tubes_chan, tubes_iface, new_tube_chan, new_tube_iface) = \
- receive_tube_offer(q, bus, conn, stream)
- # Just close the tube
- tubes_chan.Close()
+ new_tube_chan.Close()
# Receive a tube offer from Bob
- (tubes_chan, tubes_iface, new_tube_chan, new_tube_iface) = \
+ (new_tube_chan, new_tube_iface) = \
receive_tube_offer(q, bus, conn, stream)
# Just close the tube
new_tube_chan.Close()
diff --git a/tests/twisted/tubes/check-create-tube-return.py b/tests/twisted/tubes/check-create-tube-return.py
index 2a3a6304b..46db340c4 100644
--- a/tests/twisted/tubes/check-create-tube-return.py
+++ b/tests/twisted/tubes/check-create-tube-return.py
@@ -74,29 +74,5 @@ def test(q, bus, conn, stream):
assertEquals(props[cs.TARGET_HANDLE_TYPE], cs.HT_ROOM)
assertEquals(props[cs.TARGET_ID], muc)
- # Now make sure we can get our Tubes channel if we request it.
- muc = 'chat3@conf.localhost'
-
- call_async(q, conn.Requests, 'CreateChannel',
- { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TUBES,
- cs.TARGET_HANDLE_TYPE: cs.HT_ROOM,
- cs.TARGET_ID: muc})
-
- q.expect('stream-presence', to='%s/test' % muc)
- stream.send(make_muc_presence('owner', 'moderator', muc, 'bob'))
- stream.send(make_muc_presence('none', 'participant', muc, 'test'))
-
- ret, _, _ = q.expect_many(
- EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
-
- _, props = ret.value
-
- assertEquals(props[cs.CHANNEL_TYPE], cs.CHANNEL_TYPE_TUBES)
- assertEquals(props[cs.TARGET_HANDLE_TYPE], cs.HT_ROOM)
- assertEquals(props[cs.TARGET_ID], muc)
-
if __name__ == '__main__':
exec_test(test)
diff --git a/tests/twisted/tubes/close-muc-with-closed-tube.py b/tests/twisted/tubes/close-muc-with-closed-tube.py
index bcebe77f1..ed08add64 100644
--- a/tests/twisted/tubes/close-muc-with-closed-tube.py
+++ b/tests/twisted/tubes/close-muc-with-closed-tube.py
@@ -2,7 +2,7 @@
import dbus
-from servicetest import call_async, EventPattern, unwrap
+from servicetest import call_async, EventPattern, unwrap, assertEquals
from gabbletest import exec_test, make_result_iq, acknowledge_iq, make_muc_presence
import constants as cs
import ns
@@ -84,43 +84,28 @@ def test(q, bus, conn, stream):
stream.send(presence)
- # tubes channel is automatically created
- event = q.expect('dbus-signal', signal='NewChannel')
+ def new_chan_predicate(e):
+ path, props = e.args[0][0]
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
- if event.args[1] == cs.CHANNEL_TYPE_TEXT:
- # skip this one, try the next one
- event = q.expect('dbus-signal', signal='NewChannel')
+ # tube channel is automatically created
+ event = q.expect('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate)
- assert event.args[1] == cs.CHANNEL_TYPE_TUBES, event.args
- assert event.args[2] == cs.HT_ROOM
- assert event.args[3] == room_handle
+ path, props = event.args[0][0]
- tubes_chan = bus.get_object(conn.bus_name, event.args[0])
- tubes_iface = dbus.Interface(tubes_chan, event.args[1])
+ assertEquals(cs.CHANNEL_TYPE_DBUS_TUBE, props[cs.CHANNEL_TYPE])
+ assertEquals(cs.HT_ROOM, props[cs.TARGET_HANDLE_TYPE])
+ assertEquals(room_handle, props[cs.TARGET_HANDLE])
+ assertEquals('chat@conf.localhost', props[cs.TARGET_ID])
+ assertEquals(False, props[cs.REQUESTED])
- channel_props = tubes_chan.GetAll(
- cs.CHANNEL, dbus_interface=dbus.PROPERTIES_IFACE)
- assert channel_props['TargetID'] == 'chat@conf.localhost', channel_props
- assert channel_props['Requested'] == False
- assert channel_props['InitiatorID'] == ''
- assert channel_props['InitiatorHandle'] == 0
-
- tubes_self_handle = tubes_chan.GetSelfHandle(
- dbus_interface=cs.CHANNEL_IFACE_GROUP)
-
- q.expect('dbus-signal', signal='NewTube',
- args=[tube_id, bob_handle, 0, 'org.telepathy.freedesktop.test', sample_parameters, 0])
-
- expected_tube = (tube_id, bob_handle, cs.TUBE_TYPE_DBUS,
- 'org.telepathy.freedesktop.test', sample_parameters,
- cs.TUBE_STATE_LOCAL_PENDING)
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assert len(tubes) == 1, unwrap(tubes)
- t.check_tube_in_tubes(expected_tube, tubes)
+ tube_chan = bus.get_object(conn.bus_name, path)
+ tube_iface = dbus.Interface(tube_chan, cs.CHANNEL_TYPE_DBUS_TUBE)
# reject the tube
- tubes_iface.CloseTube(tube_id)
- q.expect('dbus-signal', signal='TubeClosed', args=[tube_id])
+ tube_iface.Close(dbus_interface=cs.CHANNEL)
+ q.expect('dbus-signal', signal='ChannelClosed')
# close the text channel
text_chan.Close()
diff --git a/tests/twisted/tubes/crash-on-list-channels.py b/tests/twisted/tubes/crash-on-list-channels.py
deleted file mode 100644
index b2532e515..000000000
--- a/tests/twisted/tubes/crash-on-list-channels.py
+++ /dev/null
@@ -1,62 +0,0 @@
-"""
-Regression test for a bug where calling ListChannels with an open old-skool
-DBus tube asserted.
-"""
-
-import dbus
-
-from servicetest import call_async, EventPattern
-from gabbletest import exec_test, sync_stream, make_result_iq
-
-import ns
-import constants as cs
-
-from twisted.words.xish import domish
-
-jid = 'explosions@in.the.sky'
-
-def test(q, bus, conn, stream):
- roster_event = q.expect('stream-iq', query_ns=ns.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@localhost/Resource'
- c = presence.addElement('c')
- c['xmlns'] = ns.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=ns.DISCO_INFO,
- to=('%s/Bob' % jid))
- assert event.query['node'] == \
- 'http://example.com/ICantBelieveItsNotTelepathy#1.2.3'
- result = make_result_iq(stream, event.stanza)
- query = result.firstChildElement()
- feature = query.addElement('feature')
- feature['var'] = ns.TUBES
- stream.send(result)
-
- sync_stream(q, stream)
-
- h = conn.RequestHandles(cs.HT_CONTACT, [jid])[0]
- tubes_path = conn.RequestChannel(
- cs.CHANNEL_TYPE_TUBES, cs.HT_CONTACT, h, True)
-
- tubes_chan = bus.get_object(conn.bus_name, tubes_path)
- tubes_iface = dbus.Interface(tubes_chan, cs.CHANNEL_TYPE_TUBES)
-
- tubes_iface.OfferDBusTube('bong.hits', dbus.Dictionary({}, signature='sv'))
-
- conn.ListChannels()
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/tubes/ensure-si-tube.py b/tests/twisted/tubes/ensure-si-tube.py
index 9330fa7c8..dccb337cc 100644
--- a/tests/twisted/tubes/ensure-si-tube.py
+++ b/tests/twisted/tubes/ensure-si-tube.py
@@ -4,7 +4,7 @@ Test support for creating and retrieving 1-1 tubes with EnsureChannel
import dbus
-from servicetest import call_async, EventPattern, tp_name_prefix
+from servicetest import call_async, EventPattern, tp_name_prefix, unwrap
from gabbletest import exec_test, acknowledge_iq
import constants as cs
import ns
@@ -27,12 +27,12 @@ def test(q, bus, conn, stream):
properties = conn.GetAll(
cs.CONN_IFACE_REQUESTS, dbus_interface=cs.PROPERTIES_IFACE)
assert properties.get('Channels') == [], properties['Channels']
- assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TUBES,
+ assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
},
- [cs.TARGET_HANDLE, cs.TARGET_ID]
+ [cs.TARGET_HANDLE, cs.TARGET_ID, cs.STREAM_TUBE_SERVICE]
) in properties.get('RequestableChannelClasses'),\
- properties['RequestableChannelClasses']
+ unwrap(properties['RequestableChannelClasses'])
_, vcard_event, roster_event = q.expect_many(
EventPattern('dbus-signal', signal='StatusChanged',
@@ -72,48 +72,58 @@ def test(q, bus, conn, stream):
bob_handle = conn.RequestHandles(1, ['bob@localhost'])[0]
- call_async(q, conn, 'RequestChannel',
- cs.CHANNEL_TYPE_TUBES, cs.HT_CONTACT, bob_handle, True);
+ def new_chan_predicate(e):
+ types = []
+ for _, props in e.args[0]:
+ types.append(props[cs.CHANNEL_TYPE])
- ret, old_sig, new_sig = q.expect_many(
- EventPattern('dbus-return', method='RequestChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
+ return cs.CHANNEL_TYPE_STREAM_TUBE in types
+ call_async(q, conn.Requests, 'CreateChannel',
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: bob_handle,
+ cs.STREAM_TUBE_SERVICE: 'the.service',
+ })
+
+ ret, _ = q.expect_many(
+ EventPattern('dbus-return', method='CreateChannel'),
+ EventPattern('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate),
+ )
- assert len(ret.value) == 1
- chan_path = ret.value[0]
+ chan_path, props = ret.value
# Ensure a tube to the same person; check it's the same one.
- call_async(q, conn.Requests, 'EnsureChannel',
- { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TUBES,
- cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
- cs.TARGET_HANDLE: bob_handle
- })
+# call_async(q, conn.Requests, 'EnsureChannel',
+# { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
+# cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+# cs.TARGET_HANDLE: bob_handle,
+# cs.STREAM_TUBE_SERVICE: 'the.service',
+# })
- ret = q.expect('dbus-return', method='EnsureChannel')
- yours, ensured_path, _ = ret.value
+# ret = q.expect('dbus-return', method='EnsureChannel')
+# yours, ensured_path, _ = ret.value
- assert ensured_path == chan_path, (ensured_path, chan_path)
- assert not yours
+# assert ensured_path == chan_path, (ensured_path, chan_path)
+# assert not yours
chan = bus.get_object(conn.bus_name, chan_path)
chan.Close()
-
# Now let's try ensuring a new tube.
call_async(q, conn.Requests, 'EnsureChannel',
- { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TUBES,
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
- cs.TARGET_HANDLE: bob_handle
+ cs.TARGET_HANDLE: bob_handle,
+ cs.STREAM_TUBE_SERVICE: 'the.service',
})
- ret, old_sig, new_sig = q.expect_many(
+ ret, new_sig = q.expect_many(
EventPattern('dbus-return', method='EnsureChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
+ EventPattern('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate),
)
yours, path, props = ret.value
diff --git a/tests/twisted/tubes/muc-presence.py b/tests/twisted/tubes/muc-presence.py
deleted file mode 100644
index 8efcb8780..000000000
--- a/tests/twisted/tubes/muc-presence.py
+++ /dev/null
@@ -1,19 +0,0 @@
-"""
-Regression test for a bug where, if you had any MUC Tubes channels open and
-changed your presence, a GabbleMucChannel method was called on a
-GabbleTubesChannel, crashing Gabble.
-"""
-
-from gabbletest import exec_test
-import constants as cs
-
-from muctubeutil import get_muc_tubes_channel
-
-def test(q, bus, conn, stream):
- handle, tubes_chan, tubes_iface = get_muc_tubes_channel(q, bus, conn,
- stream, 'chat@conf.localhost')
-
- conn.SimplePresence.SetPresence('away', 'Christmas lunch!')
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/tubes/muctubeutil.py b/tests/twisted/tubes/muctubeutil.py
deleted file mode 100644
index 61fa41f88..000000000
--- a/tests/twisted/tubes/muctubeutil.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import dbus
-
-from servicetest import call_async, EventPattern, tp_name_prefix
-from gabbletest import make_result_iq, make_muc_presence
-import constants as cs
-
-def get_muc_tubes_channel(q, bus, conn, stream, muc_jid, anonymous=True):
- """
- Returns a singleton list containing the MUC's handle, a proxy for the Tubes
- channel, and a proxy for the Tubes iface on that channel.
- """
- muc_server = muc_jid.split('@')[1]
- test_jid = muc_jid + "/test"
- bob_jid = muc_jid + "/bob"
-
- self_handle = conn.GetSelfHandle()
- self_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0]
-
- call_async(q, conn, 'RequestHandles', cs.HT_ROOM, [muc_jid])
-
- event = q.expect('dbus-return', method='RequestHandles')
- handles = event.value[0]
- room_handle = handles[0]
-
- # request tubes channel
- call_async(q, conn, 'RequestChannel',
- tp_name_prefix + '.Channel.Type.Tubes', cs.HT_ROOM, room_handle, True)
-
- _, stream_event = q.expect_many(
- EventPattern('dbus-signal', signal='MembersChanged',
- args=[u'', [], [], [], [2], 0, 0]),
- EventPattern('stream-presence', to=test_jid))
-
- # Send presence for other member of room.
- if not anonymous:
- real_jid = 'bob@localhost'
- else:
- real_jid = None
-
- stream.send(make_muc_presence('owner', 'moderator', muc_jid, 'bob', real_jid))
-
- # Send presence for own membership of room.
- stream.send(make_muc_presence('none', 'participant', muc_jid, 'test'))
-
- q.expect('dbus-signal', signal='MembersChanged',
- args=[u'', [2, 3], [], [], [], 0, 0])
-
- assert conn.InspectHandles(cs.HT_CONTACT, [2]) == [test_jid]
- assert conn.InspectHandles(cs.HT_CONTACT, [3]) == [bob_jid]
-
- # text and tubes channels are created
- # FIXME: We can't check NewChannel signals (old API) because two of them
- # would be fired and we can't catch twice the same signals without specifying
- # all their arguments.
- new_sig, returned = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannels'),
- EventPattern('dbus-return', method='RequestChannel'))
-
- channels = new_sig.args[0]
- assert len(channels) == 2
-
- for channel in channels:
- path, props = channel
- type = props[cs.CHANNEL_TYPE]
-
- if type == cs.CHANNEL_TYPE_TEXT:
- # check text channel properties
- assert props[cs.TARGET_HANDLE] == room_handle
- assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM
- assert props[cs.TARGET_ID] == 'chat@conf.localhost'
- assert props[cs.REQUESTED] == False
- assert props[cs.INITIATOR_HANDLE] == self_handle
- assert props[cs.INITIATOR_ID] == self_name
- elif type == cs.CHANNEL_TYPE_TUBES:
- # check tubes channel properties
- assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM
- assert props[cs.TARGET_HANDLE] == room_handle
- assert props[cs.TARGET_ID] == 'chat@conf.localhost'
- assert props[cs.REQUESTED] == True
- assert props[cs.INITIATOR_HANDLE] == self_handle
- assert props[cs.INITIATOR_ID] == self_name
- else:
- assert True
-
- tubes_chan = bus.get_object(conn.bus_name, returned.value[0])
- tubes_iface = dbus.Interface(tubes_chan,
- tp_name_prefix + '.Channel.Type.Tubes')
-
- return (room_handle, tubes_chan, tubes_iface)
diff --git a/tests/twisted/tubes/offer-muc-dbus-tube.py b/tests/twisted/tubes/offer-muc-dbus-tube.py
index 199fa3d6b..52977063c 100644
--- a/tests/twisted/tubes/offer-muc-dbus-tube.py
+++ b/tests/twisted/tubes/offer-muc-dbus-tube.py
@@ -15,7 +15,6 @@ import tubetestutil as t
from twisted.words.xish import xpath
from mucutil import join_muc, echo_muc_presence
-from muctubeutil import get_muc_tubes_channel
sample_parameters = dbus.Dictionary({
's': 'hello',
@@ -24,7 +23,7 @@ sample_parameters = dbus.Dictionary({
'i': dbus.Int32(-123),
}, signature='sv')
-def check_tube_in_presence(presence, dbus_tube_id, initiator):
+def check_tube_in_presence(presence, initiator):
tubes_nodes = xpath.queryForNodes('/presence/tubes[@xmlns="%s"]'
% ns.TUBES, presence)
assert tubes_nodes is not None
@@ -39,7 +38,7 @@ def check_tube_in_presence(presence, dbus_tube_id, initiator):
assert tube['service'] == 'com.example.TestCase'
dbus_stream_id = tube['stream-id']
my_bus_name = tube['dbus-name']
- assert tube['id'] == str(dbus_tube_id)
+ dbus_tube_id = tube['id']
params = {}
parameter_nodes = xpath.queryForNodes('/tube/parameters/parameter', tube)
@@ -52,7 +51,7 @@ def check_tube_in_presence(presence, dbus_tube_id, initiator):
'u': ('uint', '123'),
}
- return dbus_stream_id, my_bus_name
+ return dbus_stream_id, my_bus_name, dbus_tube_id
def fire_signal_on_tube(q, tube, chatroom, dbus_stream_id, my_bus_name):
@@ -118,85 +117,6 @@ def test(q, bus, conn, stream, access_control):
self_handle = conn.GetSelfHandle()
self_name = conn.InspectHandles(1, [self_handle])[0]
- handle, tubes_chan, tubes_iface = get_muc_tubes_channel(q, bus, conn,
- stream, 'chat@conf.localhost')
-
- # Exercise basic Channel Properties from spec 0.17.7
- channel_props = tubes_chan.GetAll(cs.CHANNEL,
- dbus_interface=dbus.PROPERTIES_IFACE)
- assert channel_props.get('TargetHandle') == handle,\
- (channel_props.get('TargetHandle'), handle)
- assert channel_props.get('TargetHandleType') == 2,\
- channel_props.get('TargetHandleType')
- assert channel_props.get('ChannelType') == cs.CHANNEL_TYPE_TUBES,\
- channel_props.get('ChannelType')
- assert 'Interfaces' in channel_props, channel_props
- assert cs.CHANNEL_IFACE_GROUP in channel_props['Interfaces'], \
- channel_props['Interfaces']
- assert channel_props['TargetID'] == 'chat@conf.localhost', channel_props
- assert channel_props['Requested'] == True
- assert channel_props['InitiatorID'] == 'test@localhost'
- assert channel_props['InitiatorHandle'] == conn.GetSelfHandle()
-
- # Exercise Group Properties from spec 0.17.6 (in a basic way)
- group_props = tubes_chan.GetAll(cs.CHANNEL_IFACE_GROUP,
- dbus_interface=dbus.PROPERTIES_IFACE)
- assert 'SelfHandle' in group_props, group_props
- assert 'HandleOwners' in group_props, group_props
- assert 'Members' in group_props, group_props
- assert 'LocalPendingMembers' in group_props, group_props
- assert 'RemotePendingMembers' in group_props, group_props
- assert 'GroupFlags' in group_props, group_props
-
- tubes_self_handle = tubes_chan.GetSelfHandle(
- dbus_interface=cs.CHANNEL_IFACE_GROUP)
- assert group_props['SelfHandle'] == tubes_self_handle
-
- # Offer a D-Bus tube (old API)
- call_async(q, tubes_iface, 'OfferDBusTube',
- 'com.example.TestCase', sample_parameters)
-
- new_tube_event, presence_event, offer_return_event, dbus_changed_event = \
- q.expect_many(
- EventPattern('dbus-signal', signal='NewTube'),
- EventPattern('stream-presence', to='chat@conf.localhost/test'),
- EventPattern('dbus-return', method='OfferDBusTube'),
- EventPattern('dbus-signal', signal='DBusNamesChanged', interface=cs.CHANNEL_TYPE_TUBES))
-
- # handle new_tube_event
- dbus_tube_id = new_tube_event.args[0]
- assert new_tube_event.args[1] == tubes_self_handle
- assert new_tube_event.args[2] == cs.TUBE_TYPE_DBUS
- assert new_tube_event.args[3] == 'com.example.TestCase'
- assert new_tube_event.args[4] == sample_parameters
- assert new_tube_event.args[5] == cs.TUBE_STATE_OPEN
-
- # handle offer_return_event
- assert offer_return_event.value[0] == dbus_tube_id
-
- # handle presence_event
- # We announce our newly created tube in our muc presence
- presence = presence_event.stanza
- dbus_stream_id, my_bus_name = check_tube_in_presence(presence, dbus_tube_id, 'chat@conf.localhost/test')
-
- # handle dbus_changed_event
- assert dbus_changed_event.args[0] == dbus_tube_id
- assert dbus_changed_event.args[1][0][0] == tubes_self_handle
- assert dbus_changed_event.args[1][0][1] == my_bus_name
-
- # handle offer_return_event
- assert dbus_tube_id == offer_return_event.value[0]
-
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assert len(tubes) == 1
- expected_tube = (dbus_tube_id, tubes_self_handle, cs.TUBE_TYPE_DBUS,
- 'com.example.TestCase', sample_parameters, cs.TUBE_STATE_OPEN)
- t.check_tube_in_tubes(expected_tube, tubes)
-
- dbus_tube_adr = tubes_iface.GetDBusTubeAddress(dbus_tube_id)
- tube = Connection(dbus_tube_adr)
- fire_signal_on_tube(q, tube, 'chat@conf.localhost', dbus_stream_id, my_bus_name)
-
# offer a D-Bus tube to another room using new API
muc = 'chat2@conf.localhost'
request = {
@@ -207,73 +127,40 @@ def test(q, bus, conn, stream, access_control):
}
join_muc(q, bus, conn, stream, muc, request=request)
- # The order in which the NewChannels signals are fired is
- # undefined -- it could be the (tubes, text) channels first, or it
- # could be the tube channel first; so let's accept either order
- # here.
-
- first, second = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannels'),
- EventPattern('dbus-signal', signal='NewChannels'))
-
- # NewChannels signal with the text and tubes channels together.
- def nc_textandtubes(event):
- channels = event.args[0]
- assert len(channels) == 2
- path1, prop1 = channels[0]
- path2, prop2 = channels[1]
- assert sorted([prop1[cs.CHANNEL_TYPE], prop2[cs.CHANNEL_TYPE]]) == \
- [cs.CHANNEL_TYPE_TEXT, cs.CHANNEL_TYPE_TUBES]
-
- got_text, got_tubes = False, False
+ def find_text_channel(channels):
for path, props in channels:
if props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT:
- got_text = True
-
- text_chan = dbus.Interface(bus.get_object(conn.bus_name, path),
- cs.CHANNEL)
- elif props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TUBES:
- got_tubes = True
-
- tubes_iface = dbus.Interface(bus.get_object(conn.bus_name, path),
- cs.CHANNEL_TYPE_TUBES)
- else:
- assert False
-
- assert props[cs.INITIATOR_HANDLE] == self_handle
- assert props[cs.INITIATOR_ID] == self_name
- assert cs.CHANNEL_IFACE_GROUP in props[cs.INTERFACES]
- assert props[cs.TARGET_ID] == 'chat2@conf.localhost'
- assert props[cs.REQUESTED] == False
-
- assert (got_text, got_tubes) == (True, True)
-
- return text_chan
-
- # NewChannels signal with the tube channel.
- def nc_tube(event):
- # FIXME: in this case, all channels should probably be announced together
- channels = event.args[0]
- assert len(channels) == 1
- path, prop = channels[0]
- assert prop[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
- assert prop[cs.INITIATOR_ID] == 'chat2@conf.localhost/test'
- assert prop[cs.REQUESTED] == True
- assert prop[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM
- assert prop[cs.TARGET_ID] == 'chat2@conf.localhost'
- assert prop[cs.DBUS_TUBE_SERVICE_NAME] == 'com.example.TestCase'
- assert prop[cs.DBUS_TUBE_SUPPORTED_ACCESS_CONTROLS] == [cs.SOCKET_ACCESS_CONTROL_CREDENTIALS,
+ return path, props
+
+ return None, None
+
+ def tube_chan_predicate(e):
+ path, props = e.args[0][0]
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
+
+ def text_chan_predicate(e):
+ path, _ = find_text_channel(e.args[0])
+ return path is not None
+
+ # TODO: these two should really come together
+ e_tube, e_text = q.expect_many(EventPattern('dbus-signal', signal='NewChannels',
+ predicate=tube_chan_predicate),
+ EventPattern('dbus-signal', signal='NewChannels',
+ predicate=text_chan_predicate))
+
+ e = e_tube
+ channels = e.args[0]
+ assert len(channels) == 1
+ path, prop = channels[0]
+ assert prop[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
+ assert prop[cs.INITIATOR_ID] == 'chat2@conf.localhost/test'
+ assert prop[cs.REQUESTED] == True
+ assert prop[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM
+ assert prop[cs.TARGET_ID] == 'chat2@conf.localhost'
+ assert prop[cs.DBUS_TUBE_SERVICE_NAME] == 'com.example.TestCase'
+ assert prop[cs.DBUS_TUBE_SUPPORTED_ACCESS_CONTROLS] == [cs.SOCKET_ACCESS_CONTROL_CREDENTIALS,
cs.SOCKET_ACCESS_CONTROL_LOCALHOST]
- return path, prop
-
- if len(first.args[0]) == 1:
- path, prop = nc_tube(first)
- text_chan = nc_textandtubes(second)
- else:
- text_chan = nc_textandtubes(first)
- path, prop = nc_tube(second)
-
# check that the tube channel is in the channels list
all_channels = conn.Get(cs.CONN_IFACE_REQUESTS, 'Channels',
dbus_interface=cs.PROPERTIES_IFACE, byte_arrays=True)
@@ -287,6 +174,19 @@ def test(q, bus, conn, stream, access_control):
assert tube_props['State'] == cs.TUBE_CHANNEL_STATE_NOT_OFFERED
+ # now check the text channel
+ e = e_text
+ path, prop = find_text_channel(e.args[0])
+ assert prop[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT
+ assert prop[cs.INITIATOR_HANDLE] == self_handle
+ assert prop[cs.INITIATOR_ID] == self_name
+ assert cs.CHANNEL_IFACE_GROUP in prop[cs.INTERFACES]
+ assert prop[cs.TARGET_ID] == 'chat2@conf.localhost'
+ assert prop[cs.REQUESTED] == False
+
+ text_chan = dbus.Interface(bus.get_object(conn.bus_name, path),
+ cs.CHANNEL)
+
# try to offer using a wrong access control
try:
dbus_tube_iface.Offer(sample_parameters, cs.SOCKET_ACCESS_CONTROL_PORT)
@@ -298,8 +198,7 @@ def test(q, bus, conn, stream, access_control):
# offer the tube
call_async(q, dbus_tube_iface, 'Offer', sample_parameters, access_control)
- new_tube_event, presence_event, return_event, status_event, dbus_changed_event = q.expect_many(
- EventPattern('dbus-signal', signal='NewTube'),
+ presence_event, return_event, status_event, dbus_changed_event = q.expect_many(
EventPattern('stream-presence', to='chat2@conf.localhost/test'),
EventPattern('dbus-return', method='Offer'),
EventPattern('dbus-signal', signal='TubeChannelStateChanged', args=[cs.TUBE_CHANNEL_STATE_OPEN]),
@@ -308,17 +207,11 @@ def test(q, bus, conn, stream, access_control):
tube_self_handle = tube_chan.GetSelfHandle(dbus_interface=cs.CHANNEL_IFACE_GROUP)
assert tube_self_handle != 0
- # handle new_tube_event
- dbus_tube_id = new_tube_event.args[0]
- assert new_tube_event.args[2] == cs.TUBE_TYPE_DBUS
- assert new_tube_event.args[3] == 'com.example.TestCase'
- assert new_tube_event.args[4] == sample_parameters
- assert new_tube_event.args[5] == cs.TUBE_STATE_OPEN
-
# handle presence_event
# We announce our newly created tube in our muc presence
presence = presence_event.stanza
- dbus_stream_id, my_bus_name = check_tube_in_presence(presence, dbus_tube_id, 'chat2@conf.localhost/test')
+ dbus_stream_id, my_bus_name, dbus_tube_id = check_tube_in_presence(presence,
+ 'chat2@conf.localhost/test')
# handle dbus_changed_event
added, removed = dbus_changed_event.args
@@ -330,9 +223,6 @@ def test(q, bus, conn, stream, access_control):
bob_bus_name = ':2.Ym9i'
bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat2@conf.localhost/bob'])[0]
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assertEquals(1, len(tubes))
-
def bob_in_tube():
presence = elem('presence', from_='chat2@conf.localhost/bob', to='chat2@conf.localhost')(
elem('x', xmlns=ns.MUC_USER),
@@ -422,7 +312,8 @@ def test(q, bus, conn, stream, access_control):
# tube is created as well
- e = q.expect('dbus-signal', signal='NewChannels')
+ e = q.expect('dbus-signal', signal='NewChannels',
+ predicate=tube_chan_predicate)
tube_path, props = e.args[0][0]
assertEquals(cs.CHANNEL_TYPE_DBUS_TUBE, props[cs.CHANNEL_TYPE])
assertEquals('chat2@conf.localhost/test', props[cs.INITIATOR_ID])
@@ -431,30 +322,18 @@ def test(q, bus, conn, stream, access_control):
assertEquals('com.example.TestCase', props[cs.DBUS_TUBE_SERVICE_NAME])
# text channel is created
- e = q.expect('dbus-signal', signal='NewChannels')
+ e = q.expect('dbus-signal', signal='NewChannels',
+ predicate=text_chan_predicate)
path, props = e.args[0][0]
assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE])
assertEquals(True, props[cs.REQUESTED])
- # tubes channel is created
- e = q.expect('dbus-signal', signal='NewChannels')
- path, props = e.args[0][0]
- assertEquals(cs.CHANNEL_TYPE_TUBES, props[cs.CHANNEL_TYPE])
- assertEquals(False, props[cs.REQUESTED])
-
- tubes_iface = dbus.Interface(bus.get_object(conn.bus_name, path),
- cs.CHANNEL_TYPE_TUBES)
-
# tube is local-pending
tube_chan = bus.get_object(conn.bus_name, tube_path)
state = tube_chan.Get(cs.CHANNEL_IFACE_TUBE, 'State',
dbus_interface=dbus.PROPERTIES_IFACE)
assertEquals(cs.TUBE_STATE_LOCAL_PENDING, state)
- # tube is listed on the old interface
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assertEquals(1, len(tubes))
-
if __name__ == '__main__':
# We can't use t.exec_dbus_tube_test() as we can use only the muc bytestream
exec_test(lambda q, bus, conn, stream:
diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index 433d79c82..2188e82a9 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -11,7 +11,6 @@ import constants as cs
import ns
import tubetestutil as t
from mucutil import join_muc
-from muctubeutil import get_muc_tubes_channel
from bytestream import BytestreamS5BRelay, BytestreamS5BRelayBugged
from twisted.words.xish import xpath
@@ -73,127 +72,25 @@ def test(q, bus, conn, stream, bytestream_cls,
acknowledge_iq(stream, iq_event.stanza)
- self_handle = conn.GetSelfHandle()
- self_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0]
-
t.check_conn_properties(q, conn)
- room_handle, tubes_chan, tubes_iface = get_muc_tubes_channel(q, bus, conn,
- stream, 'chat@conf.localhost')
-
- tubes_self_handle = tubes_chan.GetSelfHandle(dbus_interface=cs.CHANNEL_IFACE_GROUP)
-
bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat@conf.localhost/bob'])[0]
address = t.create_server(q, address_type)
- # offer stream tube (old API) using an Unix socket
- call_async(q, tubes_iface, 'OfferStreamTube',
- 'echo', sample_parameters, address_type, address,
- access_control, access_control_param)
+ def new_chan_predicate(e):
+ types = []
+ for _, props in e.args[0]:
+ types.append(props[cs.CHANNEL_TYPE])
- new_tube_event, stream_event, _, new_channels_event = q.expect_many(
- EventPattern('dbus-signal', signal='NewTube'),
- EventPattern('stream-presence', to='chat@conf.localhost/test'),
- EventPattern('dbus-return', method='OfferStreamTube'),
- EventPattern('dbus-signal', signal='NewChannels'))
-
- # handle new_tube_event
- stream_tube_id = new_tube_event.args[0]
- assert new_tube_event.args[1] == tubes_self_handle
- assert new_tube_event.args[2] == 1 # Stream
- assert new_tube_event.args[3] == 'echo'
- assert new_tube_event.args[4] == sample_parameters
- assert new_tube_event.args[5] == cs.TUBE_CHANNEL_STATE_OPEN
-
- # handle stream_event
- # We announce our newly created tube in our muc presence
- presence = stream_event.stanza
- tubes_nodes = xpath.queryForNodes('/presence/tubes[@xmlns="%s"]'
- % ns.TUBES, presence)
- assert tubes_nodes is not None
- assert len(tubes_nodes) == 1
+ return cs.CHANNEL_TYPE_STREAM_TUBE in types
- tube_nodes = xpath.queryForNodes('/tubes/tube', tubes_nodes[0])
- assert tube_nodes is not None
- assert len(tube_nodes) == 1
- for tube in tube_nodes:
- assert tube['type'] == 'stream'
- assert not tube.hasAttribute('initiator')
- assert tube['service'] == 'echo'
- assert not tube.hasAttribute('stream-id')
- assert not tube.hasAttribute('dbus-name')
- assert tube['id'] == str(stream_tube_id)
-
- params = {}
- parameter_nodes = xpath.queryForNodes('/tube/parameters/parameter', tube)
- for node in parameter_nodes:
- assert node['name'] not in params
- params[node['name']] = (node['type'], str(node))
- assert params == {'ay': ('bytes', 'aGVsbG8='),
- 's': ('str', 'hello'),
- 'i': ('int', '-123'),
- 'u': ('uint', '123'),
- }
-
- # tube is also announced using new API
- channels = new_channels_event.args[0]
- assert len(channels) == 1
- path, props = channels[0]
- assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
- assert props[cs.INITIATOR_HANDLE] == tubes_self_handle
- assert props[cs.INITIATOR_ID] == 'chat@conf.localhost/test'
- assert props[cs.INTERFACES] == [cs.CHANNEL_IFACE_GROUP, cs.CHANNEL_IFACE_TUBE]
- assert props[cs.REQUESTED] == True
- assert props[cs.TARGET_HANDLE] == room_handle
- assert props[cs.TARGET_ID] == 'chat@conf.localhost'
- assert props[cs.STREAM_TUBE_SERVICE] == 'echo'
-
- tube_chan = bus.get_object(conn.bus_name, path)
- tube_props = tube_chan.GetAll(cs.CHANNEL_IFACE_TUBE, dbus_interface=cs.PROPERTIES_IFACE,
- byte_arrays=True)
- assert tube_props['Parameters'] == sample_parameters
- assert tube_props['State'] == cs.TUBE_CHANNEL_STATE_OPEN
-
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assert tubes == [(
- stream_tube_id,
- tubes_self_handle,
- 1, # Stream
- 'echo',
- sample_parameters,
- cs.TUBE_CHANNEL_STATE_OPEN
- )]
-
- assert len(tubes) == 1, unwrap(tubes)
- expected_tube = (stream_tube_id, tubes_self_handle, cs.TUBE_TYPE_STREAM,
- 'echo', sample_parameters, cs.TUBE_STATE_OPEN)
- t.check_tube_in_tubes(expected_tube, tubes)
-
- # FIXME: if we use an unknown JID here, everything fails
- # (the code uses lookup where it should use ensure)
-
- bytestream = connect_to_tube(stream, q, bytestream_cls, 'chat@conf.localhost', stream_tube_id)
-
- iq_event, socket_event, _, conn_event = q.expect_many(
- EventPattern('stream-iq', iq_type='result'),
- EventPattern('socket-connected'),
- EventPattern('dbus-signal', signal='StreamTubeNewConnection',
- args=[stream_tube_id, bob_handle], interface=cs.CHANNEL_TYPE_TUBES),
- EventPattern('dbus-signal', signal='NewRemoteConnection',
- interface=cs.CHANNEL_TYPE_STREAM_TUBE))
-
- protocol = socket_event.protocol
-
- # handle iq_event
- bytestream.check_si_reply(iq_event.stanza)
- tube = xpath.queryForNodes('/iq//si/tube[@xmlns="%s"]' % ns.TUBES, iq_event.stanza)
- assert len(tube) == 1
-
- handle, access, conn_id = conn_event.args
- assert handle == bob_handle
+ def find_stream_tube(channels):
+ for path, props in channels:
+ if props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE:
+ return path, props
- use_tube(q, bytestream, protocol, conn_id)
+ return None, None
# offer a stream tube to another room (new API)
address = t.create_server(q, address_type, block_reading=True)
@@ -201,68 +98,22 @@ def test(q, bus, conn, stream, bytestream_cls,
request = {
cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
cs.TARGET_HANDLE_TYPE: cs.HT_ROOM,
- cs.TARGET_ID: 'chat2@conf.localhost',
+ cs.TARGET_ID: 'chat@conf.localhost',
cs.STREAM_TUBE_SERVICE: 'newecho',
}
_, _, new_tube_path, new_tube_props = \
- join_muc(q, bus, conn, stream, 'chat2@conf.localhost', request)
-
- # The order in which the NewChannels signals are fired is
- # undefined -- it could be the (tubes, text) channels first, or it
- # could be the tube channel first; so let's accept either order
- # here.
-
- first, second = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannels'),
- EventPattern('dbus-signal', signal='NewChannels'))
-
- # NewChannels signal with the text and tubes channels together.
- def nc_textandtubes(event):
- channels = event.args[0]
- assert len(channels) == 2
- path1, prop1 = channels[0]
- path2, prop2 = channels[1]
- assert sorted([prop1[cs.CHANNEL_TYPE], prop2[cs.CHANNEL_TYPE]]) == \
- [cs.CHANNEL_TYPE_TEXT, cs.CHANNEL_TYPE_TUBES]
-
- got_text, got_tubes = False, False
- for path, props in channels:
- if props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT:
- got_text = True
- elif props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TUBES:
- got_tubes = True
- else:
- assert False
-
- assert props[cs.INITIATOR_HANDLE] == self_handle
- assert props[cs.INITIATOR_ID] == self_name
- assert cs.CHANNEL_IFACE_GROUP in props[cs.INTERFACES]
- assert props[cs.TARGET_ID] == 'chat2@conf.localhost'
- assert props[cs.REQUESTED] == False
-
- assert (got_text, got_tubes) == (True, True)
-
- # NewChannels signal with the tube channel.
- def nc_tube(event):
- # FIXME: in this case, all channels should probably be announced together
- channels = event.args[0]
- assert len(channels) == 1
- path, prop = channels[0]
- assert prop[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
- assert prop[cs.INITIATOR_ID] == 'chat2@conf.localhost/test'
- assert prop[cs.REQUESTED] == True
- assert prop[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM
- assert prop[cs.TARGET_ID] == 'chat2@conf.localhost'
- assert prop[cs.STREAM_TUBE_SERVICE] == 'newecho'
-
- return path, prop
-
- if len(first.args[0]) == 1:
- path, prop = nc_tube(first)
- nc_textandtubes(second)
- else:
- nc_textandtubes(first)
- path, prop = nc_tube(second)
+ join_muc(q, bus, conn, stream, 'chat@conf.localhost', request)
+
+ e = q.expect('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate)
+
+ path, prop = find_stream_tube(e.args[0])
+ assert prop[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
+ assert prop[cs.INITIATOR_ID] == 'chat@conf.localhost/test'
+ assert prop[cs.REQUESTED] == True
+ assert prop[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM
+ assert prop[cs.TARGET_ID] == 'chat@conf.localhost'
+ assert prop[cs.STREAM_TUBE_SERVICE] == 'newecho'
# check that the tube channel is in the channels list
all_channels = conn.Get(cs.CONN_IFACE_REQUESTS, 'Channels',
@@ -279,21 +130,13 @@ def test(q, bus, conn, stream, bytestream_cls,
# offer the tube
call_async(q, stream_tube_iface, 'Offer', address_type, address, access_control, {'foo': 'bar'})
- new_tube_event, stream_event, _, status_event = q.expect_many(
- EventPattern('dbus-signal', signal='NewTube'),
- EventPattern('stream-presence', to='chat2@conf.localhost/test'),
+ stream_event, _, status_event = q.expect_many(
+ EventPattern('stream-presence', to='chat@conf.localhost/test'),
EventPattern('dbus-return', method='Offer'),
EventPattern('dbus-signal', signal='TubeChannelStateChanged', args=[cs.TUBE_CHANNEL_STATE_OPEN]))
tube_self_handle = tube_chan.GetSelfHandle(dbus_interface=cs.CHANNEL_IFACE_GROUP)
- assert conn.InspectHandles(cs.HT_CONTACT, [tube_self_handle]) == ['chat2@conf.localhost/test']
-
- # handle new_tube_event
- stream_tube_id = new_tube_event.args[0]
- assert new_tube_event.args[2] == 1 # Stream
- assert new_tube_event.args[3] == 'newecho'
- assert new_tube_event.args[4] == {'foo': 'bar'}
- assert new_tube_event.args[5] == cs.TUBE_CHANNEL_STATE_OPEN
+ assert conn.InspectHandles(cs.HT_CONTACT, [tube_self_handle]) == ['chat@conf.localhost/test']
presence = stream_event.stanza
tubes_nodes = xpath.queryForNodes('/presence/tubes[@xmlns="%s"]'
@@ -301,6 +144,8 @@ def test(q, bus, conn, stream, bytestream_cls,
assert tubes_nodes is not None
assert len(tubes_nodes) == 1
+ stream_tube_id = 666
+
tube_nodes = xpath.queryForNodes('/tubes/tube', tubes_nodes[0])
assert tube_nodes is not None
assert len(tube_nodes) == 1
@@ -310,7 +155,8 @@ def test(q, bus, conn, stream, bytestream_cls,
assert tube['service'] == 'newecho'
assert not tube.hasAttribute('stream-id')
assert not tube.hasAttribute('dbus-name')
- assert tube['id'] == str(stream_tube_id)
+
+ stream_tube_id = int(tube['id'])
params = {}
parameter_nodes = xpath.queryForNodes('/tube/parameters/parameter', tube)
@@ -319,9 +165,9 @@ def test(q, bus, conn, stream, bytestream_cls,
params[node['name']] = (node['type'], str(node))
assert params == {'foo': ('str', 'bar')}
- bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat2@conf.localhost/bob'])[0]
+ bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat@conf.localhost/bob'])[0]
- bytestream = connect_to_tube(stream, q, bytestream_cls, 'chat2@conf.localhost', stream_tube_id)
+ bytestream = connect_to_tube(stream, q, bytestream_cls, 'chat@conf.localhost', stream_tube_id)
iq_event, socket_event, conn_event = q.expect_many(
EventPattern('stream-iq', iq_type='result'),
diff --git a/tests/twisted/tubes/offer-no-caps.py b/tests/twisted/tubes/offer-no-caps.py
index 09532736a..6aa9f4071 100644
--- a/tests/twisted/tubes/offer-no-caps.py
+++ b/tests/twisted/tubes/offer-no-caps.py
@@ -65,30 +65,12 @@ def test(q, bus, conn, stream):
# caps to appear, just like the StreamedMedia channel does.
sync_stream(q, stream)
- requests = dbus.Interface(conn, cs.CONN_IFACE_REQUESTS)
-
- # First, we make an old-style Tubes channel, which should work; calling
- # OfferStreamTube or OfferDBusTube on it, however, should fail with
- # NotAvailable
- path, _ = requests.CreateChannel(props(cs.CHANNEL_TYPE_TUBES))
- tubes = make_channel_proxy(conn, path, 'Channel.Type.Tubes')
-
- call_async(q, tubes, 'OfferDBusTube', 'com.example.monkeys', {})
- e = q.expect('dbus-error', method='OfferDBusTube').error
- assert e.get_dbus_name() == cs.NOT_AVAILABLE, e.get_dbus_name()
-
address = t.create_server(q, cs.SOCKET_ADDRESS_TYPE_IPV4)
- call_async(q, tubes, 'OfferStreamTube', 'echo', {},
- cs.SOCKET_ADDRESS_TYPE_IPV4, address,
- cs.SOCKET_ACCESS_CONTROL_LOCALHOST, "")
- e = q.expect('dbus-error', method='OfferStreamTube').error
- assert e.get_dbus_name() == cs.NOT_AVAILABLE, e.get_dbus_name()
-
# Now we try making new-style DBusTube and StreamTube channels, and calling
# the relevant Offer method on them; this should fail with NotAvailable.
# FIXME: I think this should be NotCapable
- st_path, _ = requests.CreateChannel(props(cs.CHANNEL_TYPE_STREAM_TUBE,
+ st_path, _ = conn.Requests.CreateChannel(props(cs.CHANNEL_TYPE_STREAM_TUBE,
{cs.STREAM_TUBE_SERVICE: "newecho"}))
st_chan = bus.get_object(conn.bus_name, st_path)
st = dbus.Interface(st_chan, cs.CHANNEL_TYPE_STREAM_TUBE)
@@ -97,7 +79,7 @@ def test(q, bus, conn, stream):
e = q.expect('dbus-error', method='Offer').error
assert e.get_dbus_name() == cs.NOT_AVAILABLE, e.get_dbus_name()
- dt_path, _ = requests.CreateChannel(props(cs.CHANNEL_TYPE_DBUS_TUBE,
+ dt_path, _ = conn.Requests.CreateChannel(props(cs.CHANNEL_TYPE_DBUS_TUBE,
{ cs.DBUS_TUBE_SERVICE_NAME: "com.newecho" }))
dt_chan = bus.get_object(conn.bus_name, dt_path)
dt = dbus.Interface(dt_chan, cs.CHANNEL_TYPE_DBUS_TUBE)
diff --git a/tests/twisted/tubes/offer-private-dbus-tube.py b/tests/twisted/tubes/offer-private-dbus-tube.py
index 181311da7..bb61eb21c 100644
--- a/tests/twisted/tubes/offer-private-dbus-tube.py
+++ b/tests/twisted/tubes/offer-private-dbus-tube.py
@@ -5,7 +5,7 @@ from dbus.connection import Connection
from dbus.lowlevel import SignalMessage
from servicetest import call_async, EventPattern, unwrap, watch_tube_signals,\
- assertContains
+ assertContains, assertEquals
from gabbletest import sync_stream, make_presence
import constants as cs
import tubetestutil as t
@@ -57,8 +57,8 @@ def alice_accepts_tube(q, stream, iq_event, dbus_tube_id, bytestream_cls):
bytestream.wait_bytestream_open()
- q.expect('dbus-signal', signal='TubeStateChanged',
- args=[dbus_tube_id, cs.TUBE_STATE_OPEN])
+ q.expect('dbus-signal', signal='TubeChannelStateChanged',
+ args=[cs.TUBE_STATE_OPEN])
return bytestream
@@ -98,74 +98,24 @@ def send_dbus_message_to_alice(q, stream, dbus_tube_adr, bytestream):
q.expect('tube-signal', signal='baz', args=[42], tube=tube)
q.expect('tube-signal', signal='baz', args=[42], tube=tube)
-def offer_old_dbus_tube(q, bus, conn, stream, self_handle, alice_handle, bytestream_cls):
- # request tubes channel (old API)
- tubes_path = conn.RequestChannel(cs.CHANNEL_TYPE_TUBES, cs.HT_CONTACT,
- alice_handle, True)
- tubes_chan = bus.get_object(conn.bus_name, tubes_path)
- tubes_iface = dbus.Interface(tubes_chan, cs.CHANNEL_TYPE_TUBES)
- tubes_chan_iface = dbus.Interface(tubes_chan, cs.CHANNEL)
-
- # Exercise basic Channel Properties from spec 0.17.7
- channel_props = tubes_chan.GetAll(cs.CHANNEL, dbus_interface=cs.PROPERTIES_IFACE)
- assert channel_props.get('TargetHandle') == alice_handle,\
- (channel_props.get('TargetHandle'), alice_handle)
- assert channel_props.get('TargetHandleType') == cs.HT_CONTACT,\
- channel_props.get('TargetHandleType')
- assert channel_props.get('ChannelType') == cs.CHANNEL_TYPE_TUBES,\
- channel_props.get('ChannelType')
- assert 'Interfaces' in channel_props, channel_props
- assert channel_props['Interfaces'] == [], channel_props['Interfaces']
- assert channel_props['TargetID'] == 'alice@localhost', channel_props['TargetID']
- assert channel_props['Requested'] == True
- assert channel_props['InitiatorID'] == 'test@localhost'
- assert channel_props['InitiatorHandle'] == conn.GetSelfHandle()
-
- # Offer a D-Bus tube using old API
- call_async(q, tubes_iface, 'OfferDBusTube',
- 'com.example.TestCase', sample_parameters)
-
- new_tube_event, iq_event, offer_return_event = \
- q.expect_many(
- EventPattern('dbus-signal', signal='NewTube'),
- EventPattern('stream-iq', to='alice@localhost/Test'),
- EventPattern('dbus-return', method='OfferDBusTube'))
-
- # handle new_tube_event
- dbus_tube_id = new_tube_event.args[0]
- assert new_tube_event.args[1] == self_handle
- assert new_tube_event.args[2] == cs.TUBE_TYPE_DBUS
- assert new_tube_event.args[3] == 'com.example.TestCase'
- assert new_tube_event.args[4] == sample_parameters
- assert new_tube_event.args[5] == cs.TUBE_STATE_REMOTE_PENDING
-
- # handle offer_return_event
- assert offer_return_event.value[0] == dbus_tube_id
-
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assert len(tubes) == 1
- expected_tube = (dbus_tube_id, self_handle, cs.TUBE_TYPE_DBUS,
- 'com.example.TestCase', sample_parameters, cs.TUBE_STATE_REMOTE_PENDING)
- t.check_tube_in_tubes(expected_tube, tubes)
-
- bytestream = alice_accepts_tube(q, stream, iq_event, dbus_tube_id, bytestream_cls)
-
- dbus_tube_adr = tubes_iface.GetDBusTubeAddress(dbus_tube_id)
- send_dbus_message_to_alice(q, stream, dbus_tube_adr, bytestream)
+def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
+ bytestream_cls, access_control):
- # close the tube
- tubes_iface.CloseTube(dbus_tube_id)
- q.expect('dbus-signal', signal='TubeClosed', args=[dbus_tube_id])
+ # Offer a tube to Alice (new API)
- # and close the tubes channel
- tubes_chan_iface.Close()
- q.expect('dbus-signal', signal='Closed')
+ def new_chan_predicate(e):
+ types = []
+ for _, props in e.args[0]:
+ types.append(props[cs.CHANNEL_TYPE])
+ return cs.CHANNEL_TYPE_DBUS_TUBE in types
-def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
- bytestream_cls, access_control):
+ def find_dbus_tube(channels):
+ for path, props in channels:
+ if props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE:
+ return path, props
- # Offer a tube to Alice (new API)
+ return None, None
call_async(q, conn.Requests, 'CreateChannel',
{cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_DBUS_TUBE,
@@ -175,10 +125,11 @@ def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
}, byte_arrays=True)
cc_ret, nc = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
+ EventPattern('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate),
)
tube_path, tube_props = cc_ret.value
- new_channel_details = nc.args[0]
+ _, new_channel_props = find_dbus_tube(nc.args[0])
# check tube channel properties
assert tube_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
@@ -200,34 +151,10 @@ def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
all_channels = conn.Get(cs.CONN_IFACE_REQUESTS, 'Channels',
dbus_interface=cs.PROPERTIES_IFACE, byte_arrays=True)
- for path, props in new_channel_details:
+ for path, props in nc.args[0]:
assertContains((path, props), all_channels)
- # Under the current implementation, creating a new-style Tube channel
- # ensures that an old-style Tubes channel exists, even though Tube channels
- # aren't visible on the Tubes channel until they're offered. Another
- # correct implementation would have the Tubes channel spring up only when
- # the Tube is offered.
- #
- # Anyway. Given the current implementation, they should be announced together.
- assert len(new_channel_details) == 2, unwrap(new_channel_details)
- found_tubes = False
- found_tube = False
- for path, details in new_channel_details:
- if details[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TUBES:
- found_tubes = True
- tubes_chan = bus.get_object(conn.bus_name, path)
- tubes_iface = dbus.Interface(tubes_chan, cs.CHANNEL_TYPE_TUBES)
- elif details[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE:
- found_tube = True
- assert tube_path == path, (tube_path, path)
- else:
- assert False, (path, details)
- assert found_tube and found_tubes, unwrap(new_channel_details)
-
- # The tube's not offered, so it shouldn't be shown on the old interface.
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assert len(tubes) == 0, tubes
+ assertEquals(tube_props, new_channel_props)
tube_chan = bus.get_object(conn.bus_name, tube_path)
tube_chan_iface = dbus.Interface(tube_chan, cs.CHANNEL)
@@ -248,10 +175,9 @@ def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
# arrived if it had been sent.
sync_stream(q, stream)
call_async(q, dbus_tube_iface, 'Offer', sample_parameters, access_control)
- offer_return_event, iq_event, new_tube_event, state_event = q.expect_many(
+ offer_return_event, iq_event, state_event = q.expect_many(
EventPattern('dbus-return', method='Offer'),
EventPattern('stream-iq', to='alice@localhost/Test'),
- EventPattern('dbus-signal', signal='NewTube'),
EventPattern('dbus-signal', signal='TubeChannelStateChanged'),
)
@@ -260,13 +186,6 @@ def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
assert state_event.args[0] == cs.TUBE_CHANNEL_STATE_REMOTE_PENDING
- # Now the tube's been offered, it should be shown on the old interface
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- assert len(tubes) == 1
- expected_tube = (None, self_handle, cs.TUBE_TYPE_DBUS, 'com.example.TestCase',
- sample_parameters, cs.TUBE_STATE_REMOTE_PENDING)
- t.check_tube_in_tubes(expected_tube, tubes)
-
status = tube_chan.Get(cs.CHANNEL_IFACE_TUBE, 'State', dbus_interface=cs.PROPERTIES_IFACE)
assert status == cs.TUBE_STATE_REMOTE_PENDING
@@ -304,7 +223,6 @@ def test(q, bus, conn, stream, bytestream_cls, access_control):
sync_stream(q, stream)
- offer_old_dbus_tube(q, bus, conn, stream, self_handle, alice_handle, bytestream_cls)
offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle, bytestream_cls, access_control)
if __name__ == '__main__':
diff --git a/tests/twisted/tubes/offer-private-stream-tube.py b/tests/twisted/tubes/offer-private-stream-tube.py
index 71f59be19..de37041c2 100644
--- a/tests/twisted/tubes/offer-private-stream-tube.py
+++ b/tests/twisted/tubes/offer-private-stream-tube.py
@@ -98,27 +98,6 @@ def test(q, bus, conn, stream, bytestream_cls,
# Test tubes with Bob. Bob has tube capabilities.
bob_handle = conn.RequestHandles(1, ['bob@localhost'])[0]
- # old tubes API
- call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TUBES, cs.HT_CONTACT,
- bob_handle, True)
-
- ret, old_sig, new_sig = q.expect_many(
- EventPattern('dbus-return', method='RequestChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
-
- assert len(ret.value) == 1
- chan_path = ret.value[0]
-
- t.check_NewChannel_signal(old_sig.args, cs.CHANNEL_TYPE_TUBES, chan_path,
- bob_handle, True)
- t.check_NewChannels_signal(conn, new_sig.args, cs.CHANNEL_TYPE_TUBES, chan_path,
- bob_handle, 'bob@localhost', self_handle)
- old_tubes_channel_properties = new_sig.args[0][0]
-
- t.check_conn_properties(q, conn, [old_tubes_channel_properties])
-
# Try CreateChannel with correct properties
# Gabble must succeed
call_async(q, conn.Requests, 'CreateChannel',
@@ -128,15 +107,23 @@ def test(q, bus, conn, stream, bytestream_cls,
cs.STREAM_TUBE_SERVICE: "newecho",
})
- # the NewTube signal (old API) is not fired now as the tube wasn't offered
- # yet
- ret, old_sig, new_sig = q.expect_many(
+ def find_stream_tube(channels):
+ for path, props in channels:
+ if props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE:
+ return path, props
+
+ return None, None
+
+ def new_chan_predicate(e):
+ path, _ = find_stream_tube(e.args[0])
+ return path is not None
+
+ ret, new_sig = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
+ EventPattern('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate),
)
- assert len(ret.value) == 2 # CreateChannel returns 2 values: o, a{sv}
new_chan_path = ret.value[0]
new_chan_prop_asv = ret.value[1]
# State and Parameters are mutables so not announced
@@ -144,9 +131,6 @@ def test(q, bus, conn, stream, bytestream_cls,
assert cs.TUBE_PARAMETERS not in new_chan_prop_asv
assert new_chan_path.find("StreamTube") != -1, new_chan_path
assert new_chan_path.find("SITubesChannel") == -1, new_chan_path
- # The path of the Channel.Type.Tubes object MUST be different to the path
- # of the Channel.Type.StreamTube object !
- assert chan_path != new_chan_path
new_tube_chan = bus.get_object(conn.bus_name, new_chan_path)
new_tube_iface = dbus.Interface(new_tube_chan, cs.CHANNEL_TYPE_STREAM_TUBE)
@@ -158,110 +142,15 @@ def test(q, bus, conn, stream, bytestream_cls,
# the tube created using the new API is in the "not offered" state
assert new_tube_props['State'] == cs.TUBE_CHANNEL_STATE_NOT_OFFERED
- t.check_NewChannel_signal(old_sig.args, cs.CHANNEL_TYPE_STREAM_TUBE,
- new_chan_path, bob_handle, True)
- t.check_NewChannels_signal(conn, new_sig.args, cs.CHANNEL_TYPE_STREAM_TUBE,
- new_chan_path, bob_handle, 'bob@localhost', self_handle)
- stream_tube_channel_properties = new_sig.args[0][0]
+ _, stream_tube_channel_properties = find_stream_tube(new_sig.args[0])
assert cs.TUBE_STATE not in stream_tube_channel_properties
assert cs.TUBE_PARAMETERS not in stream_tube_channel_properties
- t.check_conn_properties(q, conn,
- [old_tubes_channel_properties, stream_tube_channel_properties])
-
- tubes_chan = bus.get_object(conn.bus_name, chan_path)
- tubes_iface = dbus.Interface(tubes_chan, cs.CHANNEL_TYPE_TUBES)
-
- t.check_channel_properties(q, bus, conn, tubes_chan, cs.CHANNEL_TYPE_TUBES,
- bob_handle, "bob@localhost")
-
- # Create another tube using old API
- call_async(q, tubes_iface, 'OfferStreamTube',
- 'echo', sample_parameters, address_type, address1,
- access_control, access_control_param)
-
- event, return_event, new_chan, new_chans = q.expect_many(
- EventPattern('stream-message'),
- EventPattern('dbus-return', method='OfferStreamTube'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'))
-
- message = event.stanza
- assert message['to'] == bob_full_jid
- tube_nodes = xpath.queryForNodes('/message/tube[@xmlns="%s"]' % ns.TUBES,
- message)
- assert tube_nodes is not None
- assert len(tube_nodes) == 1
- tube = tube_nodes[0]
-
- assert tube['service'] == 'echo'
- assert tube['type'] == 'stream'
- assert not tube.hasAttribute('initiator')
- stream_tube_id = long(tube['id'])
-
- params = {}
- parameter_nodes = xpath.queryForNodes('/tube/parameters/parameter', tube)
- for node in parameter_nodes:
- assert node['name'] not in params
- params[node['name']] = (node['type'], str(node))
- assert params == {'ay': ('bytes', 'aGVsbG8='),
- 's': ('str', 'hello'),
- 'i': ('int', '-123'),
- 'u': ('uint', '123'),
- }
-
-
- # the tube channel (new API) is announced
- t.check_NewChannel_signal(new_chan.args, cs.CHANNEL_TYPE_STREAM_TUBE,
- None, bob_handle, False)
- t.check_NewChannels_signal(conn, new_chans.args, cs.CHANNEL_TYPE_STREAM_TUBE,
- new_chan.args[0], bob_handle, "bob@localhost", self_handle)
-
- props = new_chans.args[0][0][1]
- assert cs.TUBE_STATE not in props
- assert cs.TUBE_PARAMETERS not in props
-
- # We offered a tube using the old tube API and created one with the new
- # API, so there are 2 tubes. Check the new tube API works
- assert len(filter(lambda x:
- x[1] == cs.CHANNEL_TYPE_TUBES,
- conn.ListChannels())) == 1
- channels = filter(lambda x:
- x[1] == cs.CHANNEL_TYPE_STREAM_TUBE and
- x[0] == new_chan_path,
- conn.ListChannels())
- assert len(channels) == 1
- assert new_chan_path == channels[0][0]
-
- old_tube_chan = bus.get_object(conn.bus_name, new_chan.args[0])
-
- tube_basic_props = old_tube_chan.GetAll(cs.CHANNEL,
- dbus_interface=cs.PROPERTIES_IFACE)
- assert tube_basic_props.get("InitiatorHandle") == self_handle
-
- stream_tube_props = old_tube_chan.GetAll(cs.CHANNEL_TYPE_STREAM_TUBE,
- dbus_interface=cs.PROPERTIES_IFACE)
- assert stream_tube_props.get("Service") == "echo", stream_tube_props
-
- old_tube_props = old_tube_chan.GetAll(cs.CHANNEL_IFACE_TUBE,
- dbus_interface=cs.PROPERTIES_IFACE, byte_arrays=True)
- assert old_tube_props.get("Parameters") == dbus.Dictionary(sample_parameters)
-
- # Tube have been created using the old API and so is already offered
- assert old_tube_props['State'] == cs.TUBE_CHANNEL_STATE_REMOTE_PENDING
-
- t.check_channel_properties(q, bus, conn, tubes_chan, cs.CHANNEL_TYPE_TUBES,
- bob_handle, "bob@localhost")
- t.check_channel_properties(q, bus, conn, old_tube_chan,
- cs.CHANNEL_TYPE_STREAM_TUBE, bob_handle, "bob@localhost",
- cs.TUBE_CHANNEL_STATE_REMOTE_PENDING)
-
- # Offer the first tube created (new API)
+ # Offer the first tube created
call_async(q, new_tube_iface, 'Offer', address_type, address2, access_control, new_sample_parameters)
- msg_event, new_tube_sig, state_event = q.expect_many(
+ msg_event, state_event = q.expect_many(
EventPattern('stream-message'),
- EventPattern('dbus-signal', signal='NewTube'),
EventPattern('dbus-signal', signal='TubeChannelStateChanged'))
assert state_event.args[0] == cs.TUBE_CHANNEL_STATE_REMOTE_PENDING
@@ -277,7 +166,7 @@ def test(q, bus, conn, stream, bytestream_cls,
assert tube['service'] == 'newecho'
assert tube['type'] == 'stream'
assert not tube.hasAttribute('initiator')
- new_stream_tube_id = long(tube['id'])
+ stream_tube_id = long(tube['id'])
params = {}
parameter_nodes = xpath.queryForNodes('/tube/parameters/parameter', tube)
@@ -290,17 +179,9 @@ def test(q, bus, conn, stream, bytestream_cls,
'u': ('uint', '123'),
}
- # check NewTube signal (old API)
- id, initiator_handle, type, service, params, state = new_tube_sig.args
- assert initiator_handle == self_handle
- assert type == 1 # stream
- assert service == 'newecho'
- assert params == new_sample_parameters
- assert state == 1 # remote pending
-
# The new tube has been offered, the parameters cannot be changed anymore
# We need to use call_async to check the error
- tube_prop_iface = dbus.Interface(old_tube_chan, cs.PROPERTIES_IFACE)
+ tube_prop_iface = dbus.Interface(new_tube_chan, cs.PROPERTIES_IFACE)
call_async(q, tube_prop_iface, 'Set', cs.CHANNEL_IFACE_TUBE,
'Parameters', dbus.Dictionary(
{dbus.String(u'foo2'): dbus.String(u'bar2')},
@@ -323,12 +204,10 @@ def test(q, bus, conn, stream, bytestream_cls,
stream_node['tube'] = str(stream_tube_id)
stream.send(iq)
- si_reply_event, _, _, new_conn_event, socket_event = q.expect_many(
+ si_reply_event, _, new_conn_event, socket_event = q.expect_many(
EventPattern('stream-iq', iq_type='result'),
- EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[stream_tube_id, cs.TUBE_STATE_OPEN]),
- EventPattern('dbus-signal', signal='StreamTubeNewConnection',
- args=[stream_tube_id, bob_handle]),
+ EventPattern('dbus-signal', signal='TubeChannelStateChanged',
+ args=[cs.TUBE_STATE_OPEN]),
EventPattern('dbus-signal', signal='NewRemoteConnection'),
EventPattern('socket-connected'))
@@ -348,11 +227,6 @@ def test(q, bus, conn, stream, bytestream_cls,
t.check_new_connection_access(q, access_control, access, protocol)
protocol.echoed = True
- expected_tube = (stream_tube_id, self_handle, cs.TUBE_TYPE_STREAM, 'echo',
- sample_parameters, cs.TUBE_STATE_OPEN)
- tubes = tubes_iface.ListTubes(byte_arrays=True)
- t.check_tube_in_tubes(expected_tube, tubes)
-
# The CM is the server, so fake a client wanting to talk to it
# New API tube
bytestream2 = bytestream_cls(stream, q, 'beta', bob_full_jid,
@@ -360,13 +234,11 @@ def test(q, bus, conn, stream, bytestream_cls,
iq, si = bytestream2.create_si_offer(ns.TUBES)
stream_node = si.addElement((ns.TUBES, 'stream'))
- stream_node['tube'] = str(new_stream_tube_id)
+ stream_node['tube'] = str(stream_tube_id)
stream.send(iq)
- si_reply_event, _, new_conn_event, socket_event = q.expect_many(
+ si_reply_event, new_conn_event, socket_event = q.expect_many(
EventPattern('stream-iq', iq_type='result'),
- EventPattern('dbus-signal', signal='TubeChannelStateChanged',
- args=[cs.TUBE_STATE_OPEN]),
EventPattern('dbus-signal', signal='NewRemoteConnection'),
EventPattern('socket-connected'))
@@ -386,10 +258,6 @@ def test(q, bus, conn, stream, bytestream_cls,
t.check_new_connection_access(q, access_control, access, protocol)
protocol.echoed = True
- expected_tube = (new_stream_tube_id, self_handle, cs.TUBE_TYPE_STREAM,
- 'newecho', new_sample_parameters, cs.TUBE_STATE_OPEN)
- t.check_tube_in_tubes (expected_tube, tubes_iface.ListTubes(byte_arrays=True))
-
# have the fake client open the stream
bytestream1.open_bytestream()
diff --git a/tests/twisted/tubes/test-get-available-tubes.py b/tests/twisted/tubes/test-get-available-tubes.py
index 1020c0250..23e806487 100644
--- a/tests/twisted/tubes/test-get-available-tubes.py
+++ b/tests/twisted/tubes/test-get-available-tubes.py
@@ -24,16 +24,14 @@ def test(q, bus, conn, stream):
acknowledge_iq(stream, iq_event.stanza)
- call_async(q, conn, 'RequestHandles', cs.HT_ROOM, ['chat@conf.localhost'])
-
- event = q.expect('dbus-return', method='RequestHandles')
- handles = event.value[0]
-
- # request tubes channel (old API)
- call_async(q, conn, 'RequestChannel',
- tp_name_prefix + '.Channel.Type.Tubes', cs.HT_ROOM, handles[0], True)
+ # muc stream tube
+ call_async(q, conn.Requests, 'CreateChannel', {
+ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
+ cs.TARGET_HANDLE_TYPE: cs.HT_ROOM,
+ cs.TARGET_ID: 'chat@conf.localhost',
+ cs.STREAM_TUBE_SERVICE: 'test'})
- _, stream_event = q.expect_many(
+ stream_event = q.expect_many(
EventPattern('dbus-signal', signal='MembersChanged',
args=[u'', [], [], [], [2], 0, 0]),
EventPattern('stream-presence', to='chat@conf.localhost/test'))
@@ -44,34 +42,17 @@ def test(q, bus, conn, stream):
# Send presence for own membership of room.
stream.send(make_muc_presence('owner', 'moderator', 'chat@conf.localhost', 'test'))
- new_chans, members, event = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannels'),
+ members, event = q.expect_many(
EventPattern('dbus-signal', signal='MembersChanged',
args=[u'', [2, 3], [], [], [], 0, 0]),
- EventPattern('dbus-return', method='RequestChannel'))
-
- channels = new_chans.args[0]
- assertLength(2, channels)
-
- assertEquals(conn.InspectHandles(cs.HT_CONTACT, [2]), ['chat@conf.localhost/test'])
- assertEquals(conn.InspectHandles(cs.HT_CONTACT, [3]), ['chat@conf.localhost/bob'])
- bob_handle = 3
-
- tubes_chan = bus.get_object(conn.bus_name, event.value[0])
- tubes_iface_muc = dbus.Interface(tubes_chan,
- tp_name_prefix + '.Channel.Type.Tubes')
-
- # FIXME: these using a "1-1" tubes channel too
-
- # test GetAvailableTubeTypes (old API)
- tube_types = tubes_iface_muc.GetAvailableTubeTypes()
+ EventPattern('dbus-return', method='CreateChannel'))
- assertLength(2, tube_types)
- assertContains(cs.TUBE_TYPE_DBUS, tube_types)
- assertContains(cs.TUBE_TYPE_STREAM, tube_types)
+ path = event.value[0]
+ props = event.value[1]
- # test GetAvailableStreamTubeTypes (old API)
- stream_tubes_types = tubes_iface_muc.GetAvailableStreamTubeTypes()
+ tube = bus.get_object(conn.bus_name, path)
+ stream_tubes_types = tube.Get(cs.CHANNEL_TYPE_STREAM_TUBE, 'SupportedSocketTypes',
+ dbus_interface=cs.PROPERTIES_IFACE)
if os.name == 'posix':
assert cs.SOCKET_ACCESS_CONTROL_LOCALHOST in \
@@ -88,17 +69,5 @@ def test(q, bus, conn, stream):
assertEquals([cs.SOCKET_ACCESS_CONTROL_LOCALHOST, cs.SOCKET_ACCESS_CONTROL_PORT],
stream_tubes_types[cs.SOCKET_ADDRESS_TYPE_IPV6])
- # muc stream tube (new API)
- path, props = conn.Requests.CreateChannel({
- cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
- cs.TARGET_HANDLE_TYPE: cs.HT_ROOM,
- cs.TARGET_ID: 'chat@conf.localhost',
- cs.STREAM_TUBE_SERVICE: 'test'})
-
- tube = bus.get_object(conn.bus_name, path)
- sockets = tube.Get(cs.CHANNEL_TYPE_STREAM_TUBE, 'SupportedSocketTypes',
- dbus_interface=cs.PROPERTIES_IFACE)
- assertEquals(sockets, stream_tubes_types)
-
if __name__ == '__main__':
exec_test(test)
diff --git a/tests/twisted/tubes/test-socks5-muc.py b/tests/twisted/tubes/test-socks5-muc.py
index 5f498a59e..4153801f8 100644
--- a/tests/twisted/tubes/test-socks5-muc.py
+++ b/tests/twisted/tubes/test-socks5-muc.py
@@ -6,11 +6,13 @@ if os.name != 'posix':
# skipped on non-Unix for now, because it uses a Unix socket
raise SystemExit(77)
+import dbus
+
from servicetest import call_async, EventPattern, EventProtocolClientFactory
from gabbletest import acknowledge_iq, make_muc_presence, exec_test
import constants as cs
import ns
-from muctubeutil import get_muc_tubes_channel
+from mucutil import join_muc
from bytestream import BytestreamS5BRelay, create_from_si_offer, announce_socks5_proxy
from twisted.internet import reactor
@@ -25,8 +27,7 @@ def test(q, bus, conn, stream):
announce_socks5_proxy(q, stream, disco_event.stanza)
- room_handle, tubes_chan, tubes_iface = get_muc_tubes_channel(q, bus, conn,
- stream, 'chat@conf.localhost')
+ text_chan = join_muc(q, bus, conn, stream, 'chat@conf.localhost')
# bob offers a stream tube
stream_tube_id = 1
@@ -40,20 +41,27 @@ def test(q, bus, conn, stream):
parameters = tube.addElement((None, 'parameters'))
stream.send(presence)
- e = q.expect('dbus-signal', signal='NewChannels')
+ def new_chan_predicate(e):
+ path, props = e.args[0][0]
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
+
+ e = q.expect('dbus-signal', signal='NewChannels',
+ predicate=new_chan_predicate)
channels = e.args[0]
assert len(channels) == 1
path, props = channels[0]
assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
tube_chan = bus.get_object(conn.bus_name, path)
- call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, 0, 0, '',
+ tube_iface = dbus.Interface(tube_chan, cs.CHANNEL_TYPE_STREAM_TUBE)
+
+ call_async(q, tube_iface, 'Accept', 0, 0, '',
byte_arrays=True)
accept_return_event, _ = q.expect_many(
- EventPattern('dbus-return', method='AcceptStreamTube'),
- EventPattern('dbus-signal', signal='TubeStateChanged',
- args=[stream_tube_id, cs.TUBE_CHANNEL_STATE_OPEN]))
+ EventPattern('dbus-return', method='Accept'),
+ EventPattern('dbus-signal', signal='TubeChannelStateChanged',
+ args=[cs.TUBE_CHANNEL_STATE_OPEN]))
unix_socket_adr = accept_return_event.value[0]
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index 9aeb89ed6..3eb86d9d5 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -81,24 +81,6 @@ def check_conn_properties(q, conn, channel_list=None):
assert i in properties['Channels'], \
(i, properties['Channels'])
- # 1-1 tubes channel (old API)
- assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TUBES,
- cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
- },
- [cs.TARGET_HANDLE, cs.TARGET_ID
- ]
- ) in properties.get('RequestableChannelClasses'),\
- properties['RequestableChannelClasses']
-
- # muc tubes channel (old API)
- assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TUBES,
- cs.TARGET_HANDLE_TYPE: cs.HT_ROOM,
- },
- [cs.TARGET_HANDLE, cs.TARGET_ID
- ]
- ) in properties.get('RequestableChannelClasses'),\
- properties['RequestableChannelClasses']
-
# 1-1 StreamTube channel
assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT