Permalink
Browse files

bugfix

  • Loading branch information...
1 parent c9d54f8 commit 04acdf50b3ae1ea44b26f513818adb672c3f171d @FedericoCeratto committed Apr 15, 2012
Showing with 9 additions and 2 deletions.
  1. +4 −2 src/cork.py
  2. +5 −0 test/test.py
View
@@ -338,6 +338,8 @@ def create_user(self, username, role, password, email_addr=None,
raise AuthException("The current user is not authorized to ")
if username in self._store.users:
raise AAAException("User is already existing.")
+ if role not in self._store.roles:
+ raise AAAException("Nonexistent user role.")
tstamp = str(datetime.utcnow())
self._store.users[username] = {
'role': role,
@@ -365,12 +367,12 @@ def delete_user(self, username):
def list_users(self):
"""List users.
- :return: (username, email_addr, description) generator (sorted by
+ :return: (username, role, email_addr, description) generator (sorted by
username)
"""
for un in sorted(self._store.users):
d = self._store.users[un]
- yield (un, d['email_addr'], d['desc'])
+ yield (un, d['role'], d['email_addr'], d['desc'])
@property
def current_user(self):
View
@@ -164,6 +164,11 @@ def test_unauth_create_user():
def test_create_existing_user():
assert_raises(AAAException, aaa.create_user, 'admin', 'admin', 'bogus')
+@raises(AAAException)
+@with_setup(setup_mockedadmin, teardown_dir)
+def test_create_user_with_wrong_role():
+ aaa.create_user('admin2', 'nonexistent_role', 'bogus')
+
@with_setup(setup_mockedadmin, teardown_dir)
def test_create_user():
assert len(aaa._store.users) == 1, repr(aaa._store.users)

0 comments on commit 04acdf5

Please sign in to comment.