1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
From d9eb627a71cbbf6f218507e2d0ae47bdc62e9cd6 Mon Sep 17 00:00:00 2001
From: nicolasyang <nicolasyang243@proton.me>
Date: Wed, 10 Dec 2025 14:24:19 +0800
Subject: [PATCH 5/7] remove bcrypt related unit test
Passlib is unmaintained and does not work with bcrypt 5.0.0 any more.
---
test/units/utils/test_encrypt.py | 36 --------------------------------
1 file changed, 36 deletions(-)
diff --git a/test/units/utils/test_encrypt.py b/test/units/utils/test_encrypt.py
index 2c4a612725..4f22574b6e 100644
--- a/test/units/utils/test_encrypt.py
+++ b/test/units/utils/test_encrypt.py
@@ -38,16 +38,6 @@ def assert_hash(expected, secret, algorithm, **settings):
@pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
def test_encrypt_with_ident():
- assert_hash("$2$12$123456789012345678901ufd3hZRrev.WXCbemqGIV/gmWaTGLImm",
- secret="123", algorithm="bcrypt", salt='1234567890123456789012', ident='2')
- assert_hash("$2y$12$123456789012345678901ugbM1PeTfRQ0t6dCJu5lQA8hwrZOYgDu",
- secret="123", algorithm="bcrypt", salt='1234567890123456789012', ident='2y')
- assert_hash("$2a$12$123456789012345678901ugbM1PeTfRQ0t6dCJu5lQA8hwrZOYgDu",
- secret="123", algorithm="bcrypt", salt='1234567890123456789012', ident='2a')
- assert_hash("$2b$12$123456789012345678901ugbM1PeTfRQ0t6dCJu5lQA8hwrZOYgDu",
- secret="123", algorithm="bcrypt", salt='1234567890123456789012', ident='2b')
- assert_hash("$2b$12$123456789012345678901ugbM1PeTfRQ0t6dCJu5lQA8hwrZOYgDu",
- secret="123", algorithm="bcrypt", salt='1234567890123456789012')
# negative test: sha256_crypt does not take ident as parameter so ignore it
assert_hash("$5$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7",
secret="123", algorithm="sha256_crypt", salt="12345678", rounds=5000, ident='invalid_ident')
@@ -116,10 +106,6 @@ def test_do_encrypt_passlib():
assert encrypt.do_encrypt("123", "crypt16", salt="12") == "12pELHK2ME3McUFlHxel6uMM"
- assert encrypt.do_encrypt("123", "bcrypt",
- salt='1234567890123456789012',
- ident='2a') == "$2a$12$123456789012345678901ugbM1PeTfRQ0t6dCJu5lQA8hwrZOYgDu"
-
def test_random_salt():
res = encrypt.random_salt()
@@ -127,25 +113,3 @@ def test_random_salt():
assert len(res) == 8
for res_char in res:
assert res_char in expected_salt_candidate_chars
-
-
-def test_passlib_bcrypt_salt(recwarn):
- passlib_exc = pytest.importorskip("passlib.exc")
-
- secret = 'foo'
- salt = '1234567890123456789012'
- repaired_salt = '123456789012345678901u'
- expected = '$2b$12$123456789012345678901uMv44x.2qmQeefEGb3bcIRc1mLuO7bqa'
- ident = '2b'
-
- p = encrypt.PasslibHash('bcrypt')
-
- result = p.hash(secret, salt=salt, ident=ident)
- passlib_warnings = [w.message for w in recwarn if isinstance(w.message, passlib_exc.PasslibHashWarning)]
- assert len(passlib_warnings) == 0
- assert result == expected
-
- recwarn.clear()
-
- result = p.hash(secret, salt=repaired_salt, ident=ident)
- assert result == expected
--
2.52.0
|