badmailfrom: removed tests for rcpt_handler

and shorten test response messages in badmailfromto
This commit is contained in:
Matt Simerson 2012-06-22 18:20:15 -04:00
parent feab782a0a
commit a08745acc4
2 changed files with 12 additions and 26 deletions

View File

@ -11,7 +11,6 @@ sub register_tests {
$self->register_test("test_badmailfrom_is_immune_sender", 5);
$self->register_test("test_badmailfrom_match", 7);
$self->register_test("test_badmailfrom_hook_mail", 4);
$self->register_test("test_badmailfrom_rcpt_handler", 2);
}
sub test_badmailfrom_is_immune_sender {
@ -50,31 +49,18 @@ sub test_badmailfrom_hook_mail {
$transaction->sender($address);
$self->{_badmailfrom_config} = ['matt@test.net','matt@test.com'];
$self->connection->notes('badmailfrom', '');
my ($r) = $self->hook_mail( $transaction, $address );
ok( $r == 909, "badmailfrom hook_mail");
cmp_ok( $self->connection->notes('naughty'), 'eq', 'Your envelope sender is in my badmailfrom list', "default reason");
$transaction->notes('badmailfrom', '');
my ($r, $err) = $self->hook_mail( $transaction, $address );
cmp_ok( $r, '==', 901, "hook_mail rc");
cmp_ok( $err, 'eq', 'Your envelope sender is in my badmailfrom list', "hook_mail: default reason");
$self->{_badmailfrom_config} = ['matt@test.net','matt@test.com Yer a spammin bastert'];
$self->connection->notes('badmailfrom', '');
($r) = $self->hook_mail( $transaction, $address );
ok( $r == 909, "badmailfrom hook_mail");
cmp_ok( $self->connection->notes('naughty'), 'eq', 'Yer a spammin bastert', "custom reason");
$transaction->notes('badmailfrom', '');
($r, $err) = $self->hook_mail( $transaction, $address );
cmp_ok( $r, '==', 901, "hook_mail rc");
cmp_ok( $err, 'eq', 'Yer a spammin bastert', "hook_mail: custom reason");
};
sub test_badmailfrom_rcpt_handler {
my $self = shift;
my $transaction = $self->qp->transaction;
$transaction->notes('badmailfrom', 'Yer a spammin bastart. Be gon wit yuh.' );
my ($code,$note) = $self->rcpt_handler( $transaction );
ok( $code == 901, 'badmailfrom hook hit');
ok( $note, $note );
}
sub test_badmailfrom_match {
my $self = shift;

View File

@ -20,17 +20,17 @@ sub test_badmailfromto_is_sender_immune {
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'] ), "is_immune, null sender");
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'] ), "is_immune, missing host");
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'] ), "is_immune, missing user");
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'] ), "is_immune, false");
ok( ! $self->is_sender_immune( $transaction->sender, ['bad@example.com'] ), "false");
};