[Telepathy-commits] [telepathy-idle/master] Add a couple tests for slightly buggy server behavior
Jonathon Jongsma
jonathon.jongsma at collabora.co.uk
Fri Feb 13 17:43:18 PST 2009
gimpnet IRC server has a bug where if you QUIT while it's waiting for an ident
response (at 'login'), it will totally ignore the QUIT message and go on to send
you a welcome message. I've added a test which approximates this behavior.
In addition, if you send quit behavior, but the remote server doesn't close the
socket, telepathy-idle will never actually quit (or even respond to the
Disconnect() dbus method, in fact). So I've added a test for this case.
I think we should probably unilaterally close the connection and exit after a
certain time if the server is misbehaving in one of these ways
---
tests/twisted/Makefile.am | 2 +
tests/twisted/connect/server-quit-ignore.py | 41 ++++++++++++++++++++++++++
tests/twisted/connect/server-quit-noclose.py | 34 +++++++++++++++++++++
3 files changed, 77 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/connect/server-quit-ignore.py
create mode 100644 tests/twisted/connect/server-quit-noclose.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 7b1d3b0..b6070c2 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -3,6 +3,8 @@ TWISTED_TESTS = \
connect/connect-success-ssl.py \
connect/connect-fail.py \
connect/connect-fail-ssl.py \
+ connect/server-quit-ignore.py \
+ connect/server-quit-noclose.py \
channels/join-muc-channel.py \
messages/message-order.py \
messages/leading-space.py \
diff --git a/tests/twisted/connect/server-quit-ignore.py b/tests/twisted/connect/server-quit-ignore.py
new file mode 100644
index 0000000..c598686
--- /dev/null
+++ b/tests/twisted/connect/server-quit-ignore.py
@@ -0,0 +1,41 @@
+"""
+Test what happens when we send a quit command in the middle of the 'login'
+sequence (e.g. between the USER command and the welcom response) to simulate the
+behavior of the gimpnet server (see
+http://bugs.freedesktop.org/show_bug.cgi?id=19762)
+"""
+
+from idletest import exec_test, BaseIRCServer, make_irc_event
+from servicetest import EventPattern, call_async
+from twisted.internet import reactor, ssl
+
+class IgnoreQuitServer(BaseIRCServer):
+ def handleUSER(self, args, prefix):
+ #do nothing: don't send a welcome message
+ self.event_func(make_irc_event('irc-user', None))
+
+ def handleQUIT(self, args, prefix):
+ # wait a little while and then send a welcome message
+ reactor.callLater(5, self.sendWelcome)
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]),
+ EventPattern('irc-connected'))
+ q.expect('irc-user');
+ # this should send a QUIT message to the server, but the test server should not
+ # respond properly, and will instead wait a while and then send a WELCOME msg
+ call_async(q, conn, 'Disconnect')
+ # the proper behavior of the CM is to disconnect, but the existing error is
+ # that it will parse the welcome message and attempt to go to CONNECTED
+ # state, which will cause an assertion to fail and the CM to crash
+ q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]),
+ EventPattern('irc-disconnected'),
+ EventPattern('dbus-return', method='Disconnect'))
+ return True
+
+if __name__ == '__main__':
+ exec_test(test, timeout=10, protocol=IgnoreQuitServer)
+
diff --git a/tests/twisted/connect/server-quit-noclose.py b/tests/twisted/connect/server-quit-noclose.py
new file mode 100644
index 0000000..bf0a5cf
--- /dev/null
+++ b/tests/twisted/connect/server-quit-noclose.py
@@ -0,0 +1,34 @@
+"""
+Test that telepathy-idle still quits properly after a certain amount of time
+even if the server doesn't close the connection after responding to the quit
+request.
+"""
+
+from idletest import exec_test, BaseIRCServer, make_irc_event
+from servicetest import EventPattern, call_async
+from twisted.internet import reactor, ssl
+
+class QuitNoCloseServer(BaseIRCServer):
+ def handleQUIT(self, args, prefix):
+ quit_msg = ' '.join(args).rstrip('\r\n')
+ self.sendMessage('ERROR', ':Closing Link: idle.test.server (Quit: %s)' % quit_msg)
+ # don't call self.transport.loseConnection()
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]),
+ EventPattern('irc-connected'))
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+ call_async(q, conn, 'Disconnect')
+ # the test server won't drop the connection upon receiving a QUIT message --
+ # test that we still exit and respond properly after a certain amount of time
+ q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]),
+ EventPattern('irc-disconnected'),
+ EventPattern('dbus-return', method='Disconnect'))
+ return True
+
+if __name__ == '__main__':
+ exec_test(test, timeout=10, protocol=QuitNoCloseServer)
+
--
1.5.6.5
More information about the telepathy-commits
mailing list