~ulrith/mailman/russian-2.1.20

« back to all changes in this revision

Viewing changes to tests/test_security_mgr.py

  • Committer: Barry Warsaw
  • Date: 2008-11-13 04:02:29 UTC
  • Revision ID: barry@list.org-20081113040229-10pzc4jrxycl9p2d
Apply Heiko Rommel's patch for hashlib deprecation warnings for bug 293178.
I've modified the patch to improve some of the stylistic issues.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
 
1
# Copyright (C) 2001-2008 by the Free Software Foundation, Inc.
2
2
#
3
3
# This program is free software; you can redistribute it and/or
4
4
# modify it under the terms of the GNU General Public License
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
16
# USA.
16
17
 
17
18
"""Unit tests for Mailman/SecurityManager.py
18
19
"""
20
21
import os
21
22
import unittest
22
23
import errno
23
 
import md5
24
 
import sha
25
24
import Cookie
26
25
try:
27
26
    import crypt
33
32
from Mailman import mm_cfg
34
33
from Mailman import Utils
35
34
from Mailman import Errors
 
35
from Mailman.Utils import md5_new, sha_new
36
36
 
37
37
from TestBase import TestBase
38
38
 
39
39
 
40
40
 
41
41
def password(plaintext):
42
 
    return sha.new(plaintext).hexdigest()
 
42
    return sha_new(plaintext).hexdigest()
43
43
 
44
44
 
45
45
 
132
132
    def test_list_admin_upgrade(self):
133
133
        eq = self.assertEqual
134
134
        mlist = self._mlist
135
 
        mlist.password = md5.new('ssSSss').digest()
 
135
        mlist.password = md5_new('ssSSss').digest()
136
136
        eq(mlist.Authenticate(
137
137
            [mm_cfg.AuthListAdmin], 'ssSSss'), mm_cfg.AuthListAdmin)
138
138
        eq(mlist.password, password('ssSSss'))
146
146
    def test_list_admin_oldstyle_unauth(self):
147
147
        eq = self.assertEqual
148
148
        mlist = self._mlist
149
 
        mlist.password = md5.new('ssSSss').digest()
 
149
        mlist.password = md5_new('ssSSss').digest()
150
150
        eq(mlist.Authenticate(
151
151
            [mm_cfg.AuthListAdmin], 'xxxxxx'), mm_cfg.UnAuthorized)
152
 
        eq(mlist.password, md5.new('ssSSss').digest())
 
152
        eq(mlist.password, md5_new('ssSSss').digest())
153
153
        # Test crypt upgrades if crypt is supported
154
154
        if crypt:
155
155
            mlist.password = crypted = crypt.crypt('rrRRrr', 'zc')