From d8d81bfbcaa4199abde182a5aa53197677703996 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Mon, 23 Sep 2024 09:02:23 +0800 Subject: [PATCH] raise exception --- wsgidav/dc/pam_dc.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wsgidav/dc/pam_dc.py b/wsgidav/dc/pam_dc.py index 275fe47..702ad7c 100644 --- a/wsgidav/dc/pam_dc.py +++ b/wsgidav/dc/pam_dc.py @@ -39,11 +39,15 @@ def __init__(self, wsgidav_app, config): self.pam_encoding = dc_conf.get("encoding", "utf-8") self.pam_resetcreds = dc_conf.get("resetcreds", True) self.allow_users = dc_conf.get("allow_users", "all") - assert self.allow_users in ("all", "current") or isinstance(self.allow_users, list), \ - f"Invalid 'allow_users' value: {self.allow_users!r}, expected 'all', 'current' or list of allowed users." + if not (self.allow_users in ("all", "current") or isinstance(self.allow_users, list)): + raise ValueError( + f"Invalid 'allow_users' value: {self.allow_users!r}, expected 'all', 'current' or list of allowed users." + ) self.deny_users = dc_conf.get("deny_users", []) - assert isinstance(self.deny_users, list), \ - f"Invalid 'deny_users' value: {self.deny_users!r}, expected list of denied users." + if not isinstance(self.deny_users, list): + raise ValueError( + f"Invalid 'deny_users' value: {self.deny_users!r}, expected list of denied users." + ) def __str__(self): return f"{self.__class__.__name__}({self.pam_service!r})"