def test_abort_connected(q, bus, conn, stream):
    initial_response = str('\0' + JID.split('@')[0] + '\0' + PASSWORD).encode()
    chan, authenticator = start_mechanism(q,
                                          bus,
                                          conn,
                                          mechanism='PLAIN',
                                          initial_response=initial_response)

    authenticator.success(None)
    q.expect('dbus-signal',
             signal='SASLStatusChanged',
             interface=cs.CHANNEL_IFACE_SASL_AUTH,
             args=[cs.SASL_STATUS_SERVER_SUCCEEDED, '', {}])

    chan.SASLAuthentication.AcceptSASL()
    q.expect('dbus-signal',
             signal='SASLStatusChanged',
             interface=cs.CHANNEL_IFACE_SASL_AUTH,
             args=[cs.SASL_STATUS_SUCCEEDED, '', {}])
    q.expect('dbus-signal',
             signal='StatusChanged',
             args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])

    call_async(q, chan.SASLAuthentication, 'AbortSASL',
               cs.SASL_ABORT_REASON_USER_ABORT, "aborting too late")
    q.expect('dbus-error', method='AbortSASL', name=cs.NOT_AVAILABLE)
    chan.Close()
Example #2
0
def test(q, bus, conn, stream):
    cm = bus.get_object(cs.CM + '.gabble',
        tp_path_prefix + '/ConnectionManager/gabble')
    cm_iface = dbus.Interface(cm, cs.CM)
    cm_prop_iface = dbus.Interface(cm, cs.PROPERTIES_IFACE)

    protocols = unwrap(cm_prop_iface.Get(cs.CM, 'Protocols'))
    assertEquals(set(['jabber']), set(protocols.keys()))

    protocol_names = unwrap(cm_iface.ListProtocols())
    assertEquals(set(['jabber']), set(protocol_names))

    cm_params = cm_iface.GetParameters('jabber')
    jabber_props = protocols['jabber']
    jabber_params = jabber_props[cs.PROTOCOL + '.Parameters']
    assertEquals(cm_params, jabber_params)

    proto = bus.get_object(cm.bus_name, cm.object_path + '/jabber')
    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 = jabber_props[cs.PROTOCOL + '.' + key]
        b = proto_props[key]
        assertEquals(a, b)

    assertEquals('*****@*****.**',
        unwrap(proto_iface.NormalizeContact('[email protected]/Telepathy')))

    # org.freedesktop.Telepathy.Protocol.Interface.Presence
    expected_status = {'available': (cs.PRESENCE_AVAILABLE,     True,  True),
                       'dnd'      : (cs.PRESENCE_BUSY,          True,  True),
                       'unknown'  : (cs.PRESENCE_UNKNOWN,       False, False),
                       'away'     : (cs.PRESENCE_AWAY,          True,  True),
                       'xa'       : (cs.PRESENCE_EXTENDED_AWAY, True,  True),
                       'chat'     : (cs.PRESENCE_AVAILABLE,     True,  True),
                       'error'    : (cs.PRESENCE_ERROR,         False, False),
                       'offline'  : (cs.PRESENCE_OFFLINE,       False, False),
                       'testaway' : (cs.PRESENCE_AWAY,          False, False),
                       'testbusy' : (cs.PRESENCE_BUSY,          True,  False),
                       'hidden'   : (cs.PRESENCE_HIDDEN,        True,  True)}

    presences = proto_prop_iface.Get(cs.PROTOCOL_IFACE_PRESENCES, 'Statuses');
    assertEquals(expected_status, unwrap(presences))

    # (Only) 'account' is mandatory for IdentifyAccount()
    call_async(q, proto_iface, 'IdentifyAccount', {})
    q.expect('dbus-error', method='IdentifyAccount', name=cs.INVALID_ARGUMENT)

    test_params = { 'account': 'test@localhost' }
    acc_name = unwrap(proto_iface.IdentifyAccount(test_params))
    assertEquals(test_params['account'], acc_name)

    conn.Connect()
    q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED])
    q.expect('stream-authenticated')
    q.expect('dbus-signal', signal='PresencesChanged',
        args=[{1L: (cs.PRESENCE_AVAILABLE, 'available', '')}])
Example #3
0
def test_disconnect_mid(q, bus, conn, stream):
    chan, authenticator = start_mechanism(q, bus, conn)

    authenticator.challenge(EXCHANGE[1][0])
    q.expect('dbus-signal', signal='NewChallenge',
                 interface=cs.CHANNEL_IFACE_SASL_AUTH,
                 args=[EXCHANGE[1][0]])

    call_async(q, conn, 'Disconnect')
    q.expect_many(EventPattern('dbus-signal', signal='StatusChanged',
                               args=[cs.CONN_STATUS_DISCONNECTED,
                                     cs.CSR_REQUESTED]),
                  EventPattern('dbus-return', method='Disconnect'))
def test_disconnect_mid(q, bus, conn, stream):
    chan, authenticator = start_mechanism(q, bus, conn)

    authenticator.challenge(EXCHANGE[1][0])
    q.expect('dbus-signal',
             signal='NewChallenge',
             interface=cs.CHANNEL_IFACE_SASL_AUTH,
             args=[EXCHANGE[1][0]])

    call_async(q, conn, 'Disconnect')
    q.expect_many(
        EventPattern('dbus-signal',
                     signal='StatusChanged',
                     args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]),
        EventPattern('dbus-return', method='Disconnect'))
def test_dont_get_roster(q, bus, conn, stream):
    # DownloadAtConnection = False, so let's make sure the roster
    # isn't fetched automatically
    q.forbid_events(forbidden)

    conn.Connect()
    q.expect_many(EventPattern('dbus-signal', signal='StatusChanged',
                args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]))
    sync_stream(q, stream)
    q.unforbid_events(forbidden)

    # seems fine, now calling Download should try and get the roster
    # successfully.
    call_async(q, conn.ContactList, 'Download')

    q.expect_many(EventPattern('stream-iq', query_ns=ns.ROSTER),
                  EventPattern('dbus-return', method='Download'))
def test_dont_get_roster(q, bus, conn, stream):
    # DownloadAtConnection = False, so let's make sure the roster
    # isn't fetched automatically
    q.forbid_events(forbidden)

    conn.Connect()
    q.expect_many(
        EventPattern('dbus-signal',
                     signal='StatusChanged',
                     args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]))
    sync_stream(q, stream)
    q.unforbid_events(forbidden)

    # seems fine, now calling Download should try and get the roster
    # successfully.
    call_async(q, conn.ContactList, 'Download')

    q.expect_many(EventPattern('stream-iq', query_ns=ns.ROSTER),
                  EventPattern('dbus-return', method='Download'))
Example #7
0
def test_abort_connected(q, bus, conn, stream):
    initial_response = '\0' + JID.split('@')[0] + '\0' + PASSWORD
    chan, authenticator = start_mechanism(q, bus, conn,
        mechanism='PLAIN',
        initial_response=initial_response)

    authenticator.success(None)
    q.expect('dbus-signal', signal='SASLStatusChanged',
             interface=cs.CHANNEL_IFACE_SASL_AUTH,
             args=[cs.SASL_STATUS_SERVER_SUCCEEDED, '', {}])

    chan.SASLAuthentication.AcceptSASL()
    q.expect('dbus-signal', signal='SASLStatusChanged',
             interface=cs.CHANNEL_IFACE_SASL_AUTH,
             args=[cs.SASL_STATUS_SUCCEEDED, '', {}])
    q.expect('dbus-signal', signal='StatusChanged',
             args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])

    call_async(q, chan.SASLAuthentication, 'AbortSASL',
            cs.SASL_ABORT_REASON_USER_ABORT, "aborting too late")
    q.expect('dbus-error', method='AbortSASL', name=cs.NOT_AVAILABLE)
    chan.Close()
Example #8
0
def test_disconnect_mid(q, bus, conn, stream):
    chan, props = connect_and_get_sasl_channel(q, bus, conn)

    chan.SASLAuthentication.StartMechanismWithData("ABORT-TEST", EXCHANGE[0][1])

    q.expect(
        "dbus-signal",
        signal="SASLStatusChanged",
        interface=cs.CHANNEL_IFACE_SASL_AUTH,
        args=[cs.SASL_STATUS_IN_PROGRESS, "", {}],
    )

    e = q.expect("sasl-auth", initial_response=EXCHANGE[0][1])
    authenticator = e.authenticator

    authenticator.challenge(EXCHANGE[1][0])
    q.expect("dbus-signal", signal="NewChallenge", interface=cs.CHANNEL_IFACE_SASL_AUTH, args=[EXCHANGE[1][0]])

    call_async(q, conn, "Disconnect")
    q.expect_many(
        EventPattern("dbus-signal", signal="StatusChanged", args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]),
        EventPattern("dbus-return", method="Disconnect"),
    )
Example #9
0
def test_abort_connected(q, bus, conn, stream):
    chan, props = connect_and_get_sasl_channel(q, bus, conn)

    chan.SASLAuthentication.StartMechanismWithData("PLAIN", "\0" + JID.split("@")[0] + "\0" + PASSWORD)
    e, _ = q.expect_many(
        EventPattern("sasl-auth"),
        EventPattern(
            "dbus-signal",
            signal="SASLStatusChanged",
            interface=cs.CHANNEL_IFACE_SASL_AUTH,
            args=[cs.SASL_STATUS_IN_PROGRESS, "", {}],
        ),
    )
    authenticator = e.authenticator

    authenticator.success(None)
    q.expect(
        "dbus-signal",
        signal="SASLStatusChanged",
        interface=cs.CHANNEL_IFACE_SASL_AUTH,
        args=[cs.SASL_STATUS_SERVER_SUCCEEDED, "", {}],
    )

    chan.SASLAuthentication.AcceptSASL()
    q.expect(
        "dbus-signal",
        signal="SASLStatusChanged",
        interface=cs.CHANNEL_IFACE_SASL_AUTH,
        args=[cs.SASL_STATUS_SUCCEEDED, "", {}],
    )

    e = q.expect("dbus-signal", signal="StatusChanged", args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])

    call_async(q, chan.SASLAuthentication, "AbortSASL", cs.SASL_ABORT_REASON_USER_ABORT, "aborting too late")
    q.expect("dbus-error", method="AbortSASL", name=cs.NOT_AVAILABLE)
    chan.Close()
Example #10
0
def test(q, bus, conn, stream):
    cm = bus.get_object(cs.CM + '.gabble',
                        tp_path_prefix + '/ConnectionManager/gabble')
    cm_prop_iface = dbus.Interface(cm, cs.PROPERTIES_IFACE)

    protocols = unwrap(cm_prop_iface.Get(cs.CM, 'Protocols'))
    assertEquals(set(['jabber']), set(protocols.keys()))

    jabber_props = protocols['jabber']

    proto = bus.get_object(cm.bus_name, cm.object_path + '/jabber')
    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 = jabber_props[cs.PROTOCOL + '.' + key]
        b = proto_props[key]
        assertEquals(a, b)

    assertEquals('*****@*****.**',
                 unwrap(proto_iface.NormalizeContact('[email protected]/Telepathy')))

    # Protocol.Interface.Presence
    expected_status = {
        'available': (cs.PRESENCE_AVAILABLE, True, True),
        'dnd': (cs.PRESENCE_BUSY, True, True),
        'unknown': (cs.PRESENCE_UNKNOWN, False, False),
        'away': (cs.PRESENCE_AWAY, True, True),
        'xa': (cs.PRESENCE_EXTENDED_AWAY, True, True),
        'chat': (cs.PRESENCE_AVAILABLE, True, True),
        'error': (cs.PRESENCE_ERROR, False, False),
        'offline': (cs.PRESENCE_OFFLINE, False, False),
        'testaway': (cs.PRESENCE_AWAY, False, False),
        'testbusy': (cs.PRESENCE_BUSY, True, False),
        'hidden': (cs.PRESENCE_HIDDEN, True, True)
    }

    presences = proto_prop_iface.Get(cs.PROTOCOL_IFACE_PRESENCES, 'Statuses')
    # Plugins could add additional statuses, so we check if expected_status is
    # included in presences rather than equality.
    for k, v in expected_status.items():
        assertEquals(expected_status[k], unwrap(presences[k]))

    # (Only) 'account' is mandatory for IdentifyAccount()
    call_async(q, proto_iface, 'IdentifyAccount', {})
    q.expect('dbus-error', method='IdentifyAccount', name=cs.INVALID_ARGUMENT)

    test_params = {'account': 'test@localhost'}
    acc_name = unwrap(proto_iface.IdentifyAccount(test_params))
    assertEquals(test_params['account'], acc_name)

    assertContains(cs.PROTOCOL_IFACE_AVATARS, proto_props['Interfaces'])
    avatar_props = unwrap(proto_prop_iface.GetAll(cs.PROTOCOL_IFACE_AVATARS))
    assertEquals(8192, avatar_props['MaximumAvatarBytes'])
    assertEquals(96, avatar_props['MaximumAvatarHeight'])
    assertEquals(96, avatar_props['MaximumAvatarWidth'])
    assertEquals(32, avatar_props['MinimumAvatarHeight'])
    assertEquals(32, avatar_props['MinimumAvatarWidth'])
    assertEquals(64, avatar_props['RecommendedAvatarHeight'])
    assertEquals(64, avatar_props['RecommendedAvatarWidth'])
    assertEquals(['image/png', 'image/jpeg', 'image/gif'],
                 avatar_props['SupportedAvatarMIMETypes'])

    conn.Connect()
    q.expect('dbus-signal',
             signal='StatusChanged',
             args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED])
    q.expect('stream-authenticated')
    q.expect('dbus-signal',
             signal='PresencesChanged',
             args=[{
                 1: (cs.PRESENCE_AVAILABLE, 'available', '')
             }])
    q.expect('dbus-signal',
             signal='StatusChanged',
             args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
    return
Example #11
0
def test(q, bus, conn, stream):
    cm = bus.get_object(cs.CM + '.gabble',
        tp_path_prefix + '/ConnectionManager/gabble')
    cm_prop_iface = dbus.Interface(cm, cs.PROPERTIES_IFACE)

    protocols = unwrap(cm_prop_iface.Get(cs.CM, 'Protocols'))
    assertEquals(set(['jabber']), set(protocols.keys()))

    jabber_props = protocols['jabber']

    proto = bus.get_object(cm.bus_name, cm.object_path + '/jabber')
    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 = jabber_props[cs.PROTOCOL + '.' + key]
        b = proto_props[key]
        assertEquals(a, b)

    assertEquals('*****@*****.**',
        unwrap(proto_iface.NormalizeContact('[email protected]/Telepathy')))

    # Protocol.Interface.Presence
    expected_status = {'available': (cs.PRESENCE_AVAILABLE,     True,  True),
                       'dnd'      : (cs.PRESENCE_BUSY,          True,  True),
                       'unknown'  : (cs.PRESENCE_UNKNOWN,       False, False),
                       'away'     : (cs.PRESENCE_AWAY,          True,  True),
                       'xa'       : (cs.PRESENCE_EXTENDED_AWAY, True,  True),
                       'chat'     : (cs.PRESENCE_AVAILABLE,     True,  True),
                       'error'    : (cs.PRESENCE_ERROR,         False, False),
                       'offline'  : (cs.PRESENCE_OFFLINE,       False, False),
                       'testaway' : (cs.PRESENCE_AWAY,          False, False),
                       'testbusy' : (cs.PRESENCE_BUSY,          True,  False),
                       'hidden'   : (cs.PRESENCE_HIDDEN,        True,  True)}

    presences = proto_prop_iface.Get(cs.PROTOCOL_IFACE_PRESENCES, 'Statuses');
    # Plugins could add additional statuses, so we check if expected_status is
    # included in presences rather than equality.
    for k, v in expected_status.iteritems():
        assertEquals(expected_status[k], unwrap(presences[k]))

    # (Only) 'account' is mandatory for IdentifyAccount()
    call_async(q, proto_iface, 'IdentifyAccount', {})
    q.expect('dbus-error', method='IdentifyAccount', name=cs.INVALID_ARGUMENT)

    test_params = { 'account': 'test@localhost' }
    acc_name = unwrap(proto_iface.IdentifyAccount(test_params))
    assertEquals(test_params['account'], acc_name)

    assertContains(cs.PROTOCOL_IFACE_AVATARS, proto_props['Interfaces'])
    avatar_props = unwrap(proto_prop_iface.GetAll(cs.PROTOCOL_IFACE_AVATARS))
    assertEquals(8192, avatar_props['MaximumAvatarBytes'])
    assertEquals(96, avatar_props['MaximumAvatarHeight'])
    assertEquals(96, avatar_props['MaximumAvatarWidth'])
    assertEquals(32, avatar_props['MinimumAvatarHeight'])
    assertEquals(32, avatar_props['MinimumAvatarWidth'])
    assertEquals(64, avatar_props['RecommendedAvatarHeight'])
    assertEquals(64, avatar_props['RecommendedAvatarWidth'])
    assertEquals(['image/png', 'image/jpeg', 'image/gif'], avatar_props['SupportedAvatarMIMETypes'])

    conn.Connect()
    q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED])
    q.expect('stream-authenticated')
    q.expect('dbus-signal', signal='PresencesChanged',
        args=[{1L: (cs.PRESENCE_AVAILABLE, 'available', '')}])
Example #12
0
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)
Example #13
0
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)