qpsmtpd/t/plugin_tests/badmailfromto
Matt Simerson a5420149bd remove test counters from plugin tests
replace with done_testing(), which provides the same "make sure to kvetch if tests fail to run" without requiring humans to do the bookkeeping.
2014-09-17 00:11:32 -07:00

35 lines
1.1 KiB
Perl

#!perl -w
use strict;
use Qpsmtpd::Address;
sub register_tests {
my $self = shift;
$self->register_test("test_badmailfromto_is_sender_immune");
}
sub test_badmailfromto_is_sender_immune {
my $self = shift;
my $transaction = $self->qp->transaction;
my $test_email = 'matt@test.com';
$transaction->sender( Qpsmtpd::Address->new( "<$test_email>" ) );
ok( $self->is_sender_immune( $transaction->sender, [] ), "is_immune, empty list");
$transaction->sender( Qpsmtpd::Address->new( '<>' ) );
ok( $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "null sender");
my $address = Qpsmtpd::Address->new( '<matt@>' );
$transaction->sender($address);
ok( $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "missing host");
$address = Qpsmtpd::Address->new( '<@example.com>' );
$transaction->sender($address);
ok( $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "missing user");
$transaction->sender( Qpsmtpd::Address->new( '<matt@example.com>' ) );
ok( ! $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "false");
};