def __init__(self, object, default=cs.CHANNEL, interfaces={ "ServerTLSConnection": cs.CHANNEL_TYPE_SERVER_TLS_CONNECTION }): ProxyWrapper.__init__(self, object, default, interfaces)
def __init__( self, object, default=cs.CHANNEL, interfaces={ "ServerAuthentication": cs.CHANNEL_TYPE_SERVER_AUTHENTICATION, "SASLAuthentication": cs.CHANNEL_IFACE_SASL_AUTH }): ProxyWrapper.__init__(self, object, default, interfaces)
def test(q, bus, conn, stream): messages = [] def new_message(timestamp, domain, level, string): messages.append((timestamp, domain, level, string)) debug = ProxyWrapper(bus.get_object(conn.bus_name, cs.DEBUG_PATH), cs.DEBUG_IFACE) debug.connect_to_signal('NewDebugMessage', new_message) assert len(debug.GetMessages()) > 0 # Turn signalling on and generate some messages. assert len(messages) == 0 assert debug.Properties.Get(cs.DEBUG_IFACE, 'Enabled') == False debug.Properties.Set(cs.DEBUG_IFACE, 'Enabled', True) channel_path, props = conn.Requests.CreateChannel({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, cs.TARGET_HANDLE: conn.Properties.Get(cs.CONN, "SelfHandle") }) q.expect('dbus-signal', signal='NewDebugMessage') assert len(messages) > 0 # Turn signalling off and check we don't get any more messages. debug.Properties.Set(cs.DEBUG_IFACE, 'Enabled', False) sync_dbus(bus, q, conn) snapshot = list(messages) channel = bus.get_object(conn.bus_name, channel_path) channel.Close(dbus_interface=cs.CHANNEL) q.expect('dbus-signal', signal='Closed') channel_path, props = conn.Requests.CreateChannel({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, cs.TARGET_HANDLE: conn.Properties.Get(cs.CONN, "SelfHandle") }) q.expect('dbus-signal', signal='NewChannels') assertEquals(snapshot, messages)
def test(q, bus, conn, stream): messages = [] def new_message(timestamp, domain, level, string): messages.append((timestamp, domain, level, string)) debug = ProxyWrapper(bus.get_object(conn.bus_name, cs.DEBUG_PATH), cs.DEBUG_IFACE) debug.connect_to_signal('NewDebugMessage', new_message) assert len(debug.GetMessages()) > 0 # Turn signalling on and generate some messages. assert len(messages) == 0 assert debug.Properties.Get(cs.DEBUG_IFACE, 'Enabled') == False debug.Properties.Set(cs.DEBUG_IFACE, 'Enabled', True) channel_path, props = conn.Requests.CreateChannel({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, cs.TARGET_HANDLE: conn.Properties.Get(cs.CONN, "SelfHandle") }) q.expect('dbus-signal', signal = 'NewDebugMessage') assert len(messages) > 0 # Turn signalling off and check we don't get any more messages. debug.Properties.Set(cs.DEBUG_IFACE, 'Enabled', False) sync_dbus(bus, q, conn) snapshot = list(messages) channel = bus.get_object(conn.bus_name, channel_path) channel.Close(dbus_interface=cs.CHANNEL) q.expect('dbus-signal', signal='Closed') channel_path, props = conn.Requests.CreateChannel({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, cs.TARGET_HANDLE: conn.Properties.Get(cs.CONN, "SelfHandle") }) q.expect('dbus-signal', signal='NewChannels') assertEquals (snapshot, messages)
def test(q, bus, conn, stream): messages = [] def new_message(timestamp, domain, level, string): messages.append((timestamp, domain, level, string)) debug = ProxyWrapper(bus.get_object(conn.bus_name, path), iface) debug.connect_to_signal('NewDebugMessage', new_message) if not DEBUGGING: # If we're built with --disable-debug, check that the Debug object # isn't present. call_async(q, debug, 'GetMessages') q.expect('dbus-error', method='GetMessages') return assert len(debug.GetMessages()) > 0 # Turn signalling on and generate some messages. assert len(messages) == 0 assert debug.Properties.Get(iface, 'Enabled') == False debug.Properties.Set(iface, 'Enabled', True) channel_path = conn.RequestChannel( cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, conn.GetSelfHandle(), True) q.expect('dbus-signal', signal='NewChannel') assert len(messages) > 0 # Turn signalling off and check we don't get any more messages. debug.Properties.Set(iface, 'Enabled', False) sync_dbus(bus, q, conn) snapshot = list(messages) channel = bus.get_object(conn.bus_name, channel_path) channel.Close(dbus_interface=cs.CHANNEL) q.expect('dbus-signal', signal='Closed') conn.RequestChannel( cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, conn.GetSelfHandle(), True) q.expect('dbus-signal', signal='NewChannel') assertEquals (snapshot, messages)
def __add_stream(self, content, stream_path, initial, incoming): tmpstream = self.bus.get_object(self.conn.bus_name, stream_path) content.stream = ProxyWrapper(tmpstream, cs.CALL_STREAM, {'Media': cs.CALL_STREAM_IFACE_MEDIA}) stream_props = content.stream.Properties.GetAll(cs.CALL_STREAM) assertEquals(True, stream_props['CanRequestReceiving']) if incoming: assertEquals(cs.CALL_SENDING_STATE_PENDING_SEND, stream_props['LocalSendingState']) else: assertEquals(cs.CALL_SENDING_STATE_SENDING, stream_props['LocalSendingState']) if incoming: assertEquals({self.remote_handle: cs.CALL_SENDING_STATE_SENDING}, stream_props['RemoteMembers']) else: assertEquals( {self.remote_handle: cs.CALL_SENDING_STATE_PENDING_SEND}, stream_props['RemoteMembers']) smedia_props = content.stream.Properties.GetAll( cs.CALL_STREAM_IFACE_MEDIA) assertEquals(cs.CALL_SENDING_STATE_NONE, smedia_props['SendingState']) if initial: assertEquals(cs.CALL_SENDING_STATE_NONE, smedia_props['ReceivingState']) else: assertEquals(cs.CALL_SENDING_STATE_PENDING_SEND, smedia_props['ReceivingState']) assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, smedia_props['Transport']) assertEquals([], smedia_props['LocalCandidates']) assertEquals(("", ""), smedia_props['LocalCredentials']) assertEquals([], smedia_props['STUNServers']) assertEquals([], smedia_props['RelayInfo']) assertEquals(True, smedia_props['HasServerInfo']) if incoming: assertLength(1, smedia_props['Endpoints']) self.check_endpoint(content, smedia_props['Endpoints'][0]) else: assertEquals([], smedia_props['Endpoints']) assertEquals(False, smedia_props['ICERestartPending'])
def __init__(self, object, default=cs.AUTH_TLS_CERT, interfaces={ "TLSCertificate" : cs.AUTH_TLS_CERT}): ProxyWrapper.__init__(self, object, default, interfaces)
def __init__(self, object, default=cs.CHANNEL, interfaces={ "ServerTLSConnection" : cs.CHANNEL_TYPE_SERVER_TLS_CONNECTION}): ProxyWrapper.__init__(self, object, default, interfaces)
def __init__(self, object, default=cs.CHANNEL, interfaces={ "ServerAuthentication" : cs.CHANNEL_TYPE_SERVER_AUTHENTICATION, "SASLAuthentication" : cs.CHANNEL_IFACE_SASL_AUTH}): ProxyWrapper.__init__(self, object, default, interfaces)
def add_remote_content_during_hold(self): media_unhold_events = [ EventPattern('dbus-signal', signal='SendingStateChanged'), EventPattern('dbus-signal', signal='ReceivingStateChanged') ] self.q.forbid_events(media_unhold_events) self.context.reinvite([('audio', 'recvonly'), ('audio', None)]) ca = self.q.expect('dbus-signal', signal='ContentAdded') content = self.bus.get_object(self.conn.bus_name, ca.args[0]) content_props = content.GetAll(cs.CALL_CONTENT) assertEquals(cs.CALL_DISPOSITION_NONE, content_props['Disposition']) assertEquals(cs.MEDIA_STREAM_TYPE_AUDIO, content_props['Type']) assertLength(1, content_props['Streams']) tmpstream = self.bus.get_object(self.conn.bus_name, content_props['Streams'][0]) stream = ProxyWrapper(tmpstream, cs.CALL_STREAM, {'Media': cs.CALL_STREAM_IFACE_MEDIA}) stream_props = stream.Properties.GetAll(cs.CALL_STREAM) assertEquals(True, stream_props['CanRequestReceiving']) assertEquals(cs.CALL_SENDING_STATE_PENDING_SEND, stream_props['LocalSendingState']) assertEquals({self.remote_handle: cs.CALL_SENDING_STATE_SENDING}, stream_props['RemoteMembers']) smedia_props = stream.Properties.GetAll(cs.CALL_STREAM_IFACE_MEDIA) assertEquals(cs.CALL_SENDING_STATE_NONE, smedia_props['SendingState']) assertEquals(cs.CALL_SENDING_STATE_NONE, smedia_props['ReceivingState']) mdo = content.Get(cs.CALL_CONTENT_IFACE_MEDIA, 'MediaDescriptionOffer') md = self.bus.get_object(self.conn.bus_name, mdo[0]) md.Accept(self.context.get_audio_md_dbus(self.remote_handle)) self.add_candidates(stream) acc = self.q.expect('sip-response', code=200) self.context.check_call_sdp(acc.sip_message.body, [('audio', 'sendonly'), ('audio', 'inactive')]) self.context.ack(acc.sip_message) content.Remove() reinvite_event = self.q.expect('sip-invite') self.context.check_call_sdp(reinvite_event.sip_message.body, self.medias) body = reinvite_event.sip_message.body.replace( 'sendonly', self.receiving and 'recvonly' or 'inactive') self.context.accept(reinvite_event.sip_message, body) ack_cseq = "%s ACK" % reinvite_event.cseq.split()[0] self.q.expect('sip-ack', cseq=ack_cseq) self.q.unforbid_events(media_unhold_events)
def test_protocol(q, bus, conn, stream): proto = ProxyWrapper( bus.get_object(cs.CM + '.gabble', tp_path_prefix + '/ConnectionManager/gabble/jabber'), cs.PROTOCOL, {"Addressing": cs.PROTOCOL_IFACE_ADDRESSING}) # AddressableVCardFields and AddressableURISchemes addr_props = proto.Properties.GetAll(cs.PROTOCOL_IFACE_ADDRESSING) assertEquals(sorted(["x-jabber", "x-facebook-id"]), sorted(addr_props["AddressableVCardFields"])) assertEquals(["xmpp"], addr_props["AddressableURISchemes"]) # NormalizeVCardAddress normalized_address = proto.Addressing.NormalizeVCardAddress( "X-JABBER", "[email protected]/somewhere") assertEquals("*****@*****.**", normalized_address) normalized_address = proto.Addressing.NormalizeVCardAddress( "X-FACEBOOK-ID", "12345") assertEquals("12345", normalized_address) normalized_address = proto.Addressing.NormalizeVCardAddress( "x-facebook-id", "12345") assertEquals("12345", normalized_address) call_async(q, proto.Addressing, "NormalizeVCardAddress", "x-facebook-id", "abcde") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-WEIRD-FIELD", "*****@*****.**") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.NOT_IMPLEMENTED) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-JABBER", "eitan!example.com") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-FACEBOOK-ID", "-12345!chat.facebook.com") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-FACEBOOK-ID", "*****@*****.**") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-FACEBOOK-ID", "*****@*****.**") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-FACEBOOK-ID", "*****@*****.**") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-FACEBOOK-ID", "*****@*****.**") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeVCardAddress", "X-FACEBOOK-ID", "*****@*****.**") q.expect('dbus-error', method="NormalizeVCardAddress", name=cs.INVALID_ARGUMENT) # NormalizeContactURI normalized_uri = proto.Addressing.NormalizeContactURI( "xmpp:[email protected]/resource") assertEquals("xmpp:eitan%[email protected]", normalized_uri) normalized_uri = proto.Addressing.NormalizeContactURI( "xmpp:[email protected]/resourc?e") assertEquals("xmpp:eitan%[email protected]", normalized_uri) call_async(q, proto.Addressing, "NormalizeContactURI", "Something that is far from a URI") q.expect('dbus-error', method="NormalizeContactURI", name=cs.INVALID_ARGUMENT) call_async(q, proto.Addressing, "NormalizeContactURI", "http://this@isnotawebbrowser") q.expect('dbus-error', method="NormalizeContactURI", name=cs.NOT_IMPLEMENTED) call_async(q, proto.Addressing, "NormalizeContactURI", "xmpp:something") q.expect('dbus-error', method="NormalizeContactURI", name=cs.INVALID_ARGUMENT)
def test(q, bus, conn, stream): rccs = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, 'RequestableChannelClasses') fixed = { cs.CHANNEL_TYPE: CONSOLE_PLUGIN_IFACE, cs.TARGET_HANDLE_TYPE: cs.HT_NONE, } allowed = [] assertContains((fixed, allowed), rccs) path, _ = conn.Requests.CreateChannel( {cs.CHANNEL_TYPE: CONSOLE_PLUGIN_IFACE}) other_path, _ = conn.Requests.CreateChannel( {cs.CHANNEL_TYPE: CONSOLE_PLUGIN_IFACE}) assertNotEquals(path, other_path) # leave the other one open, to test we don't crash on disconnect console = ProxyWrapper(bus.get_object(conn.bus_name, path), CONSOLE_PLUGIN_IFACE, {'Channel': cs.CHANNEL}) assert not console.Properties.Get(CONSOLE_PLUGIN_IFACE, 'SpewStanzas') es = [ EventPattern('dbus-signal', signal='StanzaReceived'), EventPattern('dbus-signal', signal='StanzaSent'), ] q.forbid_events(es) call_async(q, console, 'SendIQ', 'get', STACY, '<coffee xmlns="urn:unimaginative"/>') e = q.expect('stream-iq', iq_type='get', query_ns='urn:unimaginative', query_name='coffee') acknowledge_iq(stream, e.stanza) e = q.expect('dbus-return', method='SendIQ') type_, body = e.value assertEquals('result', type_) # We just assume the body works. # Turn on signalling incoming and outgoing stanzas console.Properties.Set(CONSOLE_PLUGIN_IFACE, 'SpewStanzas', True) sync_dbus(bus, q, conn) q.unforbid_events(es) send_unrecognised_get(q, stream) e = q.expect('dbus-signal', signal='StanzaReceived') xml, = e.args assertContains('<iq', xml) assertContains('<dont-handle-me-bro', xml) signal = q.expect('dbus-signal', signal='StanzaSent') assertContains('service-unavailable', signal.args[0]) # Turn off spewing out stanzas; check it works. console.Properties.Set(CONSOLE_PLUGIN_IFACE, 'SpewStanzas', False) q.forbid_events(es) send_unrecognised_get(q, stream) sync_dbus(bus, q, conn) # Try sending just any old stanza console.SendStanza(''' <message to='%(stacy)s' type='headline'> <body> Hi sis. </body> </message>''' % {'stacy': STACY}) e = q.expect('stream-message', to=STACY, message_type='headline') # Make sure that Wocky has filled in the jabber:client namespace we # carelessly omitted. message = e.stanza assertEquals('message', message.name) assertEquals(ns.CLIENT, message.uri) body = message.firstChildElement() assertEquals('body', body.name) assertEquals(ns.CLIENT, body.uri) console.Channel.Close()
def __init__(self, object, default=cs.AUTH_TLS_CERT, interfaces={"TLSCertificate": cs.AUTH_TLS_CERT}): ProxyWrapper.__init__(self, object, default, interfaces)