diff options
| author | bwarsaw | 2006-07-08 17:45:13 +0000 |
|---|---|---|
| committer | bwarsaw | 2006-07-08 17:45:13 +0000 |
| commit | 0e9fb0aec9fcf0027dd354b48196b1fa0d420c4d (patch) | |
| tree | f63ad44589e00c13e92cf0e83461ecb22dc5aeff | |
| parent | cbef3114de3e80b9436d909b11568858e3a1cf42 (diff) | |
| download | mailman-0e9fb0aec9fcf0027dd354b48196b1fa0d420c4d.tar.gz mailman-0e9fb0aec9fcf0027dd354b48196b1fa0d420c4d.tar.zst mailman-0e9fb0aec9fcf0027dd354b48196b1fa0d420c4d.zip | |
25 files changed, 311 insertions, 291 deletions
diff --git a/Mailman/Handlers/Acknowledge.py b/Mailman/Handlers/Acknowledge.py index dc8175773..e974844c1 100644 --- a/Mailman/Handlers/Acknowledge.py +++ b/Mailman/Handlers/Acknowledge.py @@ -1,18 +1,19 @@ -# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2006 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Send an acknowledgement of the successful post to the sender. @@ -22,10 +23,10 @@ to send acks only after successful delivery. """ -from Mailman import mm_cfg -from Mailman import Utils -from Mailman import Message from Mailman import Errors +from Mailman import Message +from Mailman import Utils +from Mailman.configuration import config from Mailman.i18n import _ @@ -34,7 +35,7 @@ def process(mlist, msg, msgdata): # Extract the sender's address and find them in the user database sender = msgdata.get('original_sender', msg.get_sender()) try: - ack = mlist.getMemberOption(sender, mm_cfg.AcknowledgePosts) + ack = mlist.getMemberOption(sender, config.AcknowledgePosts) if not ack: return except Errors.NotAMemberError: diff --git a/Mailman/Handlers/Approve.py b/Mailman/Handlers/Approve.py index ce328c07f..9e5564303 100644 --- a/Mailman/Handlers/Approve.py +++ b/Mailman/Handlers/Approve.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2005 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2006 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -27,8 +27,8 @@ import re from email.Iterators import typed_subpart_iterator -from Mailman import mm_cfg from Mailman import Errors +from Mailman.configuration import config NL = '\n' @@ -98,14 +98,14 @@ def process(mlist, msg, msgdata): lines = part.get_payload() if re.search(pattern, lines): part.set_payload(re.sub(pattern, '', lines)) - if passwd is not missing and mlist.Authenticate((mm_cfg.AuthListModerator, - mm_cfg.AuthListAdmin), + if passwd is not missing and mlist.Authenticate((config.AuthListModerator, + config.AuthListAdmin), passwd): # BAW: should we definitely deny if the password exists but does not # match? For now we'll let it percolate up for further determination. - msgdata['approved'] = 1 + msgdata['approved'] = True # Used by the Emergency module - msgdata['adminapproved'] = 1 + msgdata['adminapproved'] = True # has this message already been posted to this list? beentheres = [s.strip().lower() for s in msg.get_all('x-beenthere', [])] if mlist.GetListEmail().lower() in beentheres: diff --git a/Mailman/Handlers/AvoidDuplicates.py b/Mailman/Handlers/AvoidDuplicates.py index 24686bb8d..3aa4936b5 100644 --- a/Mailman/Handlers/AvoidDuplicates.py +++ b/Mailman/Handlers/AvoidDuplicates.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """If the user wishes it, do not send duplicates of the same message. @@ -23,7 +24,7 @@ warning header, or pass it through, depending on the user's preferences. """ from email.Utils import getaddresses, formataddr -from Mailman import mm_cfg +from Mailman.configuration import config COMMASPACE = ', ' @@ -67,7 +68,7 @@ def process(mlist, msg, msgdata): # is not a member at all, just flag the X-Mailman-Duplicate: yes # header. if mlist.isMember(r) and \ - mlist.getMemberOption(r, mm_cfg.DontReceiveDuplicates): + mlist.getMemberOption(r, config.DontReceiveDuplicates): send_duplicate = False # We'll send a duplicate unless the user doesn't wish it. If # personalization is enabled, the add-dupe-header flag will add a diff --git a/Mailman/Handlers/CalcRecips.py b/Mailman/Handlers/CalcRecips.py index 588fcb9ad..9e94d7755 100644 --- a/Mailman/Handlers/CalcRecips.py +++ b/Mailman/Handlers/CalcRecips.py @@ -25,10 +25,10 @@ SendmailDeliver and BulkDeliver modules. from Mailman import Errors from Mailman import Message -from Mailman import mm_cfg from Mailman import Utils -from Mailman.i18n import _ from Mailman.MemberAdaptor import ENABLED +from Mailman.configuration import config +from Mailman.i18n import _ @@ -41,7 +41,7 @@ def process(mlist, msg, msgdata): include_sender = 1 sender = msg.get_sender() try: - if mlist.getMemberOption(sender, mm_cfg.DontReceiveOwnPosts): + if mlist.getMemberOption(sender, config.DontReceiveOwnPosts): include_sender = 0 except Errors.NotAMemberError: pass @@ -53,8 +53,8 @@ def process(mlist, msg, msgdata): missing = [] password = msg.get('urgent', missing) if password is not missing: - if mlist.Authenticate((mm_cfg.AuthListModerator, - mm_cfg.AuthListAdmin), + if mlist.Authenticate((config.AuthListModerator, + config.AuthListAdmin), password): recips = mlist.getMemberCPAddresses(mlist.getRegularMemberKeys() + mlist.getDigestMemberKeys()) @@ -126,7 +126,7 @@ def do_topic_filters(mlist, msg, msgdata, recips): # this message by default. continue if not mlist.getMemberOption(user, - mm_cfg.ReceiveNonmatchingTopics): + config.ReceiveNonmatchingTopics): # The user has interest in some topics, but elects not to # receive message that match no topics, so zap him. zaprecips.append(user) diff --git a/Mailman/Handlers/CleanseDKIM.py b/Mailman/Handlers/CleanseDKIM.py index ec7caa134..786f365d8 100644 --- a/Mailman/Handlers/CleanseDKIM.py +++ b/Mailman/Handlers/CleanseDKIM.py @@ -4,18 +4,18 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software +# along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. -"""Remove any "DomainKeys" (or similar) header lines. +"""Remove any 'DomainKeys' (or similar) header lines. The values contained in these header lines are intended to be used by the recipient to detect forgery or tampering in transit, and the modifications @@ -31,4 +31,3 @@ def process(mlist, msg, msgdata): del msg['domainkey-signature'] del msg['dkim-signature'] del msg['authentication-results'] - diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index f384f6357..650c8548d 100644 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -24,8 +24,9 @@ from email.Errors import HeaderParseError from email.Header import Header, decode_header, make_header from email.Utils import parseaddr, formataddr, getaddresses -from Mailman import mm_cfg from Mailman import Utils +from Mailman import Version +from Mailman.configuration import config from Mailman.i18n import _ CONTINUATION = ',\n\t' @@ -89,7 +90,7 @@ def process(mlist, msg, msgdata): # using such an old version, they may be vulnerable. It's too easy to # edit the code to add a configuration variable to handle this. if not msg.has_key('x-mailman-version'): - msg['X-Mailman-Version'] = mm_cfg.VERSION + msg['X-Mailman-Version'] = Version.VERSION # We set "Precedence: list" because this is the recommendation from the # sendmail docs, the most authoritative source of this header's semantics. if not msg.has_key('precedence'): @@ -187,14 +188,18 @@ def process(mlist, msg, msgdata): subfieldfmt = '<%s>, <mailto:%s?subject=%ssubscribe>' listinfo = mlist.GetScriptURL('listinfo', absolute=1) headers = {} + # XXX reduced_list_headers used to suppress List-Help, List-Subject, and + # List-Unsubscribe from UserNotification. That doesn't seem to make sense + # any more, so always add those three headers (others will still be + # suppressed). + headers.update({ + 'List-Help' : '<mailto:%s?subject=help>' % requestaddr, + 'List-Unsubscribe': subfieldfmt % (listinfo, requestaddr, 'un'), + 'List-Subscribe' : subfieldfmt % (listinfo, requestaddr, ''), + }) if msgdata.get('reduced_list_headers'): headers['X-List-Administrivia'] = 'yes' else: - headers.update({ - 'List-Help' : '<mailto:%s?subject=help>' % requestaddr, - 'List-Unsubscribe': subfieldfmt % (listinfo, requestaddr, 'un'), - 'List-Subscribe' : subfieldfmt % (listinfo, requestaddr, ''), - }) # List-Post: is controlled by a separate attribute if mlist.include_list_post_header: headers['List-Post'] = '<mailto:%s>' % mlist.GetListEmail() @@ -258,7 +263,7 @@ def prefix_subject(mlist, msg, msgdata): prefix_pattern = p.sub(r'\s*\d+\s*', prefix_pattern) old_style = False else: - old_style = mm_cfg.OLD_STYLE_PREFIXING + old_style = config.OLD_STYLE_PREFIXING subject = re.sub(prefix_pattern, '', subject) rematch = re.match('((RE|AW|SV|VS)(\[\d+\])?:\s*)+', subject, re.I) if rematch: diff --git a/Mailman/Handlers/Hold.py b/Mailman/Handlers/Hold.py index b82bbd51c..13a6c0130 100644 --- a/Mailman/Handlers/Hold.py +++ b/Mailman/Handlers/Hold.py @@ -37,11 +37,10 @@ from email.MIMEText import MIMEText from types import ClassType from Mailman import Errors -from Mailman import i18n -from Mailman import mm_cfg from Mailman import Message from Mailman import Pending from Mailman import Utils +from Mailman import i18n log = logging.getLogger('mailman.vette') diff --git a/Mailman/Handlers/MimeDel.py b/Mailman/Handlers/MimeDel.py index 5533f54e3..fbf313bbd 100644 --- a/Mailman/Handlers/MimeDel.py +++ b/Mailman/Handlers/MimeDel.py @@ -33,12 +33,12 @@ from email.Iterators import typed_subpart_iterator from os.path import splitext from Mailman import Errors -from Mailman import mm_cfg -from Mailman.i18n import _ from Mailman.Message import UserNotification from Mailman.Queue.sbcache import get_switchboard from Mailman.Utils import oneline from Mailman.Version import VERSION +from Mailman.configuration import config +from Mailman.i18n import _ log = logging.getLogger('mailman.error') @@ -103,7 +103,7 @@ def process(mlist, msg, msgdata): if numparts <> len([subpart for subpart in msg.walk()]): changedp = 1 # Now perhaps convert all text/html to text/plain - if mlist.convert_html_to_plaintext and mm_cfg.HTML_TO_PLAIN_TEXT_COMMAND: + if mlist.convert_html_to_plaintext and config.HTML_TO_PLAIN_TEXT_COMMAND: changedp += to_plaintext(msg) # If we're left with only two parts, an empty body and one attachment, # recast the message to one of just that part @@ -201,7 +201,7 @@ def to_plaintext(msg): try: fp.write(subpart.get_payload(decode=1)) fp.close() - cmd = os.popen(mm_cfg.HTML_TO_PLAIN_TEXT_COMMAND % + cmd = os.popen(config.HTML_TO_PLAIN_TEXT_COMMAND % {'filename': filename}) plaintext = cmd.read() rtn = cmd.close() @@ -239,8 +239,8 @@ are receiving the only remaining copy of the discarded message. """), subject=_('Content filtered message notification')) if mlist.filter_action == 3 and \ - mm_cfg.OWNERS_CAN_PRESERVE_FILTERED_MESSAGES: - badq = get_switchboard(mm_cfg.BADQUEUE_DIR) + config.OWNERS_CAN_PRESERVE_FILTERED_MESSAGES: + badq = get_switchboard(config.BADQUEUE_DIR) badq.enqueue(msg, msgdata) # Most cases also discard the message raise Errors.DiscardMessage diff --git a/Mailman/Handlers/Moderate.py b/Mailman/Handlers/Moderate.py index b96bd84e8..1e09d1b93 100644 --- a/Mailman/Handlers/Moderate.py +++ b/Mailman/Handlers/Moderate.py @@ -24,10 +24,10 @@ from email.MIMEText import MIMEText from Mailman import Errors from Mailman import Message -from Mailman import mm_cfg from Mailman import Utils -from Mailman.i18n import _ from Mailman.Handlers import Hold +from Mailman.configuration import config +from Mailman.i18n import _ @@ -56,7 +56,7 @@ def process(mlist, msg, msgdata): if sender: # If the member's moderation flag is on, then perform the moderation # action. - if mlist.getMemberOption(sender, mm_cfg.Moderate): + if mlist.getMemberOption(sender, config.Moderate): # Note that for member_moderation_action, 0==Hold, 1=Reject, # 2==Discard if mlist.member_moderation_action == 0: diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py index a1325c47a..0dc21d8c4 100644 --- a/Mailman/Handlers/Scrubber.py +++ b/Mailman/Handlers/Scrubber.py @@ -34,11 +34,11 @@ from email.Generator import Generator from email.Parser import HeaderParser from email.Utils import parsedate -from Mailman import Message -from Mailman import mm_cfg from Mailman import LockFile +from Mailman import Message from Mailman import Utils from Mailman.Errors import DiscardMessage +from Mailman.configuration import config from Mailman.i18n import _ # Path characters for common platforms @@ -149,7 +149,7 @@ def replace_payload_by_text(msg, text, charset): def process(mlist, msg, msgdata=None): - sanitize = mm_cfg.ARCHIVE_HTML_SANITIZER + sanitize = config.ARCHIVE_HTML_SANITIZER outer = True if msgdata is None: msgdata = {} @@ -391,7 +391,7 @@ def save_attachment(mlist, msg, dir, filter_html=True): fnext = os.path.splitext(filename)[1] # For safety, we should confirm this is valid ext for content-type # but we can use fnext if we introduce fnext filtering - if mm_cfg.SCRUBBER_USE_ATTACHMENT_FILENAME_EXTENSION: + if config.SCRUBBER_USE_ATTACHMENT_FILENAME_EXTENSION: # HTML message doesn't have filename :-( ext = fnext or guess_extension(ctype, fnext) else: @@ -414,7 +414,7 @@ def save_attachment(mlist, msg, dir, filter_html=True): # Now base the filename on what's in the attachment, uniquifying it if # necessary. filename = msg.get_filename() - if not filename or mm_cfg.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME: + if not filename or config.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME: filebase = 'attachment' else: # Sanitize the filename given in the message headers @@ -460,7 +460,7 @@ def save_attachment(mlist, msg, dir, filter_html=True): try: fp.write(decodedpayload) fp.close() - cmd = mm_cfg.ARCHIVE_HTML_SANITIZER % {'filename' : tmppath} + cmd = config.ARCHIVE_HTML_SANITIZER % {'filename' : tmppath} progfp = os.popen(cmd, 'r') decodedpayload = progfp.read() status = progfp.close() diff --git a/Mailman/Handlers/SpamDetect.py b/Mailman/Handlers/SpamDetect.py index a927d9b58..38e028c91 100644 --- a/Mailman/Handlers/SpamDetect.py +++ b/Mailman/Handlers/SpamDetect.py @@ -32,8 +32,8 @@ from email.Generator import Generator from Mailman import Errors from Mailman import i18n -from Mailman import mm_cfg from Mailman.Handlers.Hold import hold_for_approval +from Mailman.configuration import config # First, play footsie with _ so that the following are marked as translated, # but aren't actually translated until we need the text later on. @@ -89,7 +89,7 @@ def process(mlist, msg, msgdata): if msgdata.get('approved'): return # First do site hard coded header spam checks - for header, regex in mm_cfg.KNOWN_SPAMMERS: + for header, regex in config.KNOWN_SPAMMERS: cre = re.compile(regex, re.IGNORECASE) for value in msg.get_all(header, []): mo = cre.search(value) @@ -108,15 +108,15 @@ def process(mlist, msg, msgdata): headers = re.sub('\n+', '\n', headers) headers = re.sub('\n\s', ' ', headers) for patterns, action, empty in mlist.header_filter_rules: - if action == mm_cfg.DEFER: + if action == config.DEFER: continue for pattern in patterns.splitlines(): if pattern.startswith('#'): continue if re.search(pattern, headers, re.IGNORECASE|re.MULTILINE): - if action == mm_cfg.DISCARD: + if action == config.DISCARD: raise Errors.DiscardMessage - if action == mm_cfg.REJECT: + if action == config.REJECT: if msgdata.get('toowner'): # Don't send rejection notice if addressed to '-owner' # because it may trigger a loop of notices if the @@ -124,12 +124,12 @@ def process(mlist, msg, msgdata): raise Errors.DiscardMessage raise Errors.RejectMessage( _('Message rejected by filter rule match')) - if action == mm_cfg.HOLD: + if action == config.HOLD: if msgdata.get('toowner'): # Don't hold '-owner' addressed message. We just # pass it here but list-owner can set this to be # discarded on the GUI if he wants. return hold_for_approval(mlist, msg, msgdata, HeaderMatchHold) - if action == mm_cfg.ACCEPT: + if action == config.ACCEPT: return diff --git a/Mailman/Handlers/ToArchive.py b/Mailman/Handlers/ToArchive.py index 533f20126..fdfd34c40 100644 --- a/Mailman/Handlers/ToArchive.py +++ b/Mailman/Handlers/ToArchive.py @@ -20,8 +20,8 @@ import time from cStringIO import StringIO -from Mailman import mm_cfg from Mailman.Queue.sbcache import get_switchboard +from Mailman.configuration import config @@ -35,6 +35,6 @@ def process(mlist, msg, msgdata): if msg.has_key('x-no-archive') or msg.get('x-archive', '').lower() == 'no': return # Send the message to the archiver queue - archq = get_switchboard(mm_cfg.ARCHQUEUE_DIR) + archq = get_switchboard(config.ARCHQUEUE_DIR) # Send the message to the queue archq.enqueue(msg, msgdata) diff --git a/Mailman/Handlers/ToDigest.py b/Mailman/Handlers/ToDigest.py index 5c5d4105b..9d8cc1af0 100644 --- a/Mailman/Handlers/ToDigest.py +++ b/Mailman/Handlers/ToDigest.py @@ -42,16 +42,16 @@ from email.Parser import Parser from email.Utils import getaddresses, formatdate from Mailman import Errors -from Mailman import i18n from Mailman import Message -from Mailman import mm_cfg from Mailman import Utils +from Mailman import i18n from Mailman.Handlers.Decorate import decorate from Mailman.Handlers.Scrubber import process as scrubber from Mailman.Mailbox import Mailbox from Mailman.Mailbox import Mailbox from Mailman.MemberAdaptor import ENABLED from Mailman.Queue.sbcache import get_switchboard +from Mailman.configuration import config _ = i18n._ @@ -267,8 +267,8 @@ def send_i18n_digests(mlist, mboxfp): # for the specific MIME or plain digests. keeper = {} all_keepers = {} - for header in (mm_cfg.MIME_DIGEST_KEEP_HEADERS + - mm_cfg.PLAIN_DIGEST_KEEP_HEADERS): + for header in (config.MIME_DIGEST_KEEP_HEADERS + + config.PLAIN_DIGEST_KEEP_HEADERS): all_keepers[header] = True all_keepers = all_keepers.keys() for keep in all_keepers: @@ -321,7 +321,7 @@ def send_i18n_digests(mlist, mboxfp): print >> plainmsg, _('[Message discarded by content filter]') continue # Honor the default setting - for h in mm_cfg.PLAIN_DIGEST_KEEP_HEADERS: + for h in config.PLAIN_DIGEST_KEEP_HEADERS: if msg[h]: uh = Utils.wrap('%s: %s' % (h, Utils.oneline(msg[h], lcset))) uh = '\n\t'.join(uh.split('\n')) @@ -377,7 +377,7 @@ def send_i18n_digests(mlist, mboxfp): # Do our final bit of housekeeping, and then send each message to the # outgoing queue for delivery. mlist.next_digest_number += 1 - virginq = get_switchboard(mm_cfg.VIRGINQUEUE_DIR) + virginq = get_switchboard(config.VIRGINQUEUE_DIR) # Calculate the recipients lists plainrecips = [] mimerecips = [] @@ -389,7 +389,7 @@ def send_i18n_digests(mlist, mboxfp): if user is None or mlist.getDeliveryStatus(user) <> ENABLED: continue # Otherwise, decide whether they get MIME or RFC 1153 digests - if mlist.getMemberOption(user, mm_cfg.DisableMime): + if mlist.getMemberOption(user, config.DisableMime): plainrecips.append(user) else: mimerecips.append(user) diff --git a/Mailman/Handlers/ToOutgoing.py b/Mailman/Handlers/ToOutgoing.py index 7273c41b2..c29f83f76 100644 --- a/Mailman/Handlers/ToOutgoing.py +++ b/Mailman/Handlers/ToOutgoing.py @@ -1,18 +1,19 @@ -# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2006 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Re-queue the message to the outgoing queue. @@ -21,13 +22,13 @@ posted to the list membership. Anything else that needs to go out to some recipient should just be placed in the out queue directly. """ -from Mailman import mm_cfg from Mailman.Queue.sbcache import get_switchboard +from Mailman.configuration import config def process(mlist, msg, msgdata): - interval = mm_cfg.VERP_DELIVERY_INTERVAL + interval = config.VERP_DELIVERY_INTERVAL # Should we VERP this message? If personalization is enabled for this # list and VERP_PERSONALIZED_DELIVERIES is true, then yes we VERP it. # Also, if personalization is /not/ enabled, but VERP_DELIVERY_INTERVAL is @@ -39,17 +40,17 @@ def process(mlist, msg, msgdata): if msgdata.has_key('verp'): pass elif mlist.personalize: - if mm_cfg.VERP_PERSONALIZED_DELIVERIES: - msgdata['verp'] = 1 + if config.VERP_PERSONALIZED_DELIVERIES: + msgdata['verp'] = True elif interval == 0: # Never VERP pass elif interval == 1: # VERP every time - msgdata['verp'] = 1 + msgdata['verp'] = True else: - # VERP every `inteval' number of times - msgdata['verp'] = not int(mlist.post_id) % interval + # VERP every `interval' number of times + msgdata['verp'] = not (int(mlist.post_id) % interval) # And now drop the message in qfiles/out - outq = get_switchboard(mm_cfg.OUTQUEUE_DIR) + outq = get_switchboard(config.OUTQUEUE_DIR) outq.enqueue(msg, msgdata, listname=mlist.internal_name()) diff --git a/Mailman/Handlers/ToUsenet.py b/Mailman/Handlers/ToUsenet.py index b51c00a65..5ca926164 100644 --- a/Mailman/Handlers/ToUsenet.py +++ b/Mailman/Handlers/ToUsenet.py @@ -19,7 +19,7 @@ import logging -from Mailman import mm_cfg +from Mailman.configuration import config from Mailman.Queue.sbcache import get_switchboard COMMASPACE = ', ' @@ -45,5 +45,5 @@ def process(mlist, msg, msgdata): COMMASPACE.join(error)) return # Put the message in the news runner's queue - newsq = get_switchboard(mm_cfg.NEWSQUEUE_DIR) + newsq = get_switchboard(config.NEWSQUEUE_DIR) newsq.enqueue(msg, msgdata, listname=mlist.internal_name()) diff --git a/Mailman/ListAdmin.py b/Mailman/ListAdmin.py index 2e8fc1a42..84b97e2fd 100644 --- a/Mailman/ListAdmin.py +++ b/Mailman/ListAdmin.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Mixin class for MailList which handles administrative requests. @@ -37,12 +38,12 @@ from email.MIMEMessage import MIMEMessage from email.Utils import getaddresses from Mailman import Errors -from Mailman import i18n from Mailman import Message -from Mailman import mm_cfg from Mailman import Utils +from Mailman import i18n from Mailman.Queue.sbcache import get_switchboard from Mailman.UserDesc import UserDesc +from Mailman.configuration import config _ = i18n._ @@ -86,13 +87,13 @@ class ListAdmin: if e.errno <> errno.ENOENT: raise self.__db = {} # put version number in new database - self.__db['version'] = IGN, mm_cfg.REQUESTS_FILE_SCHEMA_VERSION + self.__db['version'] = IGN, config.REQUESTS_FILE_SCHEMA_VERSION def __closedb(self): if self.__db is not None: assert self.Locked() # Save the version number - self.__db['version'] = IGN, mm_cfg.REQUESTS_FILE_SCHEMA_VERSION + self.__db['version'] = IGN, config.REQUESTS_FILE_SCHEMA_VERSION # Now save a temp file and do the tmpfile->real file dance. BAW: # should we be as paranoid as for the config.pck file? Should we # use pickle? @@ -185,16 +186,16 @@ class ListAdmin: # get the message sender sender = msg.get_sender() # calculate the file name for the message text and write it to disk - if mm_cfg.HOLD_MESSAGES_AS_PICKLES: + if config.HOLD_MESSAGES_AS_PICKLES: ext = 'pck' else: ext = 'txt' filename = 'heldmsg-%s-%d.%s' % (self.internal_name(), id, ext) omask = os.umask(002) try: - fp = open(os.path.join(mm_cfg.DATA_DIR, filename), 'w') + fp = open(os.path.join(config.DATA_DIR, filename), 'w') try: - if mm_cfg.HOLD_MESSAGES_AS_PICKLES: + if config.HOLD_MESSAGES_AS_PICKLES: cPickle.dump(msg, fp, 1) else: g = Generator(fp) @@ -224,7 +225,7 @@ class ListAdmin: def __handlepost(self, record, value, comment, preserve, forward, addr): # For backwards compatibility with pre 2.0beta3 ptime, sender, subject, reason, filename, msgdata = record - path = os.path.join(mm_cfg.DATA_DIR, filename) + path = os.path.join(config.DATA_DIR, filename) # Handle message preservation if preserve: parts = os.path.split(path)[1].split(DASH) @@ -241,7 +242,7 @@ class ListAdmin: finally: fp.close() # Save the plain text to a .msg file, not a .pck file - outpath = os.path.join(mm_cfg.SPAM_DIR, spamfile) + outpath = os.path.join(config.SPAM_DIR, spamfile) head, ext = os.path.splitext(outpath) outpath = head + '.msg' outfp = open(outpath, 'w') @@ -255,10 +256,10 @@ class ListAdmin: fp = None msg = None status = REMOVE - if value == mm_cfg.DEFER: + if value == config.DEFER: # Defer status = DEFER - elif value == mm_cfg.APPROVE: + elif value == config.APPROVE: # Approved. try: msg = readMessage(path) @@ -283,16 +284,16 @@ class ListAdmin: msg.get('message-id', 'n/a')) # Stick the message back in the incoming queue for further # processing. - inq = get_switchboard(mm_cfg.INQUEUE_DIR) + inq = get_switchboard(config.INQUEUE_DIR) inq.enqueue(msg, _metadata=msgdata) - elif value == mm_cfg.REJECT: + elif value == config.REJECT: # Rejected rejection = 'Refused' self.__refuse(_('Posting of your message titled "%(subject)s"'), sender, comment or _('[No reason given]'), lang=self.getMemberLanguage(sender)) else: - assert value == mm_cfg.DISCARD + assert value == config.DISCARD # Discarded rejection = 'Discarded' # Forward the message @@ -401,17 +402,17 @@ class ListAdmin: def __handlesubscription(self, record, value, comment): stime, addr, fullname, password, digest, lang = record - if value == mm_cfg.DEFER: + if value == config.DEFER: return DEFER - elif value == mm_cfg.DISCARD: + elif value == config.DISCARD: pass - elif value == mm_cfg.REJECT: + elif value == config.REJECT: self.__refuse(_('Subscription request'), addr, comment or _('[No reason given]'), lang=lang) else: # subscribe - assert value == mm_cfg.SUBSCRIBE + assert value == config.SUBSCRIBE try: userdesc = UserDesc(addr, fullname, password, digest, lang) self.ApprovedAddMember(userdesc, whence='via admin approval') @@ -453,14 +454,14 @@ class ListAdmin: def __handleunsubscription(self, record, value, comment): addr = record - if value == mm_cfg.DEFER: + if value == config.DEFER: return DEFER - elif value == mm_cfg.DISCARD: + elif value == config.DISCARD: pass - elif value == mm_cfg.REJECT: + elif value == config.REJECT: self.__refuse(_('Unsubscription request'), addr, comment) else: - assert value == mm_cfg.UNSUBSCRIBE + assert value == config.UNSUBSCRIBE try: self.ApprovedDeleteMember(addr) except Errors.NotAMemberError: diff --git a/Mailman/Message.py b/Mailman/Message.py index b39bcb3fe..147ac073d 100644 --- a/Mailman/Message.py +++ b/Mailman/Message.py @@ -248,10 +248,10 @@ class UserNotification(Message): virginq = get_switchboard(config.VIRGINQUEUE_DIR) # The message metadata better have a `recip' attribute virginq.enqueue(self, - listname = mlist.internal_name(), - recips = self.recips, - nodecorate = 1, - reduced_list_headers = 1, + listname=mlist.internal_name(), + recips=self.recips, + nodecorate=True, + reduced_list_headers=True, **_kws) @@ -279,9 +279,9 @@ class OwnerNotification(UserNotification): virginq = get_switchboard(config.VIRGINQUEUE_DIR) # The message metadata better have a `recip' attribute virginq.enqueue(self, - listname = mlist.internal_name(), - recips = self.recips, - nodecorate = 1, - reduced_list_headers = 1, - envsender = self._sender, + listname=mlist.internal_name(), + recips=self.recips, + nodecorate=True, + reduced_list_headers=True, + envsender=self._sender, **_kws) diff --git a/Mailman/bin/mailmanctl.py b/Mailman/bin/mailmanctl.py index a91b5651b..0c83e3324 100644 --- a/Mailman/bin/mailmanctl.py +++ b/Mailman/bin/mailmanctl.py @@ -164,7 +164,7 @@ def kill_watcher(sig): def get_lock_data(): # Return the hostname, pid, and tempfile - fp = open(config.LOCKFILE) + fp = open(config.LOCK_FILE) try: filename = os.path.split(fp.read().strip())[1] finally: @@ -205,7 +205,7 @@ def acquire_lock_1(force): # Force removal of lock first lock._disown() hostname, pid, tempfile = get_lock_data() - os.unlink(config.LOCKFILE) + os.unlink(config.LOCK_FILE) os.unlink(os.path.join(config.LOCK_DIR, tempfile)) return acquire_lock_1(force=False) @@ -236,7 +236,7 @@ process on some other host may have acquired it. We can't test for stale locks across host boundaries, so you'll have to do this manually. Or, if you know the lock is stale, re-run mailmanctl with the -s flag. -Lock file: $config.LOCKFILE +Lock file: $config.LOCK_FILE Lock host: $status Exiting.""") @@ -255,7 +255,10 @@ def start_runner(qrname, slice, count): exe = os.path.join(config.BIN_DIR, 'qrunner') # config.PYTHON, which is the absolute path to the Python interpreter, # must be given as argv[0] due to Python's library search algorithm. - os.execl(config.PYTHON, config.PYTHON, exe, rswitch, '-s') + args = [config.PYTHON, config.PYTHON, exe, rswitch, '-s'] + if opts.config: + args.extend(['-C', opts.config]) + os.execl(*args) # Should never get here raise RuntimeError, 'os.execl() failed' @@ -304,7 +307,7 @@ def check_privs(): def main(): - global elog, qlog + global elog, qlog, opts parser, opts, args = parseargs() config.load(opts.config) diff --git a/Mailman/bin/testall.py b/Mailman/bin/testall.py index dae46b7ff..61b1cc7c7 100644 --- a/Mailman/bin/testall.py +++ b/Mailman/bin/testall.py @@ -23,8 +23,9 @@ import sys import optparse import unittest +from Mailman import Version from Mailman import loginit -from Mailman import mm_cfg +from Mailman.configuration import config from Mailman.i18n import _ __i18n_templates__ = True @@ -43,7 +44,7 @@ def v_callback(option, opt, value, parser): def parseargs(): - parser = optparse.OptionParser(version=mm_cfg.MAILMAN_VERSION, + parser = optparse.OptionParser(version=Version.MAILMAN_VERSION, usage=_("""\ %prog [options] [tests] @@ -63,6 +64,8 @@ Reduce verbosity by 1 (but not below 0).""")) parser.add_option('-e', '--stderr', default=False, action='store_true', help=_('Propagate log errors to stderr.')) + parser.add_option('-C', '--config', + help=_('Alternative configuration file to use')) opts, args = parser.parse_args() return parser, opts, args @@ -135,6 +138,7 @@ def main(): global basedir parser, opts, args = parseargs() + config.load(opts.config) if not args: args = ['.'] loginit.initialize(propagate=opts.stderr) diff --git a/Mailman/testing/base.py b/Mailman/testing/base.py index 83a8044d3..76c7243af 100644 --- a/Mailman/testing/base.py +++ b/Mailman/testing/base.py @@ -26,7 +26,7 @@ from cStringIO import StringIO from Mailman import MailList from Mailman import Utils -from Mailman import mm_cfg +from Mailman.configuration import config NL = '\n' @@ -61,7 +61,7 @@ class TestBase(unittest.TestCase): 'archives/public/%s', 'archives/public/%s.mbox', ]: - dir = os.path.join(mm_cfg.VAR_PREFIX, dirtmpl % listname) + dir = os.path.join(config.VAR_PREFIX, dirtmpl % listname) if os.path.islink(dir): os.unlink(dir) elif os.path.isdir(dir): diff --git a/Mailman/testing/emailbase.py b/Mailman/testing/emailbase.py index 6c290c8e5..c062ea08a 100644 --- a/Mailman/testing/emailbase.py +++ b/Mailman/testing/emailbase.py @@ -18,16 +18,18 @@ """Base class for tests that email things.""" import os +import stat import smtpd import socket import asyncore import tempfile import subprocess -from Mailman import mm_cfg +from Mailman.configuration import config from Mailman.testing.base import TestBase -TESTPORT = 10825 +TESTPORT = 10825 +PERMISSIONS = stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH @@ -57,16 +59,18 @@ class EmailBase(TestBase): # configuration file that causes the underlying outgoing runner to use # the same port, then start Mailman. fd, self._configfile = tempfile.mkstemp(suffix='.cfg') - print 'config file:', self._configfile fp = os.fdopen(fd, 'w') print >> fp, 'SMTPPORT =', TESTPORT + config.SMTPPORT = TESTPORT fp.close() + # Loosen up the permissions + os.chmod(self._configfile, PERMISSIONS) # Second argument is ignored. self._server = SinkServer(('localhost', TESTPORT), None) - os.system('bin/mailmanctl start') + os.system('bin/mailmanctl -C %s -q start' % self._configfile) def tearDown(self): - os.system('bin/mailmanctl stop') + os.system('bin/mailmanctl -C %s -q stop' % self._configfile) self._server.close() TestBase.tearDown(self) os.remove(self._configfile) @@ -80,7 +84,7 @@ class EmailBase(TestBase): try: try: # timeout is in milliseconds, see asyncore.py poll3() - asyncore.loop(timeout=30.0) + asyncore.loop() MSGTEXT = None except asyncore.ExitNow: pass diff --git a/Mailman/testing/test_handlers.py b/Mailman/testing/test_handlers.py index 056fde1c0..630d08286 100644 --- a/Mailman/testing/test_handlers.py +++ b/Mailman/testing/test_handlers.py @@ -29,9 +29,10 @@ from email.Generator import Generator from Mailman import Errors from Mailman import Message -from Mailman import mm_cfg +from Mailman import Version from Mailman.MailList import MailList from Mailman.Queue.Switchboard import Switchboard +from Mailman.configuration import config from Mailman.testing.base import TestBase from Mailman.Handlers import Acknowledge @@ -65,14 +66,14 @@ class TestAcknowledge(TestBase): def setUp(self): TestBase.setUp(self) # We're going to want to inspect this queue directory - self._sb = Switchboard(mm_cfg.VIRGINQUEUE_DIR) + self._sb = Switchboard(config.VIRGINQUEUE_DIR) # Add a member self._mlist.addNewMember('aperson@dom.ain') self._mlist.personalize = False def tearDown(self): - for f in os.listdir(mm_cfg.VIRGINQUEUE_DIR): - os.unlink(os.path.join(mm_cfg.VIRGINQUEUE_DIR, f)) + for f in os.listdir(config.VIRGINQUEUE_DIR): + os.unlink(os.path.join(config.VIRGINQUEUE_DIR, f)) TestBase.tearDown(self) def test_no_ack_msgdata(self): @@ -112,7 +113,7 @@ From: aperson@dom.ain def test_ack_no_subject(self): eq = self.assertEqual self._mlist.setMemberOption( - 'aperson@dom.ain', mm_cfg.AcknowledgePosts, 1) + 'aperson@dom.ain', config.AcknowledgePosts, 1) eq(len(self._sb.files()), 0) msg = email.message_from_string("""\ From: aperson@dom.ain @@ -151,7 +152,7 @@ Your preferences: http://www.dom.ain/mailman/options/_xtest/aperson%40dom.ain def test_ack_with_subject(self): eq = self.assertEqual self._mlist.setMemberOption( - 'aperson@dom.ain', mm_cfg.AcknowledgePosts, 1) + 'aperson@dom.ain', config.AcknowledgePosts, 1) eq(len(self._sb.files()), 0) msg = email.message_from_string("""\ From: aperson@dom.ain @@ -317,7 +318,7 @@ From: cperson@dom.ain """, Message.Message) self._mlist.setMemberOption('cperson@dom.ain', - mm_cfg.DontReceiveOwnPosts, 1) + config.DontReceiveOwnPosts, 1) CalcRecips.process(self._mlist, msg, msgdata) self.failUnless(msgdata.has_key('recips')) recips = msgdata['recips'] @@ -494,7 +495,7 @@ From: aperson@dom.ain """, Message.Message) CookHeaders.process(self._mlist, msg, {}) - eq(msg['x-mailman-version'], mm_cfg.VERSION) + eq(msg['x-mailman-version'], Version.VERSION) def test_existing_mmversion(self): eq = self.assertEqual @@ -680,12 +681,12 @@ From: aperson@dom.ain From: aperson@dom.ain """, Message.Message) - oldval = mm_cfg.DEFAULT_URL_HOST - mm_cfg.DEFAULT_URL_HOST = 'www.dom.ain' + oldval = config.DEFAULT_URL_HOST + config.DEFAULT_URL_HOST = 'www.dom.ain' try: CookHeaders.process(self._mlist, msg, {}) finally: - mm_cfg.DEFAULT_URL_HOST = oldval + config.DEFAULT_URL_HOST = oldval eq(msg['list-id'], '<_xtest.dom.ain>') eq(msg['list-help'], '<mailto:_xtest-request@dom.ain?subject=help>') eq(msg['list-unsubscribe'], @@ -972,19 +973,19 @@ class TestHold(TestBase): self._mlist.respond_to_post_requests = 0 self._mlist.admin_immed_notify = 0 # We're going to want to inspect this queue directory - self._sb = Switchboard(mm_cfg.VIRGINQUEUE_DIR) + self._sb = Switchboard(config.VIRGINQUEUE_DIR) def tearDown(self): - for f in os.listdir(mm_cfg.VIRGINQUEUE_DIR): - os.unlink(os.path.join(mm_cfg.VIRGINQUEUE_DIR, f)) + for f in os.listdir(config.VIRGINQUEUE_DIR): + os.unlink(os.path.join(config.VIRGINQUEUE_DIR, f)) TestBase.tearDown(self) try: - os.unlink(os.path.join(mm_cfg.DATA_DIR, 'pending.db')) + os.unlink(os.path.join(config.DATA_DIR, 'pending.db')) except OSError, e: if e.errno <> errno.ENOENT: raise - for f in [holdfile for holdfile in os.listdir(mm_cfg.DATA_DIR) + for f in [holdfile for holdfile in os.listdir(config.DATA_DIR) if holdfile.startswith('heldmsg-')]: - os.unlink(os.path.join(mm_cfg.DATA_DIR, f)) + os.unlink(os.path.join(config.DATA_DIR, f)) def test_short_circuit(self): msgdata = {'approved': 1} @@ -1114,10 +1115,10 @@ From: aperson@dom.ain # for the hold message. data = self._mlist.pend_confirm(cookie) eq(data, ('H', 1)) - heldmsg = os.path.join(mm_cfg.DATA_DIR, 'heldmsg-_xtest-1.pck') + heldmsg = os.path.join(config.DATA_DIR, 'heldmsg-_xtest-1.pck') self.failUnless(os.path.exists(heldmsg)) os.unlink(heldmsg) - holdfiles = [f for f in os.listdir(mm_cfg.DATA_DIR) + holdfiles = [f for f in os.listdir(config.DATA_DIR) if f.startswith('heldmsg-')] eq(len(holdfiles), 0) @@ -1205,7 +1206,7 @@ yyy eq = self.assertEqual # XXX Skip this test if the html->text converter program is not # available. - program = mm_cfg.HTML_TO_PLAIN_TEXT_COMMAND.split()[0] + program = config.HTML_TO_PLAIN_TEXT_COMMAND.split()[0] if os.path.isfile(program): msg = email.message_from_string("""\ From: aperson@dom.ain @@ -1325,15 +1326,15 @@ To: xlist@dom.ain A message. """) - spammers = mm_cfg.KNOWN_SPAMMERS[:] + spammers = config.KNOWN_SPAMMERS[:] try: - mm_cfg.KNOWN_SPAMMERS.append(('from', '.?person')) + config.KNOWN_SPAMMERS.append(('from', '.?person')) self.assertRaises(SpamDetect.SpamDetected, SpamDetect.process, self._mlist, msg1, {}) rtn = SpamDetect.process(self._mlist, msg2, {}) self.assertEqual(rtn, None) finally: - mm_cfg.KNOWN_SPAMMERS = spammers + config.KNOWN_SPAMMERS = spammers @@ -1456,11 +1457,11 @@ class TestToArchive(TestBase): def setUp(self): TestBase.setUp(self) # We're going to want to inspect this queue directory - self._sb = Switchboard(mm_cfg.ARCHQUEUE_DIR) + self._sb = Switchboard(config.ARCHQUEUE_DIR) def tearDown(self): - for f in os.listdir(mm_cfg.ARCHQUEUE_DIR): - os.unlink(os.path.join(mm_cfg.ARCHQUEUE_DIR, f)) + for f in os.listdir(config.ARCHQUEUE_DIR): + os.unlink(os.path.join(config.ARCHQUEUE_DIR, f)) TestBase.tearDown(self) def test_short_circuit(self): @@ -1525,15 +1526,15 @@ Here is message %(i)d for i in range(5): g.flatten(self._makemsg(i), unixfrom=1) fp.close() - self._sb = Switchboard(mm_cfg.VIRGINQUEUE_DIR) + self._sb = Switchboard(config.VIRGINQUEUE_DIR) def tearDown(self): try: os.unlink(self._path) except OSError, e: if e.errno <> errno.ENOENT: raise - for f in os.listdir(mm_cfg.VIRGINQUEUE_DIR): - os.unlink(os.path.join(mm_cfg.VIRGINQUEUE_DIR, f)) + for f in os.listdir(config.VIRGINQUEUE_DIR): + os.unlink(os.path.join(config.VIRGINQUEUE_DIR, f)) TestBase.tearDown(self) def test_short_circuit(self): @@ -1591,16 +1592,16 @@ class TestToOutgoing(TestBase): def setUp(self): TestBase.setUp(self) # We're going to want to inspect this queue directory - self._sb = Switchboard(mm_cfg.OUTQUEUE_DIR) + self._sb = Switchboard(config.OUTQUEUE_DIR) # Save and set this value - self._interval = mm_cfg.VERP_DELIVERY_INTERVAL - mm_cfg.VERP_DELIVERY_INTERVAL = 1 + self._interval = config.VERP_DELIVERY_INTERVAL + config.VERP_DELIVERY_INTERVAL = 1 def tearDown(self): # Restore this value - mm_cfg.VERP_DELIVERY_INTERVAL = self._interval - for f in os.listdir(mm_cfg.OUTQUEUE_DIR): - os.unlink(os.path.join(mm_cfg.OUTQUEUE_DIR, f)) + config.VERP_DELIVERY_INTERVAL = self._interval + for f in os.listdir(config.OUTQUEUE_DIR): + os.unlink(os.path.join(config.OUTQUEUE_DIR, f)) TestBase.tearDown(self) def test_outgoing(self): @@ -1631,11 +1632,11 @@ class TestToUsenet(TestBase): def setUp(self): TestBase.setUp(self) # We're going to want to inspect this queue directory - self._sb = Switchboard(mm_cfg.NEWSQUEUE_DIR) + self._sb = Switchboard(config.NEWSQUEUE_DIR) def tearDown(self): - for f in os.listdir(mm_cfg.NEWSQUEUE_DIR): - os.unlink(os.path.join(mm_cfg.NEWSQUEUE_DIR, f)) + for f in os.listdir(config.NEWSQUEUE_DIR): + os.unlink(os.path.join(config.NEWSQUEUE_DIR, f)) TestBase.tearDown(self) def test_short_circuit(self): diff --git a/Mailman/testing/test_membership.py b/Mailman/testing/test_membership.py index d6f4343d2..b98e1b187 100644 --- a/Mailman/testing/test_membership.py +++ b/Mailman/testing/test_membership.py @@ -24,9 +24,9 @@ import unittest from Mailman import MailList from Mailman import MemberAdaptor from Mailman import Utils -from Mailman import mm_cfg from Mailman.Errors import NotAMemberError from Mailman.UserDesc import UserDesc +from Mailman.configuration import config from Mailman.testing.base import TestBase @@ -49,7 +49,7 @@ class TestNoMembers(TestBase): 'nobody@dom.ain', 'blarg') eq(mlist.getMemberLanguage('nobody@dom.ain'), mlist.preferred_language) raises(NotAMemberError, mlist.getMemberOption, - 'nobody@dom.ain', mm_cfg.AcknowledgePosts) + 'nobody@dom.ain', config.AcknowledgePosts) raises(NotAMemberError, mlist.getMemberName, 'nobody@dom.ain') raises(NotAMemberError, mlist.getMemberTopics, 'nobody@dom.ain') raises(NotAMemberError, mlist.removeMember, 'nobody@dom.ain') @@ -97,8 +97,8 @@ class TestMembers(TestBase): ['person@dom.ain', None]) eq(mlist.getMemberPassword('person@dom.ain'), 'xxXXxx') eq(mlist.getMemberLanguage('person@dom.ain'), 'en') - eq(mlist.getMemberOption('person@dom.ain', mm_cfg.Digests), 0) - eq(mlist.getMemberOption('person@dom.ain', mm_cfg.AcknowledgePosts), 0) + eq(mlist.getMemberOption('person@dom.ain', config.Digests), 0) + eq(mlist.getMemberOption('person@dom.ain', config.AcknowledgePosts), 0) eq(mlist.getMemberName('person@dom.ain'), 'A. Nice Person') eq(mlist.getMemberTopics('person@dom.ain'), []) @@ -126,7 +126,7 @@ class TestMembers(TestBase): 'person@dom.ain', 'blarg') eq(mlist.getMemberLanguage('person@dom.ain'), mlist.preferred_language) raises(NotAMemberError, mlist.getMemberOption, - 'person@dom.ain', mm_cfg.AcknowledgePosts) + 'person@dom.ain', config.AcknowledgePosts) raises(NotAMemberError, mlist.getMemberName, 'person@dom.ain') raises(NotAMemberError, mlist.getMemberTopics, 'person@dom.ain') @@ -163,8 +163,8 @@ class TestMembers(TestBase): ['nice@dom.ain', None]) eq(mlist.getMemberPassword('nice@dom.ain'), 'xxXXxx') eq(mlist.getMemberLanguage('nice@dom.ain'), 'en') - eq(mlist.getMemberOption('nice@dom.ain', mm_cfg.Digests), 0) - eq(mlist.getMemberOption('nice@dom.ain', mm_cfg.AcknowledgePosts), 0) + eq(mlist.getMemberOption('nice@dom.ain', config.Digests), 0) + eq(mlist.getMemberOption('nice@dom.ain', config.AcknowledgePosts), 0) eq(mlist.getMemberName('nice@dom.ain'), 'A. Nice Person') eq(mlist.getMemberTopics('nice@dom.ain'), []) # Check the old address @@ -181,7 +181,7 @@ class TestMembers(TestBase): 'person@dom.ain', 'blarg') eq(mlist.getMemberLanguage('person@dom.ain'), mlist.preferred_language) raises(NotAMemberError, mlist.getMemberOption, - 'person@dom.ain', mm_cfg.AcknowledgePosts) + 'person@dom.ain', config.AcknowledgePosts) raises(NotAMemberError, mlist.getMemberName, 'person@dom.ain') raises(NotAMemberError, mlist.getMemberTopics, 'person@dom.ain') @@ -195,41 +195,41 @@ class TestMembers(TestBase): def test_set_language(self): # This test requires that the 'xx' language be in the global - # mm_cfg.LC_DESCRIPTIONS. Save that value and be sure to restore it + # config.LC_DESCRIPTIONS. Save that value and be sure to restore it # after the test is done. - odesc = mm_cfg.LC_DESCRIPTIONS.copy() + odesc = config.LC_DESCRIPTIONS.copy() try: - mm_cfg.add_language('xx', 'Xxian', 'utf-8') + config.add_language('xx', 'Xxian', 'utf-8') self._mlist.available_languages.append('xx') self._mlist.setMemberLanguage('person@dom.ain', 'xx') self.assertEqual(self._mlist.getMemberLanguage('person@dom.ain'), 'xx') finally: - mm_cfg.LC_DESCRIPTIONS = odesc + config.LC_DESCRIPTIONS = odesc def test_basic_option(self): eq = self.assertEqual gmo = self._mlist.getMemberOption # First test the current option values - eq(gmo('person@dom.ain', mm_cfg.Digests), 0) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 0) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 0) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 0) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 0) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 0) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 0) + eq(gmo('person@dom.ain', config.Digests), 0) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 0) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 0) + eq(gmo('person@dom.ain', config.DisableMime), 0) + eq(gmo('person@dom.ain', config.ConcealSubscription), 0) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 0) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 0) def test_set_digests(self): eq = self.assertEqual gmo = self._mlist.getMemberOption - self._mlist.setMemberOption('person@dom.ain', mm_cfg.Digests, 1) - eq(gmo('person@dom.ain', mm_cfg.Digests), 1) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 0) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 0) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 0) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 0) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 0) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 0) + self._mlist.setMemberOption('person@dom.ain', config.Digests, 1) + eq(gmo('person@dom.ain', config.Digests), 1) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 0) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 0) + eq(gmo('person@dom.ain', config.DisableMime), 0) + eq(gmo('person@dom.ain', config.ConcealSubscription), 0) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 0) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 0) def test_set_disable_delivery(self): eq = self.assertEqual @@ -260,79 +260,79 @@ class TestMembers(TestBase): eq = self.assertEqual gmo = self._mlist.getMemberOption self._mlist.setMemberOption('person@dom.ain', - mm_cfg.DontReceiveOwnPosts, 1) - eq(gmo('person@dom.ain', mm_cfg.Digests), 0) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 1) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 0) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 0) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 0) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 0) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 0) + config.DontReceiveOwnPosts, 1) + eq(gmo('person@dom.ain', config.Digests), 0) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 1) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 0) + eq(gmo('person@dom.ain', config.DisableMime), 0) + eq(gmo('person@dom.ain', config.ConcealSubscription), 0) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 0) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 0) def test_set_acknowledge_posts(self): eq = self.assertEqual gmo = self._mlist.getMemberOption self._mlist.setMemberOption('person@dom.ain', - mm_cfg.AcknowledgePosts, 1) - eq(gmo('person@dom.ain', mm_cfg.Digests), 0) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 0) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 1) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 0) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 0) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 0) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 0) + config.AcknowledgePosts, 1) + eq(gmo('person@dom.ain', config.Digests), 0) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 0) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 1) + eq(gmo('person@dom.ain', config.DisableMime), 0) + eq(gmo('person@dom.ain', config.ConcealSubscription), 0) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 0) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 0) def test_disable_mime(self): eq = self.assertEqual gmo = self._mlist.getMemberOption self._mlist.setMemberOption('person@dom.ain', - mm_cfg.DisableMime, 1) - eq(gmo('person@dom.ain', mm_cfg.Digests), 0) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 0) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 0) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 1) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 0) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 0) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 0) + config.DisableMime, 1) + eq(gmo('person@dom.ain', config.Digests), 0) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 0) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 0) + eq(gmo('person@dom.ain', config.DisableMime), 1) + eq(gmo('person@dom.ain', config.ConcealSubscription), 0) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 0) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 0) def test_conceal_subscription(self): eq = self.assertEqual gmo = self._mlist.getMemberOption self._mlist.setMemberOption('person@dom.ain', - mm_cfg.ConcealSubscription, 1) - eq(gmo('person@dom.ain', mm_cfg.Digests), 0) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 0) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 0) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 0) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 1) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 0) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 0) + config.ConcealSubscription, 1) + eq(gmo('person@dom.ain', config.Digests), 0) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 0) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 0) + eq(gmo('person@dom.ain', config.DisableMime), 0) + eq(gmo('person@dom.ain', config.ConcealSubscription), 1) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 0) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 0) def test_suppress_password_reminder(self): eq = self.assertEqual gmo = self._mlist.getMemberOption self._mlist.setMemberOption('person@dom.ain', - mm_cfg.SuppressPasswordReminder, 1) - eq(gmo('person@dom.ain', mm_cfg.Digests), 0) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 0) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 0) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 0) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 0) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 1) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 0) + config.SuppressPasswordReminder, 1) + eq(gmo('person@dom.ain', config.Digests), 0) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 0) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 0) + eq(gmo('person@dom.ain', config.DisableMime), 0) + eq(gmo('person@dom.ain', config.ConcealSubscription), 0) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 1) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 0) def test_receive_nonmatching_topics(self): eq = self.assertEqual gmo = self._mlist.getMemberOption self._mlist.setMemberOption('person@dom.ain', - mm_cfg.ReceiveNonmatchingTopics, 1) - eq(gmo('person@dom.ain', mm_cfg.Digests), 0) - eq(gmo('person@dom.ain', mm_cfg.DontReceiveOwnPosts), 0) - eq(gmo('person@dom.ain', mm_cfg.AcknowledgePosts), 0) - eq(gmo('person@dom.ain', mm_cfg.DisableMime), 0) - eq(gmo('person@dom.ain', mm_cfg.ConcealSubscription), 0) - eq(gmo('person@dom.ain', mm_cfg.SuppressPasswordReminder), 0) - eq(gmo('person@dom.ain', mm_cfg.ReceiveNonmatchingTopics), 1) + config.ReceiveNonmatchingTopics, 1) + eq(gmo('person@dom.ain', config.Digests), 0) + eq(gmo('person@dom.ain', config.DontReceiveOwnPosts), 0) + eq(gmo('person@dom.ain', config.AcknowledgePosts), 0) + eq(gmo('person@dom.ain', config.DisableMime), 0) + eq(gmo('person@dom.ain', config.ConcealSubscription), 0) + eq(gmo('person@dom.ain', config.SuppressPasswordReminder), 0) + eq(gmo('person@dom.ain', config.ReceiveNonmatchingTopics), 1) def test_member_name(self): self._mlist.setMemberName('person@dom.ain', 'A. Good Person') diff --git a/Mailman/testing/test_message.py b/Mailman/testing/test_message.py index 93e0525e9..504adfc9e 100644 --- a/Mailman/testing/test_message.py +++ b/Mailman/testing/test_message.py @@ -45,21 +45,22 @@ class TestSentMessage(EmailBase): msgid = qmsg['message-id'] unless(msgid.startswith('<mailman.')) unless(msgid.endswith('._xtest@dom.ain>')) - eq(qmsg['sender'], '_xtest-admin@dom.ain') - eq(qmsg['errors-to'], '_xtest-admin@dom.ain') + eq(qmsg['sender'], '_xtest-bounces@dom.ain') + eq(qmsg['errors-to'], '_xtest-bounces@dom.ain') eq(qmsg['x-beenthere'], '_xtest@dom.ain') eq(qmsg['x-mailman-version'], Version.VERSION) eq(qmsg['precedence'], 'bulk') + # UserNotifications have reduced_list_headers so it won't have + # List-Help, List-Subscribe, or List-Unsubscribe. XXX Why would that + # possibly be? eq(qmsg['list-help'], '<mailto:_xtest-request@dom.ain?subject=help>') - eq(qmsg['list-post'], '<mailto:_xtest@dom.ain>') eq(qmsg['list-subscribe'], """\ <http://www.dom.ain/mailman/listinfo/_xtest>, - <mailto:_xtest-request@dom.ain?subject=subscribe>""") +\t<mailto:_xtest-request@dom.ain?subject=subscribe>""") eq(qmsg['list-id'], '<_xtest.dom.ain>') eq(qmsg['list-unsubscribe'], """\ <http://www.dom.ain/mailman/listinfo/_xtest>, - <mailto:_xtest-request@dom.ain?subject=unsubscribe>""") - eq(qmsg['list-archive'], '<http://www.dom.ain/pipermail/_xtest>') +\t<mailto:_xtest-request@dom.ain?subject=unsubscribe>""") eq(qmsg.get_payload(), 'About your test list') def test_bounce_message(self): @@ -81,11 +82,11 @@ yadda yadda yadda # message. msg1 = qmsg.get_payload(0) eq(msg1.get_type(), 'text/plain') - eq(msg1.get_payload(), '[No bounce details are available]\n') + eq(msg1.get_payload(), '[No bounce details are available]') msg2 = qmsg.get_payload(1) eq(msg2.get_type(), 'message/rfc822') - unless(not msg2.is_multipart()) - msg3 = msg2.get_payload() + unless(msg2.is_multipart()) + msg3 = msg2.get_payload(0) eq(msg3.get_payload(), 'yadda yadda yadda\n') diff --git a/Mailman/testing/test_security_mgr.py b/Mailman/testing/test_security_mgr.py index 700167358..ea7db5d9f 100644 --- a/Mailman/testing/test_security_mgr.py +++ b/Mailman/testing/test_security_mgr.py @@ -34,7 +34,7 @@ from StringIO import StringIO from Mailman import Errors from Mailman import Utils -from Mailman import mm_cfg +from Mailman.configuration import config from Mailman.testing.base import TestBase @@ -52,32 +52,32 @@ class TestSecurityManager(TestBase): def test_auth_context_info_authuser(self): mlist = self._mlist - self.assertRaises(TypeError, mlist.AuthContextInfo, mm_cfg.AuthUser) + self.assertRaises(TypeError, mlist.AuthContextInfo, config.AuthUser) # Add a member mlist.addNewMember('aperson@dom.ain', password='xxXXxx') self.assertEqual( - mlist.AuthContextInfo(mm_cfg.AuthUser, 'aperson@dom.ain'), + mlist.AuthContextInfo(config.AuthUser, 'aperson@dom.ain'), ('_xtest+user+aperson--at--dom.ain', 'xxXXxx')) def test_auth_context_moderator(self): mlist = self._mlist mlist.mod_password = 'yyYYyy' self.assertEqual( - mlist.AuthContextInfo(mm_cfg.AuthListModerator), + mlist.AuthContextInfo(config.AuthListModerator), ('_xtest+moderator', 'yyYYyy')) def test_auth_context_admin(self): mlist = self._mlist mlist.password = 'zzZZzz' self.assertEqual( - mlist.AuthContextInfo(mm_cfg.AuthListAdmin), + mlist.AuthContextInfo(config.AuthListAdmin), ('_xtest+admin', 'zzZZzz')) def test_auth_context_site(self): mlist = self._mlist mlist.password = 'aaAAaa' self.assertEqual( - mlist.AuthContextInfo(mm_cfg.AuthSiteAdmin), + mlist.AuthContextInfo(config.AuthSiteAdmin), ('_xtest+admin', 'aaAAaa')) def test_auth_context_huh(self): @@ -95,53 +95,53 @@ class TestAuthenticate(TestBase): def tearDown(self): try: - os.unlink(mm_cfg.SITE_PW_FILE) + os.unlink(config.SITE_PW_FILE) except OSError, e: if e.errno <> errno.ENOENT: raise try: - os.unlink(mm_cfg.LISTCREATOR_PW_FILE) + os.unlink(config.LISTCREATOR_PW_FILE) except OSError, e: if e.errno <> errno.ENOENT: raise TestBase.tearDown(self) def test_auth_creator(self): self.assertEqual(self._mlist.Authenticate( - [mm_cfg.AuthCreator], 'ccCCcc'), mm_cfg.AuthCreator) + [config.AuthCreator], 'ccCCcc'), config.AuthCreator) def test_auth_creator_unauth(self): self.assertEqual(self._mlist.Authenticate( - [mm_cfg.AuthCreator], 'xxxxxx'), mm_cfg.UnAuthorized) + [config.AuthCreator], 'xxxxxx'), config.UnAuthorized) def test_auth_site_admin(self): self.assertEqual(self._mlist.Authenticate( - [mm_cfg.AuthSiteAdmin], 'bbBBbb'), mm_cfg.AuthSiteAdmin) + [config.AuthSiteAdmin], 'bbBBbb'), config.AuthSiteAdmin) def test_auth_site_admin_unauth(self): self.assertEqual(self._mlist.Authenticate( - [mm_cfg.AuthSiteAdmin], 'xxxxxx'), mm_cfg.UnAuthorized) + [config.AuthSiteAdmin], 'xxxxxx'), config.UnAuthorized) def test_list_admin(self): self._mlist.password = password('ttTTtt') self.assertEqual(self._mlist.Authenticate( - [mm_cfg.AuthListAdmin], 'ttTTtt'), mm_cfg.AuthListAdmin) + [config.AuthListAdmin], 'ttTTtt'), config.AuthListAdmin) def test_list_admin_unauth(self): self._mlist.password = password('ttTTtt') self.assertEqual(self._mlist.Authenticate( - [mm_cfg.AuthListAdmin], 'xxxxxx'), mm_cfg.UnAuthorized) + [config.AuthListAdmin], 'xxxxxx'), config.UnAuthorized) def test_list_admin_upgrade(self): eq = self.assertEqual mlist = self._mlist mlist.password = md5.new('ssSSss').digest() eq(mlist.Authenticate( - [mm_cfg.AuthListAdmin], 'ssSSss'), mm_cfg.AuthListAdmin) + [config.AuthListAdmin], 'ssSSss'), config.AuthListAdmin) eq(mlist.password, password('ssSSss')) # Test crypt upgrades if crypt is supported if crypt: mlist.password = crypt.crypt('rrRRrr', 'zc') eq(self._mlist.Authenticate( - [mm_cfg.AuthListAdmin], 'rrRRrr'), mm_cfg.AuthListAdmin) + [config.AuthListAdmin], 'rrRRrr'), config.AuthListAdmin) eq(mlist.password, password('rrRRrr')) def test_list_admin_oldstyle_unauth(self): @@ -149,45 +149,45 @@ class TestAuthenticate(TestBase): mlist = self._mlist mlist.password = md5.new('ssSSss').digest() eq(mlist.Authenticate( - [mm_cfg.AuthListAdmin], 'xxxxxx'), mm_cfg.UnAuthorized) + [config.AuthListAdmin], 'xxxxxx'), config.UnAuthorized) eq(mlist.password, md5.new('ssSSss').digest()) # Test crypt upgrades if crypt is supported if crypt: mlist.password = crypted = crypt.crypt('rrRRrr', 'zc') eq(self._mlist.Authenticate( - [mm_cfg.AuthListAdmin], 'xxxxxx'), mm_cfg.UnAuthorized) + [config.AuthListAdmin], 'xxxxxx'), config.UnAuthorized) eq(mlist.password, crypted) def test_list_moderator(self): self._mlist.mod_password = password('mmMMmm') self.assertEqual(self._mlist.Authenticate( - [mm_cfg.AuthListModerator], 'mmMMmm'), mm_cfg.AuthListModerator) + [config.AuthListModerator], 'mmMMmm'), config.AuthListModerator) def test_user(self): mlist = self._mlist mlist.addNewMember('aperson@dom.ain', password='nosrepa') self.assertEqual(mlist.Authenticate( - [mm_cfg.AuthUser], 'nosrepa', 'aperson@dom.ain'), mm_cfg.AuthUser) + [config.AuthUser], 'nosrepa', 'aperson@dom.ain'), config.AuthUser) def test_wrong_user(self): mlist = self._mlist mlist.addNewMember('aperson@dom.ain', password='nosrepa') self.assertEqual( - mlist.Authenticate([mm_cfg.AuthUser], 'nosrepa', 'bperson@dom.ain'), - mm_cfg.UnAuthorized) + mlist.Authenticate([config.AuthUser], 'nosrepa', 'bperson@dom.ain'), + config.UnAuthorized) def test_no_user(self): mlist = self._mlist mlist.addNewMember('aperson@dom.ain', password='nosrepa') - self.assertEqual(mlist.Authenticate([mm_cfg.AuthUser], 'norespa'), - mm_cfg.UnAuthorized) + self.assertEqual(mlist.Authenticate([config.AuthUser], 'norespa'), + config.UnAuthorized) def test_user_unauth(self): mlist = self._mlist mlist.addNewMember('aperson@dom.ain', password='nosrepa') self.assertEqual(mlist.Authenticate( - [mm_cfg.AuthUser], 'xxxxxx', 'aperson@dom.ain'), - mm_cfg.UnAuthorized) + [config.AuthUser], 'xxxxxx', 'aperson@dom.ain'), + config.UnAuthorized) def test_value_error(self): self.assertRaises(ValueError, self._mlist.Authenticate, @@ -213,22 +213,22 @@ class TestWebAuthenticate(TestBase): mlist.addNewMember('aperson@dom.ain', password='qqQQqq') # Set up the cookie data sfp = StripperIO() - print >> sfp, mlist.MakeCookie(mm_cfg.AuthSiteAdmin) + print >> sfp, mlist.MakeCookie(config.AuthSiteAdmin) # AuthCreator isn't handled in AuthContextInfo() - print >> sfp, mlist.MakeCookie(mm_cfg.AuthListAdmin) - print >> sfp, mlist.MakeCookie(mm_cfg.AuthListModerator) - print >> sfp, mlist.MakeCookie(mm_cfg.AuthUser, 'aperson@dom.ain') + print >> sfp, mlist.MakeCookie(config.AuthListAdmin) + print >> sfp, mlist.MakeCookie(config.AuthListModerator) + print >> sfp, mlist.MakeCookie(config.AuthUser, 'aperson@dom.ain') # Strip off the "Set-Cookie: " prefix cookie = sfp.getvalue() os.environ['HTTP_COOKIE'] = cookie def tearDown(self): try: - os.unlink(mm_cfg.SITE_PW_FILE) + os.unlink(config.SITE_PW_FILE) except OSError, e: if e.errno <> errno.ENOENT: raise try: - os.unlink(mm_cfg.LISTCREATOR_PW_FILE) + os.unlink(config.LISTCREATOR_PW_FILE) except OSError, e: if e.errno <> errno.ENOENT: raise del os.environ['HTTP_COOKIE'] @@ -236,24 +236,24 @@ class TestWebAuthenticate(TestBase): def test_auth_site_admin(self): self.assertEqual(self._mlist.WebAuthenticate( - [mm_cfg.AuthSiteAdmin], 'xxxxxx'), 1) + [config.AuthSiteAdmin], 'xxxxxx'), 1) def test_list_admin(self): self.assertEqual(self._mlist.WebAuthenticate( - [mm_cfg.AuthListAdmin], 'xxxxxx'), 1) + [config.AuthListAdmin], 'xxxxxx'), 1) def test_list_moderator(self): self.assertEqual(self._mlist.WebAuthenticate( - [mm_cfg.AuthListModerator], 'xxxxxx'), 1) + [config.AuthListModerator], 'xxxxxx'), 1) def test_user(self): self.assertEqual(self._mlist.WebAuthenticate( - [mm_cfg.AuthUser], 'xxxxxx'), 1) + [config.AuthUser], 'xxxxxx'), 1) def test_not_a_user(self): self._mlist.removeMember('aperson@dom.ain') self.assertEqual(self._mlist.WebAuthenticate( - [mm_cfg.AuthUser], 'xxxxxx', 'aperson@dom.ain'), 0) + [config.AuthUser], 'xxxxxx', 'aperson@dom.ain'), 0) |
