diff --git a/authentik/lib/tests/__init__.py b/authentik/lib/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/authentik/lib/tests.py b/authentik/lib/tests/test_serializer_model.py similarity index 100% rename from authentik/lib/tests.py rename to authentik/lib/tests/test_serializer_model.py diff --git a/authentik/providers/saml/tests/test_utils_time.py b/authentik/lib/tests/test_utils_time.py similarity index 90% rename from authentik/providers/saml/tests/test_utils_time.py rename to authentik/lib/tests/test_utils_time.py index 419d205e9..cc16550e1 100644 --- a/authentik/providers/saml/tests/test_utils_time.py +++ b/authentik/lib/tests/test_utils_time.py @@ -20,6 +20,8 @@ class TestTimeUtils(TestCase): """Test invalid expression""" with self.assertRaises(ValueError): timedelta_from_string("foo") + with self.assertRaises(ValueError): + timedelta_from_string("bar=baz") def test_validation(self): """Test Django model field validator""" diff --git a/authentik/lib/utils/time.py b/authentik/lib/utils/time.py index 4ba41ddb5..a4109f5af 100644 --- a/authentik/lib/utils/time.py +++ b/authentik/lib/utils/time.py @@ -35,4 +35,6 @@ def timedelta_from_string(expr: str) -> datetime.timedelta: if key.lower() not in ALLOWED_KEYS: continue kwargs[key.lower()] = float(value) + if len(kwargs) < 1: + raise ValueError("No valid keys to pass to timedelta") return datetime.timedelta(**kwargs)