forked from Github-Mirrors/canaille
ldap_backend: improved coverage
This commit is contained in:
parent
dab82e6466
commit
fda205cbf5
1 changed files with 6 additions and 8 deletions
|
@ -16,17 +16,15 @@ def setup_ldap_models(config):
|
|||
|
||||
LDAPObject.root_dn = config["LDAP"]["ROOT_DN"]
|
||||
|
||||
user_base = config["LDAP"]["USER_BASE"]
|
||||
if user_base.endswith(config["LDAP"]["ROOT_DN"]):
|
||||
user_base = user_base[: -len(config["LDAP"]["ROOT_DN"]) - 1]
|
||||
user_base = config["LDAP"]["USER_BASE"].replace(config["LDAP"]["ROOT_DN"], "")
|
||||
User.base = user_base
|
||||
User.id = config["LDAP"].get("USER_ID_ATTRIBUTE", User.DEFAULT_ID_ATTRIBUTE)
|
||||
User.object_class = [config["LDAP"].get("USER_CLASS", User.DEFAULT_OBJECT_CLASS)]
|
||||
|
||||
group_base = config["LDAP"].get("GROUP_BASE")
|
||||
if group_base.endswith(config["LDAP"]["ROOT_DN"]):
|
||||
group_base = group_base[: -len(config["LDAP"]["ROOT_DN"]) - 1]
|
||||
Group.base = group_base
|
||||
group_base = (
|
||||
config["LDAP"].get("GROUP_BASE", "").replace(config["LDAP"]["ROOT_DN"], "")
|
||||
)
|
||||
Group.base = group_base or None
|
||||
Group.id = config["LDAP"].get("GROUP_ID_ATTRIBUTE", Group.DEFAULT_ID_ATTRIBUTE)
|
||||
Group.object_class = [config["LDAP"].get("GROUP_CLASS", Group.DEFAULT_OBJECT_CLASS)]
|
||||
|
||||
|
@ -35,7 +33,7 @@ def setup_backend(app):
|
|||
try: # pragma: no cover
|
||||
if request.endpoint == "static":
|
||||
return
|
||||
except RuntimeError:
|
||||
except RuntimeError: # pragma: no cover
|
||||
pass
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue