From d811d6dbddfdbc22def435f5232e22968a4867d6 Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Wed, 8 Sep 2004 21:48:27 +0000 Subject: [PATCH] A real test (and a flaw in the harness fixed) git-svn-id: https://svn.perl.org/qpsmtpd/trunk@314 958fd67b-6ff1-0310-b445-bb7760255be9 --- t/Test/Qpsmtpd.pm | 2 +- t/Test/Qpsmtpd/Plugin.pm | 3 ++- t/plugin_tests/dnsbl | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 t/plugin_tests/dnsbl diff --git a/t/Test/Qpsmtpd.pm b/t/Test/Qpsmtpd.pm index 51b9b23..2458b4b 100644 --- a/t/Test/Qpsmtpd.pm +++ b/t/Test/Qpsmtpd.pm @@ -103,7 +103,7 @@ sub run_plugin_tests { # Now run them foreach my $plugin (@plugins) { - $plugin->run_tests(); + $plugin->run_tests($self); } } diff --git a/t/Test/Qpsmtpd/Plugin.pm b/t/Test/Qpsmtpd/Plugin.pm index ffd5810..396e895 100644 --- a/t/Test/Qpsmtpd/Plugin.pm +++ b/t/Test/Qpsmtpd/Plugin.pm @@ -30,10 +30,11 @@ sub total_tests { } sub run_tests { - my ($plugin) = @_; + my ($plugin, $qp) = @_; foreach my $t (@{$plugin->{_tests}}) { my $method = $t->{name}; diag "Running $method tests for plugin " . $plugin->plugin_name; + local $plugin->{_qp} = $qp; $plugin->$method(); } } diff --git a/t/plugin_tests/dnsbl b/t/plugin_tests/dnsbl new file mode 100644 index 0000000..987893e --- /dev/null +++ b/t/plugin_tests/dnsbl @@ -0,0 +1,25 @@ + +sub register_tests { + my $self = shift; + $self->register_test("test_local", 1); + $self->register_test("test_returnval", 1); +} + +sub test_local { + my $self = shift; + + my $connection = $self->qp->connection; + $connection->remote_ip('127.0.0.2'); # standard dnsbl test value + + $self->connect_handler($self->qp->transaction); + + ok($self->qp->connection->notes('dnsbl_sockets')); +} + +sub test_returnval { + my $self = shift; + + my ($ret, $note) = $self->rcpt_handler($self->qp->transaction, 'rcpt@example.com'); + is($ret, DENY, "Check we got a DENY"); + diag("dnsbl result: $note"); +}