summaryrefslogtreecommitdiff
path: root/tests/twisted/avahi/tubes
diff options
context:
space:
mode:
Diffstat (limited to 'tests/twisted/avahi/tubes')
-rw-r--r--tests/twisted/avahi/tubes/disabled-1-1-tubes.py62
-rw-r--r--tests/twisted/avahi/tubes/offer-private-stream-tube.py360
-rw-r--r--tests/twisted/avahi/tubes/request-invalid-dbus-tube.py62
-rw-r--r--tests/twisted/avahi/tubes/tube-close.py71
-rw-r--r--tests/twisted/avahi/tubes/tubes-to-nonexistant-ids.py54
-rw-r--r--tests/twisted/avahi/tubes/two-private-stream-tubes.py329
6 files changed, 0 insertions, 938 deletions
diff --git a/tests/twisted/avahi/tubes/disabled-1-1-tubes.py b/tests/twisted/avahi/tubes/disabled-1-1-tubes.py
deleted file mode 100644
index a30acd56..00000000
--- a/tests/twisted/avahi/tubes/disabled-1-1-tubes.py
+++ /dev/null
@@ -1,62 +0,0 @@
-"""
-Test if 1-1 tubes support is properly disabled.
-This test should be removed as soon as we re-enable 1-1 tubes support.
-"""
-from saluttest import exec_test, wait_for_contact_in_publish
-from avahitest import AvahiAnnouncer, AvahiListener
-from avahitest import get_host_name
-import avahi
-import dbus
-import os
-import errno
-import string
-
-from xmppstream import setup_stream_listener, connect_to_stream
-from servicetest import make_channel_proxy, Event
-
-from twisted.words.xish import xpath, domish
-from twisted.internet.protocol import Factory, Protocol, ClientCreator
-from twisted.internet import reactor
-
-import constants as cs
-
-PUBLISHED_NAME="test-tube"
-
-CHANNEL_TYPE_TUBES = "org.freedesktop.Telepathy.Channel.Type.Tubes"
-HT_CONTACT = 1
-HT_CONTACT_LIST = 3
-TEXT_MESSAGE_TYPE_NORMAL = dbus.UInt32(0)
-SOCKET_ADDRESS_TYPE_UNIX = dbus.UInt32(0)
-SOCKET_ADDRESS_TYPE_IPV4 = dbus.UInt32(2)
-SOCKET_ACCESS_CONTROL_LOCALHOST = dbus.UInt32(0)
-
-sample_parameters = dbus.Dictionary({
- 's': 'hello',
- 'ay': dbus.ByteArray('hello'),
- 'u': dbus.UInt32(123),
- 'i': dbus.Int32(-123),
- }, signature='sv')
-
-def test(q, bus, conn):
- conn.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
- basic_txt = { "txtvers": "1", "status": "avail" }
-
- contact_name = PUBLISHED_NAME + get_host_name()
- listener, port = setup_stream_listener(q, contact_name)
-
- announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, basic_txt)
-
- handle = wait_for_contact_in_publish(q, bus, conn, contact_name)
-
- # we can't request 1-1 tubes channel
- try:
- conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_CONTACT, handle,
- True)
- except dbus.DBusException, e:
- assert e.get_dbus_name() == cs.NOT_IMPLEMENTED
- else:
- assert False, "Should raise NotImplemented error"
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/avahi/tubes/offer-private-stream-tube.py b/tests/twisted/avahi/tubes/offer-private-stream-tube.py
deleted file mode 100644
index 68fcb2cb..00000000
--- a/tests/twisted/avahi/tubes/offer-private-stream-tube.py
+++ /dev/null
@@ -1,360 +0,0 @@
-from saluttest import exec_test, wait_for_contact_in_publish
-from avahitest import AvahiAnnouncer, AvahiListener
-from avahitest import get_host_name
-import avahi
-import dbus
-import os
-import errno
-import string
-
-from xmppstream import setup_stream_listener, connect_to_stream
-from servicetest import make_channel_proxy, Event, EventPattern, call_async, \
- tp_name_prefix, sync_dbus
-
-from twisted.words.xish import xpath, domish
-from twisted.internet.protocol import Factory, Protocol, ClientCreator
-from twisted.internet import reactor
-
-from constants import INVALID_ARGUMENT, NOT_IMPLEMENTED
-
-PUBLISHED_NAME="test-tube"
-
-CHANNEL_TYPE_TUBES = "org.freedesktop.Telepathy.Channel.Type.Tubes"
-HT_CONTACT = 1
-HT_CONTACT_LIST = 3
-TEXT_MESSAGE_TYPE_NORMAL = dbus.UInt32(0)
-SOCKET_ADDRESS_TYPE_UNIX = dbus.UInt32(0)
-SOCKET_ADDRESS_TYPE_IPV4 = dbus.UInt32(2)
-SOCKET_ADDRESS_TYPE_IPV6 = dbus.UInt32(3)
-SOCKET_ACCESS_CONTROL_LOCALHOST = dbus.UInt32(0)
-
-sample_parameters = dbus.Dictionary({
- 's': 'hello',
- 'ay': dbus.ByteArray('hello'),
- 'u': dbus.UInt32(123),
- 'i': dbus.Int32(-123),
- }, signature='sv')
-
-test_string = "This string travels on a tube !"
-
-print "FIXME: disabled because 1-1 tubes are disabled for now"
-# exiting 77 causes automake to consider the test to have been skipped
-raise SystemExit(77)
-
-def check_conn_properties(q, bus, conn, channel_list=None):
- properties = conn.GetAll(
- 'org.freedesktop.Telepathy.Connection.Interface.Requests',
- dbus_interface='org.freedesktop.DBus.Properties')
-
- if channel_list == None:
- assert properties.get('Channels') == [], properties['Channels']
- else:
- for i in channel_list:
- assert i in properties['Channels'], \
- (i, properties['Channels'])
-
- assert ({'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.Tubes',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_CONTACT,
- },
- ['org.freedesktop.Telepathy.Channel.TargetHandle',
- ]
- ) in properties.get('RequestableChannelClasses'),\
- properties['RequestableChannelClasses']
- assert ({'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_CONTACT,
- },
- ['org.freedesktop.Telepathy.Channel.TargetHandle',
- 'org.freedesktop.Telepathy.Channel.TargetID',
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube.Service',
- ]
- ) in properties.get('RequestableChannelClasses'),\
- properties['RequestableChannelClasses']
-
-def check_channel_properties(q, bus, conn, channel, channel_type,
- contact_handle, contact_id, state=None):
- # Exercise basic Channel Properties from spec 0.17.7
- # on the channel of type channel_type
- channel_props = channel.GetAll(
- 'org.freedesktop.Telepathy.Channel',
- dbus_interface='org.freedesktop.DBus.Properties')
- assert channel_props.get('TargetHandle') == contact_handle,\
- (channel_props.get('TargetHandle'), contact_handle)
- assert channel_props.get('TargetHandleType') == HT_CONTACT,\
- channel_props.get('TargetHandleType')
- assert channel_props.get('ChannelType') == \
- 'org.freedesktop.Telepathy.Channel.Type.' + channel_type,\
- channel_props.get('ChannelType')
- assert 'Interfaces' in channel_props, channel_props
- assert 'org.freedesktop.Telepathy.Channel.Interface.Group' not in \
- channel_props['Interfaces'], \
- channel_props['Interfaces']
- assert channel_props['TargetID'] == contact_id
-
- if channel_type == "Tubes":
- assert state is None
- else:
- assert state is not None
- tube_props = channel.GetAll(
- 'org.freedesktop.Telepathy.Channel.Interface.Tube',
- dbus_interface='org.freedesktop.DBus.Properties')
- assert tube_props['State'] == state, tube_props['State']
- # no strict check but at least check the properties exist
- assert tube_props.has_key('Parameters')
-
- self_handle = conn.GetSelfHandle()
- self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0]
-
- assert channel_props['Requested'] == True
- assert channel_props['InitiatorID'] == self_handle_name
- assert channel_props['InitiatorHandle'] == self_handle
-
-
-def check_NewChannel_signal(old_sig, channel_type, chan_path, contact_handle):
- assert old_sig[0] == chan_path, old_sig[0]
- assert old_sig[1] == tp_name_prefix + '.Channel.Type.' + channel_type
- assert old_sig[2] == HT_CONTACT
- assert old_sig[3] == contact_handle
- assert old_sig[4] == True # suppress handler
-
-def check_NewChannels_signal(conn, new_sig, channel_type, chan_path, contact_handle,
- contact_id, initiator_handle):
- assert len(new_sig) == 1
- assert len(new_sig[0]) == 1 # one channel
- assert len(new_sig[0][0]) == 2 # two struct members
- assert new_sig[0][0][0] == chan_path
- emitted_props = new_sig[0][0][1]
-
- initiator_name = conn.InspectHandles(HT_CONTACT, [initiator_handle])[0]
- assert emitted_props[tp_name_prefix + '.Channel.ChannelType'] ==\
- tp_name_prefix + '.Channel.Type.' + channel_type
- assert emitted_props[tp_name_prefix + '.Channel.TargetHandleType'] == \
- HT_CONTACT
- assert emitted_props[tp_name_prefix + '.Channel.TargetHandle'] ==\
- contact_handle
- assert emitted_props[tp_name_prefix + '.Channel.TargetID'] == \
- contact_id
- assert emitted_props[tp_name_prefix + '.Channel.Requested'] == True
- assert emitted_props[tp_name_prefix + '.Channel.InitiatorHandle'] \
- == initiator_handle
- assert emitted_props[tp_name_prefix + '.Channel.InitiatorID'] == \
- initiator_name
-
-def test(q, bus, conn):
-
- # define a basic tcp server that echoes what the client says, but with
- # swapcase
- class TrivialServer(Protocol):
- def dataReceived(self, data):
- self.transport.write(string.swapcase(data))
- e = Event('server-data-received', service = self, data = data)
- q.append(e)
-
- # define a basic tcp client
- class ClientGreeter(Protocol):
- def dataReceived(self, data):
- e = Event('client-data-received', service = self, data = data)
- q.append(e)
- def client_connected_cb(p):
- e = Event('client-connected', transport = p.transport)
- q.append(e)
-
- # create the server
- factory = Factory()
- factory.protocol = TrivialServer
- server_socket_address = os.getcwd() + '/stream'
- try:
- os.remove(server_socket_address)
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- l = reactor.listenUNIX(server_socket_address, factory)
-
-
- check_conn_properties(q, bus, conn)
-
- conn.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
- basic_txt = { "txtvers": "1", "status": "avail" }
-
- contact_name = PUBLISHED_NAME + "@" + get_host_name()
- listener, port = setup_stream_listener(q, contact_name)
-
- announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, basic_txt)
-
- handle = wait_for_contact_in_publish(q, bus, conn, contact_name)
-
- # NewChannels would be emitted for the contact list channels, we don't
- # want this to interfere with the NewChannels signals for the requested
- # tubes channel
- sync_dbus(bus, q, conn)
-
- # old requestotron
- call_async(q, conn, 'RequestChannel',
- CHANNEL_TYPE_TUBES, HT_CONTACT, 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]
-
- check_NewChannel_signal(old_sig.args, "Tubes", chan_path, handle)
- check_NewChannels_signal(conn, new_sig.args, "Tubes", chan_path,
- handle, contact_name, conn.GetSelfHandle())
- emitted_props = new_sig.args[0][0][1]
- old_tubes_channel_properties = new_sig.args[0][0]
-
- check_conn_properties(q, bus, conn, [old_tubes_channel_properties])
-
- # new requestotron
- requestotron = dbus.Interface(conn,
- 'org.freedesktop.Telepathy.Connection.Interface.Requests')
-
- # Try to CreateChannel with unknown properties
- # Salut must return an error
- try:
- requestotron.CreateChannel(
- {'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType':
- HT_CONTACT,
- 'org.freedesktop.Telepathy.Channel.TargetHandle':
- handle,
- 'this.property.does.not.exist':
- 'this.value.should.not.exist'
- })
- except dbus.DBusException, e:
- assert e.get_dbus_name() == NOT_IMPLEMENTED, e.get_dbus_name()
- else:
- assert False, "Should raise NotImplemented error"
-
- # CreateChannel failed, we expect no new channel
- check_conn_properties(q, bus, conn, [old_tubes_channel_properties])
-
- # Try to CreateChannel with missing properties ("Service")
- # Salut must return an error
- try:
- requestotron.CreateChannel(
- {'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType':
- HT_CONTACT,
- 'org.freedesktop.Telepathy.Channel.TargetHandle':
- handle
- });
- except dbus.DBusException, e:
- assert e.get_dbus_name() == INVALID_ARGUMENT, e.get_dbus_name()
- else:
- assert False, "Should raise InvalidArgument error"
-
- # CreateChannel failed, we expect no new channel
- check_conn_properties(q, bus, conn, [old_tubes_channel_properties])
-
- # Try to CreateChannel with correct properties
- # Salut must succeed
- call_async(q, requestotron, 'CreateChannel',
- {'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType':
- HT_CONTACT,
- 'org.freedesktop.Telepathy.Channel.TargetHandle':
- handle,
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube.Service':
- "newecho"
- });
- ret, old_sig, new_sig = q.expect_many(
- EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
-
- assert len(ret.value) == 2 # CreateChannel returns 2 values: o, a{sv}
- new_chan_path = ret.value[0]
- stream_tube_channel_properties = ret.value
- # 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
-
- channels = new_sig.args[0]
- # tubes and tube channels are announced
- assert len(channels) == 2
-
- check_conn_properties(q, bus, conn,
- [old_tubes_channel_properties, stream_tube_channel_properties])
-
- assert stream_tube_channel_properties[1]['org.freedesktop.Telepathy.Channel.Type.StreamTube.Service'] == \
- 'newecho'
- assert stream_tube_channel_properties[1]['org.freedesktop.Telepathy.Channel.Type.StreamTube.SupportedSocketTypes'] == \
- {SOCKET_ADDRESS_TYPE_UNIX: [SOCKET_ACCESS_CONTROL_LOCALHOST],
- SOCKET_ADDRESS_TYPE_IPV4: [SOCKET_ACCESS_CONTROL_LOCALHOST],
- SOCKET_ADDRESS_TYPE_IPV6: [SOCKET_ACCESS_CONTROL_LOCALHOST]}
-
- # continue
- tubes_channel = make_channel_proxy(conn, chan_path, "Channel.Type.Tubes")
- tube_channel = make_channel_proxy(conn, new_chan_path,
- "Channel.Type.StreamTube")
- check_channel_properties(q, bus, conn, tubes_channel, "Tubes", handle,
- contact_name)
- check_channel_properties(q, bus, conn, tube_channel, "StreamTube",
- handle, contact_name, 3)
-
- tube_channel.Offer(SOCKET_ADDRESS_TYPE_UNIX, dbus.ByteArray(server_socket_address),
- SOCKET_ACCESS_CONTROL_LOCALHOST, {'foo': 'bar'})
-
- e = q.expect('stream-iq')
- iq_tube = xpath.queryForNodes('/iq/tube', e.stanza)[0]
- transport = xpath.queryForNodes('/iq/tube/transport', e.stanza)[0]
- assert iq_tube.attributes['type'] == 'stream'
- assert iq_tube.attributes['service'] == 'newecho', \
- iq_tube.attributes['service']
- assert iq_tube.attributes['id'] is not None
- port = transport.attributes['port']
- assert port is not None
- port = int(port)
- assert port > 1024
- assert port < 65536
-
- params = {}
- parameter_nodes = xpath.queryForNodes('/iq/tube/parameters/parameter',
- e.stanza)
- for node in parameter_nodes:
- assert node['name'] not in params
- params[node['name']] = (node['type'], str(node))
- assert params == {'foo': ('str', 'bar')}, params
-
- # find the right host/IP address because Salut checks it
- self_handle = conn.GetSelfHandle()
- self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0]
- AvahiListener(q).listen_for_service("_presence._tcp")
- e = q.expect('service-added', name = self_handle_name,
- protocol = avahi.PROTO_INET)
- service = e.service
- service.resolve()
- e = q.expect('service-resolved', service = service)
- host_name = e.host_name
-
- client = ClientCreator(reactor, ClientGreeter)
- client.connectTCP(host_name, port).addCallback(client_connected_cb)
-
- e = q.expect('client-connected')
- client_transport = e.transport
- client_transport.write(test_string)
-
- e = q.expect('server-data-received')
- assert e.data == test_string
-
- e = q.expect('client-data-received')
- assert e.data == string.swapcase(test_string)
-
- # Close the tubes propertly
- for i in tubes_channel.ListTubes():
- tubes_channel.CloseTube(i[0])
- conn.Disconnect()
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/avahi/tubes/request-invalid-dbus-tube.py b/tests/twisted/avahi/tubes/request-invalid-dbus-tube.py
deleted file mode 100644
index f1cb8792..00000000
--- a/tests/twisted/avahi/tubes/request-invalid-dbus-tube.py
+++ /dev/null
@@ -1,62 +0,0 @@
-from saluttest import exec_test
-from avahitest import AvahiAnnouncer, AvahiListener
-from avahitest import get_host_name
-import avahi
-import dbus
-import os
-import errno
-import string
-
-from xmppstream import setup_stream_listener, connect_to_stream
-from servicetest import make_channel_proxy, Event, EventPattern, call_async, \
- tp_name_prefix, sync_dbus
-
-from twisted.words.xish import xpath, domish
-from twisted.internet.protocol import Factory, Protocol, ClientCreator
-from twisted.internet import reactor
-import constants as cs
-
-print "FIXME: disabled because new DBus tube API is not implemented"
-# exiting 77 causes automake to consider the test to have been skipped
-raise SystemExit(77)
-
-PUBLISHED_NAME="test-tube"
-
-CHANNEL_TYPE_TUBES = "org.freedesktop.Telepathy.Channel.Type.Tubes"
-C_T_DTUBE = 'org.freedesktop.Telepathy.Channel.Type.DBusTube'
-HT_CONTACT = 1
-
-invalid_service_names = [ 'invalidServiceName'
- , 'one ten hundred thousand million'
- , 'me.is.it.you?.hello.you.sexy.sons.o.@#$%.heh'
- , ':1.1'
- , ''
- ]
-
-def test(q, bus, conn):
- conn.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
-
- requestotron = dbus.Interface(conn,
- 'org.freedesktop.Telepathy.Connection.Interface.Requests')
-
- for invalid_service_name in invalid_service_names:
- try:
- requestotron.CreateChannel(
- {'org.freedesktop.Telepathy.Channel.ChannelType':
- C_T_DTUBE,
- 'org.freedesktop.Telepathy.Channel.TargetHandleType':
- HT_CONTACT,
- 'org.freedesktop.Telepathy.Channel.TargetID':
- 'alice',
- C_T_DTUBE + '.ServiceName':
- invalid_service_name
- });
- except dbus.DBusException, e:
- assert e.get_dbus_name() == cs.INVALID_ARGUMENT,\
- (e.get_dbus_name(), invalid_service_name)
- else:
- assert False, "Should raise InvalidArgument error"
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/avahi/tubes/tube-close.py b/tests/twisted/avahi/tubes/tube-close.py
deleted file mode 100644
index ae2c2af0..00000000
--- a/tests/twisted/avahi/tubes/tube-close.py
+++ /dev/null
@@ -1,71 +0,0 @@
-"""
-Offer a 1-1 stream tube and close the connection. Salut must just send a
-stanza to close the tube and disconnect.
-"""
-
-from saluttest import exec_test, wait_for_contact_in_publish
-from avahitest import AvahiAnnouncer, AvahiListener
-from avahitest import get_host_name
-import avahi
-
-from xmppstream import setup_stream_listener, connect_to_stream
-from servicetest import make_channel_proxy
-
-from twisted.words.xish import xpath, domish
-
-import dbus
-
-PUBLISHED_NAME="test-tube"
-
-CHANNEL_TYPE_TUBES = "org.freedesktop.Telepathy.Channel.Type.Tubes"
-HT_CONTACT = 1
-HT_CONTACT_LIST = 3
-SOCKET_ADDRESS_TYPE_IPV4 = dbus.UInt32(2)
-SOCKET_ACCESS_CONTROL_LOCALHOST = dbus.UInt32(0)
-
-#print "FIXME: test-tube-close.py disabled because sending a close stanza on "
-#print "disconnection is not yet implemented in telepathy-salut. It requires "
-#print "to ensure the XmppConnection and reestablish it"
-print "FIXME: disabled because 1-1 tubes are disabled for now"
-# exiting 77 causes automake to consider the test to have been skipped
-raise SystemExit(77)
-
-def test(q, bus, conn):
- # Salut will not connect to this socket, the test finishs before
- socket_address = ('0.0.0.0', dbus.UInt16(0))
-
- conn.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
- basic_txt = { "txtvers": "1", "status": "avail" }
-
- contact_name = PUBLISHED_NAME + "@" + get_host_name()
- listener, port = setup_stream_listener(q, contact_name)
-
- announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, basic_txt)
-
- handle = wait_for_contact_in_publish(q, bus, conn, contact_name)
-
- t = conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_CONTACT, handle,
- True)
- tubes_channel = make_channel_proxy(conn, t, "Channel.Type.Tubes")
-
- tubes_channel.OfferStreamTube("http", dbus.Dictionary({}),
- SOCKET_ADDRESS_TYPE_IPV4, socket_address,
- SOCKET_ACCESS_CONTROL_LOCALHOST, "")
-
- e = q.expect('stream-iq')
-
- # Close the connection just after the tube has been offered.
- conn.Disconnect()
-
- # receive the close stanza for the tube
- event = q.expect('stream-message')
- message = event.stanza
- close_node = xpath.queryForNodes('/message/close[@xmlns="%s"]' % NS_TUBES,
- message)
- assert close_node is not None
-
- q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/avahi/tubes/tubes-to-nonexistant-ids.py b/tests/twisted/avahi/tubes/tubes-to-nonexistant-ids.py
deleted file mode 100644
index 7fb9b162..00000000
--- a/tests/twisted/avahi/tubes/tubes-to-nonexistant-ids.py
+++ /dev/null
@@ -1,54 +0,0 @@
-"""
-Test that requests for Tubes and StreamTube channels to ids which aren't
-actually on the network fail gracefully with NotAvailable
-"""
-
-from saluttest import exec_test
-
-from constants import (
- HT_CONTACT, CONN_IFACE_REQUESTS,
- CHANNEL_TYPE, TARGET_HANDLE_TYPE, TARGET_HANDLE,
- CHANNEL_TYPE_TUBES, CHANNEL_TYPE_STREAM_TUBE,
- NOT_AVAILABLE
- )
-
-import dbus
-
-arbitrary_ids = [ "DooN4Bei@TheeK6bo-Tegh4aci", "ahrui1iM@Dai6igho-ADetaes3" ]
-
-print "FIXME: disabled because 1-1 tubes are disabled for now"
-# exiting 77 causes automake to consider the test to have been skipped
-raise SystemExit(77)
-
-def test(q, bus, conn):
- conn.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
-
- h1, h2 = conn.RequestHandles(HT_CONTACT, arbitrary_ids)
-
- try:
- conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_CONTACT, h1, True)
- except dbus.DBusException, e:
- assert e.get_dbus_name() == NOT_AVAILABLE, e.get_dbus_name()
- else:
- assert False, "Should raise NotAvailable error"
-
- requestotron = dbus.Interface(conn, CONN_IFACE_REQUESTS)
-
- try:
- requestotron.CreateChannel({
- CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
- TARGET_HANDLE_TYPE: HT_CONTACT,
- TARGET_HANDLE: h2,
- CHANNEL_TYPE_STREAM_TUBE + ".Service": "com.example",
- })
- except dbus.DBusException, e:
- assert e.get_dbus_name() == NOT_AVAILABLE, e.get_dbus_name()
- else:
- assert False, "Should raise NotAvailable error"
-
- conn.Disconnect()
- q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/avahi/tubes/two-private-stream-tubes.py b/tests/twisted/avahi/tubes/two-private-stream-tubes.py
deleted file mode 100644
index e1956be9..00000000
--- a/tests/twisted/avahi/tubes/two-private-stream-tubes.py
+++ /dev/null
@@ -1,329 +0,0 @@
-from saluttest import exec_test
-import dbus
-import os
-import errno
-import string
-
-from servicetest import make_channel_proxy, Event, EventPattern, call_async
-
-from twisted.internet.protocol import Factory, Protocol, ClientCreator
-from twisted.internet import reactor
-from constants import *
-import tubetestutil as t
-
-sample_parameters = dbus.Dictionary({
- 's': 'hello',
- 'ay': dbus.ByteArray('hello'),
- 'u': dbus.UInt32(123),
- 'i': dbus.Int32(-123),
- }, signature='sv')
-
-test_string = "This string travels on a tube !"
-
-SERVER_WELCOME_MSG = "Welcome!"
-
-print "FIXME: disabled because 1-1 tubes are disabled for now"
-# exiting 77 causes automake to consider the test to have been skipped
-raise SystemExit(77)
-
-def test(q, bus, conn):
-
- # define a basic tcp server that echoes what the client says, but with
- # swapcase
- class TrivialServer(Protocol):
- def dataReceived(self, data):
- self.transport.write(string.swapcase(data))
- e = Event('server-data-received', service = self, data = data)
- q.append(e)
-
- def connectionMade(self):
- e = Event('server-connected', transport = self.transport)
- q.append(e)
-
- # send welcome message to the client
- self.transport.write(SERVER_WELCOME_MSG)
-
- # define a basic tcp client
- class ClientGreeter(Protocol):
- def dataReceived(self, data):
- e = Event('client-data-received', service = self, data = data)
- q.append(e)
-
- def client_connected_cb(p):
- e = Event('client-connected', transport = p.transport)
- q.append(e)
-
- # create the server
- factory = Factory()
- factory.protocol = TrivialServer
- server_socket_address = os.getcwd() + '/stream'
- try:
- os.remove(server_socket_address)
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- l = reactor.listenUNIX(server_socket_address, factory)
-
- contact1_name, conn2, contact2_name, contact2_handle_on_conn1,\
- contact1_handle_on_conn2 = t.connect_two_accounts(q, bus, conn)
-
- conn1_self_handle = conn.GetSelfHandle()
-
- # contact1 offers stream tube to contact2 (old API)
- contact1_tubes_channel_path = conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_CONTACT,
- contact2_handle_on_conn1, True)
- contact1_tubes_channel = make_channel_proxy(conn, contact1_tubes_channel_path, "Channel.Type.Tubes")
- contact1_tubes_channel_iface = make_channel_proxy(conn, contact1_tubes_channel_path, "Channel")
-
- tube_id = contact1_tubes_channel.OfferStreamTube("http", sample_parameters,
- SOCKET_ADDRESS_TYPE_UNIX, dbus.ByteArray(server_socket_address),
- SOCKET_ACCESS_CONTROL_LOCALHOST, "")
-
- contact2_tubes_channel_path = None
- while contact2_tubes_channel_path is None:
- e = q.expect('dbus-signal', signal='NewChannel')
- if (e.args[1] == CHANNEL_TYPE_TUBES) and (e.path.endswith("testsuite2") == True):
- contact2_tubes_channel_path = e.args[0]
-
- contact2_tubes_channel = make_channel_proxy(conn2, contact2_tubes_channel_path, "Channel.Type.Tubes")
- contact2_tubes_channel_iface = make_channel_proxy(conn, contact2_tubes_channel_path, "Channel")
-
- contact2_tubes = contact2_tubes_channel.ListTubes()
- assert len(contact2_tubes) == 1
- contact2_tube = contact2_tubes[0]
- assert contact2_tube[0] is not None # tube id
- assert contact2_tube[1] is not None # initiator
- assert contact2_tube[2] == 1 # type = stream tube
- assert contact2_tube[3] == 'http' # service = http
- assert contact2_tube[4] is not None # parameters
- assert contact2_tube[5] == 0, contact2_tube[5] # status = local pending
-
- unix_socket_adr = contact2_tubes_channel.AcceptStreamTube(
- contact2_tube[0], 0, 0, '', byte_arrays=True)
-
- client = ClientCreator(reactor, ClientGreeter)
- client.connectUNIX(unix_socket_adr).addCallback(client_connected_cb)
-
- # server got the connection
- _, e, new_conn_event, data_event = q.expect_many(
- EventPattern('server-connected'),
- EventPattern('client-connected'),
- EventPattern('dbus-signal', signal='StreamTubeNewConnection', path=contact1_tubes_channel_path),
- EventPattern('client-data-received'))
-
- client_transport = e.transport
-
- id, handle = new_conn_event.args
- assert id == tube_id
- assert handle == contact2_handle_on_conn1
-
- # client receives server's welcome message
- assert data_event.data == SERVER_WELCOME_MSG
-
- client_transport.write(test_string)
-
- server_received, client_received = q.expect_many(
- EventPattern('server-data-received'),
- EventPattern('client-data-received'))
-
- assert server_received.data == test_string
- assert client_received.data == string.swapcase(test_string)
-
- # Close the tube propertly
- call_async(q, contact1_tubes_channel, 'CloseTube', tube_id)
-
- q.expect_many(
- EventPattern('dbus-signal', signal='TubeClosed', path=contact1_tubes_channel_path),
- EventPattern('dbus-signal', signal='TubeClosed', path=contact2_tubes_channel_path),
- EventPattern('dbus-return', method='CloseTube'))
-
- # close both tubes channels
- contact1_tubes_channel_iface.Close()
- contact2_tubes_channel_iface.Close()
-
- # now contact1 will offer another stream tube to contact2 using the new
- # API
-
- # Can we request private stream tubes?
- properties = conn.GetAll(CONN_IFACE_REQUESTS, dbus_interface=PROPERTIES_IFACE)
-
- assert ({CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
- TARGET_HANDLE_TYPE: HT_CONTACT},
- [TARGET_HANDLE, TARGET_ID, STREAM_TUBE_SERVICE]
- ) in properties.get('RequestableChannelClasses'),\
- properties['RequestableChannelClasses']
-
- requestotron = dbus.Interface(conn, CONN_IFACE_REQUESTS)
-
- requestotron.CreateChannel({
- CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
- TARGET_HANDLE_TYPE: HT_CONTACT,
- TARGET_ID: contact2_name,
- STREAM_TUBE_SERVICE: 'test'})
-
- # tubes and tube channels are created on the first connection
- e = q.expect('dbus-signal', signal='NewChannels', path=conn.object.object_path)
- channels = e.args[0]
- assert len(channels) == 2
-
- # get the list of all channels to check that newly announced ones are in it
- all_channels = conn.Get(CONN_IFACE_REQUESTS, 'Channels', dbus_interface=PROPERTIES_IFACE,
- byte_arrays=True)
-
- got_tubes, got_tube = False, False
- for path, props in channels:
- if props[CHANNEL_TYPE] == CHANNEL_TYPE_TUBES:
- got_tubes = True
- assert props[REQUESTED] == False
- assert props[INTERFACES] == []
- elif props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE:
- got_tube = True
- assert props[REQUESTED] == True
- assert props[INTERFACES] == [CHANNEL_IFACE_TUBE]
- assert props[STREAM_TUBE_SERVICE] == 'test'
-
- contact1_tube = bus.get_object(conn.bus_name, path)
- contact1_stream_tube = make_channel_proxy(conn, path, "Channel.Type.StreamTube")
- contact1_tube_channel = make_channel_proxy(conn, path, "Channel")
- tube1_path = path
- else:
- assert False
-
- assert props[INITIATOR_HANDLE] == conn1_self_handle
- assert props[INITIATOR_ID] == contact1_name
- assert props[TARGET_ID] == contact2_name
-
- assert (path, props) in all_channels, (path, props)
-
- assert got_tubes
- assert got_tube
-
- state = contact1_stream_tube.Get(CHANNEL_IFACE_TUBE, 'State', dbus_interface=PROPERTIES_IFACE)
- assert state == TUBE_CHANNEL_STATE_NOT_OFFERED
-
- call_async(q, contact1_stream_tube, 'Offer', SOCKET_ADDRESS_TYPE_UNIX,
- dbus.ByteArray(server_socket_address), SOCKET_ACCESS_CONTROL_LOCALHOST, sample_parameters)
-
- _, return_event, new_chans = q.expect_many(
- EventPattern('dbus-signal', signal='TubeChannelStateChanged',
- args=[TUBE_CHANNEL_STATE_REMOTE_PENDING]),
- EventPattern('dbus-return', method='Offer'),
- EventPattern('dbus-signal', signal='NewChannels', path=conn2.object.object_path))
-
- state = contact1_stream_tube.Get(CHANNEL_IFACE_TUBE, 'State', dbus_interface=PROPERTIES_IFACE)
- assert state == TUBE_CHANNEL_STATE_REMOTE_PENDING
-
- # tube and tubes channels have been created on conn2
- channels = new_chans.args[0]
- assert len(channels) == 2
-
- # get the list of all channels to check that newly announced ones are in it
- all_channels = conn2.Get(CONN_IFACE_REQUESTS, 'Channels', dbus_interface=PROPERTIES_IFACE,
- byte_arrays=True)
-
- got_tubes, got_tube = False, False
- for path, props in channels:
- if props[CHANNEL_TYPE] == CHANNEL_TYPE_TUBES:
- got_tubes = True
- assert props[REQUESTED] == False
- assert props[INTERFACES] == []
- elif props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE:
- got_tube = True
- assert props[REQUESTED] == False
- assert props[INTERFACES] == [CHANNEL_IFACE_TUBE]
- assert props[STREAM_TUBE_SERVICE] == 'test'
-
- contact2_tube = bus.get_object(conn.bus_name, path)
- contact2_stream_tube = make_channel_proxy(conn, path, "Channel.Type.StreamTube")
- contact2_tube_channel = make_channel_proxy(conn, path, "Channel")
- tube2_path = path
- else:
- assert False
-
- assert props[INITIATOR_HANDLE] == contact1_handle_on_conn2
- assert props[INITIATOR_ID] == contact1_name
- assert props[TARGET_ID] == contact1_name
-
- assert (path, props) in all_channels, (path, props)
-
- assert got_tubes
- assert got_tube
-
- state = contact2_tube.Get(CHANNEL_IFACE_TUBE, 'State', dbus_interface=PROPERTIES_IFACE)
- assert state == TUBE_CHANNEL_STATE_LOCAL_PENDING
-
- # second connection: accept the tube (new API)
- unix_socket_adr = contact2_stream_tube.Accept(SOCKET_ADDRESS_TYPE_UNIX,
- SOCKET_ACCESS_CONTROL_LOCALHOST, '', byte_arrays=True)
-
- state = contact2_tube.Get(CHANNEL_IFACE_TUBE, 'State', dbus_interface=PROPERTIES_IFACE)
- assert state == TUBE_CHANNEL_STATE_OPEN
-
- q.expect_many(
- EventPattern('dbus-signal', signal='TubeChannelStateChanged', path=tube2_path,
- args=[TUBE_CHANNEL_STATE_OPEN]),
- EventPattern('dbus-signal', signal='TubeChannelStateChanged', path=tube1_path,
- args=[TUBE_CHANNEL_STATE_OPEN]))
-
- client = ClientCreator(reactor, ClientGreeter)
- client.connectUNIX(unix_socket_adr).addCallback(client_connected_cb)
-
- # server got the connection
- _, client_connected, remote_sig, local_sig, data_received = q.expect_many(
- EventPattern('server-connected'),
- EventPattern('client-connected'),
- EventPattern('dbus-signal', signal='NewRemoteConnection',
- path=tube1_path),
- EventPattern('dbus-signal', signal='NewLocalConnection',
- path=tube2_path),
- EventPattern('client-data-received'))
-
- client_transport = client_connected.transport
-
- handle, conn_param, contact1_tube_conn_id = remote_sig.args
- assert handle == contact2_handle_on_conn1
- assert contact1_tube_conn_id != 0
-
- contact2_tube_conn_id = local_sig.args[0]
- assert contact2_tube_conn_id != 0
-
- # client receives server's welcome message
- assert data_received.data == SERVER_WELCOME_MSG
-
- client_transport.write(test_string)
-
- server_received, client_received = q.expect_many(
- EventPattern('server-data-received'),
- EventPattern('client-data-received'))
-
- assert server_received.data == test_string
- assert client_received.data == string.swapcase(test_string)
-
- # contact1 close the tube
- call_async(q, contact1_tube_channel, 'Close')
-
- # tube is closed on both sides
- _, e1, e2, _, _, _, _ = q.expect_many(
- EventPattern('dbus-return', method='Close'),
- EventPattern('dbus-signal', signal='ConnectionClosed', path=tube1_path),
- EventPattern('dbus-signal', signal='ConnectionClosed', path=tube2_path),
- EventPattern('dbus-signal', signal='Closed', path=tube1_path),
- EventPattern('dbus-signal', signal='Closed', path=tube2_path),
- EventPattern('dbus-signal', signal='ChannelClosed', path=conn.object.object_path),
- EventPattern('dbus-signal', signal='ChannelClosed', path=conn2.object.object_path))
-
- conn_id, error, dbus_msg = e1.args
- assert conn_id == contact1_tube_conn_id
- assert error == CANCELLED
-
- conn_id, error, dbus_msg = e2.args
- assert conn_id == contact2_tube_conn_id
- assert error == CANCELLED
-
- conn.Disconnect()
- q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
- conn2.Disconnect()
- q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
-
-if __name__ == '__main__':
- exec_test(test)