Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Extreme Programming in Perl Robert Nagler phần 8 ppsx
Nội dung xem thử
Mô tả chi tiết
calling context, and improves testability.
The second case tests the server supports CAPA (capabilities), UIDL
(unique identifiers), and CRAM (challenge/response authentication). The
capability list is unordered so we check the list for UIDL then CRAM or the
reverse. Bivio::Test allows us to specify a Regexp instance (qr//) as the
expected value. The case passes if the expected regular expression matches
the actual return, which is serialized by Data::Dumper.
13.6 Validate Using Implementation Knowledge
foreach my $mode (qw(BEST APOP CRAM-MD5 PASS)) {
$pop3 = Mail::POP3Client->new(%$cfg, AUTH_MODE => $mode);
is_deeply([$pop3->Body(1)], $body_lines);
is($pop3->Close, 1);
}
$pop3 = Mail::POP3Client->new(%$cfg, AUTH_MODE => ’BAD-MODE’);
like($pop3->Message, qr/BAD-MODE/);
is($pop3->State, ’AUTHORIZATION’);
is($pop3->Close, 1);
$pop3 = Mail::POP3Client->new(
%$cfg, AUTH_MODE => ’BEST’, PASSWORD => ’BAD-PASSWORD’);
like($pop3->Message, qr/PASS failed/);
is($pop3->State, ’AUTHORIZATION’);
is($pop3->Close, 1);
$pop3 = Mail::POP3Client->new(
%$cfg, AUTH_MODE => ’APOP’, PASSWORD => ’BAD-PASSWORD’);
like($pop3->Message, qr/APOP failed/);
is($pop3->Close, 1);
Once we have validated the server’s capabilities, we test the authentication interface. Mail::POP3Client defaults to AUTH MODE BEST, but we test
each mode explictly here. The other cases test the default mode. To be
sure authentication was successful, we download the body of the first message and compare it with the value we sent. POP3 authentication implies
Copyright c 2004 Robert Nagler
All rights reserved [email protected]
115