From 3d50ae4a70097c72b76db0b35c8f466d15ad751b Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Tue, 18 Feb 2025 06:13:11 +0100 Subject: [PATCH 1/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0ab4f4..f9e2a473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Add: option [auth] type oauth2 by code migration from https://gitlab.mim-libre.fr/alphabet/radicale_oauth/-/blob/dev/oauth2/ * Fix: catch OS errors on PUT MKCOL MKCALENDAR MOVE PROPPATCH (insufficient storage, access denied, internal server error) +* Test: skip bcrypt related tests if module is missing ## 3.4.1 * Add: option [auth] dovecot_connection_type / dovecot_host / dovecot_port From 48a634af9fe77e037535df59d4a7a41151049ccb Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Tue, 18 Feb 2025 06:13:19 +0100 Subject: [PATCH 2/4] check whether bcrypt module is available --- radicale/tests/test_auth.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/radicale/tests/test_auth.py b/radicale/tests/test_auth.py index f2ba577b..7abb23e9 100644 --- a/radicale/tests/test_auth.py +++ b/radicale/tests/test_auth.py @@ -41,6 +41,14 @@ class TestBaseAuthRequests(BaseTest): """ + # test for available bcrypt module + try: + import bcrypt + except ImportError as e: + has_bcrypt = 0 + else: + has_bcrypt = 1 + def _test_htpasswd(self, htpasswd_encryption: str, htpasswd_content: str, test_matrix: Union[str, Iterable[Tuple[str, str, bool]]] = "ascii") -> None: From 3914735ec0e1a28ddd325d3ebfafbfeb4e522d78 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Tue, 18 Feb 2025 06:13:39 +0100 Subject: [PATCH 3/4] skip bcrypt related tests if module is missing --- radicale/tests/test_auth.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radicale/tests/test_auth.py b/radicale/tests/test_auth.py index 7abb23e9..6745e665 100644 --- a/radicale/tests/test_auth.py +++ b/radicale/tests/test_auth.py @@ -99,10 +99,12 @@ class TestBaseAuthRequests(BaseTest): def test_htpasswd_sha512(self) -> None: self._test_htpasswd("sha512", "tmp:$6$3Qhl8r6FLagYdHYa$UCH9yXCed4A.J9FQsFPYAOXImzZUMfvLa0lwcWOxWYLOF5sE/lF99auQ4jKvHY2vijxmefl7G6kMqZ8JPdhIJ/") + @pytest.mark.skipif(has_bcrypt == 0, reason="No bcrypt module installed") def test_htpasswd_bcrypt(self) -> None: self._test_htpasswd("bcrypt", "tmp:$2y$05$oD7hbiQFQlvCM7zoalo/T.MssV3V" "NTRI3w5KDnj8NTUKJNWfVpvRq") + @pytest.mark.skipif(has_bcrypt == 0, reason="No bcrypt module installed") def test_htpasswd_bcrypt_unicode(self) -> None: self._test_htpasswd("bcrypt", "😀:$2y$10$Oyz5aHV4MD9eQJbk6GPemOs4T6edK" "6U9Sqlzr.W1mMVCS8wJUftnW", "unicode") From f6b5cb8a1e79b7862b975541b1bc21342742f098 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Tue, 18 Feb 2025 06:14:59 +0100 Subject: [PATCH 4/4] make flake8 happy --- radicale/tests/test_auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radicale/tests/test_auth.py b/radicale/tests/test_auth.py index 6745e665..6c356f97 100644 --- a/radicale/tests/test_auth.py +++ b/radicale/tests/test_auth.py @@ -44,7 +44,7 @@ class TestBaseAuthRequests(BaseTest): # test for available bcrypt module try: import bcrypt - except ImportError as e: + except ImportError: has_bcrypt = 0 else: has_bcrypt = 1