assertEquals((cs.PARAM_REQUIRED, 's', ''), param_map['first-name']) assertDoesNotContain('first', param_map) assertEquals((cs.PARAM_REQUIRED, 's', ''), param_map['last-name']) assertDoesNotContain('last', param_map) assertEquals((0, 's', ''), param_map['email']) assertEquals((0, 's', ''), param_map['jid']) elif name == 'icq': assertEquals('x-icq', flat_props['VCardField']) assertEquals('im-icq', flat_props['Icon']) elif name == 'groupwise': assertEquals('x-groupwise', flat_props['VCardField']) assertEquals('im-groupwise', flat_props['Icon']) elif name == 'sipe': assertEquals('im-sipe', flat_props['Icon']) assertDoesNotContain('usersplit1', param_map) assertEquals((cs.PARAM_HAS_DEFAULT, 's', ''), param_map['login']) assertEquals('[email protected],', protocol_iface.IdentifyAccount({ 'account': '*****@*****.**', 'password': '******'})) assertEquals(r'[email protected],WORKGROUP\Bill', protocol_iface.IdentifyAccount({ 'account': '*****@*****.**', 'login': r'WORKGROUP\Bill', 'password': '******'})) if __name__ == '__main__': exec_test(test)
assertEquals((0, 's', ''), param_map['email']) assertEquals((0, 's', ''), param_map['jid']) elif name == 'icq': assertEquals('x-icq', flat_props['VCardField']) assertEquals('im-icq', flat_props['Icon']) elif name == 'groupwise': assertEquals('x-groupwise', flat_props['VCardField']) assertEquals('im-groupwise', flat_props['Icon']) elif name == 'sipe': assertEquals('im-sipe', flat_props['Icon']) assertDoesNotContain('usersplit1', param_map) assertEquals((cs.PARAM_HAS_DEFAULT, 's', ''), param_map['login']) assertEquals( '[email protected],', protocol_iface.IdentifyAccount({ 'account': '*****@*****.**', 'password': '******' })) assertEquals( r'[email protected],WORKGROUP\Bill', protocol_iface.IdentifyAccount({ 'account': '*****@*****.**', 'login': r'WORKGROUP\Bill', 'password': '******' })) if __name__ == '__main__': exec_test(test)
) # fd.o#32278: # When this was breaking, gabble received AcceptSASL and told the # success_async GAsyncResult to complete in an idle. But, before # the result got its callback called, Close was also received and # the auth manager cleared its channel. When the idle function was # finally reached it saw it no longer had a channel (it had been # cleared in the closed callback) and thought it should be # chaining up to the wocky auth registry but of course it should # be calling the channel finish function. call_async(q, chan.SASLAuthentication, 'AcceptSASL') call_async(q, chan, 'Close') 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]) if __name__ == '__main__': exec_test(test_close_straight_after_accept, { 'password': None, 'account': "[email protected]/Resource" }, do_connect=False)
pass # In response, the server sends a roster update: iq = IQ(stream, "set") item = iq.addElement((ns.ROSTER, 'query')).addElement('item') item['jid'] = jid item['subscription'] = 'none' # no ask='subscribe' any more. stream.send(iq) # In response, Haze should announce that Marco has been removed from # subscribe:remote-pending; but it can't know that, so nothing happens. def test_remove_local(q, bus, conn, stream): test(q, bus, conn, stream, remove=True, local=True) def test_remove_remote(q, bus, conn, stream): test(q, bus, conn, stream, remove=True, local=False) def test_unsubscribe_remote(q, bus, conn, stream): test(q, bus, conn, stream, remove=False, local=False) if __name__ == '__main__': exec_test(test_remove_local) exec_test(test_remove_remote) exec_test(test_unsubscribe_remote)
minh = props['MinimumAvatarHeight'] maxw = props['MaximumAvatarWidth'] maxh = props['MaximumAvatarHeight'] maxb = props['MaximumAvatarBytes'] rech = props['RecommendedAvatarHeight'] recw = props['RecommendedAvatarWidth'] assert types[0] == 'image/png', types assert minw == 32, minw assert minh == 32, minh assert maxw == 96, maxw assert maxh == 96, maxh # libpurple currently says there's no max size #assert maxb == 8192, maxb # there's no way for libpurple to recommend a size, so we offer no opinion assert recw == 0, recw assert rech == 0, rech # deprecated version types, minw, minh, maxw, maxh, maxb = conn.Avatars.GetAvatarRequirements() assert types[0] == 'image/png', types assert minw == 32, minw assert minh == 32, minh assert maxw == 96, maxw assert maxh == 96, maxh # libpurple currently says there's no max size #assert maxb == 8192, maxb if __name__ == '__main__': exec_test(test, do_connect=False)
default_group = None for group in groups: if group == '3 letter names': continue if default_group is not None: raise AssertionError('Two unexplained groups: %s, %s' % (group, default_group)) default_group = group call_async(q, conn.ContactList, 'GetContactListAttributes', [cs.CONN_IFACE_CONTACT_GROUPS], False) r = q.expect('dbus-return', method='GetContactListAttributes') assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][amy][cs.ATTR_SUBSCRIBE]) assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][bob][cs.ATTR_SUBSCRIBE]) assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][chris][cs.ATTR_SUBSCRIBE]) assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][amy][cs.ATTR_PUBLISH]) assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][bob][cs.ATTR_PUBLISH]) assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][chris][cs.ATTR_PUBLISH]) assertSameSets(['3 letter names'], r.value[0][amy][cs.ATTR_GROUPS]) assertSameSets(['3 letter names'], r.value[0][bob][cs.ATTR_GROUPS]) assertSameSets([default_group], r.value[0][chris][cs.ATTR_GROUPS]) if __name__ == '__main__': exec_test(test, protocol=JabberXmlStream, do_connect=False)
maxw = props['MaximumAvatarWidth'] maxh = props['MaximumAvatarHeight'] maxb = props['MaximumAvatarBytes'] rech = props['RecommendedAvatarHeight'] recw = props['RecommendedAvatarWidth'] assert types[0] == 'image/png', types assert minw == 32, minw assert minh == 32, minh assert maxw == 96, maxw assert maxh == 96, maxh # libpurple currently says there's no max size #assert maxb == 8192, maxb # there's no way for libpurple to recommend a size, so we offer no opinion assert recw == 0, recw assert rech == 0, rech # deprecated version types, minw, minh, maxw, maxh, maxb = conn.Avatars.GetAvatarRequirements() assert types[0] == 'image/png', types assert minw == 32, minw assert minh == 32, minh assert maxw == 96, maxw assert maxh == 96, maxh # libpurple currently says there's no max size #assert maxb == 8192, maxb if __name__ == '__main__': exec_test(test, do_connect=False)
EventPattern('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED]), EventPattern('stream-authenticated'), ) event = q.expect('stream-iq', query_ns=ns.ROSTER) event.stanza['type'] = 'result' item = event.query.addElement('item') item['jid'] = '*****@*****.**' item['subscription'] = 'both' stream.send(event.stanza) q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]) bob_handle = conn.get_contact_handle_sync('*****@*****.**') check_rccs(conn, bob_handle) # now a randomer who isn't even in our contact list amy_handle = conn.get_contact_handle_sync('*****@*****.**') check_rccs(conn, amy_handle) if __name__ == '__main__': exec_test(test_self_handle) exec_test(test_someone_else, do_connect=False, protocol=JabberXmlStream)
q.expect_many( EventPattern('dbus-return', method='StartMechanismWithData'), EventPattern('dbus-signal', signal='SASLStatusChanged', interface=cs.CHANNEL_IFACE_SASL_AUTH, args=[cs.SASL_STATUS_SERVER_SUCCEEDED, '', {}]), ) # fd.o#32278: # When this was breaking, gabble received AcceptSASL and told the # success_async GAsyncResult to complete in an idle. But, before # the result got its callback called, Close was also received and # the auth manager cleared its channel. When the idle function was # finally reached it saw it no longer had a channel (it had been # cleared in the closed callback) and thought it should be # chaining up to the wocky auth registry but of course it should # be calling the channel finish function. call_async(q, chan.SASLAuthentication, 'AcceptSASL') call_async(q, chan, 'Close') 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]) if __name__ == '__main__': exec_test(test_close_straight_after_accept, {'password': None, 'account' : "[email protected]/Resource"}, do_connect=False)
if default_group is not None: raise AssertionError('Two unexplained groups: %s, %s' % (group, default_group)) default_group = group call_async(q, conn.ContactList, 'GetContactListAttributes', [cs.CONN_IFACE_CONTACT_GROUPS], False) r = q.expect('dbus-return', method='GetContactListAttributes') assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][amy][cs.ATTR_SUBSCRIBE]) assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][bob][cs.ATTR_SUBSCRIBE]) assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][chris][cs.ATTR_SUBSCRIBE]) assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][amy][cs.ATTR_PUBLISH]) assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][bob][cs.ATTR_PUBLISH]) assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][chris][cs.ATTR_PUBLISH]) assertSameSets(['3 letter names'], r.value[0][amy][cs.ATTR_GROUPS]) assertSameSets(['3 letter names'], r.value[0][bob][cs.ATTR_GROUPS]) assertSameSets([default_group], r.value[0][chris][cs.ATTR_GROUPS]) if __name__ == '__main__': exec_test(test, protocol=JabberXmlStream, do_connect=False)
if local: raise AssertionError("Haze can't do this ") else: # ...in the other client. pass # In response, the server sends a roster update: iq = IQ(stream, "set") item = iq.addElement((ns.ROSTER, 'query')).addElement('item') item['jid'] = jid item['subscription'] = 'none' # no ask='subscribe' any more. stream.send(iq) # In response, Haze should announce that Marco has been removed from # subscribe:remote-pending; but it can't know that, so nothing happens. def test_remove_local(q, bus, conn, stream): test(q, bus, conn, stream, remove=True, local=True) def test_remove_remote(q, bus, conn, stream): test(q, bus, conn, stream, remove=True, local=False) def test_unsubscribe_remote(q, bus, conn, stream): test(q, bus, conn, stream, remove=False, local=False) if __name__ == '__main__': exec_test(test_remove_local) exec_test(test_remove_remote) exec_test(test_unsubscribe_remote)
signal='ChannelClosed', args=[chan.object_path]), # Unhelpfully prpl-jabber just sets the account to disabled so we # don't get an error. # EventPattern('dbus-signal', path=conn.object_path, # signal='ConnectionError', # predicate=lambda e: e.args[0] == cs.AUTHENTICATION_FAILED), EventPattern('dbus-signal', path=conn.object_path, signal='StatusChanged'), ) status, reason = status_changed.args assertEquals(cs.CONN_STATUS_DISCONNECTED, status) # We would like to have # assertEquals(cs.CSR_AUTHENTICATION_FAILED, reason) # prpl-sipe does actually report a connection error rather # than just disabling the account, so yay. prpl-silc sets # PURPLE_CONNECTION_ERROR_OTHER_ERROR, which also comes out as # AUTHENTICATION_FAILED. No other prpls use # purple_account_request_password(). if __name__ == '__main__': exec_test(test_no_password, { 'password': None, 'account': JID }, do_connect=False)
""" Test network error handling. """ import dbus from servicetest import (assertEquals, assertContains) from hazetest import exec_test import constants as cs def test(q, bus, conn, stream): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED]) e = q.expect('dbus-signal', signal='ConnectionError') error, details = e.args assertEquals(cs.CONNECTION_FAILED, error) assertContains('debug-message', details) q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_NETWORK_ERROR]) if __name__ == '__main__': exec_test(test, {'port': dbus.UInt32(14243)}, do_connect=False)
chan.Close() _, _, status_changed = q.expect_many( EventPattern('dbus-signal', path=chan.object_path, signal='Closed'), EventPattern('dbus-signal', path=conn.object_path, signal='ChannelClosed', args=[chan.object_path]), # Unhelpfully prpl-jabber just sets the account to disabled so we # don't get an error. # EventPattern('dbus-signal', path=conn.object_path, # signal='ConnectionError', # predicate=lambda e: e.args[0] == cs.AUTHENTICATION_FAILED), EventPattern('dbus-signal', path=conn.object_path, signal='StatusChanged'), ) status, reason = status_changed.args assertEquals(cs.CONN_STATUS_DISCONNECTED, status) # We would like to have # assertEquals(cs.CSR_AUTHENTICATION_FAILED, reason) # prpl-sipe does actually report a connection error rather # than just disabling the account, so yay. prpl-silc sets # PURPLE_CONNECTION_ERROR_OTHER_ERROR, which also comes out as # AUTHENTICATION_FAILED. No other prpls use # purple_account_request_password(). if __name__ == '__main__': exec_test(test_no_password, {'password': None,'account' : JID}, do_connect=False)