Crate indymilter_test

Source
Expand description

A library for testing milters.

The API provided is powerful, but rather low-level. It provides little guidance on how to interact with the milter under test. You must be familiar with the steps of an SMTP conversation. See the included tests for basic usage, and consult the sendmail API documentation.

§Usage

The purpose of indymilter-test is exercising some milter and checking that it behaves as expected. Running the milter is out of scope for this library. You must arrange for the milter to be set up and torn down yourself. In any case, indymilter-test requires to be passed a listening socket to talk to the milter under test.

The main API item is TestConnection. Open the connection directly with TestConnection::open or configure it with TestConnection::configure.

When designing a test case, keep in mind that your method calls on TestConnection should be those of a well-behaved MTA. The sequence of steps will usually be: open the connection, interact with the milter under test while asserting expected responses, close the connection. As mentioned, familiarity with the milter protocol is assumed.

As a quick overview, the following are the SMTP commands that an MTA may forward to a milter, in order. Negotiation is done automatically when opening the test connection.

During the message-scoped commands, abort aborts processing for the current message. The commands indicated may be called repeatedly.

§Cargo features

The optional feature regex enables implementations of Matcher for regular expressions.

Structs§

Actions
Flags that represent eom actions.
AnyMatcher
A matcher that accepts any input.
EomActions
End-of-message actions received from the milter.
ProtoOpts
Flags that represent milter protocol options.
TestConnection
A milter test connection.
TestConnectionBuilder
A builder for milter test connections.

Enums§

EomAction
An end-of-message action performed by a milter.
MacroStage
The stage for which macros are sent.
SocketInfo
Socket information.
Status
The status returned for a milter command.
TestError
Errors that may occur when interacting with the milter API.

Traits§

IntoCString
Infallible conversion to a C string.
IntoSocketInfo
Infallible conversion to SocketInfo.
Matcher
A matcher for results expected from a milter.

Functions§

any
Returns a matcher that accepts any input.

Type Aliases§

TestResult
A result type specialised for test errors.
Version
The type of the milter protocol version.