Test case for Milter.config (still failing)
This commit is contained in:
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
from ConfigParser import ConfigParser
|
try:
|
||||||
|
from configparser import ConfigParser
|
||||||
|
except:
|
||||||
|
from ConfigParser import ConfigParser
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
class MilterConfigParser(ConfigParser):
|
class MilterConfigParser(ConfigParser):
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ class TestBase(object):
|
|||||||
## The macros returned by protocol stage
|
## The macros returned by protocol stage
|
||||||
self._symlist = [ None, None, None, None, None, None, None ]
|
self._symlist = [ None, None, None, None, None, None, None ]
|
||||||
|
|
||||||
|
def _close(self):
|
||||||
|
close(self.logfp)
|
||||||
|
|
||||||
def log(self,*msg):
|
def log(self,*msg):
|
||||||
for i in msg: print(i,file=self.logfp,end=None)
|
for i in msg: print(i,file=self.logfp,end=None)
|
||||||
print(file=self.logfp)
|
print(file=self.logfp)
|
||||||
@@ -204,6 +207,8 @@ class TestBase(object):
|
|||||||
self._body.write(header)
|
self._body.write(header)
|
||||||
self._body.write(b'\n\n')
|
self._body.write(b'\n\n')
|
||||||
self._body.write(body)
|
self._body.write(body)
|
||||||
|
self.close()
|
||||||
|
self._close()
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
## Feed an email contained in a file to the %milter.
|
## Feed an email contained in a file to the %milter.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import testmime
|
|||||||
import testsample
|
import testsample
|
||||||
import testutils
|
import testutils
|
||||||
import testgrey
|
import testgrey
|
||||||
|
import testcfg
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
@@ -11,6 +12,7 @@ def suite():
|
|||||||
s.addTest(testsample.suite())
|
s.addTest(testsample.suite())
|
||||||
s.addTest(testutils.suite())
|
s.addTest(testutils.suite())
|
||||||
s.addTest(testgrey.suite())
|
s.addTest(testgrey.suite())
|
||||||
|
s.addTest(testcfg.suite())
|
||||||
return s
|
return s
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# sample SRS configuration
|
||||||
|
[srs]
|
||||||
|
;secret="shhhh!"
|
||||||
|
;maxage=21
|
||||||
|
;hashlength=5
|
||||||
|
# if defined, SRS uses a database for opaque rewriting
|
||||||
|
;database=/var/log/milter/srsdata
|
||||||
|
# sign these domains using SES to prevent forged bounces instead of SRS
|
||||||
|
;ses = localdomain1.com, localdomain2.org
|
||||||
|
# sign these domains using SRS in signing mode to prevent forged bounces
|
||||||
|
;sign = localdomain1.com, localdomain2.org
|
||||||
|
# rewrite all other domains to this domain using SRS
|
||||||
|
;fwdomain = mydomain.com
|
||||||
|
# additional domains to decode (reverse) srs
|
||||||
|
# NOTE: bms.py in milter package can also do this, as can pysrs.m4 HACK.
|
||||||
|
;srs = otherdomain.com
|
||||||
|
# do not rewrite mail to these domains
|
||||||
|
;nosrs = braindeadmail.com
|
||||||
|
# Treat these localparts as a DSN. Lot's of braindead systems
|
||||||
|
# send non-DSN mail to MAIL FROM.
|
||||||
|
;banned_users = mailer-daemon, clamav, postmaster
|
||||||
|
|
||||||
|
[srsmilter]
|
||||||
|
;datadir=/var/lib/milter
|
||||||
|
socketname = /var/run/milter/srsmilter
|
||||||
|
miltername = pysrsfilter
|
||||||
|
# reject DSNs to unsigned recipients (bounce spam)
|
||||||
|
reject_spoofed = true
|
||||||
|
;trusted_relay = 1.2.3.4
|
||||||
|
internal_connect = 192.168.*.*,127.0.0.1,::1
|
||||||
|
# Enable outgoing SRS via CHGFROM (see code for limitations)
|
||||||
|
miltersrs = false
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
import unittest
|
||||||
|
from Milter.config import MilterConfigParser
|
||||||
|
|
||||||
|
class ConfigTestCase(unittest.TestCase):
|
||||||
|
def testConfig(self):
|
||||||
|
cp = MilterConfigParser()
|
||||||
|
cp.read(['test/pysrs.cfg'])
|
||||||
|
socketname = cp.getdefault('srsmilter','socketname',
|
||||||
|
'/var/run/milter/srsmilter')
|
||||||
|
self.assertEqual(socketname,'/var/run/milter/srsmilter')
|
||||||
|
|
||||||
|
def suite(): return unittest.makeSuite(ConfigTestCase,'test')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user