qpsmtpd/t/plugin_tests/virus/clamdscan
Matt Simerson ebdb25a4bd extracted config*() from Qpsmtpd.pm -> Config.pm
* includes full test converage for Qpsmtpd::Config
    * folded t/config.t into t/qpsmtpd-config.t
* includes additional tests for Qpsmtpd
    * folded t/tempstuff into t/qpsmtpd.t
* PBP adjustments here and there
* other tweaks to handle test warnings
2014-09-15 23:41:31 -07:00

90 lines
2.2 KiB
Perl

#!perl -w
use strict;
use warnings;
use Qpsmtpd::Constants;
sub register_tests {
my $self = shift;
eval 'use ClamAV::Client'; ## no critic (Stringy)
if ( ! $@ ) {
$self->register_test('test_register', 3);
$self->register_test('test_get_clamd', 1);
};
$self->register_test('test_err_and_return', 2);
$self->register_test('test_get_filename', 1);
$self->register_test('test_set_permission', 1);
$self->register_test('test_is_too_big', 2);
$self->register_test('test_is_not_multipart', 2);
}
sub test_register {
my $self = shift;
ok( $self->{_args}{deny_viruses} eq 'yes', "deny_viruses");
ok( $self->{_args}{max_size} == 128, "max_size");
ok( $self->{_args}{scan_all} == 0, "scan_all");
};
sub test_err_and_return {
my $self = shift;
$self->{_args}{defer_on_error} = 1;
my ($code, $mess) = $self->err_and_return( "test oops" );
cmp_ok( DENYSOFT, '==', $code, "oops ($mess)");
$self->{_args}{defer_on_error} = 0;
($code, $mess) = $self->err_and_return( "test oops" );
cmp_ok( DECLINED, '==', $code, "oops ($mess)");
}
sub test_get_filename {
my $self = shift;
my $tran = $self->qp->transaction();
$tran->{_body_array} = ['line','two'];
my $filename = $self->get_filename();
ok( $filename, "get_filename ($filename)" );
}
sub test_set_permission {
my $self = shift;
ok( $self->set_permission(), "set_permission" );
}
sub test_get_clamd {
my $self = shift;
my $clamd = $self->get_clamd();
ok( ref $clamd, "get_clamd: " . ref $clamd );
}
sub test_is_too_big {
my $self = shift;
my $tran = shift || $self->qp->transaction();
$self->{_args}{max_size} = 8;
$tran->{_body_size} = (7 * 1024 );
ok( ! $self->is_too_big( $tran ), "is_too_big");
$tran->{_body_size} = (9 * 1024 );
ok( $self->is_too_big( $tran ), "is_too_big");
}
sub test_is_not_multipart {
my $self = shift;
my $tran = shift || $self->qp->transaction();
ok( $self->is_not_multipart(), "not_multipart" );
if ( $tran->header ) {
$tran->header->add('Content-Type', 'multipart/alternative; boundary="Jx3Wbb8BMHsO=_?:"');
ok( ! $self->is_not_multipart(), "not_multipart" );
}
else {
ok( 1 );
}
}