summarylogtreecommitdiffstats
path: root/0003-remove-crypt-related-tests.patch
blob: 588e9a503fc5d95dbc6654a7d7cbf69ed198fecc (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
From 4fade05f2c69eb6978194da8f5bd42f02c2fbfeb Mon Sep 17 00:00:00 2001
From: nicolasyang <nicolasyang243@proton.me>
Date: Tue, 24 Dec 2024 12:33:23 +0800
Subject: [PATCH 3/3] remove crypt related tests

---
 test/units/utils/test_encrypt.py | 78 --------------------------------
 1 file changed, 78 deletions(-)

diff --git a/test/units/utils/test_encrypt.py b/test/units/utils/test_encrypt.py
index be32579019..2c4a612725 100644
--- a/test/units/utils/test_encrypt.py
+++ b/test/units/utils/test_encrypt.py
@@ -36,27 +36,6 @@ def assert_hash(expected, secret, algorithm, **settings):
         assert excinfo.value.args[0] == "passlib must be installed and usable to hash with '%s'" % algorithm
 
 
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_passlib_or_crypt():
-    with passlib_off():
-        expected = "$5$rounds=5000$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7"
-        assert encrypt.passlib_or_crypt("123", "sha256_crypt", salt="12345678", rounds=5000) == expected
-
-    expected = "$5$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7"
-    assert encrypt.passlib_or_crypt("123", "sha256_crypt", salt="12345678", rounds=5000) == expected
-
-
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_encrypt_with_rounds_no_passlib():
-    with passlib_off():
-        assert_hash("$5$rounds=5000$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7",
-                    secret="123", algorithm="sha256_crypt", salt="12345678", rounds=5000)
-        assert_hash("$5$rounds=10000$12345678$JBinliYMFEcBeAXKZnLjenhgEhTmJBvZn3aR8l70Oy/",
-                    secret="123", algorithm="sha256_crypt", salt="12345678", rounds=10000)
-        assert_hash("$6$rounds=5000$12345678$LcV9LQiaPekQxZ.OfkMADjFdSO2k9zfbDQrHPVcYjSLqSdjLYpsgqviYvTEP/R41yPmhH3CCeEDqVhW1VHr3L.",
-                    secret="123", algorithm="sha512_crypt", salt="12345678", rounds=5000)
-
-
 @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",
@@ -85,19 +64,6 @@ def test_encrypt_with_rounds():
                 secret="123", algorithm="sha512_crypt", salt="12345678", rounds=5000)
 
 
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_encrypt_default_rounds_no_passlib():
-    with passlib_off():
-        assert_hash("$1$12345678$tRy4cXc3kmcfRZVj4iFXr/",
-                    secret="123", algorithm="md5_crypt", salt="12345678")
-        assert_hash("$5$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7",
-                    secret="123", algorithm="sha256_crypt", salt="12345678")
-        assert_hash("$6$12345678$LcV9LQiaPekQxZ.OfkMADjFdSO2k9zfbDQrHPVcYjSLqSdjLYpsgqviYvTEP/R41yPmhH3CCeEDqVhW1VHr3L.",
-                    secret="123", algorithm="sha512_crypt", salt="12345678")
-
-        assert encrypt.CryptHash("md5_crypt").hash("123")
-
-
 # If passlib is not installed. this is identical to the test_encrypt_default_rounds_no_passlib() test
 @pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
 def test_encrypt_default_rounds():
@@ -111,16 +77,6 @@ def test_encrypt_default_rounds():
     assert encrypt.PasslibHash("md5_crypt").hash("123")
 
 
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_password_hash_filter_no_passlib():
-    with passlib_off():
-        assert not encrypt.PASSLIB_AVAILABLE
-        assert get_encrypted_password("123", "md5", salt="12345678") == "$1$12345678$tRy4cXc3kmcfRZVj4iFXr/"
-
-        with pytest.raises(AnsibleFilterError):
-            get_encrypted_password("123", "crypt16", salt="12")
-
-
 @pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
 def test_password_hash_filter_passlib():
 
@@ -148,16 +104,6 @@ def test_password_hash_filter_passlib():
     assert get_encrypted_password("123", "pbkdf2_sha256", ident='invalid_ident')
 
 
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_do_encrypt_no_passlib():
-    with passlib_off():
-        assert not encrypt.PASSLIB_AVAILABLE
-        assert encrypt.do_encrypt("123", "md5_crypt", salt="12345678") == "$1$12345678$tRy4cXc3kmcfRZVj4iFXr/"
-
-        with pytest.raises(AnsibleError):
-            encrypt.do_encrypt("123", "crypt16", salt="12")
-
-
 @pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
 def test_do_encrypt_passlib():
     with pytest.raises(AnsibleError):
@@ -183,30 +129,6 @@ def test_random_salt():
         assert res_char in expected_salt_candidate_chars
 
 
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_invalid_crypt_salt():
-    pytest.raises(
-        AnsibleError,
-        encrypt.CryptHash('bcrypt')._salt,
-        '_',
-        None
-    )
-    encrypt.CryptHash('bcrypt')._salt('1234567890123456789012', None)
-    pytest.raises(
-        AnsibleError,
-        encrypt.CryptHash('bcrypt')._salt,
-        'kljsdf',
-        None
-    )
-    encrypt.CryptHash('sha256_crypt')._salt('123456', None)
-    pytest.raises(
-        AnsibleError,
-        encrypt.CryptHash('sha256_crypt')._salt,
-        '1234567890123456789012',
-        None
-    )
-
-
 def test_passlib_bcrypt_salt(recwarn):
     passlib_exc = pytest.importorskip("passlib.exc")
 
-- 
2.47.1