From 97dcd4e6a110c426cfd620dd03fc368e75bb5924 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 30 Apr 2013 14:35:11 +0100 Subject: Add (failing?) tests --- tests/twisted/Makefile.am | 2 ++ tests/twisted/connect/connect-close-ssl.py | 28 ++++++++++++++++++++++ .../connect/disconnect-during-cert-verification.py | 28 ++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 tests/twisted/connect/connect-close-ssl.py create mode 100644 tests/twisted/connect/disconnect-during-cert-verification.py diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 684918f..6063454 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -1,10 +1,12 @@ TWISTED_TESTS = \ cm/protocol.py \ + connect/connect-close-ssl.py \ connect/connect-success.py \ connect/connect-success-ssl.py \ connect/connect-reject-ssl.py \ connect/connect-fail.py \ connect/connect-fail-ssl.py \ + connect/disconnect-during-cert-verification.py \ connect/ping.py \ connect/server-quit-ignore.py \ connect/server-quit-noclose.py \ diff --git a/tests/twisted/connect/connect-close-ssl.py b/tests/twisted/connect/connect-close-ssl.py new file mode 100644 index 0000000..6fecd50 --- /dev/null +++ b/tests/twisted/connect/connect-close-ssl.py @@ -0,0 +1,28 @@ + +""" +Test connecting to a SSL server. +""" + +import dbus +import constants as cs +from idletest import exec_test, SSLIRCServer +from servicetest import EventPattern, wrap_channel + +def test(q, bus, conn, stream): + conn.Connect() + q.expect_many( + EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), + EventPattern('irc-connected')) + e = q.expect('dbus-signal', signal='NewChannels') + channels = e.args[0] + path, props = channels[0] + + channel = wrap_channel(bus.get_object(conn.bus_name, path), + cs.CHANNEL_TYPE_SERVER_TLS_CONNECTION) + channel.Close() + + q.expect('dbus-signal', signal='StatusChanged', args=[2, 2]) + +if __name__ == '__main__': + exec_test(test, {'use-ssl':dbus.Boolean(True)}, protocol=SSLIRCServer) + diff --git a/tests/twisted/connect/disconnect-during-cert-verification.py b/tests/twisted/connect/disconnect-during-cert-verification.py new file mode 100644 index 0000000..83fe004 --- /dev/null +++ b/tests/twisted/connect/disconnect-during-cert-verification.py @@ -0,0 +1,28 @@ +""" +Test disconnecting while a certificate verification channel is open. +""" + +import dbus +import constants as cs +from idletest import exec_test, SSLIRCServer +from servicetest import EventPattern, sync_dbus + +def test(q, bus, conn, stream): + conn.Connect() + q.expect_many( + EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), + EventPattern('irc-connected')) + e = q.expect('dbus-signal', signal='NewChannels') + + conn.Disconnect() + q.expect_many( + EventPattern('dbus-signal', signal='StatusChanged'), + EventPattern('irc-disconnected'), + ) + + # Idle would now crash in an idle callback; so let's see if it's alive. + sync_dbus(bus, q, conn) + +if __name__ == '__main__': + exec_test(test, {'use-ssl':dbus.Boolean(True)}, protocol=SSLIRCServer) + -- cgit v1.2.3