pymilter
0.9.6
|
Test mixin for unit testing milter applications. More...
Public Member Functions | |
def | __init__ |
def | log |
def | setsymval |
Set a macro value. More... | |
def | getsymval |
def | replacebody |
def | chgheader |
def | addheader |
def | delrcpt |
def | addrcpt |
def | setreply |
Save the reply codes and messages in self._reply. More... | |
def | setsymlist |
def | feedFile |
Feed a file like object to the milter. More... | |
def | feedMsg |
Feed an email contained in a file to the milter. More... | |
def | connect |
Call the connect and helo callbacks. More... | |
Public Attributes | |
logfp | |
Private Attributes | |
_protocol | |
_delrcpt | |
List of recipients deleted. | |
_addrcpt | |
List of recipients added. | |
_macros | |
Macros defined. | |
_body | |
The message body. More... | |
_bodyreplaced | |
True if the milter replaced the message body. More... | |
_headerschanged | |
True if the milter changed any headers. More... | |
_reply | |
Reply codes and messages set by milter. | |
_msg | |
The rfc822 message object for the current email being fed to the milter. More... | |
_symlist | |
Test mixin for unit testing milter applications.
This mixin overrides many Milter.MilterBase methods with stub versions that simply record what was done.
def Milter.test.TestBase.connect | ( | self, | |
host = 'localhost' , |
|||
helo = 'spamrelay' , |
|||
ip = '1.2.3.4' |
|||
) |
Call the connect and helo callbacks.
The helo callback is not called if connect does not return CONTINUE.
host | the hostname passed to the connect callback |
helo | the hostname passed to the helo callback |
ip | the IP address passed to the connect callback |
References Milter.test.TestBase._body, Milter.test.TestBase._bodyreplaced, Milter.greysql.Greylist.close(), Milter.greylist.Greylist.close(), Milter.Base.close(), Milter.Milter.close(), Milter.Base.hello(), Milter.Milter.hello(), and Milter.Base.negotiate().
def Milter.test.TestBase.feedFile | ( | self, | |
fp, | |||
sender = "spam@adv.com" , |
|||
rcpt = "victim@lamb.com" , |
|||
rcpts | |||
) |
Feed a file like object to the milter.
Calls envfrom, envrcpt for each recipient, header for each header field, body for each body block, and finally eom. A return code from the milter other than CONTINUE returns immediately with that return code.
This is a convenience method, a test could invoke the callbacks in sequence on its own - and for some complex tests, this may be necessary.
fp | the file with rfc2822 message stream |
sender | the MAIL FROM |
rcpt | RCPT TO - additional recipients may follow |
References Milter.test.TestBase._body, Milter.test.TestBase._bodyreplaced, Milter.test.TestBase._headerschanged, Milter.test.TestBase._msg, Milter.test.TestBase._reply, Milter.Base.body(), Milter.Base.envfrom(), Milter.Milter.envfrom(), Milter.Base.envrcpt(), Milter.Milter.envrcpt(), Milter.Base.eoh(), Milter.Milter.eoh(), Milter.Base.eom(), Milter.Milter.eom(), Milter.Base.header(), and Milter.Milter.header().
Referenced by Milter.test.TestBase.feedMsg().
def Milter.test.TestBase.feedMsg | ( | self, | |
fname, | |||
sender = "spam@adv.com" , |
|||
rcpts | |||
) |
Feed an email contained in a file to the milter.
This is a convenience method that invokes feedFile .
sender | MAIL FROM |
rcpts | RCPT TO, multiple recipients may be supplied |
References Milter.test.TestBase.feedFile().
def Milter.test.TestBase.setreply | ( | self, | |
rcode, | |||
xcode, | |||
msg | |||
) |
Save the reply codes and messages in self._reply.
References Milter.Base._actions, Milter.test.TestBase._reply, and Milter.test.TestBase._symlist.
def Milter.test.TestBase.setsymval | ( | self, | |
name, | |||
val | |||
) |
Set a macro value.
These are retrieved by the milter with getsymval.
name | the macro name, as passed to getsymval |
val | the macro value |
References Milter.test.TestBase._body, Milter.test.TestBase._bodyreplaced, Milter.test.TestBase._headerschanged, Milter.test.TestBase._macros, Milter.test.TestBase._msg, Milter.test.TestBase.log(), Milter.Base.log(), and Milter.Milter.log().
|
private |
The message body.
Referenced by Milter.test.TestBase.connect(), Milter.test.TestBase.feedFile(), and Milter.test.TestBase.setsymval().
|
private |
True if the milter replaced the message body.
Referenced by Milter.test.TestBase.connect(), Milter.test.TestBase.feedFile(), and Milter.test.TestBase.setsymval().
|
private |
True if the milter changed any headers.
Referenced by Milter.test.TestBase.feedFile(), and Milter.test.TestBase.setsymval().
|
private |
The rfc822 message object for the current email being fed to the milter.
Referenced by Milter.test.TestBase.feedFile(), and Milter.test.TestBase.setsymval().