Skip to content

Commit d82e9e9

Browse files
author
Andrey Lebedev
committed
role names made case insensitive
1 parent 1e6049b commit d82e9e9

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Feature:
4343
- relaxed CVS importing (sf feature 693277)
4444
- added support for searching on ranges of dates (see doc/user_guide.txt in
4545
chapter "Searching Page" for details)
46+
- role names made case insensitive
4647

4748

4849
Fixed:

roundup/security.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Role:
2727
- permissions
2828
'''
2929
def __init__(self, name='', description='', permissions=None):
30-
self.name = name
30+
self.name = name.lower()
3131
self.description = description
3232
if permissions is None:
3333
permissions = []
@@ -98,7 +98,7 @@ def hasPermission(self, permission, userid, classname=None):
9898
roles = self.db.user.get(userid, 'roles')
9999
if roles is None:
100100
return 0
101-
for rolename in roles.split(','):
101+
for rolename in [x.lower() for x in roles.split(',')]:
102102
if not rolename or not self.role.has_key(rolename):
103103
continue
104104
# for each of the user's Roles, check the permissions
@@ -155,7 +155,7 @@ def addPermissionToRole(self, rolename, permission):
155155
156156
'rolename' is the name of the role to add the permission to.
157157
'''
158-
role = self.role[rolename]
158+
role = self.role[rolename.lower()]
159159
role.permissions.append(permission)
160160

161161
# vim: set filetype=python ts=4 sw=4 et si

test/test_mailgw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_mailgw.py,v 1.40 2003-02-28 03:33:25 richard Exp $
11+
# $Id: test_mailgw.py,v 1.41 2003-03-13 09:27:24 kedder Exp $
1212

1313
import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib
1414

@@ -644,7 +644,7 @@ def testNosyRemove(self):
644644
def testNewUserAuthor(self):
645645
# first without the permission
646646
# heh... just ignore the API for a second ;)
647-
self.db.security.role['Anonymous'].permissions=[]
647+
self.db.security.role['anonymous'].permissions=[]
648648
anonid = self.db.user.lookup('anonymous')
649649
self.db.user.set(anonid, roles='Anonymous')
650650

@@ -670,7 +670,7 @@ def testNewUserAuthor(self):
670670

671671
# now with the permission
672672
p = self.db.security.getPermission('Email Registration')
673-
self.db.security.role['Anonymous'].permissions=[p]
673+
self.db.security.role['anonymous'].permissions=[p]
674674
handler = self.instance.MailGW(self.instance, self.db)
675675
handler.trapExceptions = 0
676676
message = cStringIO.StringIO(s)

0 commit comments

Comments
 (0)