|
12 | 12 | # ruff: noqa: I001 - yes I know I am using \ to continue the line...
|
13 | 13 | from roundup.password import PasswordValueError, encodePassword, \
|
14 | 14 | h64decode, h64encode
|
15 |
| - |
| 15 | +from roundup.password import crypt as crypt_method |
16 | 16 |
|
17 | 17 | def Identity(x):
|
18 | 18 | return x
|
@@ -57,11 +57,15 @@ def test_h64encode_h64decode(self, s):
|
57 | 57 | @settings(max_examples=_max_examples)
|
58 | 58 | def test_encodePassword(self, password, scheme):
|
59 | 59 |
|
60 |
| - if scheme == "crypt" and password and "\x00" in password: |
| 60 | + if scheme == "crypt" and password and "\x00" in password: |
61 | 61 | with self.assertRaises(ValueError) as e:
|
62 | 62 | encodePassword(password, scheme)
|
63 |
| - self.assertEqual(e.exception.args[0], |
64 |
| - "embedded null character") |
| 63 | + if crypt_method: |
| 64 | + self.assertEqual(e.exception.args[0], |
| 65 | + "embedded null character") |
| 66 | + else: |
| 67 | + self.assertEqual(e.exception.args[0], |
| 68 | + "Unsupported encryption scheme 'crypt'") |
65 | 69 | elif scheme == "plaintext":
|
66 | 70 | if password is not None:
|
67 | 71 | self.assertEqual(encodePassword(password, scheme), password)
|
@@ -90,7 +94,9 @@ def test_encodePassword(self, password, scheme):
|
90 | 94 | # d41d8cd98f00b204e9800998ecf8427e'
|
91 | 95 | self.assertRegex(pw, r"^[a-z0-9]{32}$")
|
92 | 96 | elif scheme == "crypt":
|
93 |
| - # WqzFDzhi8MmoU |
94 |
| - self.assertRegex(pw, r"^[A-Za-z0-9./]{13}$") |
| 97 | + # crypt_method is None if crypt is unknown |
| 98 | + if crypt_method: |
| 99 | + # WqzFDzhi8MmoU |
| 100 | + self.assertRegex(pw, r"^[A-Za-z0-9./]{13}$") |
95 | 101 | else:
|
96 | 102 | self.assertFalse("Unknown scheme: %s, val: %s" % (scheme, pw))
|
0 commit comments