qpsmtpd/t/plugin_tests/auth/auth_checkpassword
Matt Simerson a5420149bd remove test counters from plugin tests
replace with done_testing(), which provides the same "make sure to kvetch if tests fail to run" without requiring humans to do the bookkeeping.
2014-09-17 00:11:32 -07:00

45 lines
1.2 KiB
Perl

#!perl -w
warn "loaded auth_checkpassword\n";
sub register_tests {
my $self = shift;
my ($vpopdir) = (getpwnam('vpopmail'))[7];
if ( ! $vpopdir ) {
warn "skipping tests, vpopmail not installed\n";
return;
};
if ( ! -d "$vpopdir/domains/example.com" ) {
warn "skipping tests, no example users set up.\n";
return;
};
$self->register_test("test_auth_checkpassword");
}
my @u_list = qw ( good bad none );
my %u_data = (
good => [ 'postmaster@example.com', OK, 'Good Strong Passphrase' ],
bad => [ 'bad@example.com', DENY, 'not_bad_pass' ],
none => [ 'none@example.com', DECLINED, '' ],
);
sub test_auth_checkpassword {
my $self = shift;
my ($tran, $ret, $note, $u, $r, $p, $a );
$tran = $self->qp->transaction;
for $u ( @u_list ) {
( $a,$r,$p ) = @{$u_data{$u}};
($ret, $note) = $self->auth_checkpassword($tran,'LOGIN',$a,$p);
defined $note or $note='No-Message';
is ($ret, $r, $note);
($ret, $note) = $self->auth_checkpassword($tran,'PLAIN',$a,$p);
defined $note or $note='No-Message';
is ($ret, $r, $note);
}
}