] assertLength(2, media_classes) for media_class in media_classes: fixed, allowed = media_class assertEquals(cs.HT_CONTACT, fixed[cs.TARGET_HANDLE_TYPE]) assert fixed.has_key(cs.CALL_INITIAL_AUDIO) or fixed.has_key( cs.CALL_INITIAL_VIDEO) expected_allowed = [ cs.TARGET_ID, cs.TARGET_HANDLE, cs.CALL_INITIAL_VIDEO, cs.CALL_INITIAL_AUDIO, cs.CALL_INITIAL_VIDEO_NAME, cs.CALL_INITIAL_AUDIO_NAME, cs.CALL_INITIAL_TRANSPORT, cs.DTMF_INITIAL_TONES, ] allowed.sort() expected_allowed.sort() assertSameSets(expected_allowed, allowed) if __name__ == '__main__': exec_test(rccs)
) assert len(ret.value) == 2 emitted_props = ret.value[1] assertEquals(cs.CHANNEL_TYPE_TEXT, emitted_props[cs.CHANNEL_TYPE]) assertEquals(cs.HT_CONTACT, emitted_props[cs.TARGET_HANDLE_TYPE]) assertEquals(foo_handle, emitted_props[cs.TARGET_HANDLE]) assertEquals(uri, emitted_props[cs.TARGET_ID]) assertEquals(True, emitted_props[cs.REQUESTED]) assertEquals(self_handle, emitted_props[cs.INITIATOR_HANDLE]) assertEquals(self_uri, emitted_props[cs.INITIATOR_ID]) assert len(new_sig.args) == 1 assert len(new_sig.args[0]) == 1 # one channel assert len(new_sig.args[0][0]) == 2 # two struct members assert new_sig.args[0][0][0] == ret.value[0] assert new_sig.args[0][0][1] == ret.value[1] properties = conn.GetAll(cs.CONN_IFACE_REQUESTS, dbus_interface=cs.PROPERTIES_IFACE) assert new_sig.args[0][0] in properties['Channels'], \ (new_sig.args[0][0], properties['Channels']) conn.Disconnect() q.expect('dbus-signal', signal='StatusChanged', args=[2, 1]) if __name__ == '__main__': exec_test(test)
proto_iface = dbus.Interface(proto, cs.PROTOCOL) proto_prop_iface = dbus.Interface(proto, cs.PROPERTIES_IFACE) proto_props = unwrap(proto_prop_iface.GetAll(cs.PROTOCOL)) for key in ['Parameters', 'Interfaces', 'ConnectionInterfaces', 'RequestableChannelClasses', u'VCardField', u'EnglishName', u'Icon']: a = local_props[cs.PROTOCOL + '.' + key] b = proto_props[key] assertEquals(a, b) assertEquals('x-sip', proto_props['VCardField']) assertEquals('SIP', proto_props['EnglishName']) assertEquals('im-sip', proto_props['Icon']) assertContains(cs.CONN_IFACE_ALIASING, proto_props['ConnectionInterfaces']) assertContains(cs.CONN_IFACE_CONTACTS, proto_props['ConnectionInterfaces']) assertContains(cs.CONN_IFACE_REQUESTS, proto_props['ConnectionInterfaces']) assertEquals('sip:[email protected]', unwrap(proto_iface.NormalizeContact('*****@*****.**'))) # Only account is mandatory call_async(q, proto_iface, 'IdentifyAccount', {}) q.expect('dbus-error', method='IdentifyAccount', name=cs.INVALID_ARGUMENT) test_params = {'account': '*****@*****.**'} acc_name = unwrap(proto_iface.IdentifyAccount(test_params)) assertEquals('*****@*****.**', acc_name) if __name__ == '__main__': exec_test(test)
""" Test SIP registration failure. """ from sofiatest import exec_test def test(q, bus, conn, sip): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[1, 1]) q.expect('dbus-signal', signal='StatusChanged', args=[2, 3]) return True if __name__ == '__main__': exec_test(test, register_cb=lambda *args: False)
def run(**params): exec_test( lambda q, b, c, s: run_call_test(q, b, c, s, incoming=True, **params)) exec_test( lambda q, b, c, s: run_call_test(q, b, c, s, incoming=False, **params))
from sofiatest import exec_test from servicetest import assertEquals import constants as cs def test(q, bus, conn, sip): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[1, 1]) q.expect('sip-register') nc = q.expect('dbus-signal', signal='NewChannels') (((path, props),),) = nc.args assertEquals(cs.CHANNEL_TYPE_SERVER_AUTHENTICATION, props[cs.CHANNEL_TYPE]) assertEquals(['X-TELEPATHY-PASSWORD'], props[cs.SASL_AVAILABLE_MECHANISMS]) chan = dbus.Interface(bus.get_object(conn._named_service, path), cs.CHANNEL_IFACE_SASL_AUTH) chan.StartMechanismWithData('X-TELEPATHY-PASSWORD', 'wrong password') chan.AcceptSASL() q.expect('sip-register') q.expect('dbus-signal', signal='StatusChanged', args=[2, 3]) return True if __name__ == '__main__': exec_test(test, register_cb=lambda *args: False, params={"password": None})
""" Test connecting to a server (successful REGISTER). """ from sofiatest import exec_test def test(q, bus, conn, sip): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[1, 1]) q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) conn.Disconnect() q.expect('dbus-signal', signal='StatusChanged', args=[2, 1]) return True if __name__ == '__main__': exec_test(test, params={"password": None})
def run(**params): exec_test(lambda q, b, c, s: run_call_test(q, b, c, s, incoming=True, **params)) exec_test(lambda q, b, c, s: run_call_test(q, b, c, s, incoming=False, **params))
from sofiatest import exec_test from servicetest import assertEquals import constants as cs def test(q, bus, conn, sip): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[1, 1]) q.expect('sip-register') nc = q.expect('dbus-signal', signal='NewChannels') (((path, props), ), ) = nc.args assertEquals(cs.CHANNEL_TYPE_SERVER_AUTHENTICATION, props[cs.CHANNEL_TYPE]) assertEquals(['X-TELEPATHY-PASSWORD'], props[cs.SASL_AVAILABLE_MECHANISMS]) chan = dbus.Interface(bus.get_object(conn._named_service, path), cs.CHANNEL_IFACE_SASL_AUTH) chan.StartMechanismWithData('X-TELEPATHY-PASSWORD', 'wrong password') chan.AcceptSASL() q.expect('sip-register') q.expect('dbus-signal', signal='StatusChanged', args=[2, 3]) return True if __name__ == '__main__': exec_test(test, register_cb=lambda *args: False, params={"password": None})