From 7bddff824d79e851033e88fe418b5a5eaa6faa85 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 11 May 2011 19:39:17 +0100 Subject: Add a Twisted test for very long messages. This exposed an arguable bug in the previous parser where the server sending an over-long line led to it being ignored completely. I'm not 100% sure this is that useful. --- tests/twisted/Makefile.am | 1 + tests/twisted/channels/very-long-names-reply.py | 83 +++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/twisted/channels/very-long-names-reply.py diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index f33c1a5..933de93 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -13,6 +13,7 @@ TWISTED_TESTS = \ channels/requests-create.py \ channels/requests-muc.py \ channels/muc-channel-topic.py \ + channels/very-long-names-reply.py \ messages/accept-invalid-nicks.py \ messages/contactinfo-request.py \ messages/messages-iface.py \ diff --git a/tests/twisted/channels/very-long-names-reply.py b/tests/twisted/channels/very-long-names-reply.py new file mode 100644 index 0000000..1b01185 --- /dev/null +++ b/tests/twisted/channels/very-long-names-reply.py @@ -0,0 +1,83 @@ +""" +Regression test for , where +if the members of a room were sent in an overly-long 353 message, only some (or +none) of them would be announced by Idle. +""" + +import dbus +from servicetest import call_async, assertEquals, assertContains +from idletest import exec_test, BaseIRCServer +import constants as cs + +other_members_ = [ + 'c2tarun', 'seb128', 'sol0', 'mikhailz', 'pecisk_darbs', 'jonnylamb', + 'Vudentz', 'vtheman', 'drdanz_home', 'asabil', 'mhr3', 'Naveen', + 'pavank10', 'mikhas', 'tomeu', 'smcv', 'bleeter', 'aef', 'gimzo', + 'nerd_bloke', 'bcurtiswx', 'orospakr', 'KaKaRoTo-KS', 'treitter', 'pessi', + 'Maiku', 'Mozillion', 'rishi', 'comawhite', 'araujo', 'burger', 'zimmerle', + 'mchro', 'sjoerd', 'lcuk', 'Robot101', 'mimico', 'magcius', 'hadess', + 'neoclust', 'siraj', 'kenvandine', 'wjt', 'jprvita|afk', 'rektide', + 'fredp', 'kutio', 'phako', 'mwk', 'bigon', 'Elleo', 'dgrift', 'superdump', + 'cosimoc', 'felipe`', 'domme', 'mortenmj', 'staz_', 'kov', 'drf__', + 'jonner', 'a{sv}bot', 'xclaesse', 'cassidy', 'rgs_', 'pcapriotti', + 'schoenemann', 'jbos', 'mbatle', 'andrunko', 'robtaylor', 'alasdair', + 'sladen', 'albanc', 'barisione', 'inz', 'eeejay', 'pochu', 'Hei_Ku', 'KA_', + 'grundleborg', 'lool', 'ocrete', 'elmo', 'lfrb', 'KaKaRoTo', 'stormer', + 'gkiagia', 'KA', 'abner', 'w00t_', 'oggis_', 'ike', +] +other_members = [] +for x in other_members_: + other_members.extend([x, x + '_'])#, x + '__', x + '___']) + +# The important thing about this test is not the specific identifiers, it's +# that they don't fit within the official limit of a single IRC message. +#assert len(' '.join(other_members)) > 512 + +class BlahBlah(BaseIRCServer): + def handleJOIN(self, args, prefix): + room = args[0] + self.rooms.append(room) + self.sendJoin(room, other_members) + +def test(q, bus, conn, stream): + conn.Connect() + q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) + q.expect('stream-WHOIS') + + other_member_handles = conn.RequestHandles(cs.HT_CONTACT, other_members) + + call_async(q, conn.Requests, 'CreateChannel', + dbus.Dictionary( + { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, + cs.TARGET_HANDLE_TYPE: cs.HT_ROOM, + cs.TARGET_ID: '#freenodeisbroken', + })) + q.expect('stream-JOIN') + + # FIXME: Idle probably shouldn't return from CreateChannel until it has the + # member list. What it actually does at the moment is: return, + # MembersChanged(added=[self_handle]), then + # MembersChanged(added=[...everyone else...]). So for now the test expects + # this ordering so that we can test the bit we're actually interested in. + q.expect('dbus-return', method='CreateChannel') + e = q.expect('dbus-signal', signal='MembersChangedDetailed') + added, _, _, _, _ = e.args + assertEquals([conn.GetSelfHandle()], added) + + e = q.expect('dbus-signal', signal='MembersChangedDetailed') + added, _, _, _, details = e.args + + if set(added) != set(other_member_handles): + # Yeah, this will break if other_member_handles < added, but it'll + # still assert. Interestingly this test case doesn't trigger the same + # bug as Freenode did: when I connected to Freenode, Idle got some of + # the room members (but not all of them), whereas this test just made + # Idle never see any members at all. + raise AssertionError( + "'Added' array missing these members: %s" % + [ (h, i) for h, i in zip(other_member_handles, other_members) + if h not in added + ]) + +if __name__ == '__main__': + exec_test(test, protocol=BlahBlah) -- cgit v1.2.3