qpsmtpd/t/plugin_tests/ident/geoip
Matt Simerson 2dcd34467e geoip: eval loading of Geo::IP, tests, enabled in config
eval Geo::IP and log an error if missing
added 2 tests
enabled in config/plugins
2012-05-22 17:40:02 -04:00

31 lines
576 B
Perl

#!perl -w
use strict;
use warnings;
use Qpsmtpd::Constants;
sub register_tests {
my $self = shift;
eval 'use Geo::IP';
if ( $@ ) {
warn "could not load Geo::IP\n";
$self->log(LOGERROR, "could not load Geo::IP");
return;
};
$self->register_test('test_geoip_lookup', 2);
};
sub test_geoip_lookup {
my $self = shift;
$self->qp->connection->remote_ip('24.24.24.24');
cmp_ok( $self->connect_handler(), '==', DECLINED, "exit code");
cmp_ok( $self->qp->connection->notes('geoip_country'), 'eq', 'US', "note");
};