From ac6afb2b824cd7b0876c7404b6559fb16bc869de Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 18 Dec 2021 14:46:54 +0100 Subject: [PATCH] stages/email: add test for non-existent directory Signed-off-by: Jens Langhammer --- authentik/stages/email/models.py | 2 +- authentik/stages/email/tests/test_templates.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/authentik/stages/email/models.py b/authentik/stages/email/models.py index 9c96a8906..0908a0010 100644 --- a/authentik/stages/email/models.py +++ b/authentik/stages/email/models.py @@ -37,7 +37,7 @@ def get_template_choices(): dirs = [Path(x) for x in settings.TEMPLATES[0]["DIRS"]] for template_dir in dirs: - if not template_dir.exists(): + if not template_dir.exists() or not template_dir.is_dir(): continue for template in template_dir.glob("**/*.html"): path = str(template) diff --git a/authentik/stages/email/tests/test_templates.py b/authentik/stages/email/tests/test_templates.py index 01f6d9213..a60266a65 100644 --- a/authentik/stages/email/tests/test_templates.py +++ b/authentik/stages/email/tests/test_templates.py @@ -13,7 +13,7 @@ from authentik.stages.email.models import get_template_choices def get_templates_setting(temp_dir: str) -> dict[str, Any]: """Patch settings TEMPLATE's dir property""" templates_setting = settings.TEMPLATES - templates_setting[0]["DIRS"] = [temp_dir] + templates_setting[0]["DIRS"] = [temp_dir, "foo"] return templates_setting