Make test cases work. (Previous commit incomplete)

This commit is contained in:
Stuart D. Gathman
2016-12-02 00:19:27 -05:00
parent 381e906b6a
commit 2fa952e108
3 changed files with 10 additions and 6 deletions
+7 -5
View File
@@ -185,13 +185,15 @@ def noreply(func):
# If some or all of these are unused, the bandwidth can be saved # If some or all of these are unused, the bandwidth can be saved
# by listing the ones that are used. # by listing the ones that are used.
# @since 1.0.2 # @since 1.0.2
def symlist(func,*syms): def symlist(*syms):
if func.__name__ not in MACRO_CALLBACKS:
raise ValueError('@symlist applied to non-symlist method: '+func.__name__)
if len(syms) > 5: if len(syms) > 5:
raise ValueError('@symlist limited to 5 macros by MTA: '+func.__name__) raise ValueError('@symlist limited to 5 macros by MTA: '+func.__name__)
func._symlist = syms def setsyms(func):
return func if func.__name__ not in MACRO_CALLBACKS:
raise ValueError('@symlist applied to non-symlist method: '+func.__name__)
func._symlist = syms
return func
return setsyms
## Disabled action exception. ## Disabled action exception.
# set_flags() can tell the MTA that this application will not use certain # set_flags() can tell the MTA that this application will not use certain
+2 -1
View File
@@ -120,7 +120,7 @@ class TestBase(object):
self._reply = (rcode,xcode) + msg self._reply = (rcode,xcode) + msg
def setsymlist(self,stage,macros): def setsymlist(self,stage,macros):
if not self._actions & SETSYMLIST: if not self._actions & Milter.SETSYMLIST:
raise DisabledAction("SETSYMLIST") raise DisabledAction("SETSYMLIST")
if self._stage != -1: if self._stage != -1:
raise RuntimeError("setsymlist may only be called from negotiate") raise RuntimeError("setsymlist may only be called from negotiate")
@@ -220,6 +220,7 @@ class TestBase(object):
def connect(self,host='localhost',helo='spamrelay',ip='1.2.3.4'): def connect(self,host='localhost',helo='spamrelay',ip='1.2.3.4'):
self._body = None self._body = None
self._bodyreplaced = False self._bodyreplaced = False
self._setctx(None)
opts = [ Milter.CURR_ACTS,~0,0,0 ] opts = [ Milter.CURR_ACTS,~0,0,0 ]
self._stage = -1 self._stage = -1
rc = self.negotiate(opts) rc = self.negotiate(opts)
+1
View File
@@ -47,6 +47,7 @@ class sampleMilter(Milter.Milter):
self.mailfrom = f self.mailfrom = f
self.bodysize = 0 self.bodysize = 0
self.user = self.getsymval('{auth_authen}') self.user = self.getsymval('{auth_authen}')
self.auth_type = self.getsymval('{auth_type}')
if self.user: if self.user:
self.log("user",self.user,"sent mail from",f,str) self.log("user",self.user,"sent mail from",f,str)
else: else: