qpsmtpd/t/plugin_tests/sender_permitted_from
2012-06-23 00:53:46 -04:00

47 lines
1.1 KiB
Perl

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