2012-05-09 06:03:44 +02:00
|
|
|
#!perl -w
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Qpsmtpd::Constants;
|
|
|
|
|
|
|
|
my $r;
|
|
|
|
|
|
|
|
sub register_tests {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
eval 'use Mail::SPF';
|
|
|
|
return if $@;
|
|
|
|
|
2012-06-23 06:53:46 +02:00
|
|
|
$self->register_test('test_is_in_relayclients', 2);
|
2012-05-09 06:03:44 +02:00
|
|
|
$self->register_test('test_is_special_recipient', 5);
|
|
|
|
}
|
|
|
|
|
2012-06-23 06:53:46 +02:00
|
|
|
sub test_is_in_relayclients {
|
2012-05-09 06:03:44 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $transaction = $self->qp->transaction;
|
2012-06-23 06:53:46 +02:00
|
|
|
$self->qp->connection->remote_ip('192.1.7.8');
|
|
|
|
ok( ! $self->is_in_relayclients( $transaction ), "is_in_relayclients -");
|
2012-05-09 06:03:44 +02:00
|
|
|
|
|
|
|
$self->qp->connection->relay_client(0);
|
2012-06-23 06:53:46 +02:00
|
|
|
$self->qp->connection->remote_ip('192.0.7.5');
|
2012-05-09 06:03:44 +02:00
|
|
|
my $client_ip = $self->qp->connection->remote_ip;
|
2012-06-23 06:53:46 +02:00
|
|
|
ok( $client_ip, "relayclients ($client_ip)");
|
2012-05-09 06:03:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
sub test_is_special_recipient {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $transaction = $self->qp->transaction;
|
|
|
|
my $address = Qpsmtpd::Address->new('user@example.com');
|
|
|
|
|
2012-06-23 06:53:46 +02:00
|
|
|
ok( ! $self->is_special_recipient( $address ), "not special");
|
2012-05-09 06:03:44 +02:00
|
|
|
|
|
|
|
foreach my $user ( qw/ postmaster abuse mailer-daemon root / ) {
|
|
|
|
$address = Qpsmtpd::Address->new("$user\@example.com");
|
2012-06-23 06:53:46 +02:00
|
|
|
ok( $self->is_special_recipient( $address ), "special: $user");
|
2012-05-09 06:03:44 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|