updated SPF tests

This commit is contained in:
Matt Simerson 2012-06-23 00:53:46 -04:00
parent 439e9fe566
commit 14767f9b18

View File

@ -13,25 +13,21 @@ sub register_tests {
eval 'use Mail::SPF'; eval 'use Mail::SPF';
return if $@; return if $@;
$self->register_test('test_is_relayclient', 3); $self->register_test('test_is_in_relayclients', 2);
$self->register_test('test_is_special_recipient', 5); $self->register_test('test_is_special_recipient', 5);
} }
sub test_is_relayclient { sub test_is_in_relayclients {
my $self = shift; my $self = shift;
my $transaction = $self->qp->transaction; my $transaction = $self->qp->transaction;
ok( ! $self->is_relayclient( $transaction ), $self->qp->connection->remote_ip('192.1.7.8');
"sender_permitted_from, is_relayclient -"); ok( ! $self->is_in_relayclients( $transaction ), "is_in_relayclients -");
$self->qp->connection->relay_client(1);
ok( $self->is_relayclient( $transaction ),
"sender_permitted_from, is_relayclient +");
$self->qp->connection->relay_client(0); $self->qp->connection->relay_client(0);
$self->qp->connection->remote_ip('192.168.7.5'); $self->qp->connection->remote_ip('192.0.7.5');
my $client_ip = $self->qp->connection->remote_ip; my $client_ip = $self->qp->connection->remote_ip;
ok( $client_ip, "sender_permitted_from, relayclients ($client_ip)"); ok( $client_ip, "relayclients ($client_ip)");
}; };
sub test_is_special_recipient { sub test_is_special_recipient {
@ -40,11 +36,11 @@ sub test_is_special_recipient {
my $transaction = $self->qp->transaction; my $transaction = $self->qp->transaction;
my $address = Qpsmtpd::Address->new('user@example.com'); my $address = Qpsmtpd::Address->new('user@example.com');
ok( ! $self->is_special_recipient( $address ), "is_special_recipient -"); ok( ! $self->is_special_recipient( $address ), "not special");
foreach my $user ( qw/ postmaster abuse mailer-daemon root / ) { foreach my $user ( qw/ postmaster abuse mailer-daemon root / ) {
$address = Qpsmtpd::Address->new("$user\@example.com"); $address = Qpsmtpd::Address->new("$user\@example.com");
ok( $self->is_special_recipient( $address ), "is_special_recipient ($user)"); ok( $self->is_special_recipient( $address ), "special: $user");
}; };
}; };