NAME

Mail::Milter::Authentication::Tester::HandlerTester - Class for testing handlers

VERSION

version 3.20241024

SYNOPSIS

Emulates an Authentication Milter environment with methods for testing Handlers.

Can snapshot and restore state at any point.

DESCRIPTION

Make testing of Authentication Milter Handler modules easier.

NAME

Mail::Milter::Authentication::Tester::HandlerTester - Test harness for testing Authentication Milter Handlers

CONSTRUCTOR

new( $args )

Instantiate a new HandlerTester object.

$args is a hashref with the following entries.

prefix

Required

The Prefix path containing the authentication milter config file(s). This should contain all configuration files required for your test, the main authentication_milter.json file can be overridden by the handler_config option (see below).

This location should, for example, contain a valid mail-dmarc.ini for any tests using the DMARC handler.

handler_config

If present, the config will be built from a generic default SMTP environment, with the given HASHREF substituted as the Handler configuration. This eliminates the need to have a config file for each handler configuration you wish to test.

zonedata

The zonefile data for use with Net::DNS::Resolver::Mock

zonefile

A zonefile for use with Net::DNS::Resolver::Mock

METHODS

snapshot( $name )

Save a snapshot with the given name

switch( $name )

Restore state from the given snapshot

handler()

Returns the Handler object

connect( $name, $ip )

Call the connect callbacks with the given data.

Returns the value of get_return()

helo( $name )

Call the helo callbacks with the given data.

Returns the value of get_return();

mailfrom( $email )

Call the envfrom callbacks with the given data.

Returns the value of get_return();

rcptto( $email )

Call the envrcpt callbacks with the given data.

Returns the value of get_return();

header( $key, $value )

Call the header callbacks with the given data.

Returns the value of get_return()

end_of_headers()

Call the end_of_headers callbacks.

Returns the value of get_return()

body( $body_chunk )

Call the body callbacks with the given data.

Returns the value of get_return()

end_of_message()

Call the eom callbacks.

Returns the value of get_return()

close()

Call the close callbacks.

Returns the value of get_return()

abort()

Call the abort callbacks.

addheader()

Call the addheader callbacks.

run( $args )

Run with a given set of data as defined in $args hashref.

Dies if the mail would be rejected.

Arguments of $args are.

connect_name

The name of the connecting server.

connect_ip

The ip address of the connecting server.

helo

The helo string.

mailfrom

The envelope MAILFROM address.

rcptto

Arrayref of the envelope RCPTTO addresses.

body

The email body.

get_return()

Returns the value of get_return() from the current handler object.

get_reject_mail()

Returns the value of get_reject_mail() from the current handler object.

servername()

Returns a dummy authservid servername.

get_authresults_header()

Returns a Mail::AuthenticationResults::Header object representing the authentication results header which would be added to the message.

DEPENDENCIES

Carp
Clone
Mail::AuthenticationResults::Header
Mail::AuthenticationResults::Header::AuthServID
Mail::Milter::Authentication
Mail::Milter::Authentication::Protocol::Milter
Mail::Milter::Authentication::Protocol::SMTP
Mail::Milter::Authentication::Config
Module::Load
Net::DNS::Resolver::Mock

AUTHORS

Marc Bradshaw <marc@marcbradshaw.net>

COPYRIGHT

Copyright 2018

This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Marc Bradshaw <marc@marcbradshaw.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by Marc Bradshaw.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.