You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by si...@apache.org on 2023/11/26 11:36:39 UTC

svn commit: r1914137 - in /spamassassin/trunk: lib/Mail/SpamAssassin/Plugin/DKIM.pm t/dkim.t

Author: sidney
Date: Sun Nov 26 11:36:39 2023
New Revision: 1914137

URL: http://svn.apache.org/viewvc?rev=1914137&view=rev
Log:
bug 8198 Fix warning from bad version check and skip tests that fail under old versions of DKIM

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm
    spamassassin/trunk/t/dkim.t

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm?rev=1914137&r1=1914136&r2=1914137&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm Sun Nov 26 11:36:39 2023
@@ -134,6 +134,7 @@ use Mail::SpamAssassin::Plugin;
 use Mail::SpamAssassin::Logger;
 use Mail::SpamAssassin::Timeout;
 use Mail::SpamAssassin::Util qw(idn_to_ascii);
+use version;
 
 use strict;
 use warnings;
@@ -730,7 +731,6 @@ sub _dkim_load_modules {
       dbg("dkim: cannot load Mail::DKIM module, DKIM checks disabled: %s",
           $eval_stat);
     } else {
-      use version 0.77;
       my $version = Mail::DKIM::Verifier->VERSION;
       if (version->parse($version) >= version->parse(0.31)) {
         dbg("dkim: using Mail::DKIM version $version");
@@ -883,7 +883,7 @@ sub _check_dkim_signature {
   } else {
     # signature objects not provided by the caller, must verify for ourselves
     my $timemethod = $self->{main}->time_method("check_dkim_signature");
-    if (Mail::DKIM::Verifier->VERSION >= 0.40) {
+    if (version->parse(Mail::DKIM::Verifier->VERSION) >= version->parse(0.40)) {
       my $edns = $conf->{dns_options}->{edns};
       if ($edns && $edns >= 1024) {
         # Let Mail::DKIM use our interface to Net::DNS::Resolver.

Modified: spamassassin/trunk/t/dkim.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/dkim.t?rev=1914137&r1=1914136&r2=1914137&view=diff
==============================================================================
--- spamassassin/trunk/t/dkim.t (original)
+++ spamassassin/trunk/t/dkim.t Sun Nov 26 11:36:39 2023
@@ -10,15 +10,22 @@ use SATest; sa_t_init("dkim");
 
 use vars qw(%patterns %anti_patterns);
 
+my $tests = 258;
+my $version;
+
 use constant HAS_DKIM_VERIFIER => eval {
   require Mail::DKIM::Verifier;
-  version->parse(Mail::DKIM::Verifier->VERSION) >= version->parse(0.31);
+  $version = version->parse(Mail::DKIM::Verifier->VERSION);
+  $version >= version->parse(0.31);
 };
 
 use Test::More;
 plan skip_all => "Net tests disabled" unless conf_bool('run_net_tests');
 plan skip_all => "Needs Mail::DKIM::Verifier >= 0.31" unless HAS_DKIM_VERIFIER ;
-plan tests => 258;
+
+$tests -= 8 if $version < version->parse(0.37);
+$tests -= 16 if $version < version->parse(0.34);
+plan tests => $tests;
 
 use IO::File;
 use Mail::SpamAssassin;
@@ -123,7 +130,6 @@ $spamassassin_obj = Mail::SpamAssassin->
 ok($spamassassin_obj);
 $spamassassin_obj->compile_now;  # try to preloaded most modules
 
-my $version = Mail::DKIM::Verifier->VERSION;
 print "Using Mail::DKIM version $version\n";
 
 # mail samples test-pass* should all pass DKIM validation
@@ -132,7 +138,10 @@ local *DIR;
 opendir(DIR, $dirname) or die "Cannot open directory $dirname: $!";
 while (defined($fn = readdir(DIR))) {
   next  if $fn eq '.' || $fn eq '..';
+  # skip test cases that fail in older versions of Mail::DKIM
   next  if $fn !~ /^test-pass-\d*\.msg$/;
+  next if $version < version->parse(0.34) && $fn =~ /^test-pass-1[34]\.msg$/;
+  next if $version < version->parse(0.37) && $fn =~ /^test-pass-15\.msg$/;
   push(@test_filenames, "$dirname/$fn");
 }
 closedir(DIR) or die "Error closing directory $dirname: $!";
@@ -184,13 +193,6 @@ closedir(DIR) or die "Error closing dire
 test_samples(\@test_filenames, \@patt_antipatt_list);
 
 STDOUT->autoflush(1);
-if ($version < 0.34) {
-  print STDERR "\n\n*** Mail::DKIM $version, Tests 105, 109, 113, 117, 120 ".
-               "are expected to fail with versions older than 0.34\n\n";
-} elsif ($version < 0.37) {
-  print STDERR "\n\n*** Mail::DKIM $version, Test 120 ".
-               "is expected to fail with versions older than 0.36_5\n\n";
-}
 
 END {
   $spamassassin_obj->finish  if $spamassassin_obj;