def announce_contact(self, name=CONTACT_NAME, metadata=True): client = 'http://telepathy.freedesktop.org/fake-client' features = [ns.IQ_OOB] if metadata: features += [ns.TP_FT_METADATA] ver = compute_caps_hash([], features, {}) txt_record = { "txtvers": "1", "status": "avail", "node": client, "ver": ver, "hash": "sha-1"} suffix = '@%s' % get_host_name() name += ('-' + os.path.splitext(os.path.basename(sys.argv[0]))[0]) self.contact_name = name + suffix if len(self.contact_name) > 63: allowed = 63 - len(suffix) self.contact_name = name[:allowed] + suffix self.listener, port = setup_stream_listener(self.q, self.contact_name) self.contact_service = AvahiAnnouncer(self.contact_name, "_presence._tcp", port, txt_record) self.handle = wait_for_contact_in_publish(self.q, self.bus, self.conn, self.contact_name) # expect salut to disco our caps e = self.q.expect('incoming-connection', listener=self.listener) stream = e.connection e = self.q.expect('stream-iq', to=self.contact_name, query_ns=ns.DISCO_INFO, connection=stream) assertEquals(client + '#' + ver, e.query['node']) send_disco_reply(stream, e.stanza, [], features) # lose the connection here to ensure connections are created # where necessary; I just wanted salut to know my caps. stream.send('</stream:stream>') # spend a bit of time in the main loop to ensure the last two # stanzas are actually received by salut before closing the # connection. sync_dbus(self.bus, self.q, self.conn) stream.transport.loseConnection()
class FileTransferTest(object): CONTACT_NAME = 'test-ft' service_name = 'wacky.service.name' metadata = {'loads': ['of', 'blahblah', 'stuff'], 'mental': ['data', 'sidf']} def __init__(self, ft_protocol=cs.SOCKET_ADDRESS_TYPE_UNIX): self.file = File() self.contact_service = None self.ft_proto = ft_protocol def _get_socket_address_family(self): if self.ft_proto == cs.SOCKET_ADDRESS_TYPE_IPV4: return socket.AF_INET elif self.ft_proto == cs.SOCKET_ADDRESS_TYPE_IPV6: return socket.AF_INET6 elif self.ft_proto == cs.SOCKET_ADDRESS_TYPE_UNIX: return socket.AF_UNIX assert False def connect(self): self.conn.Connect() self.q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) self.self_handle = self.conn.Properties.Get(cs.CONN, "SelfHandle") self.self_handle_name = self.conn.Properties.Get(cs.CONN, "SelfID") def announce_contact(self, name=CONTACT_NAME, metadata=True): client = 'http://telepathy.freedesktop.org/fake-client' features = [ns.IQ_OOB] if metadata: features += [ns.TP_FT_METADATA] ver = compute_caps_hash([], features, {}) txt_record = { "txtvers": "1", "status": "avail", "node": client, "ver": ver, "hash": "sha-1"} suffix = '@%s' % get_host_name() name += ('-' + os.path.splitext(os.path.basename(sys.argv[0]))[0]) self.contact_name = name + suffix if len(self.contact_name) > 63: allowed = 63 - len(suffix) self.contact_name = name[:allowed] + suffix self.listener, port = setup_stream_listener(self.q, self.contact_name) self.contact_service = AvahiAnnouncer(self.contact_name, "_presence._tcp", port, txt_record) self.handle = wait_for_contact_in_publish(self.q, self.bus, self.conn, self.contact_name) # expect salut to disco our caps e = self.q.expect('incoming-connection', listener=self.listener) stream = e.connection e = self.q.expect('stream-iq', to=self.contact_name, query_ns=ns.DISCO_INFO, connection=stream) assertEquals(client + '#' + ver, e.query['node']) send_disco_reply(stream, e.stanza, [], features) # lose the connection here to ensure connections are created # where necessary; I just wanted salut to know my caps. stream.send('</stream:stream>') # spend a bit of time in the main loop to ensure the last two # stanzas are actually received by salut before closing the # connection. sync_dbus(self.bus, self.q, self.conn) stream.transport.loseConnection() def wait_for_contact(self): if not hasattr(self, 'handle'): self.handle = wait_for_contact_in_publish(self.q, self.bus, self.conn, self.contact_name) def create_ft_channel(self): self.channel = make_channel_proxy(self.conn, self.ft_path, 'Channel') self.ft_channel = make_channel_proxy(self.conn, self.ft_path, 'Channel.Type.FileTransfer') self.ft_props = dbus.Interface(self.bus.get_object( self.conn.object.bus_name, self.ft_path), PROPERTIES_IFACE) def close_channel(self): self.channel.Close() self.q.expect('dbus-signal', signal='Closed') def test(self, q, bus, conn): self.q = q self.bus = bus self.conn = conn for fct in self._actions: # stop if a function returns True if fct(): break # if we announced the service, let's be sure to get rid of it if self.contact_service: self.contact_service.stop()
def test(q, bus, conn): forbidden = [EventPattern('dbus-signal', signal='ServiceAdded'), EventPattern('dbus-signal', signal='ServiceRemoved')] q.forbid_events(forbidden) conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0, 0]) # announce a contact with the right caps ver = compute_caps_hash([], [], banshee) txt_record = { "txtvers": "1", "status": "avail", "node": CLIENT_NAME, "ver": ver, "hash": "sha-1"} contact_name = "test-service@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, txt_record) handle = wait_for_contact_in_publish(q, bus, conn, contact_name) # this is the first presence, Salut connects to the contact e = q.expect('incoming-connection', listener=listener) incoming = e.connection # Salut looks up its capabilities event = q.expect('stream-iq', connection=incoming, query_ns=ns.DISCO_INFO) query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assertEquals(CLIENT_NAME + '#' + ver, query_node.attributes['node']) contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] # send good reply result = make_result_iq(event.stanza) query = result.firstChildElement() query['node'] = CLIENT_NAME + '#' + ver x = query.addElement((ns.X_DATA, 'x')) x['type'] = 'result' # FORM_TYPE field = x.addElement((None, 'field')) field['var'] = 'FORM_TYPE' field['type'] = 'hidden' field.addElement((None, 'value'), content='urn:ytstenut:capabilities#org.gnome.Banshee') # type field = x.addElement((None, 'field')) field['var'] = 'type' field.addElement((None, 'value'), content='application') # name field = x.addElement((None, 'field')) field['var'] = 'name' field.addElement((None, 'value'), content='en_GB/Banshee Media Player') field.addElement((None, 'value'), content='fr/Banshee Lecteur de Musique') # capabilities field = x.addElement((None, 'field')) field['var'] = 'capabilities' field.addElement((None, 'value'), content='urn:ytstenut:capabilities:yts-caps-audio') field.addElement((None, 'value'), content='urn:ytstenut:data:jingle:rtp') incoming.send(result) # this will be fired as text channel caps will be fired q.expect('dbus-signal', signal='ContactCapabilitiesChanged', predicate=lambda e: contact_handle in e.args[0]) # add evince tmp = banshee.copy() tmp.update(evince) ver = compute_caps_hash([], [], tmp) txt_record['ver'] = ver announcer.update(txt_record) # Salut looks up our capabilities event = q.expect('stream-iq', connection=incoming, query_ns='http://jabber.org/protocol/disco#info') query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assert query_node.attributes['node'] == \ CLIENT_NAME + '#' + txt_record['ver'] # send good reply result['id'] = event.stanza['id'] query['node'] = CLIENT_NAME + '#' + ver x = query.addElement((ns.X_DATA, 'x')) x['type'] = 'result' # FORM_TYPE field = x.addElement((None, 'field')) field['var'] = 'FORM_TYPE' field['type'] = 'hidden' field.addElement((None, 'value'), content='urn:ytstenut:capabilities#org.gnome.Evince') # type field = x.addElement((None, 'field')) field['var'] = 'type' field.addElement((None, 'value'), content='application') # name field = x.addElement((None, 'field')) field['var'] = 'name' field.addElement((None, 'value'), content='en_GB/Evince Picture Viewer') field.addElement((None, 'value'), content='fr/Evince uh, ow do you say') # capabilities field = x.addElement((None, 'field')) field['var'] = 'capabilities' field.addElement((None, 'value'), content='urn:ytstenut:capabilities:pics') incoming.send(result) # this will be fired as text channel caps will be fired q.expect('dbus-signal', signal='ContactCapabilitiesChanged', predicate=lambda e: contact_handle in e.args[0]) # now finally ensure the sidecar path, props = conn.Future.EnsureSidecar(ycs.STATUS_IFACE) assertEquals({}, props) status = ProxyWrapper(bus.get_object(conn.bus_name, path), ycs.STATUS_IFACE, {}) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals({contact_name: { 'org.gnome.Banshee': ('application', {'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique'}, ['urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp']), 'org.gnome.Evince': ('application', {'en_GB': 'Evince Picture Viewer', 'fr': 'Evince uh, ow do you say'}, ['urn:ytstenut:capabilities:pics'])} }, discovered)
class FileTransferTest(object): CONTACT_NAME = 'test-ft' service_name = 'wacky.service.name' metadata = { 'loads': ['of', 'blahblah', 'stuff'], 'mental': ['data', 'sidf'] } def __init__(self, ft_protocol=cs.SOCKET_ADDRESS_TYPE_UNIX): self.file = File() self.contact_service = None self.ft_proto = ft_protocol def _get_socket_address_family(self): if self.ft_proto == cs.SOCKET_ADDRESS_TYPE_IPV4: return socket.AF_INET elif self.ft_proto == cs.SOCKET_ADDRESS_TYPE_IPV6: return socket.AF_INET6 elif self.ft_proto == cs.SOCKET_ADDRESS_TYPE_UNIX: return socket.AF_UNIX assert False def connect(self): self.conn.Connect() self.q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) self.self_handle = self.conn.Properties.Get(cs.CONN, "SelfHandle") self.self_handle_name = self.conn.Properties.Get(cs.CONN, "SelfID") def announce_contact(self, name=CONTACT_NAME, metadata=True): client = 'http://telepathy.freedesktop.org/fake-client' features = [ns.IQ_OOB] if metadata: features += [ns.TP_FT_METADATA] ver = compute_caps_hash([], features, {}) txt_record = { "txtvers": "1", "status": "avail", "node": client, "ver": ver, "hash": "sha-1" } suffix = '@%s' % get_host_name() name += ('-' + os.path.splitext(os.path.basename(sys.argv[0]))[0]) self.contact_name = name + suffix if len(self.contact_name) > 63: allowed = 63 - len(suffix) self.contact_name = name[:allowed] + suffix self.listener, port = setup_stream_listener(self.q, self.contact_name) self.contact_service = AvahiAnnouncer(self.contact_name, "_presence._tcp", port, txt_record) self.handle = wait_for_contact_in_publish(self.q, self.bus, self.conn, self.contact_name) # expect salut to disco our caps e = self.q.expect('incoming-connection', listener=self.listener) stream = e.connection e = self.q.expect('stream-iq', to=self.contact_name, query_ns=ns.DISCO_INFO, connection=stream) assertEquals(client + '#' + ver, e.query['node']) send_disco_reply(stream, e.stanza, [], features) # lose the connection here to ensure connections are created # where necessary; I just wanted salut to know my caps. stream.send('</stream:stream>') # spend a bit of time in the main loop to ensure the last two # stanzas are actually received by salut before closing the # connection. sync_dbus(self.bus, self.q, self.conn) stream.transport.loseConnection() def wait_for_contact(self): if not hasattr(self, 'handle'): self.handle = wait_for_contact_in_publish(self.q, self.bus, self.conn, self.contact_name) def create_ft_channel(self): self.channel = make_channel_proxy(self.conn, self.ft_path, 'Channel') self.ft_channel = make_channel_proxy(self.conn, self.ft_path, 'Channel.Type.FileTransfer') self.ft_props = dbus.Interface( self.bus.get_object(self.conn.object.bus_name, self.ft_path), PROPERTIES_IFACE) def close_channel(self): self.channel.Close() self.q.expect('dbus-signal', signal='Closed') def test(self, q, bus, conn): self.q = q self.bus = bus self.conn = conn for fct in self._actions: # stop if a function returns True if fct(): break # if we announced the service, let's be sure to get rid of it if self.contact_service: self.contact_service.stop()
def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) basic_txt = {"txtvers": "1", "status": "avail"} self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") contact_name = "test-text-channel@" + 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) # create a clique room basic_txt = {"txtvers": "0"} AvahiAnnouncer("myroom", "_clique._udp", 41377, basic_txt) # connect a stream 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) xmpp_connection = connect_to_stream(q, contact_name, self_handle_name, str(e.pt), e.port) e = q.expect('connection-result') assert e.succeeded, e.reason e = q.expect('stream-opened', connection=xmpp_connection) # send an invitation message = domish.Element(('', 'message')) message['type'] = 'normal' message.addElement('body', content='You got a Clique chatroom invitation') invite = message.addElement((NS_CLIQUE, 'invite')) invite.addElement('roomname', content='myroom') invite.addElement('reason', content='Inviting to this room') invite.addElement('address', content='127.0.0.1') invite.addElement('port', content='41377') xmpp_connection.send(message) # group channel is created e = q.expect('dbus-signal', signal='NewChannel', predicate=lambda e: e.args[1] == cs.CHANNEL_TYPE_TEXT and e. args[2] == cs.HT_ROOM) path = e.args[0] channel = make_channel_proxy(conn, path, 'Channel') props_iface = dbus.Interface(bus.get_object(conn.object.bus_name, path), dbus.PROPERTIES_IFACE) q.expect('dbus-signal', signal='MembersChanged', path=path) lp_members = props_iface.Get( 'org.freedesktop.Telepathy.Channel.Interface.Group', 'LocalPendingMembers') assert len(lp_members) == 1 added, actor, reason, msg = lp_members[0] assert added == self_handle assert actor == handle assert reason == 4 #invited assert msg == 'Inviting to this room' # decline invitation channel.Close() q.expect('dbus-signal', signal='Closed')
def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) basic_txt = {"txtvers": "1", "status": "avail"} self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") contact_name = "test-muc@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) AvahiAnnouncer(contact_name, "_presence._tcp", port, basic_txt) handle = wait_for_contact_in_publish(q, bus, conn, contact_name) requests_iface = dbus.Interface(conn, cs.CONN_IFACE_REQUESTS) # Create a connection to send the muc invite 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) outbound = connect_to_stream(q, contact_name, self_handle_name, str(e.pt), e.port) e = q.expect('connection-result') assert e.succeeded, e.reason e = q.expect('stream-opened', connection=outbound) # connected to Salut, now send the muc invite msg = domish.Element((None, 'message')) msg['to'] = self_handle_name msg['from'] = contact_name msg['type'] = 'normal' body = msg.addElement('body', content='You got a Clique chatroom invitation') invite = msg.addElement((NS_CLIQUE, 'invite')) invite.addElement('roomname', content='my-room') invite.addElement('reason', content='Inviting to this room') # FIXME: we should create a real Clique room and use its IP and port. # Hardcode values for now. The IP is a multicast address. invite.addElement('address', content='239.255.71.249') invite.addElement('port', content='62472') outbound.send(msg) e = q.expect('dbus-signal', signal='NewChannels', predicate=lambda e: e.args[0][0][1][cs.CHANNEL_TYPE] == cs. CHANNEL_TYPE_TEXT) channels = e.args[0] assert len(channels) == 1 path, props = channels[0] channel = make_channel_proxy(conn, path, "Channel") channel_group = make_channel_proxy(conn, path, "Channel.Interface.Group") # check channel properties # org.freedesktop.Telepathy.Channel D-Bus properties assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT assertContains(cs.CHANNEL_IFACE_GROUP, props[cs.INTERFACES]) assertContains(cs.CHANNEL_IFACE_MESSAGES, props[cs.INTERFACES]) assert props[cs.TARGET_ID] == 'my-room' assert props[cs.TARGET_HANDLE_TYPE] == HT_ROOM assert props[cs.REQUESTED] == False assert props[cs.INITIATOR_HANDLE] == handle assert props[cs.INITIATOR_ID] == contact_name # we are added to local pending e = q.expect('dbus-signal', signal='MembersChanged') msg, added, removed, lp, rp, actor, reason = e.args assert msg == 'Inviting to this room' assert added == [] assert removed == [] assert lp == [self_handle] assert rp == [] assert actor == handle assert reason == 4 # invited # TODO: join the muc, check if we are added to remote-pending and then # to members. This would need some tweak in Salut and/or the test framework # as Clique takes too much time to join the room and so the event times # out. # TODO: test sending invitations # FIXME: fd.o #30531: this ought to work, but doesn't #channel_group.RemoveMembersWithReason([self_handle], "bored now", 0) channel.Close() q.expect('dbus-signal', signal='Closed')
def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) basic_txt = { "txtvers": "1", "status": "avail" } contact_name = "test-text-channel@" + 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.Requests.CreateChannel({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, cs.TARGET_HANDLE: handle})[0] text_channel = make_channel_proxy(conn, t, "Channel.Type.Text") text_channel.Send(cs.MT_NORMAL, INCOMING_MESSAGE) e = q.expect('incoming-connection', listener = listener) incoming = e.connection e = q.expect('stream-message', connection = incoming) assert e.message_type == "chat" body = xpath.queryForNodes("/message/body", e.stanza ) assert map(str, body) == [ INCOMING_MESSAGE ] # drop the connection incoming.transport.loseConnection() # Now send a message to salut self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") 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) outbound = connect_to_stream(q, contact_name, self_handle_name, str(e.pt), e.port) e = q.expect('connection-result') assert e.succeeded, e.reason e = q.expect('stream-opened', connection = outbound) # connected to salut, now send a message message = domish.Element(('', 'message')) message['type'] = "chat" message.addElement('body', content=OUTGOING_MESSAGE) e.connection.send(message) e = q.expect('dbus-signal', signal='Received') assert e.args[2] == handle assert e.args[3] == cs.MT_NORMAL assert e.args[5] == OUTGOING_MESSAGE
def test(q, bus, conn): self_name = 'testsuite' + '@' + get_host_name() conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) basic_txt = { "txtvers": "1", "status": "avail" } contact_name = "test-request-im@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) # FIXME: this is a hack to be sure to have all the contact list channels # announced so they won't interfere with the muc ones announces. wait_for_contact_list(q, conn) AvahiAnnouncer(contact_name, "_presence._tcp", port, basic_txt) handle = wait_for_contact_in_publish(q, bus, conn, contact_name) # check if we can request roomlist channels properties = conn.GetAll( tp_name_prefix + '.Connection.Interface.Requests', dbus_interface='org.freedesktop.DBus.Properties') assert ({tp_name_prefix + '.Channel.ChannelType': cs.CHANNEL_TYPE_TEXT, tp_name_prefix + '.Channel.TargetHandleType': cs.HT_CONTACT, }, [tp_name_prefix + '.Channel.TargetHandle', tp_name_prefix + '.Channel.TargetID'], ) in properties.get('RequestableChannelClasses'),\ properties['RequestableChannelClasses'] # create muc channel requestotron = dbus.Interface(conn, tp_name_prefix + '.Connection.Interface.Requests') call_async(q, requestotron, 'CreateChannel', { tp_name_prefix + '.Channel.ChannelType': cs.CHANNEL_TYPE_TEXT, tp_name_prefix + '.Channel.TargetHandleType': cs.HT_CONTACT, tp_name_prefix + '.Channel.TargetID': contact_name, }) ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), EventPattern('dbus-signal', signal='NewChannels'), ) path2 = ret.value[0] chan = make_channel_proxy(conn, path2, "Channel") props = ret.value[1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ cs.CHANNEL_TYPE_TEXT assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_CONTACT assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle assert props[tp_name_prefix + '.Channel.TargetID'] == contact_name assert props[tp_name_prefix + '.Channel.Requested'] == True assert props[tp_name_prefix + '.Channel.InitiatorHandle'] \ == conn.Properties.Get(cs.CONN, "SelfHandle") assert props[tp_name_prefix + '.Channel.InitiatorID'] \ == self_name assert new_sig.args[0][0][0] == path2 assert new_sig.args[0][0][1] == props # ensure roomlist channel yours, ensured_path, ensured_props = requestotron.EnsureChannel( { tp_name_prefix + '.Channel.ChannelType': cs.CHANNEL_TYPE_TEXT, tp_name_prefix + '.Channel.TargetHandleType': cs.HT_CONTACT, tp_name_prefix + '.Channel.TargetHandle': handle, }) assert not yours assert ensured_path == path2, (ensured_path, path2) conn.Disconnect() q.expect_many( EventPattern('dbus-signal', signal='Closed', path=path2), EventPattern('dbus-signal', signal='ChannelClosed', args=[path2]), EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]), )
def test_ft_caps_from_contact(q, bus, conn, client): conn_caps_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACT_CAPS) conn_contacts_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACTS) # send presence with FT capa ver = compute_caps_hash([], [ns.IQ_OOB], {}) txt_record = { "txtvers": "1", "status": "avail", "node": client, "ver": ver, "hash": "sha-1" } contact_name = "test-caps-ft@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, txt_record) # this is the first presence, Salut connects to the contact e = q.expect('incoming-connection', listener=listener) incoming = e.connection # Salut looks up our capabilities event = q.expect('stream-iq', connection=incoming, query_ns='http://jabber.org/protocol/disco#info') query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assert query_node.attributes['node'] == \ client + '#' + ver, (query_node.attributes['node'], client, ver) contact_handle = conn_contacts_iface.GetContactByID(contact_name, [])[0] # send good reply result = make_result_iq(event.stanza) query = result.firstChildElement() query['node'] = client + '#' + ver feature = query.addElement('feature') feature['var'] = ns.IQ_OOB incoming.send(result) # FT capa is announced e = q.expect('dbus-signal', signal='ContactCapabilitiesChanged', predicate=lambda e: contact_handle in e.args[0]) caps = e.args[0][contact_handle] assertContains(ft_caps, caps) # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assert caps_via_contacts_iface == caps, caps_via_contacts_iface # check if Salut announces the OOB capa self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") 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() receive_presence_and_ask_caps(q, incoming, service, contact_name) # capa announced without FT ver = compute_caps_hash([], ["http://telepathy.freedesktop.org/xmpp/pony"], {}) txt_record = { "txtvers": "1", "status": "avail", "node": client, "ver": ver, "hash": "sha-1" } contact_name = "test-caps-ft2@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, txt_record) # this is the first presence, Salut connects to the contact e = q.expect('incoming-connection', listener=listener) incoming = e.connection # Salut looks up our capabilities event = q.expect('stream-iq', connection=incoming, query_ns='http://jabber.org/protocol/disco#info') query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assert query_node.attributes['node'] == \ client + '#' + ver, (query_node.attributes['node'], client, ver) contact_handle = conn_contacts_iface.GetContactByID(contact_name, [])[0] # send good reply result = make_result_iq(event.stanza) query = result.firstChildElement() query['node'] = client + '#' + ver feature = query.addElement('feature') feature['var'] = "http://telepathy.freedesktop.org/xmpp/pony" incoming.send(result) # the FT capability is not announced e = q.expect('dbus-signal', signal='ContactCapabilitiesChanged') caps = e.args[0][contact_handle] assertDoesNotContain(ft_caps, caps) # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assert caps_via_contacts_iface == caps, caps_via_contacts_iface # no capabilites announced (assume FT is supported to insure interop) txt_record = {"txtvers": "1", "status": "avail"} contact_name = "test-caps-ft-no-capa2@" + get_host_name() contact_handle = conn_contacts_iface.GetContactByID(contact_name, [])[0] listener, port = setup_stream_listener(q, contact_name) announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, txt_record) # FT capa is announced e = q.expect('dbus-signal', signal='ContactCapabilitiesChanged', predicate=lambda e: contact_handle in e.args[0].keys()) caps = e.args[0][contact_handle] assertContains(ft_caps, caps) # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assert caps_via_contacts_iface == caps, caps_via_contacts_iface
def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTED, cs.CSR_NONE_SPECIFIED]) assertContains(cs.CONN_IFACE_CONTACT_INFO, conn.Properties.Get(cs.CONN, "Interfaces")) ci_props = conn.Properties.GetAll(cs.CONN_IFACE_CONTACT_INFO) assertEquals(cs.CONTACT_INFO_FLAG_PUSH, ci_props['ContactInfoFlags']) assertEquals( [ ('n', [], cs.CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT, 1), ('fn', [], cs.CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT, 1), ('email', ['type=internet'], cs.CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT, 1), ('x-jabber', [], cs.CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT, 1), ], ci_props['SupportedFields']) # Just to verify that RCI does approximately nothing and doesn't crash. conn.ContactInfo.RefreshContactInfo([21,42,88]) basic_txt = { "txtvers": "1", "status": "avail" } contact_name = "aliastest@" + get_host_name() announcer = AvahiAnnouncer(contact_name, "_presence._tcp", 1234, basic_txt) handle = wait_for_contact_in_publish(q, bus, conn, contact_name) alias = wait_for_aliases_changed(q, handle) assertEquals(contact_name, alias) for (alias, dict, expect_contact_info_changed) in [ # Contact publishes just one of 1st and last ("last", { "last": "last" }, True), ("1st", { "1st": "1st"}, True), # Contact publishes a meaningful value for one of 1st and last, and an # empty value for the other one and for "nick". Empty values should be # treated as if missing. ("last", { "last": "last", "1st": "", "nick": "" }, True), ("1st", { "1st": "1st", "last": "", "nick": "" }, True), # When a contact publishes both 1st and last, we have to join them # together in a stupid anglo-centric way, like iChat does. ("1st last", { "1st": "1st", "last": "last" }, True), # Nickname should be preferred as the alias to 1st or last. Since we # don't report nicknames in ContactInfo, and nothing else has changed # from the last update, no ContactInfo changes should be announced. ("nickname", { "1st": "1st", "last": "last", "nick": "nickname" }, False), # If the contact stops publishing any of this stuff, we should fall back # to their JID as their alias. (contact_name, {}, True) ]: txt = basic_txt.copy() txt.update(dict) announcer.set(txt) a = wait_for_aliases_changed (q, handle) assert a == alias, (a, alias, txt) if expect_contact_info_changed: info = wait_for_contact_info_changed(q, handle) check_contact_info(info, dict) attrs = conn.Contacts.GetContactAttributes([handle], [cs.CONN_IFACE_ALIASING], True)[handle] assertEquals(alias, attrs[cs.CONN_IFACE_ALIASING + "/alias"]) check_all_contact_info_methods(conn, handle, dict) for keys in [ # Check a few neat transitions, with no empty fields { "email": "*****@*****.**" }, { "jid": "*****@*****.**", "email": "*****@*****.**" }, { "jid": "*****@*****.**" }, # Check that empty fields are treated as if omitted { "email": "*****@*****.**", "jid": "" }, { "jid": "*****@*****.**", "email": "" }, ]: txt = basic_txt.copy() txt.update(keys) announcer.set(txt) info = wait_for_contact_info_changed(q, handle) check_contact_info(info, keys) check_all_contact_info_methods(conn, handle, keys) # Try an invalid handle. Request should return InvalidHandle. # (Technically so should RefreshContactInfo but I am lazy.) call_async(q, conn.ContactInfo, 'RequestContactInfo', 42) q.expect('dbus-error', method='RequestContactInfo', name=cs.INVALID_HANDLE) # Try a valid handle for whom we have no data from the network. # Request should fail. h = conn.Contacts.GetContactByID('rthrtha@octopus', [])[0] call_async(q, conn.ContactInfo, 'RequestContactInfo', h) q.expect('dbus-error', method='RequestContactInfo', name=cs.NOT_AVAILABLE)
def test(q, bus, conn): call_async(q, conn.Future, 'EnsureSidecar', ycs.STATUS_IFACE) conn.Connect() # Now we're connected, the call we made earlier should return. e = q.expect('dbus-return', method='EnsureSidecar') path, props = e.value assertEquals({}, props) status = ProxyWrapper(bus.get_object(conn.bus_name, path), ycs.STATUS_IFACE, {}) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals({}, discovered) # announce a contact with the right caps ver = compute_caps_hash([], [], banshee) txt_record = { "txtvers": "1", "status": "avail", "node": CLIENT_NAME, "ver": ver, "hash": "sha-1" } contact_name = "test-service@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, txt_record) handle = wait_for_contact_in_publish(q, bus, conn, contact_name) # this is the first presence, Salut connects to the contact e = q.expect('incoming-connection', listener=listener) incoming = e.connection # Salut looks up its capabilities event = q.expect('stream-iq', connection=incoming, query_ns=ns.DISCO_INFO) query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assertEquals(CLIENT_NAME + '#' + ver, query_node.attributes['node']) contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] # send good reply result = make_result_iq(event.stanza) query = result.firstChildElement() query['node'] = CLIENT_NAME + '#' + ver x = query.addElement((ns.X_DATA, 'x')) x['type'] = 'result' # FORM_TYPE field = x.addElement((None, 'field')) field['var'] = 'FORM_TYPE' field['type'] = 'hidden' field.addElement((None, 'value'), content='urn:ytstenut:capabilities#org.gnome.Banshee') # type field = x.addElement((None, 'field')) field['var'] = 'type' field.addElement((None, 'value'), content='application') # name field = x.addElement((None, 'field')) field['var'] = 'name' field.addElement((None, 'value'), content='en_GB/Banshee Media Player') field.addElement((None, 'value'), content='fr/Banshee Lecteur de Musique') # capabilities field = x.addElement((None, 'field')) field['var'] = 'capabilities' field.addElement((None, 'value'), content='urn:ytstenut:capabilities:yts-caps-audio') field.addElement((None, 'value'), content='urn:ytstenut:data:jingle:rtp') incoming.send(result) # this will be fired as text channel caps will be fired _, e = q.expect_many( EventPattern('dbus-signal', signal='ContactCapabilitiesChanged', predicate=lambda e: contact_handle in e.args[0]), EventPattern('dbus-signal', signal='ServiceAdded')) contact_id, service_name, details = e.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Banshee', service_name) type, name_map, caps = details assertEquals('application', type) assertEquals( { 'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique' }, name_map) assertSameSets([ 'urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp' ], caps) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals( { contact_name: { 'org.gnome.Banshee': ('application', { 'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique' }, [ 'urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp' ]) }, }, discovered) # add evince tmp = banshee.copy() tmp.update(evince) ver = compute_caps_hash([], [], tmp) txt_record['ver'] = ver announcer.update(txt_record) # Salut looks up our capabilities event = q.expect('stream-iq', connection=incoming, query_ns='http://jabber.org/protocol/disco#info') query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assert query_node.attributes['node'] == \ CLIENT_NAME + '#' + txt_record['ver'] # send good reply result['id'] = event.stanza['id'] query['node'] = CLIENT_NAME + '#' + ver x = query.addElement((ns.X_DATA, 'x')) x['type'] = 'result' # FORM_TYPE field = x.addElement((None, 'field')) field['var'] = 'FORM_TYPE' field['type'] = 'hidden' field.addElement((None, 'value'), content='urn:ytstenut:capabilities#org.gnome.Evince') # type field = x.addElement((None, 'field')) field['var'] = 'type' field.addElement((None, 'value'), content='application') # name field = x.addElement((None, 'field')) field['var'] = 'name' field.addElement((None, 'value'), content='en_GB/Evince Picture Viewer') field.addElement((None, 'value'), content='fr/Evince uh, ow do you say') # capabilities field = x.addElement((None, 'field')) field['var'] = 'capabilities' field.addElement((None, 'value'), content='urn:ytstenut:capabilities:pics') incoming.send(result) e = q.expect('dbus-signal', signal='ServiceAdded') contact_id, service_name, details = e.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Evince', service_name) type, name_map, caps = details assertEquals('application', type) assertEquals( { 'en_GB': 'Evince Picture Viewer', 'fr': 'Evince uh, ow do you say' }, name_map) assertSameSets(['urn:ytstenut:capabilities:pics'], caps) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals( { contact_name: { 'org.gnome.Banshee': ('application', { 'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique' }, [ 'urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp' ]), 'org.gnome.Evince': ('application', { 'en_GB': 'Evince Picture Viewer', 'fr': 'Evince uh, ow do you say' }, ['urn:ytstenut:capabilities:pics']) } }, discovered) # remove evince ver = compute_caps_hash([], [], banshee) txt_record['ver'] = ver forbidden = [ EventPattern('dbus-signal', signal='stream-iq', connection=incoming) ] q.forbid_events(forbidden) announcer.update(txt_record) e = q.expect('dbus-signal', signal='ServiceRemoved') contact_id, service_name = e.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Evince', service_name) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals( { contact_name: { 'org.gnome.Banshee': ('application', { 'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique' }, [ 'urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp' ]) }, }, discovered) sync_stream(q, incoming) q.unforbid_events(forbidden) # now just evince ver = compute_caps_hash([], [], evince) txt_record['ver'] = ver announcer.update(txt_record) # Salut looks up our capabilities event = q.expect('stream-iq', connection=incoming, query_ns='http://jabber.org/protocol/disco#info') query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assert query_node.attributes['node'] == \ CLIENT_NAME + '#' + txt_record['ver'] # send good reply result = make_result_iq(event.stanza) query = result.firstChildElement() query['node'] = CLIENT_NAME + '#' + ver x = query.addElement((ns.X_DATA, 'x')) x['type'] = 'result' # FORM_TYPE field = x.addElement((None, 'field')) field['var'] = 'FORM_TYPE' field['type'] = 'hidden' field.addElement((None, 'value'), content='urn:ytstenut:capabilities#org.gnome.Evince') # type field = x.addElement((None, 'field')) field['var'] = 'type' field.addElement((None, 'value'), content='application') # name field = x.addElement((None, 'field')) field['var'] = 'name' field.addElement((None, 'value'), content='en_GB/Evince Picture Viewer') field.addElement((None, 'value'), content='fr/Evince uh, ow do you say') # capabilities field = x.addElement((None, 'field')) field['var'] = 'capabilities' field.addElement((None, 'value'), content='urn:ytstenut:capabilities:pics') incoming.send(result) sa, sr = q.expect_many( EventPattern('dbus-signal', signal='ServiceAdded'), EventPattern('dbus-signal', signal='ServiceRemoved')) contact_id, service_name, details = sa.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Evince', service_name) type, name_map, caps = details assertEquals('application', type) assertEquals( { 'en_GB': 'Evince Picture Viewer', 'fr': 'Evince uh, ow do you say' }, name_map) assertSameSets(['urn:ytstenut:capabilities:pics'], caps) contact_id, service_name = sr.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Banshee', service_name) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals( { contact_name: { 'org.gnome.Evince': ('application', { 'en_GB': 'Evince Picture Viewer', 'fr': 'Evince uh, ow do you say' }, ['urn:ytstenut:capabilities:pics']) } }, discovered) # just banshee again ver = compute_caps_hash([], [], banshee) txt_record['ver'] = ver forbidden = [ EventPattern('dbus-signal', signal='stream-iq', connection=incoming) ] q.forbid_events(forbidden) announcer.update(txt_record) sr, sa = q.expect_many( EventPattern('dbus-signal', signal='ServiceRemoved'), EventPattern('dbus-signal', signal='ServiceAdded')) contact_id, service_name = sr.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Evince', service_name) contact_id, service_name, details = sa.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Banshee', service_name) type, name_map, caps = details assertEquals('application', type) assertEquals( { 'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique' }, name_map) assertSameSets([ 'urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp' ], caps) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals( { contact_name: { 'org.gnome.Banshee': ('application', { 'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique' }, [ 'urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp' ]) } }, discovered) sync_stream(q, incoming) q.unforbid_events(forbidden) # both again ver = compute_caps_hash([], [], tmp) txt_record['ver'] = ver announcer.update(txt_record) sa = q.expect('dbus-signal', signal='ServiceAdded') contact_id, service_name, details = sa.args assertEquals(contact_name, contact_id) assertEquals('org.gnome.Evince', service_name) type, name_map, caps = details assertEquals('application', type) assertEquals( { 'en_GB': 'Evince Picture Viewer', 'fr': 'Evince uh, ow do you say' }, name_map) assertSameSets(['urn:ytstenut:capabilities:pics'], caps) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals( { contact_name: { 'org.gnome.Banshee': ('application', { 'en_GB': 'Banshee Media Player', 'fr': 'Banshee Lecteur de Musique' }, [ 'urn:ytstenut:capabilities:yts-caps-audio', 'urn:ytstenut:data:jingle:rtp' ]), 'org.gnome.Evince': ('application', { 'en_GB': 'Evince Picture Viewer', 'fr': 'Evince uh, ow do you say' }, ['urn:ytstenut:capabilities:pics']) } }, discovered) sync_stream(q, incoming) # and finally, nothing ver = compute_caps_hash([], [], {}) txt_record['ver'] = ver announcer.update(txt_record) # Salut looks up our capabilities event = q.expect('stream-iq', connection=incoming, query_ns='http://jabber.org/protocol/disco#info') query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assert query_node.attributes['node'] == \ CLIENT_NAME + '#' + txt_record['ver'] # send good reply result = make_result_iq(event.stanza) query = result.firstChildElement() query['node'] = CLIENT_NAME + '#' + ver incoming.send(result) q.expect_many( EventPattern('dbus-signal', signal='ServiceRemoved', args=[contact_name, 'org.gnome.Banshee']), EventPattern('dbus-signal', signal='ServiceRemoved', args=[contact_name, 'org.gnome.Evince'])) discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredServices', dbus_interface=dbus.PROPERTIES_IFACE) assertEquals({}, discovered)
def receive_caps(q, bus, conn, service, contact, contact_handle, features, expected_caps, expect_disco=True, expect_ccc=True): ver = compute_caps_hash([], features, {}) txt_record = { "txtvers": "1", "status": "avail", "node": client, "ver": ver, "hash": "sha-1" } listener, port = setup_stream_listener(q, contact) AvahiAnnouncer(contact, "_presence._tcp", port, txt_record) if expect_disco: # Salut looks up our capabilities e = q.expect('incoming-connection', listener=listener) stream = e.connection event = q.expect('stream-iq', to=contact, query_ns=ns.DISCO_INFO, connection=stream) query_node = xpath.queryForNodes('/iq/query', event.stanza)[0] assert query_node.attributes['node'] == \ client + '#' + ver # send good reply result = make_result_iq(event.stanza) query = result.firstChildElement() query['node'] = client + '#' + ver for f in features: feature = query.addElement('feature') feature['var'] = f stream.send(result) if expect_ccc: event = q.expect('dbus-signal', signal='ContactCapabilitiesChanged') announced_ccs, = event.args assertSameElements(expected_caps, announced_ccs[contact_handle]) else: if expect_disco: # Make sure Salut's got the caps sync_stream(q, stream) # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.ATTR_CONTACT_CAPABILITIES] assertSameElements(expected_caps, caps_via_contacts_iface) # close the connection and expect a new one to be opened by Salut # the next time we need some discoing doing if expect_disco: stream.send('</stream:stream>') stream.transport.loseConnection() # pass some time so Salut knows the connection is lost and # won't try and send stuff down a closed connection on the # next test. sync_dbus(bus, q, conn)
def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) activity_txt = { "type": "org.laptop.HelloMesh", "name": "HelloMesh", "color": "#7b83c1,#260993", "txtvers": "0", "activity-id": ACTIVITY_ID, "room": ACTIVITY_ID } # Listen for announcements l = AvahiListener(q).listen_for_service("_olpc-activity1._udp") # Assert that the testsuite doesn't announce the activity service_name = ACTIVITY_ID + ":" + TESTSUITE_PUBLISHED_NAME + "@" + get_host_name() forbiden_event = EventPattern('service-added', name=service_name) q.forbid_events([forbiden_event]) contact_name = PUBLISHED_NAME + "@" + get_host_name() activity_name = ACTIVITY_ID + ":" + PUBLISHED_NAME + "@" + get_host_name() AvahiAnnouncer(contact_name, "_presence._tcp", 1234, {}) act_hostname = ACTIVITY_ID + ":" + PUBLISHED_NAME + \ "._clique._udp." + get_domain_name() act_address = "239.253.70.70" announce_address(act_hostname, act_address) # FIXME, if we use the same name as the running salut will MembersChanged # isn't signalled later on, needs to be fixed. AvahiAnnouncer(ACTIVITY_ID + ":" + PUBLISHED_NAME, "_clique._udp", 12345, {}, hostname = act_hostname) AvahiAnnouncer(activity_name, "_olpc-activity1._udp", 0, activity_txt) # Publish a contact, now get it's handle handle = wait_for_contact_in_publish(q, bus, conn, contact_name) # Assert that the remote handles signals it joined the activity while True: e = q.expect('dbus-signal', signal = 'ActivitiesChanged') if e.args[0] == handle and e.args[1] != []: assert len(e.args[1]) == 1 assert e.args[1][0][0] == ACTIVITY_ID activity_handle = e.args[1][0][1] break act_prop_iface = dbus.Interface(conn, cs.ACTIVITY_PROPERTIES) act_properties = act_prop_iface.GetProperties(activity_handle) assert act_properties['private'] == False assert act_properties['color'] == activity_txt['color'] assert act_properties['name'] == activity_txt['name'] assert act_properties['type'] == activity_txt['type'] room_channel = conn.RequestChannel(CHANNEL_TYPE_TEXT, HT_ROOM, activity_handle, True) q.expect('dbus-signal', signal='MembersChanged', path=room_channel, args = [u'', [1L], [], [], [], 1L, 0L]) # Make it public that we joined the activity q.unforbid_events([forbiden_event]) buddy_info_iface = dbus.Interface(conn, cs.BUDDY_INFO) buddy_info_iface.SetActivities([(ACTIVITY_ID, activity_handle)]) q.expect('service-added', name = ACTIVITY_ID + ":" + TESTSUITE_PUBLISHED_NAME + "@" + get_host_name()) buddy_info_iface.SetActivities([]) q.expect('service-removed', name = ACTIVITY_ID + ":" + TESTSUITE_PUBLISHED_NAME + "@" + get_host_name())