1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-06-20 10:43:00 +02:00

multiple modifications:

* adding logs in conf loading
* fixing attributes/roles handling in class LdapCherry
* fix unit test on logs
* add unit test for random exception
This commit is contained in:
kakwa 2015-05-20 12:44:33 +02:00
parent b653f5512c
commit 6a610c079e
2 changed files with 34 additions and 3 deletions

View File

@ -197,6 +197,10 @@ class LdapCherry(object):
# definition of the template directory
self.template_dir = self._get_param('resources', 'templates.dir', config)
cherrypy.log.error(
msg = "Loading templates from dir <%(dir)s>" % { 'dir': self.template_dir },
severity = logging.DEBUG
)
# preload templates
self.temp_lookup = lookup.TemplateLookup(
directories=self.template_dir, input_encoding='utf-8'
@ -210,16 +214,38 @@ class LdapCherry(object):
#auth = __import__(auth_module, globals(), locals(), ['Auth'], -1)
#self.auth = auth.Auth(config['auth'], cherrypy.log)
self.roles_file = self._get_param('roles', 'roles.file', config)
cherrypy.log.error(
msg = "Loading roles file <%(file)s>" % { 'file': self.roles_file },
severity = logging.DEBUG
)
self.roles = Roles(self.roles_file)
self.attributes_file = self._get_param('attributes', 'attributes.file', config)
self.roles = Attributes(self.attributes_file)
cherrypy.log.error(
msg = "Loading attributes file <%(file)s>" % { 'file': self.attributes_file },
severity = logging.DEBUG
)
self.attributes = Attributes(self.attributes_file)
cherrypy.log.error(
msg = "Init directories backends",
severity = logging.DEBUG
)
self._init_backends(config)
self._check_backends()
cherrypy.log.error(
msg = "Application started",
severity = logging.INFO
)
except Exception as e:
self._handle_exception(e)
cherrypy.log.error(
msg = "Application failed to start",
severity = logging.ERROR
)
exit(1)
def _reraise(self, exception):

View File

@ -58,7 +58,7 @@ class TestError(object):
cfg['global']['log.access_handler']=t
cfg['global']['log.error_handler']=t
app._set_access_log(cfg, logging.DEBUG)
app._set_access_log(cfg, logging.DEBUG)
app._set_error_log(cfg, logging.DEBUG)
def testMissingBackend(self):
app = LdapCherry()
@ -71,7 +71,6 @@ class TestError(object):
else:
raise AssertionError("expected an exception")
def testMissingParameters(self):
app = LdapCherry()
try:
@ -81,6 +80,12 @@ class TestError(object):
else:
raise AssertionError("expected an exception")
def testRandomException(self):
app = LdapCherry()
loadconf('./tests/cfg/ldapcherry.ini', app)
e = Exception()
app._handle_exception(e)
def testLogger(self):
app = LdapCherry()
loadconf('./tests/cfg/ldapcherry.ini', app)