b00f4c7793
which will merge into the main branch fairly easily
82 lines
2.1 KiB
Perl
82 lines
2.1 KiB
Perl
#!perl -w
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Qpsmtpd::Constants;
|
|
|
|
sub register_tests {
|
|
my $self = shift;
|
|
|
|
eval 'use ClamAV::Client';
|
|
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 $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" );
|
|
|
|
$tran->header->add('Content-Type', 'multipart/alternative; boundary="Jx3Wbb8BMHsO=_?:"');
|
|
ok( ! $self->is_not_multipart(), "not_multipart" );
|
|
}
|
|
|