Testsuite: avoid recent-perl feature use
[exim.git] / test / runtest
index 8df2be00571411fa522edf66c2b3d932087630f6..b6d419bbaa153ce63ad9d6e962c5481596e53842 100755 (executable)
@@ -494,6 +494,9 @@ RESET_AFTER_EXTRA_LINE_READ:
   # Date/time in header lines and SMTP responses
   s/[A-Z][a-z]{2},\s\d\d?\s[A-Z][a-z]{2}\s\d\d\d\d\s\d\d\:\d\d:\d\d\s[-+]\d{4}
     /Tue, 2 Mar 1999 09:44:33 +0000/gx;
+  # and in a French locale
+  s/\S{4},\s\d\d?\s[^,]+\s\d\d\d\d\s\d\d\:\d\d:\d\d\s[-+]\d{4}
+    /dim., 10 f\xE9vr 2019 20:05:49 +0000/gx;
 
   # Date/time in logs and in one instance of a filter test
   s/^\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d(\s[+-]\d\d\d\d)?\s/1999-03-02 09:44:33 /gx;
@@ -544,6 +547,15 @@ RESET_AFTER_EXTRA_LINE_READ:
   s/(could not connect to .*: Connection) reset by peer$/$1 refused/;
 
   # ======== TLS certificate algorithms ========
+  #
+  # In Received: headers, convert RFC 8314 style ciphersuite to
+  # the older (comment) style, keeping only the Auth element
+  # (discarding kex, cipher, mac).  For TLS 1.3 there is no kex
+  # element (and no _WITH); insert a spurious "RSA".
+
+  s/^\s+by .+ with .+ \K tls TLS_.*?([^_]+)_WITH.+$/(TLS1.x:ke-$1-AES256-SHAnnn:xxx)/;
+  s/^\s+by .+ with .+ \K tls TLS_.+$/(TLS1.x:ke-RSA-AES256-SHAnnn:xxx)/;
+
   # Test machines might have various different TLS library versions supporting
   # different protocols; can't rely upon TLS 1.2's AES256-GCM-SHA384, so we
   # treat the standard algorithms the same.
@@ -591,10 +603,19 @@ RESET_AFTER_EXTRA_LINE_READ:
   s/(?<!ke-)((EC)?DHE-)?(RSA|ECDSA)-(AES256|CHACHA20)-(GCM-SHA384|POLY1305):256/ke-$3-AES256-SHAnnn:xxx/g;
 
   # GnuTLS have seen:
+  #   TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256
+  #   TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM__AEAD:256
+  #   TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256
+  #   TLS1.3:ECDHE_PSK_SECP256R1__AES_256_GCM__AEAD:256
+  #
   #   TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256
   #   TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128
   #   TLS1.2:RSA_AES_256_CBC_SHA1:256 (canonical)
   #   TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128
+  #   TLS1.2:ECDHE_SECP256R1__RSA_SHA256__AES_256_GCM:256
+  #   TLS1.2:ECDHE_SECP256R1__RSA_SHA256__AES_128_CBC__SHA256:128
+  #   TLS1.2:ECDHE_SECP256R1__ECDSA_SHA512__AES_256_GCM:256
+  #   TLS1.2:RSA__CAMELLIA_256_GCM:256 (leave the cipher name)
   #
   #   X=TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256
   #   X=TLS1.2:RSA_AES_256_CBC_SHA1:256
@@ -606,11 +627,21 @@ RESET_AFTER_EXTRA_LINE_READ:
   #   DHE-RSA-AES256-SHA
   # picking latter as canonical simply because regex easier that way.
   s/\bDHE_RSA_AES_128_CBC_SHA1:128/RSA-AES256-SHA1:256/g;
-  s/TLS1.[012]:((EC)?DHE_)?(RSA|ECDSA)_AES_(256|128)_(CBC|GCM)_SHA(1|256|384):(256|128)/TLS1.x:ke-$3-AES256-SHAnnn:xxx/g;
+  s/TLS1.[0123]:                                               # TLS version
+       ((EC)?DHE(_((?<psk>PSK)_)?(SECP256R1|X25519))?__?)?     # key-exchange
+       ((?<auth>RSA|ECDSA)((_PSS_RSAE)?_SHA(512|256))?__?)?    # authentication
+       AES_(256|128)_(CBC|GCM)                                 # cipher
+       (__?SHA(1|256|384))?:                                   # PRF
+       (256|128)                                               # cipher strength
+    /"TLS1.x:ke-"
+       . (defined($+{psk}) ? $+{psk} : "")
+       . (defined($+{auth}) ? $+{auth} : "")
+       . "-AES256-SHAnnn:xxx"/gex;
+  s/TLS1.2:RSA__CAMELLIA_256_GCM(_SHA384)?:256/TLS1.2:RSA_CAMELLIA_256_GCM-SHAnnn:256/g;
   s/\b(ECDHE-(RSA|ECDSA)-AES256-SHA|DHE-RSA-AES256-SHA256)\b/ke-$2-AES256-SHAnnn/g;
 
   # GnuTLS library error message changes
-  s/No certificate was found/The peer did not send any certificate/g;
+  s/(No certificate was found|Certificate is required)/The peer did not send any certificate/g;
 #(dodgy test?)  s/\(certificate verification failed\): invalid/\(gnutls_handshake\): The peer did not send any certificate./g;
   s/\(gnutls_priority_set\): No or insufficient priorities were set/\(gnutls_handshake\): Could not negotiate a supported cipher suite/g;
   s/\(gnutls_handshake\): \KNo supported cipher suites have been found.$/Could not negotiate a supported cipher suite./;
@@ -719,9 +750,6 @@ RESET_AFTER_EXTRA_LINE_READ:
   s/waiting for children of \d+/waiting for children of pppp/;
   s/waiting for (\S+) \(\d+\)/waiting for $1 (pppp)/;
 
-  # The spool header file name varies with PID
-  s%^(Writing spool header file: .*/hdr).[0-9]{1,5}%$1.pppp%;
-
   # ======== Port numbers ========
   # Incoming port numbers may vary, but not in daemon startup line.
 
@@ -960,6 +988,9 @@ RESET_AFTER_EXTRA_LINE_READ:
     s/^waiting for server to shut down\.+ done$/waiting for server to shut down.... done/;
     s/^\/.*postgres /POSTGRES /;
 
+    # DMARC is not always supported by the build
+    next if /^dmarc_tld_file =/;
+
     # ARC is not always supported by the build
     next if /^arc_sign =/;
     }
@@ -1247,6 +1278,21 @@ RESET_AFTER_EXTRA_LINE_READ:
     s/(TLS error on connection [^:]*: error:)[0-9A-F]{8}(:system library):(?:fopen|func\(4095\)):(No such file or directory)$/$1xxxxxxxx$2:fopen:$3/;
     s/(DANE attempt failed.*error:)[0-9A-F]{8}(:SSL routines:)(ssl3_get_server_certificate|tls_process_server_certificate|CONNECT_CR_CERT)(?=:certificate verify failed$)/$1xxxxxxxx$2ssl3_get_server_certificate/;
     s/(DKIM: validation error: )error:[0-9A-F]{8}:rsa routines:(?:(?i)int_rsa_verify|CRYPTO_internal):(?:bad signature|algorithm mismatch)$/$1Public key signature verification has failed./;
+    s/ARC: AMS signing: privkey PEM-block import: error:\K[0-9A-F]{8}:(PEM routines):get_name:(no start line)/0906D06C:$1:PEM_read_bio:$2/;
+
+    # gnutls version variances
+    if (/TLS error on connection \(recv\): .* (Decode error|peer did not send any certificate)/)
+      {
+      my $prev = $_;
+      $_ = <IN>;
+      if (/error on first read/)
+       {
+       s/TLS session: \Kerror on first read:/(gnutls_handshake): A TLS fatal alert has been received.:/;
+       goto RESET_AFTER_EXTRA_LINE_READ;
+       }
+      else
+       { $_ = $prev; }
+      }
 
     # DKIM timestamps
     if ( /(DKIM: d=.*) t=([0-9]*) x=([0-9]*) / )
@@ -1254,6 +1300,16 @@ RESET_AFTER_EXTRA_LINE_READ:
       my ($prefix, $t_diff) = ($1, $3 - $2);
       s/DKIM: d=.* t=[0-9]* x=[0-9]* /${prefix} t=T x=T+${t_diff} /;
       }
+
+    # port numbers
+    s/(?:\[[^\]]*\]:|port )\K$parm_port_d/PORT_D/;
+    s/(?:\[[^\]]*\]:|port )\K$parm_port_d2/PORT_D2/;
+    s/(?:\[[^\]]*\]:|port )\K$parm_port_d3/PORT_D3/;
+    s/(?:\[[^\]]*\]:|port )\K$parm_port_d4/PORT_D4/;
+    s/(?:\[[^\]]*\]:|port )\K$parm_port_s/PORT_S/;
+    s/(?:\[[^\]]*\]:|port )\K$parm_port_n/PORT_N/;
+    s/I=\[[^\]]*\]:\K\d+/ppppp/;
+
     }
 
   # ======== mail ========
@@ -1628,7 +1684,9 @@ $munges =
                      s! DN="[^,"]*\K,!/!;
                     ',
       'rejectlog' => 's/ X=TLS\S+ / X=TLS_proto_and_cipher /',
-      'mail'      => 's/ \(TLS[^)]*\)/ (TLS_proto_and_cipher)/',
+      'mail'      => 's/^\s+by .+ with .+ \K tls TLS_.+$/(TLS_proto_and_cipher)/;
+                     s/ \(TLS[^)]*\)/ (TLS_proto_and_cipher)/;
+                    ',
     },
 
     'debug_pid' =>
@@ -2199,7 +2257,7 @@ elsif (/^millisleep\s+(.*)$/)
 
 
 # The "munge" command selects one of a hardwired set of test-result modifications
-# to be made before result compares are run agains the golden set.  This lets
+# to be made before result compares are run against the golden set.  This lets
 # us account for test-system dependent things which only affect a few, but known,
 # test-cases.
 # Currently only the last munge takes effect.
@@ -2787,7 +2845,6 @@ foreach (@eximinfo)
     my $git = `git describe --dirty=-XX --match 'exim-4*'`;
     if (defined $git and $? == 0) {
       chomp $git;
-      $version =~ s/^\d+\K\./_/;
       $git =~ s/^exim-//i;
       $git =~ s/.*-\Kg([[:xdigit:]]+(?:-XX)?)/$1/;
       print <<___
@@ -2864,7 +2921,7 @@ die "CONFIGURE_GROUP ($parm_configure_group) does not match the group invoking $
        if 0020 & (stat "$parm_cwd/test-config")[2]
        and $parm_configure_group != $);
 
-die "aux-fixed file is world-writeable; best to strip them all, recursively\n"
+die "aux-fixed file is group-writeable; best to strip them all, recursively\n"
        if 0020 & (stat "aux-fixed/0037.f-1")[2];
 
 
@@ -3292,7 +3349,7 @@ while (not ($parm_ipv4 and $parm_ipv6) and defined($_ = <IFCONFIG>))
     $parm_ipv4 = $1;
     }
 
-  if (not $parm_ipv6 and /^\s*inet6(?:\saddr)?:?\s?([abcdef\d:]+)(?:\/\d+)/i)
+  if (not $parm_ipv6 and /^\s*inet6(?:\saddr)?:?\s?([abcdef\d:]+)(?:%[^ \/]+)?(?:\/\d+)?/i)
     {
     next if $1 eq '::1' or $1 =~ /^fe80/i;
     $parm_ipv6 = $1;
@@ -3352,6 +3409,7 @@ else
 
 print "IPv4 address is $parm_ipv4\n";
 print "IPv6 address is $parm_ipv6\n";
+$parm_ipv6 =~ /^[^%\/]*/;
 
 # For munging test output, we need the reversed IP addresses.