Matt Sergeant escribió:
On Tue, 29 Jul 2008, Jose Luis Martinez wrote:
BTW: any comment on how to elaborate a testing framework. Comments
from the QP-gurus would be helpful.
For some in house code here that's similar to Qpsmtpd we basically have
a data driven test system. You specify in a config file what plugins to
load, and any other config file contents (supports CDB files too), and
it generates the right config, and starts the daemon. Then you specify
things like HELO, IP, full email contents, etc and it talks to the
daemon using those details, and checks for the expected outcome.
Obviously not all that is possible with qpsmtpd (e.g. you can't spoof
the IP easily), but most of it is. And it makes developing tests much
easier.
I can probably share a bit of the code if it helps.
If you can share the basic structure of the tests, and how you are
managing the different configs and startup / teardown of the daemons ,
that would be nice.
Our in-house tests look like this (we are migrating test to Test::SMTP
for further legibility, but this one has not been migrated):
--------------------
my $smtp = Net::SMTP->new($MAILHOST,
#EHLO for this transaction
'Hello' => 'my.mail.domain',
'Debug' => $ENV{'DEBUG_SMTP'} || 0,
);
my $mail_from = '[EMAIL PROTECTED]';
cmp_ok($smtp->mail($mail_from), '==', 1, "Accepted mail from: $mail_from");
my $rcpt_to;
$rcpt_to = '001@';
cmp_ok($smtp->recipient($rcpt_to), '==', 0, "Rejected mail for: $rcpt_to");
cmp_ok($smtp->code(), '==', 501, '501 code to invalid RCPT');
ok($smtp->message() =~ m/could not parse recipient/, 'text OK for
invalid RCPT');
$rcpt_to = '@';
cmp_ok($smtp->recipient($rcpt_to), '==', 0, "Rejected mail for: $rcpt_to");
cmp_ok($smtp->code(), '==', 501, '501 code to invalid RCPT');
ok($smtp->message() =~ m/could not parse recipient/, 'text OK for
invalid RCPT');
$rcpt_to = '@domain.com';
cmp_ok($smtp->recipient($rcpt_to), '==', 0, "Rejected mail for: $rcpt_to");
cmp_ok($smtp->code(), '==', 501, '501 code to invalid RCPT');
ok($smtp->message() =~ m/could not parse recipient/, 'text OK for
invalid RCPT');
$rcpt_to = '001@@@';
cmp_ok($smtp->recipient($rcpt_to), '==', 0, "Rejected mail for: $rcpt_to");
cmp_ok($smtp->code(), '==', 501, '501 code to invalid RCPT');
ok($smtp->message() =~ m/could not parse recipient/, 'text OK for
invalid RCPT');
$rcpt_to = '@@@domain.com';
cmp_ok($smtp->recipient($rcpt_to), '==', 0, "Rejected mail for: $rcpt_to");
cmp_ok($smtp->code(), '==', 501, '501 code to invalid RCPT');
ok($smtp->message() =~ m/could not parse recipient/, 'text OK for
invalid RCPT');
cmp_ok($smtp->data(), '==', 0, 'Denied data command');
cmp_ok($smtp->code(), '==', 503, 'Denied with 503 return');
ok($smtp->message() =~ m/RCPT first/, 'text RCPT first');
cmp_ok($smtp->quit(), '==', 1, 'Accepted QUIT');
---------------------------------------------
We are actually doing tests on a QP instance with just one configuration
and one server engine (the one we use in production environments), so we
haven't had the need to manage different configs and startup / teardown
daemons per test. I think this is a must-have for the QPSMTPD project.
Thanks,
Jose Luis Martinez
[EMAIL PROTECTED]