|
pymilter 1.0.5
|
Test mixin for unit testing milter applications. More...
Public Member Functions | |
| __init__ (self, logfile='test/milter.log') | |
| log (self, *msg) | |
| setsymval (self, name, val) | |
| Set a macro value. | |
| getsymval (self, name) | |
| replacebody (self, chunk) | |
| chgfrom (self, sender, params=None) | |
| quarantine (self, reason) | |
| progress (self) | |
| chgheader (self, field, idx, value) | |
| addheader (self, field, value, idx=-1) | |
| delrcpt (self, rcpt) | |
| addrcpt (self, rcpt) | |
| setreply (self, rcode, xcode, *msg) | |
| Save the reply codes and messages in self._reply. | |
| setsymlist (self, stage, macros) | |
| feedFile (self, fp, sender="spam@adv.com", rcpt="victim@lamb.com", *rcpts) | |
| Feed a file like object to the milter. | |
| feedMsg (self, fname, sender="spam@adv.com", *rcpts) | |
| Feed an email contained in a file to the milter. | |
| connect (self, host='localhost', helo='spamrelay', ip='1.2.3.4') | |
| Call the connect and helo callbacks. | |
Public Attributes | |
| logfp = open(logfile,"a") | |
Protected Member Functions | |
| _close (self) | |
Test mixin for unit testing milter applications.
This mixin overrides many Milter.MilterBase methods with stub versions that simply record what was done.
| 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 _body, _bodyreplaced, Milter.Base._setctx(), _stage, Milter.Base.close(), Milter.greylist.Greylist.close(), Milter.greysql.Greylist.close(), Milter.Milter.close(), Milter.policy.DB.close(), Milter.policy.MTAPolicy.close(), Milter.sgmllib.SGMLParser.close(), Milter.sgmllib.TestSGMLParser.close(), connect(), Milter.Base.hello(), Milter.Milter.hello(), and Milter.Base.negotiate().
Referenced by connect().
| 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 _body, _bodyreplaced, _close(), _headerschanged, _msg, _reply, _sender, _stage, Milter.Base.body(), Milter.Base.close(), Milter.greylist.Greylist.close(), Milter.greysql.Greylist.close(), Milter.Milter.close(), Milter.policy.DB.close(), Milter.policy.MTAPolicy.close(), Milter.sgmllib.SGMLParser.close(), Milter.sgmllib.TestSGMLParser.close(), Milter.Base.data(), 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_bytes, and Milter.Base.header_bytes().
Referenced by feedMsg().
| 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 feedFile().
| 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 _body, _bodyreplaced, _envfromchanged, _macros, _sender, _stage, _symlist, Milter.Base.log(), Milter.Milter.log(), and log().