2012-05-05 07:04:33 +02:00
|
|
|
#!perl -w
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use Qpsmtpd::Address;
|
|
|
|
|
|
|
|
sub register_tests {
|
|
|
|
my $self = shift;
|
|
|
|
|
2014-09-17 08:16:53 +02:00
|
|
|
$self->register_test("test_badmailfromto_is_sender_immune");
|
2012-05-05 07:04:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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( '<>' ) );
|
2012-06-23 00:20:15 +02:00
|
|
|
ok( $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "null sender");
|
2012-05-05 07:04:33 +02:00
|
|
|
|
|
|
|
my $address = Qpsmtpd::Address->new( '<matt@>' );
|
|
|
|
$transaction->sender($address);
|
2012-06-23 00:20:15 +02:00
|
|
|
ok( $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "missing host");
|
2012-05-05 07:04:33 +02:00
|
|
|
|
|
|
|
$address = Qpsmtpd::Address->new( '<@example.com>' );
|
|
|
|
$transaction->sender($address);
|
2012-06-23 00:20:15 +02:00
|
|
|
ok( $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "missing user");
|
2012-05-05 07:04:33 +02:00
|
|
|
|
|
|
|
$transaction->sender( Qpsmtpd::Address->new( '<matt@example.com>' ) );
|
2012-06-23 00:20:15 +02:00
|
|
|
ok( ! $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "false");
|
2012-05-05 07:04:33 +02:00
|
|
|
};
|
|
|
|
|