mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-25 18:54:29 +01: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:
parent
b653f5512c
commit
6a610c079e
@ -197,6 +197,10 @@ class LdapCherry(object):
|
|||||||
|
|
||||||
# definition of the template directory
|
# definition of the template directory
|
||||||
self.template_dir = self._get_param('resources', 'templates.dir', config)
|
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
|
# preload templates
|
||||||
self.temp_lookup = lookup.TemplateLookup(
|
self.temp_lookup = lookup.TemplateLookup(
|
||||||
directories=self.template_dir, input_encoding='utf-8'
|
directories=self.template_dir, input_encoding='utf-8'
|
||||||
@ -210,16 +214,38 @@ class LdapCherry(object):
|
|||||||
#auth = __import__(auth_module, globals(), locals(), ['Auth'], -1)
|
#auth = __import__(auth_module, globals(), locals(), ['Auth'], -1)
|
||||||
#self.auth = auth.Auth(config['auth'], cherrypy.log)
|
#self.auth = auth.Auth(config['auth'], cherrypy.log)
|
||||||
|
|
||||||
|
|
||||||
self.roles_file = self._get_param('roles', 'roles.file', config)
|
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.roles = Roles(self.roles_file)
|
||||||
|
|
||||||
self.attributes_file = self._get_param('attributes', 'attributes.file', config)
|
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._init_backends(config)
|
||||||
self._check_backends()
|
self._check_backends()
|
||||||
|
cherrypy.log.error(
|
||||||
|
msg = "Application started",
|
||||||
|
severity = logging.INFO
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._handle_exception(e)
|
self._handle_exception(e)
|
||||||
|
cherrypy.log.error(
|
||||||
|
msg = "Application failed to start",
|
||||||
|
severity = logging.ERROR
|
||||||
|
)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def _reraise(self, exception):
|
def _reraise(self, exception):
|
||||||
|
@ -58,7 +58,7 @@ class TestError(object):
|
|||||||
cfg['global']['log.access_handler']=t
|
cfg['global']['log.access_handler']=t
|
||||||
cfg['global']['log.error_handler']=t
|
cfg['global']['log.error_handler']=t
|
||||||
app._set_access_log(cfg, logging.DEBUG)
|
app._set_access_log(cfg, logging.DEBUG)
|
||||||
app._set_access_log(cfg, logging.DEBUG)
|
app._set_error_log(cfg, logging.DEBUG)
|
||||||
|
|
||||||
def testMissingBackend(self):
|
def testMissingBackend(self):
|
||||||
app = LdapCherry()
|
app = LdapCherry()
|
||||||
@ -71,7 +71,6 @@ class TestError(object):
|
|||||||
else:
|
else:
|
||||||
raise AssertionError("expected an exception")
|
raise AssertionError("expected an exception")
|
||||||
|
|
||||||
|
|
||||||
def testMissingParameters(self):
|
def testMissingParameters(self):
|
||||||
app = LdapCherry()
|
app = LdapCherry()
|
||||||
try:
|
try:
|
||||||
@ -81,6 +80,12 @@ class TestError(object):
|
|||||||
else:
|
else:
|
||||||
raise AssertionError("expected an exception")
|
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):
|
def testLogger(self):
|
||||||
app = LdapCherry()
|
app = LdapCherry()
|
||||||
loadconf('./tests/cfg/ldapcherry.ini', app)
|
loadconf('./tests/cfg/ldapcherry.ini', app)
|
||||||
|
Loading…
Reference in New Issue
Block a user