You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/03/02 05:26:17 UTC

svn commit: rev 6962 - incubator/spamassassin/trunk/t

Author: felicity
Date: Mon Mar  1 20:26:16 2004
New Revision: 6962

Modified:
   incubator/spamassassin/trunk/t/report_safe.t
Log:
added some more meat to report_safe.  specifically, look for report_safe 0 to kill 'x-spam-status: no' in the original message

Modified: incubator/spamassassin/trunk/t/report_safe.t
==============================================================================
--- incubator/spamassassin/trunk/t/report_safe.t	(original)
+++ incubator/spamassassin/trunk/t/report_safe.t	Mon Mar  1 20:26:16 2004
@@ -2,17 +2,26 @@
 
 use lib '.'; use lib 't';
 use SATest; sa_t_init("report_safe");
-use Test; BEGIN { plan tests => 3 };
+use Test; BEGIN { plan tests => 8 };
 
 # ---------------------------------------------------------------------------
 
-my $test = 'data/spam/gtube.eml';
-open(TEST, $test);
-my $original;
-while (<TEST>) {
-    $original .= $_;
+# Use a slightly modified gtube ...
+my $origtest = 'data/spam/gtube.eml';
+my $test = 'log/report_safe.eml';
+my $original = '';
+if (open(OTEST, $origtest) && open(TEST, ">$test")) {
+  local $/=undef;
+  $original .= "X-Spam-Prev-Subject: this is a test\n";
+  $original .= "X-Spam-Status: No, this should fail horribly!\n";
+  $original .= <OTEST>;
+  print TEST $original;
+  close(TEST);
+  close(OTEST);
+}
+else {
+  die "can't open input files: $!";
 }
-close(TEST);
 
 # unfortunately, we can't use a regexp since quotemeta is used on patterns
 sub safe {
@@ -32,22 +41,22 @@
 my $disposition = 'inline';
 my $message;
 
-%patterns = ();
-%anti_patterns = ($original => P_1);
+%patterns = ('X-Spam-Status: Yes' => 'XSS_Yes', 'X-Spam-Prev-Subject: this is a test' => 'XSS_Prev_Subject');
+%anti_patterns = ($original => P_1, 'X-Spam-Status: No' => 'XSS_No');
 tstprefs ("report_safe 0\n");
-sarun ("-L -t < $test", \&patterns_run_cb);
+sarun ("-L < $test", \&patterns_run_cb);
 ok_all_patterns();
 
 $message = safe($boundary, '', 'message/rfc822', $description, 'inline');
-%patterns = ($message => P_2);
+%patterns = ($message => P_2, 'X-Spam-Status: Yes' => 'XSS_Yes');
 %anti_patterns = ();
 tstprefs ("report_safe 1\n");
-sarun ("-L -t < $test", \&patterns_run_cb);
+sarun ("-L < $test", \&patterns_run_cb);
 ok_all_patterns();
 
 $message = safe($boundary, '', 'text/plain', $description, 'inline');
-%patterns = ($message => P_3);
+%patterns = ($message => P_3, 'X-Spam-Status: Yes' => 'XSS_Yes');
 %anti_patterns = ();
 tstprefs ("report_safe 2\n");
-sarun ("-L -t < $test", \&patterns_run_cb);
+sarun ("-L < $test", \&patterns_run_cb);
 ok_all_patterns();