From f1540a3eed6beff57b6d7aead199f924c18c3d54 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 16 Apr 2024 20:15:11 -0700 Subject: [PATCH] add more deps --- .github/workflows/ci.yml | 2 +- META.yml | 2 + Makefile.PL | 1 + t/plugin_tests/dspam | 96 ---------------------------------------- 4 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 t/plugin_tests/dspam diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa7b8ea5..573eaf87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,6 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 - - name: Install Perl Modules with cpanm uses: perl-actions/install-with-cpanm@v1 continue-on-error: true @@ -56,5 +55,6 @@ jobs: install: | Regexp::Common + - run: cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib) - run: cpanm --installdeps -n -f . - run: prove -lv t diff --git a/META.yml b/META.yml index f296dcfe..ac386c8d 100644 --- a/META.yml +++ b/META.yml @@ -24,9 +24,11 @@ requires: File::NFSLock: 0 File::Tail: 0 File::Temp: 0 + GeoIP2: 0 IO::Socket::SSL: 0 MIME::Base64: 0 Mail::DKIM: 0 + Mail::DMARC: 0 Mail::Header: 0 Mail::SPF: 0 Net::DNS: 0.39 diff --git a/Makefile.PL b/Makefile.PL index 41daaae9..75678477 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -23,6 +23,7 @@ WriteMakefile( 'Test::Output' => 0, # modules for specific features 'Mail::DKIM' => 0.40, + 'Mail::DMARC' => 0, 'File::Tail' => 0, # log/summarize, log/watch 'Time::TAI64' => 0, # log2sql # 'DBI' => 0, # auth_vpopmail_sql and diff --git a/t/plugin_tests/dspam b/t/plugin_tests/dspam deleted file mode 100644 index 93729def..00000000 --- a/t/plugin_tests/dspam +++ /dev/null @@ -1,96 +0,0 @@ -#!perl -w - -use strict; -use warnings; - -use Mail::Header; -use Qpsmtpd::Constants; - -my $r; - -sub register_tests { - my $self = shift; - - $self->register_test('test_get_dspam_results'); - $self->register_test('test_log_and_return'); - $self->register_test('test_reject_type'); -} - -sub test_log_and_return { - my $self = shift; - - my $transaction = $self->qp->transaction; - - # reject not set - $self->{_args}{reject} = undef; - $transaction->notes('dspam', { class=> 'Spam', probability => .99, confidence=>1 } ); - ($r) = $self->log_and_return( $transaction ); - cmp_ok( $r, '==', DECLINED, "($r)"); - - # reject exceeded - $self->{_args}{reject} = .95; - $transaction->notes('dspam', { class=> 'Spam', probability => .99, confidence=>1 } ); - ($r) = $self->log_and_return( $transaction ); - cmp_ok( $r, '==', DENY, "($r)"); - - # below reject threshold - $transaction->notes('dspam', { class=> 'Spam', probability => .94, confidence=>1 } ); - ($r) = $self->log_and_return( $transaction ); - cmp_ok( $r, '==', DECLINED, "($r)"); - - # requires agreement - $self->{_args}{reject} = 'agree'; - $transaction->notes('spamassassin', { is_spam => 'Yes', score => 25 } ); - $transaction->notes('dspam', { class=> 'Spam', probability => .90, confidence=>1 } ); - ($r) = $self->log_and_return( $transaction ); - cmp_ok( $r, '==', DENY, "($r)"); - - # requires agreement - $transaction->notes('spamassassin', { is_spam => 'No', score => 15 } ); - $transaction->notes('dspam', { class=> 'Spam', probability => .96, confidence=>1 } ); - ($r) = $self->log_and_return( $transaction ); - cmp_ok( $r, '==', DECLINED, "($r)"); - - # requires agreement - $transaction->notes('spamassassin', { is_spam => 'Yes', score => 10 } ); - $transaction->notes('dspam', { class=> 'Innocent', probability => .96, confidence=>1 } ); - ($r) = $self->log_and_return( $transaction ); - cmp_ok( $r, '==', DECLINED, "($r)"); -} - -sub test_get_dspam_results { - my $self = shift; - - my $transaction = $self->qp->transaction; - my $header = Mail::Header->new(Modify => 0, MailFrom => "COERCE"); - $transaction->header( $header ); - - my @dspam_sample_headers = ( - 'Innocent, probability=0.0000, confidence=0.69', - 'Innocent, probability=0.0000, confidence=0.85', - 'Innocent, probability=0.0023, confidence=1.00', - 'Spam, probability=1.0000, confidence=0.87', - 'Spam, probability=1.0000, confidence=0.99', - 'Whitelisted', - ); - - foreach my $header ( @dspam_sample_headers ) { - $transaction->header->delete('X-DSPAM-Result'); - $transaction->header->add('X-DSPAM-Result', $header); - my $r = $self->get_dspam_results($transaction); - ok( ref $r, "r: ($header)" ); - } -} - -sub test_reject_type { - my $self = shift; - - $self->{_args}{reject_type} = undef; - cmp_ok( $self->get_reject_type(), '==', DENY, "default"); - - $self->{_args}{reject_type} = 'temp'; - cmp_ok( $self->get_reject_type(), '==', DENYSOFT, "defer"); - - $self->{_args}{reject_type} = 'disconnect'; - cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect"); -}