2012-06-22 11:38:01 +02:00
|
|
|
#!perl -w
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Qpsmtpd::Constants;
|
|
|
|
|
|
|
|
sub register_tests {
|
|
|
|
my $self = shift;
|
|
|
|
|
2014-09-16 08:41:31 +02:00
|
|
|
eval 'use ClamAV::Client'; ## no critic (Stringy)
|
2012-06-22 11:38:01 +02:00
|
|
|
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;
|
2014-09-16 08:41:31 +02:00
|
|
|
my $tran = $self->qp->transaction();
|
|
|
|
$tran->{_body_array} = ['line','two'];
|
|
|
|
|
2012-06-22 11:38:01 +02:00
|
|
|
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" );
|
|
|
|
|
2012-06-23 05:37:42 +02:00
|
|
|
if ( $tran->header ) {
|
|
|
|
$tran->header->add('Content-Type', 'multipart/alternative; boundary="Jx3Wbb8BMHsO=_?:"');
|
|
|
|
ok( ! $self->is_not_multipart(), "not_multipart" );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ok( 1 );
|
|
|
|
}
|
2012-06-22 11:38:01 +02:00
|
|
|
}
|
|
|
|
|