tests: show test-patchbomb-tls.t smtp server log stable
authorMads Kiilerich <mads@kiilerich.com>
Thu, 23 Mar 2023 16:48:44 +0100
branchstable
changeset 50729 5644f6286618
parent 50728 80c8dcfb73c6
child 50730 cfb6ca77e6bc
tests: show test-patchbomb-tls.t smtp server log Improve test coverage by exposing what the smtp server actually receives. Make dummystmtpd redirect stderr to a log file.
tests/dummysmtpd.py
tests/test-patchbomb-tls.t
--- a/tests/dummysmtpd.py	Wed Jun 28 01:31:10 2023 +0200
+++ b/tests/dummysmtpd.py	Thu Mar 23 16:48:44 2023 +0100
@@ -93,6 +93,7 @@
     op.add_option('--pid-file', metavar='FILE')
     op.add_option('--tls', choices=['none', 'smtps'], default='none')
     op.add_option('--certificate', metavar='FILE')
+    op.add_option('--logfile', metavar='FILE')
 
     opts, args = op.parse_args()
     if opts.tls == 'smtps' and not opts.certificate:
@@ -113,6 +114,7 @@
         runfn=run,
         runargs=[pycompat.sysexecutable, pycompat.fsencode(__file__)]
         + pycompat.sysargv[1:],
+        logfile=opts.logfile,
     )
 
 
--- a/tests/test-patchbomb-tls.t	Wed Jun 28 01:31:10 2023 +0200
+++ b/tests/test-patchbomb-tls.t	Thu Mar 23 16:48:44 2023 +0100
@@ -5,7 +5,7 @@
   $ CERTSDIR="$TESTDIR/sslcerts"
   $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub.pem" >> server.pem
 
-  $ "$PYTHON" "$TESTDIR/dummysmtpd.py" -p $HGPORT --pid-file a.pid -d \
+  $ "$PYTHON" "$TESTDIR/dummysmtpd.py" -p $HGPORT --pid-file a.pid --logfile log -d \
   > --tls smtps --certificate `pwd`/server.pem
   listening at localhost:$HGPORT (?)
   $ cat a.pid >> $DAEMON_PIDS
@@ -75,6 +75,10 @@
   (see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error or set hostsecurity.localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e to trust this server)
   [150]
 
+  $ cat ../log
+  * ssl error (glob)
+  $ : > ../log
+
 With global certificates:
 
   $ try --debug --config web.cacerts="$CERTSDIR/pub.pem"
@@ -86,6 +90,10 @@
   (verifying remote certificate)
   sending [PATCH] a ...
 
+  $ cat ../log
+  * from=quux to=foo, bar (glob)
+  $ : > ../log
+
 With invalid certificates:
 
   $ try --config web.cacerts="$CERTSDIR/pub-other.pem"
@@ -96,4 +104,8 @@
   (?i)abort: .*?certificate.verify.failed.* (re)
   [255]
 
+  $ cat ../log
+  * ssl error (glob)
+  $ : > ../log
+
   $ cd ..