Sendmail-PMilter
view release on metacpan or search on metacpan
t/00_pmilter.t view on Meta::CPAN
'SMFIF_DELRCPT' => 0x00000008, # Milter may delete recipients
'SMFIF_CHGHDRS' => 0x00000010, # Milter may change/delete headers
'SMFIF_QUARANTINE' => 0x00000020, # Milter may quarantine message
'SMFIF_CHGFROM' => 0x00000040, # Milter may change "from" (envelope sender)
'SMFIF_ADDRCPT_PAR' => 0x00000080, # Milter may add recipients (like SMFIF_ADDRCPT, but include extra arguments in the call)
'SMFIF_SETSYMLIST' => 0x00000100, # Milter may send set of symbols (macros) that it wants
# Convenience bit sets of the 'actions' associated with the SMFIF_* flags above, grouped by Milter Protocol Version.
'SMFI_V1_ACTS' => 0x0000000F, # SMFIF_ADDHDRS|SMFIF_CHGBODY|SMFIF_ADDRCPT|SMFIF_DELRCPT
'SMFI_V2_ACTS' => 0x0000003F, # SMFI_V1_ACTS|SMFIF_CHGHDRS|SMFIF_QUARANTINE
'SMFI_V6_ACTS' => 0x000001FF, # SMFI_V2_ACTS|SMFIF_CHGFROM|SMFIF_ADDRCPT_PAR|SMFIF_SETSYMLIST
'SMFI_CURR_ACTS' => 0x000001FF, # SMFI_V6_ACTS (as of July 2019; see mfapi.h and mfdef.h in the Sendmail source)
'MAXREPLYLEN' => 980, # Maximum length of lines in a reply from the MTA to the client.
'MAXREPLIES' => 32, # Maximum number of lines in a multi-line reply from the MTA to the client.
);
foreach my $constant (keys %CONSTANTS) {
no strict 'refs';
my $symbol = "Sendmail::PMilter::$constant"->();
ok( defined $symbol, "Sendmail::PMilter::$constant" );
SKIP: {
skip("- Sendmail::PMilter::$constant not defined", 1) unless defined $symbol;
is( $symbol, $CONSTANTS{$constant} );
}
}
# Of the module methods, the get_sendmail_cf function is tested first given
# the number of other methods dependent upon this method. By default, this
# method should return the Sendmail configuration file as '/etc/mail/sendmail.cf'.
ok( my $cf = $milter->get_sendmail_cf );
ok( defined $cf );
is( $cf, '/etc/mail/sendmail.cf' );
# Test the corresponding set_sendmail_cf function by setting a new value for
# this parameter and then testing the return value from get_sendmail_cf
ok( $milter->set_sendmail_cf('t/files/sendmail.cf') );
is( $milter->get_sendmail_cf, 't/files/sendmail.cf' );
ok( $milter->set_sendmail_cf() );
is( $milter->get_sendmail_cf, '/etc/mail/sendmail.cf' );
# Test the auto_getconn function using our own set of test sendmail
# configuration files - The first test should fail as a result of the name
# parameter not having been defined.
eval { $milter->auto_getconn() };
ok( defined $@ );
my @sockets = (
'local:/var/run/milter.sock',
'unix:/var/run/milter.sock',
'inet:3333@localhost',
'inet6:3333@localhost'
);
foreach my $index (0 .. 4) {
my $cf = sprintf('t/files/sendmail%d.cf', $index);
SKIP: {
skip("- Missing file $cf", 3) unless -e $cf;
ok( $milter->set_sendmail_cf($cf), $cf );
my $socket = shift @sockets;
ok(
( ! defined $socket ) or
( my $milter_socket = $milter->auto_getconn('test-milter') )
);
is( $milter_socket, $socket, defined $socket ? $socket : '(undef)' );
# Test the creation of the milter connection socket with the setconn function
# for each of the test sendmail configuration files parsed.
}
}
1;
__END__
( run in 1.966 second using v1.01-cache-2.11-cpan-5a3173703d6 )