Skip to content

Commit 93970a1

Browse files
authored
Merge pull request #1700 from pbiering/skip-bcrypt-test-if-missing
Skip bcrypt test if missing
2 parents c606271 + f6b5cb8 commit 93970a1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Add: option [auth] type oauth2 by code migration from https://gitlab.mim-libre.fr/alphabet/radicale_oauth/-/blob/dev/oauth2/
66
* Fix: catch OS errors on PUT MKCOL MKCALENDAR MOVE PROPPATCH (insufficient storage, access denied, internal server error)
7+
* Test: skip bcrypt related tests if module is missing
78

89
## 3.4.1
910
* Add: option [auth] dovecot_connection_type / dovecot_host / dovecot_port

radicale/tests/test_auth.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ class TestBaseAuthRequests(BaseTest):
4141
4242
"""
4343

44+
# test for available bcrypt module
45+
try:
46+
import bcrypt
47+
except ImportError:
48+
has_bcrypt = 0
49+
else:
50+
has_bcrypt = 1
51+
4452
def _test_htpasswd(self, htpasswd_encryption: str, htpasswd_content: str,
4553
test_matrix: Union[str, Iterable[Tuple[str, str, bool]]]
4654
= "ascii") -> None:
@@ -91,10 +99,12 @@ def test_htpasswd_sha256(self) -> None:
9199
def test_htpasswd_sha512(self) -> None:
92100
self._test_htpasswd("sha512", "tmp:$6$3Qhl8r6FLagYdHYa$UCH9yXCed4A.J9FQsFPYAOXImzZUMfvLa0lwcWOxWYLOF5sE/lF99auQ4jKvHY2vijxmefl7G6kMqZ8JPdhIJ/")
93101

102+
@pytest.mark.skipif(has_bcrypt == 0, reason="No bcrypt module installed")
94103
def test_htpasswd_bcrypt(self) -> None:
95104
self._test_htpasswd("bcrypt", "tmp:$2y$05$oD7hbiQFQlvCM7zoalo/T.MssV3V"
96105
"NTRI3w5KDnj8NTUKJNWfVpvRq")
97106

107+
@pytest.mark.skipif(has_bcrypt == 0, reason="No bcrypt module installed")
98108
def test_htpasswd_bcrypt_unicode(self) -> None:
99109
self._test_htpasswd("bcrypt", "😀:$2y$10$Oyz5aHV4MD9eQJbk6GPemOs4T6edK"
100110
"6U9Sqlzr.W1mMVCS8wJUftnW", "unicode")

0 commit comments

Comments
 (0)