From 60b74decd9622bf90e378c4cce28d21f35c2f38f Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Thu, 17 May 2007 22:00:55 +0000 Subject: [PATCH] More tests git-svn-id: https://svn.perl.org/qpsmtpd/trunk@736 958fd67b-6ff1-0310-b445-bb7760255be9 --- t/plugin_tests/auth::auth_flat_file | 27 +++++++++++++++++++++++++++ t/plugin_tests/auth::authdeny | 14 ++++++++++++++ t/plugin_tests/auth::authnull | 14 ++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 t/plugin_tests/auth::auth_flat_file create mode 100644 t/plugin_tests/auth::authdeny create mode 100644 t/plugin_tests/auth::authnull diff --git a/t/plugin_tests/auth::auth_flat_file b/t/plugin_tests/auth::auth_flat_file new file mode 100644 index 0000000..7f36f23 --- /dev/null +++ b/t/plugin_tests/auth::auth_flat_file @@ -0,0 +1,27 @@ +# -*-perl-*- [emacs] + +sub register_tests { + my $self = shift; + $self->register_test("test_authsql", 3); +} + +my @u_list = qw ( good bad none ); +my %u_data = ( + good => [ 'good@example.com', OK, 'good_pass' ], + bad => [ 'bad@example.com', DENY, 'not_bad_pass' ], + none => [ 'none@example.com', DECLINED, '' ], + ); + +sub test_authsql { + 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->authsql($tran,'CRAMMD5',$a,$p); + defined $note or $note='No-Message'; + is ($ret, $r, $note); + # - for debugging. + # warn "$note\n"; + } +} diff --git a/t/plugin_tests/auth::authdeny b/t/plugin_tests/auth::authdeny new file mode 100644 index 0000000..08c8cd3 --- /dev/null +++ b/t/plugin_tests/auth::authdeny @@ -0,0 +1,14 @@ +# -*-perl-*- [emacs] + +sub register_tests { + my $self = shift; + $self->register_test("test_authdeny", 1); +} + +sub test_authdeny { + my $self = shift; + my $address = Qpsmtpd::Address->parse(''); + my ($ret, $note) = $self->hook_auth($self->qp->transaction, 'bogus_method', + 'bogus_user'); + is ($ret, DECLINED, "bogus_user is not free to abuse my relay"); +} diff --git a/t/plugin_tests/auth::authnull b/t/plugin_tests/auth::authnull new file mode 100644 index 0000000..3a412f7 --- /dev/null +++ b/t/plugin_tests/auth::authnull @@ -0,0 +1,14 @@ +# -*-perl-*- [emacs] + +sub register_tests { + my $self = shift; + $self->register_test("test_authnull", 1); +} + +sub test_authnull { + my $self = shift; + my $address = Qpsmtpd::Address->parse(''); + my ($ret, $note) = $self->hook_auth($self->qp->transaction, 'bogus_method', + 'bogus_user'); + is ($ret, OK, "bogus_user is free to abuse my relay"); +}