Test::Mailmunge::RegressionUtils − utility functions for Mailmunge regression tests
This class defines a number of functions in the main package that are useful for regression tests.
The mailmunge regression−tests assume they are running in an environment similar to the docker images built by the "build−docker−container" supplied in the mailmunge source code. THEY ARE UNLIKELY TO WORK IN ANY OTHER ENVIRONMENT.
$file is assumed to be an RFC5322 mail message. Return only the body of the message after skipping the header lines.
Returns true if it looks like the regression−test server is running Postfix; false otherwise. We assume the server is running Sendmail if it's not running Postfix.
Returns the regression−test server's IP address if it could be determined; undef if not. This will not be the loopback address, but the IP address of a non−loopback interface.
Runs an SMTP session. Connects to $ip and HELOs as $helo. Use $sender as the envelope sender. Uses each recipient in @$recips in a RCPT To: command. ($recips must be an arrayref.) And transmits $msg as the message body; $msg must be a string representing an RFC5322 mail message.
Returns a hash
containing:
stage
The stage at which the SMTP session ended. One of "connect", "helo", "mail", "rcpt", "data", "datasend", or "quit".
code
The three−digit SMTP code returned by the SMTP server for the final command sent.
|
dsn |
The three−number "a.b.c" DSN returned by the SMTP server for the final command sent. |
|||
|
txt |
The reply text returned by the SMTP server for the final command sent. |
Returns the directory in which regression−test messages are dropped.
Deletes all files in maildrop_msg_dir()
Returns the full path to the maildrop file. If $file is not supplied, defaults to 'maildrop.msg'
Returns the quarantine directory '/var/spool/mm−quarantine'
Deletes all files from the quarantine directory.
Returns the first directory under quarantine_dir() that has a quarantined message. Returns undef if no quarantined messages are found.
Returns a string containing an RFC5322 message taken from the file "t/msgs/$source_msg". The string "__SUBJECT__" in that file is replaced with $subject. If $output_file is provided, then the string ": maildrop.msg" in the source message is replaced with ": $output_file". This directs the regression−test maildrop process to drop the message in "maildrop_msg_dir() . '/' . $output_file"
Waits up to (about) four seconds for all files named in the argument list to exist. Returns 1 if all of the files exist, or 0 if the function timed out before all files appeared.
Flushes the MTA queues using the appropriate commands depending on whether the MTA is Sendmail or Postfix. You need to run the regression tests as root for this to work.
Clears out the MTA queues using the appropriate commands depending on whether the MTA is Sendmail or Postfix. Again, only works if you're running as root.
Returns an arrayref of queue−IDs in the MTA's "hold" queue. The contents of the arrayref are unspecified, but the number of items is the number of messages in the "hold" queue of the MTA.
Dianne Skoll <[email protected]>
This code is licensed under the terms of the GNU General Public License, version 2.