develooper Front page | perl.cvs.qpsmtpd | Postings from May 2007

[svn:qpsmtpd] r736 - in trunk/t/plugin_tests: . auth

From:
msergeant
Date:
May 17, 2007 15:01
Subject:
[svn:qpsmtpd] r736 - in trunk/t/plugin_tests: . auth
Message ID:
20070517220057.ADFABCB9B8@x12.develooper.com
Author: msergeant
Date: Thu May 17 15:00:55 2007
New Revision: 736

Added:
   trunk/t/plugin_tests/auth/
   trunk/t/plugin_tests/auth::auth_flat_file
   trunk/t/plugin_tests/auth::authdeny
   trunk/t/plugin_tests/auth::authnull

Log:
More tests


Added: trunk/t/plugin_tests/auth::auth_flat_file
==============================================================================
--- (empty file)
+++ trunk/t/plugin_tests/auth::auth_flat_file	Thu May 17 15:00:55 2007
@@ -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";
+    }
+}

Added: trunk/t/plugin_tests/auth::authdeny
==============================================================================
--- (empty file)
+++ trunk/t/plugin_tests/auth::authdeny	Thu May 17 15:00:55 2007
@@ -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('<me@example.com>');
+    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");
+}

Added: trunk/t/plugin_tests/auth::authnull
==============================================================================
--- (empty file)
+++ trunk/t/plugin_tests/auth::authnull	Thu May 17 15:00:55 2007
@@ -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('<me@example.com>');
+    my ($ret, $note) = $self->hook_auth($self->qp->transaction, 'bogus_method',
+					'bogus_user');
+    is ($ret, OK, "bogus_user is free to abuse my relay");
+}



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About