# HG changeset patch # User Mads Kiilerich # Date 1687787499 -7200 # Node ID cfb6ca77e6bc03653b1e1bc0e8b50ac804389bd1 # Parent 5644f6286618217d6c4bceb6702a51cd8912a96b tests: improve test-patchbomb-tls.t by by logging errors and data The actual SSL error might be like: ::1 ssl error: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:1002) and will probably vary so much that it can't be checked in the test. It is however very useful when debugging failures. diff -r 5644f6286618 -r cfb6ca77e6bc tests/dummysmtpd.py --- a/tests/dummysmtpd.py Thu Mar 23 16:48:44 2023 +0100 +++ b/tests/dummysmtpd.py Mon Jun 26 15:51:39 2023 +0200 @@ -28,7 +28,10 @@ smtpd.SMTPServer.__init__(self, localaddr, remoteaddr=None) def process_message(self, peer, mailfrom, rcpttos, data, **kwargs): - log('%s from=%s to=%s\n' % (peer[0], mailfrom, ', '.join(rcpttos))) + log( + '%s from=%s to=%s\n%s\n' + % (peer[0], mailfrom, ', '.join(rcpttos), data.decode()) + ) def handle_error(self): # On Windows, a bad SSL connection sometimes generates a WSAECONNRESET. @@ -54,8 +57,8 @@ try: # wrap_socket() would block, but we don't care conn = sslutil.wrapserversocket(conn, ui, certfile=self._certfile) - except ssl.SSLError: - log('%s ssl error\n' % addr[0]) + except ssl.SSLError as e: + log('%s ssl error: %s\n' % (addr[0], e)) conn.close() return smtpd.SMTPChannel(self, conn, addr) diff -r 5644f6286618 -r cfb6ca77e6bc tests/test-patchbomb-tls.t --- a/tests/test-patchbomb-tls.t Thu Mar 23 16:48:44 2023 +0100 +++ b/tests/test-patchbomb-tls.t Mon Jun 26 15:51:39 2023 +0200 @@ -76,7 +76,7 @@ [150] $ cat ../log - * ssl error (glob) + * ssl error: * (glob) $ : > ../log With global certificates: @@ -92,6 +92,35 @@ $ cat ../log * from=quux to=foo, bar (glob) + MIME-Version: 1.0 + Content-Type: text/plain; charset="us-ascii" + Content-Transfer-Encoding: 7bit + Subject: [PATCH] a + X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab + X-Mercurial-Series-Index: 1 + X-Mercurial-Series-Total: 1 + Message-Id: <*@test-hostname> (glob) + X-Mercurial-Series-Id: <*@test-hostname> (glob) + User-Agent: Mercurial-patchbomb* (glob) + Date: * (glob) + From: quux + To: foo + Cc: bar + + # HG changeset patch + # User test + # Date 1 0 + # Thu Jan 01 00:00:01 1970 +0000 + # Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab + # Parent 0000000000000000000000000000000000000000 + a + + diff -r 0000000000000000000000000000000000000000 -r 8580ff50825a50c8f716709acdf8de0deddcd6ab a + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/a Thu Jan 01 00:00:01 1970 +0000 + @@ -0,0 +1,1 @@ + +a + $ : > ../log With invalid certificates: @@ -105,7 +134,7 @@ [255] $ cat ../log - * ssl error (glob) + * ssl error: * (glob) $ : > ../log $ cd ..