b89a6d9e4c
s/register/init/ to match new plugin style (jpeacock) * lib/Qpsmtpd/Address.pm t/qpsmtpd-address.t Ill-formed addresses should return null not partial garbage. Resolves https://rt.perl.org/rt3/Ticket/Display.html?id=38746 Patch by Hanno Hecker. * plugins/virus/clamav Clamav alternate config file. Resolves https://rt.perl.org/rt3/Ticket/Display.html?id=38736 Patch by Robin Bowes. * lib/Qpsmtpd/SMTP.pm lib/Qpsmtpd.pm Return multiline responses from plugins. Resolves https://rt.perl.org/rt3/Ticket/Display.html?id=38741 Patch by Charlie Brady. git-svn-id: https://svn.perl.org/qpsmtpd/branches/0.3x@630 958fd67b-6ff1-0310-b445-bb7760255be9
109 lines
2.9 KiB
Perl
109 lines
2.9 KiB
Perl
#!/usr/bin/perl
|
|
use strict;
|
|
$^W = 1;
|
|
|
|
use Test::More qw/no_plan/;
|
|
|
|
BEGIN {
|
|
use_ok('Qpsmtpd::Address');
|
|
}
|
|
|
|
my $as;
|
|
my $ao;
|
|
|
|
$as = '<>';
|
|
$ao = Qpsmtpd::Address->parse($as);
|
|
ok ($ao, "parse $as");
|
|
is ($ao->format, $as, "format $as");
|
|
|
|
$as = '<postmaster>';
|
|
$ao = Qpsmtpd::Address->parse($as);
|
|
ok ($ao, "parse $as");
|
|
is ($ao->format, $as, "format $as");
|
|
|
|
$as = '<foo@example.com>';
|
|
$ao = Qpsmtpd::Address->parse($as);
|
|
ok ($ao, "parse $as");
|
|
is ($ao->format, $as, "format $as");
|
|
|
|
is ($ao->user, 'foo', 'user');
|
|
is ($ao->host, 'example.com', 'host');
|
|
|
|
# the \ before the @ in the local part is not required, but
|
|
# allowed. For simplicity we add a backslash before all characters
|
|
# which are not allowed in a dot-string.
|
|
$as = '<"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at>';
|
|
$ao = Qpsmtpd::Address->parse($as);
|
|
ok ($ao, "parse $as");
|
|
is ($ao->format, '<"musa_ibrah\@caramail.comandrea.luger"@wifo.ac.at>', "format $as");
|
|
|
|
# email addresses with spaces
|
|
$as = '<foo bar@example.com>';
|
|
$ao = Qpsmtpd::Address->parse($as);
|
|
ok ($ao, "parse $as");
|
|
is ($ao->format, '<"foo\ bar"@example.com>', "format $as");
|
|
|
|
$as = 'foo@example.com';
|
|
$ao = Qpsmtpd::Address->new($as);
|
|
ok ($ao, "new $as");
|
|
is ($ao->address, $as, "address $as");
|
|
|
|
$as = '<foo@example.com>';
|
|
$ao = Qpsmtpd::Address->new($as);
|
|
ok ($ao, "new $as");
|
|
is ($ao->address, 'foo@example.com', "address $as");
|
|
|
|
$as = '<foo@foo.x.example.com>';
|
|
$ao = Qpsmtpd::Address->new($as);
|
|
ok ($ao, "new $as");
|
|
is ($ao->format, $as, "format $as");
|
|
|
|
$as = 'foo@foo.x.example.com';
|
|
ok ($ao = Qpsmtpd::Address->parse('<'.$as.'>'), "parse $as");
|
|
is ($ao && $ao->address, $as, "address $as");
|
|
|
|
# Not sure why we can change the address like this, but we can so test it ...
|
|
is ($ao && $ao->address('test@example.com'), 'test@example.com', 'address(test@example.com)');
|
|
|
|
$as = '<foo@foo.x.example.com>';
|
|
$ao = Qpsmtpd::Address->new($as);
|
|
ok ($ao, "new $as");
|
|
is ($ao->format, $as, "format $as");
|
|
is ("$ao", $as, "overloaded stringify $as");
|
|
|
|
$as = 'foo@foo.x.example.com';
|
|
ok ($ao = Qpsmtpd::Address->parse("<$as>"), "parse <$as>");
|
|
is ($ao && $ao->address, $as, "address $as");
|
|
ok ($ao eq $as, "overloaded 'cmp' operator");
|
|
|
|
my @unsorted_list = map { Qpsmtpd::Address->new($_) }
|
|
qw(
|
|
"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at
|
|
foo@example.com
|
|
ask@perl.org
|
|
foo@foo.x.example.com
|
|
jpeacock@cpan.org
|
|
test@example.com
|
|
);
|
|
|
|
# NOTE that this is sorted by _host_ not by _domain_
|
|
my @sorted_list = map { Qpsmtpd::Address->new($_) }
|
|
qw(
|
|
jpeacock@cpan.org
|
|
foo@example.com
|
|
test@example.com
|
|
foo@foo.x.example.com
|
|
ask@perl.org
|
|
"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at
|
|
);
|
|
|
|
my @test_list = sort @unsorted_list;
|
|
|
|
is_deeply( \@test_list, \@sorted_list, "sort via overloaded 'cmp' operator");
|
|
|
|
# RT#38746 - non-RFC compliant address should return undef
|
|
|
|
$as='<user@example.com#>';
|
|
$ao = Qpsmtpd::Address->new($as);
|
|
is ($ao, undef, "illegal $as");
|