1
0
Fork 0

improve test coverage (addresses #28)

* gnuviechadmin/tests/functional/test_xmlrpc_users.py:
  push test coverage to 100%
* gnuviechadmin/xmlrpc/users.py:
  implement rudimentary role_exists methods
  fix variable name
* add egg-info

git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@263 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2009-07-05 22:40:32 +00:00
parent daf9517a83
commit 3683df2011
7 changed files with 173 additions and 3 deletions

View file

@ -0,0 +1,13 @@
Metadata-Version: 1.0
Name: gnuviechadmin
Version: 0.1.dev-20090705
Summary: gnuviechadmin server administration suite
Home-page: http://www.gnuviech-server.de/projects/gnuviechadmin
Author: Jan Dittberner
Author-email: jan@dittberner.info
License: GPL
Description: this is a suite of tools for administering a server
it contains tools for maintaining e.g. clients, domains, users, mail
accounts
Keywords: administration backend frontend
Platform: UNKNOWN

View file

@ -0,0 +1,38 @@
setup.cfg
setup.py
bin/gva
bin/gvaserver
gnuviechadmin/__init__.py
gnuviechadmin/exceptions.py
gnuviechadmin.egg-info/PKG-INFO
gnuviechadmin.egg-info/SOURCES.txt
gnuviechadmin.egg-info/dependency_links.txt
gnuviechadmin.egg-info/requires.txt
gnuviechadmin.egg-info/top_level.txt
gnuviechadmin/backend/BackendEntity.py
gnuviechadmin/backend/BackendEntityHandler.py
gnuviechadmin/backend/BackendTo.py
gnuviechadmin/backend/__init__.py
gnuviechadmin/backend/client.py
gnuviechadmin/backend/domain.py
gnuviechadmin/backend/record.py
gnuviechadmin/backend/settings.py
gnuviechadmin/backend/sysuser.py
gnuviechadmin/backend/tables.py
gnuviechadmin/cli/CliCommand.py
gnuviechadmin/cli/__init__.py
gnuviechadmin/cli/client.py
gnuviechadmin/cli/domain.py
gnuviechadmin/cli/record.py
gnuviechadmin/cli/sysuser.py
gnuviechadmin/tests/__init__.py
gnuviechadmin/tests/functional/__init__.py
gnuviechadmin/tests/functional/test_util_passwordutils.py
gnuviechadmin/util/__init__.py
gnuviechadmin/util/getenttools.py
gnuviechadmin/util/gpgmail.py
gnuviechadmin/util/passwordutils.py
gnuviechadmin/util/stmtcreator.py
gnuviechadmin/xmlrpc/XMLRPCFacade.py
gnuviechadmin/xmlrpc/__init__.py
gnuviechadmin/xmlrpc/users.py

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,3 @@
SQLAlchemy>=0.4
sqlalchemy-migrate>=0.4
AuthKit>=0.4

View file

@ -0,0 +1 @@
gnuviechadmin

View file

@ -0,0 +1,106 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 by Jan Dittberner.
#
# 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.
#
# Version: $Id$
"""Unit tests for gnuviechadmin.xmlrpc.users.
"""
from gnuviechadmin.xmlrpc.users import ClientUserProvider, \
MailuserUserProvider, SysuserUserProvider, GVAUsers
from authkit.users import AuthKitNoSuchUserError
from unittest import TestCase
class TestClientUserProvider(TestCase):
subject = None
def setUp(self):
self.subject = ClientUserProvider(None)
def test_user(self):
user = self.subject.user('dummy')
self.assertEquals(user['roles'], ['client'])
try:
user = self.subject.user('nodummy')
self.fail('should have raised AuthKitNoSuchUserError.')
except AuthKitNoSuchUserError, e:
pass
def test_list_roles(self):
self.assertEquals(self.subject.list_roles(), ['client'])
class TestMailuserUserProvider(TestCase):
subject = None
def setUp(self):
self.subject = MailuserUserProvider(None)
def test_user(self):
try:
user = self.subject.user('dummy')
self.fail('should have raised AuthKitNoSuchUserError.')
except AuthKitNoSuchUserError, e:
pass
def test_list_roles(self):
self.assertEquals(self.subject.list_roles(), ['mailuser'])
class TestSysuserUserProvider(TestCase):
subject = None
def setUp(self):
self.subject = SysuserUserProvider(None)
def test_user(self):
try:
user = self.subject.user('dummy')
self.fail('should have raised AuthKitNoSuchUserError.')
except AuthKitNoSuchUserError, e:
pass
def test_list_roles(self):
self.assertEquals(self.subject.list_roles(), ['sysuser'])
class TestGVAUsers(TestCase):
subject = None
def setUp(self):
self.subject = GVAUsers(None, [ClientUserProvider,
MailuserUserProvider,
SysuserUserProvider])
def test_list_roles(self):
roles = self.subject.list_roles()
self.assertEquals(roles, ['client', 'mailuser', 'sysuser'])
def test_role_exists(self):
self.assertFalse(self.subject.role_exists('dummy'))
for role in ('client', 'mailuser', 'sysuser'):
self.assertTrue(self.subject.role_exists(role))
def test_user(self):
try:
self.subject.user('nouser')
self.fail('should have raised AuthKitNoSuchUserError.')
except AuthKitNoSuchUserError, e:
pass
user = self.subject.user('dummy')
print user

View file

@ -46,11 +46,14 @@ class ClientUserProvider(UserProvider):
print 'checking %s' % username print 'checking %s' % username
if username == 'dummy': if username == 'dummy':
return self._get_user(username, 'client') return self._get_user(username, 'client')
return AuthKitNoSuchUserError() raise AuthKitNoSuchUserError()
def list_roles(self): def list_roles(self):
return ['client'] return ['client']
def role_exists(self, role):
return 'client' == role
class MailuserUserProvider(UserProvider): class MailuserUserProvider(UserProvider):
"""A UserProvider implementation class for mail users.""" """A UserProvider implementation class for mail users."""
@ -61,6 +64,9 @@ class MailuserUserProvider(UserProvider):
def list_roles(self): def list_roles(self):
return ['mailuser'] return ['mailuser']
def role_exists(self, role):
return 'mailuser' == role
class SysuserUserProvider(UserProvider): class SysuserUserProvider(UserProvider):
"""A UserProvider implementation class for system users.""" """A UserProvider implementation class for system users."""
@ -71,6 +77,9 @@ class SysuserUserProvider(UserProvider):
def list_roles(self): def list_roles(self):
return ['sysuser'] return ['sysuser']
def role_exists(self, role):
return 'sysuser' == role
class GVAUsers(Users): class GVAUsers(Users):
"""This class provides an implementation of authkit.users.Users """This class provides an implementation of authkit.users.Users
@ -119,7 +128,6 @@ class GVAUsers(Users):
try: try:
return prov.user(username) return prov.user(username)
except Exception, e: except Exception, e:
print e log.debug("Backend %s didn't find user %s" % (prov,
log.debug("Backend %s didn't find user %s" % (backend,
username)) username))
raise AuthKitNoSuchUserError() raise AuthKitNoSuchUserError()