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:
parent
daf9517a83
commit
3683df2011
7 changed files with 173 additions and 3 deletions
13
gnuviechadmin.egg-info/PKG-INFO
Normal file
13
gnuviechadmin.egg-info/PKG-INFO
Normal 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
|
38
gnuviechadmin.egg-info/SOURCES.txt
Normal file
38
gnuviechadmin.egg-info/SOURCES.txt
Normal 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
|
1
gnuviechadmin.egg-info/dependency_links.txt
Normal file
1
gnuviechadmin.egg-info/dependency_links.txt
Normal file
|
@ -0,0 +1 @@
|
|||
|
3
gnuviechadmin.egg-info/requires.txt
Normal file
3
gnuviechadmin.egg-info/requires.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
SQLAlchemy>=0.4
|
||||
sqlalchemy-migrate>=0.4
|
||||
AuthKit>=0.4
|
1
gnuviechadmin.egg-info/top_level.txt
Normal file
1
gnuviechadmin.egg-info/top_level.txt
Normal file
|
@ -0,0 +1 @@
|
|||
gnuviechadmin
|
106
gnuviechadmin/tests/functional/test_xmlrpc_users.py
Normal file
106
gnuviechadmin/tests/functional/test_xmlrpc_users.py
Normal 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
|
|
@ -46,11 +46,14 @@ class ClientUserProvider(UserProvider):
|
|||
print 'checking %s' % username
|
||||
if username == 'dummy':
|
||||
return self._get_user(username, 'client')
|
||||
return AuthKitNoSuchUserError()
|
||||
raise AuthKitNoSuchUserError()
|
||||
|
||||
def list_roles(self):
|
||||
return ['client']
|
||||
|
||||
def role_exists(self, role):
|
||||
return 'client' == role
|
||||
|
||||
|
||||
class MailuserUserProvider(UserProvider):
|
||||
"""A UserProvider implementation class for mail users."""
|
||||
|
@ -61,6 +64,9 @@ class MailuserUserProvider(UserProvider):
|
|||
def list_roles(self):
|
||||
return ['mailuser']
|
||||
|
||||
def role_exists(self, role):
|
||||
return 'mailuser' == role
|
||||
|
||||
|
||||
class SysuserUserProvider(UserProvider):
|
||||
"""A UserProvider implementation class for system users."""
|
||||
|
@ -71,6 +77,9 @@ class SysuserUserProvider(UserProvider):
|
|||
def list_roles(self):
|
||||
return ['sysuser']
|
||||
|
||||
def role_exists(self, role):
|
||||
return 'sysuser' == role
|
||||
|
||||
|
||||
class GVAUsers(Users):
|
||||
"""This class provides an implementation of authkit.users.Users
|
||||
|
@ -119,7 +128,6 @@ class GVAUsers(Users):
|
|||
try:
|
||||
return prov.user(username)
|
||||
except Exception, e:
|
||||
print e
|
||||
log.debug("Backend %s didn't find user %s" % (backend,
|
||||
log.debug("Backend %s didn't find user %s" % (prov,
|
||||
username))
|
||||
raise AuthKitNoSuchUserError()
|
||||
|
|
Loading…
Reference in a new issue