Restore the `test_hash_length_expansion`/`test_wrong_initial_hash_length` vault test
Marco Ricci

Marco Ricci commited on 2026-07-05 16:52:19
Zeige 1 geänderte Dateien mit 18 Einfügungen und 0 Löschungen.


This test exercises the "automatically enlarging the sequin input" path
of passphrase derivation in vault.

We originally removed this test because its original name and
description suggested a somewhat different purpose, and necessity.
... ...
@@ -810,6 +810,24 @@ class TestUtilities(TestVault):
810 810
             )
811 811
         assert v._estimate_sufficient_hash_length(8.0) >= entropy
812 812
 
813
+    @Parametrize.SAMPLE_SERVICES_AND_PHRASES
814
+    def test_wrong_initial_hash_length(
815
+        self,
816
+        monkeypatch: pytest.MonkeyPatch,
817
+        service: str | bytes,
818
+        expected: bytes,
819
+    ) -> None:
820
+        """
821
+        Generating passphrases with the wrong starting hash length still works.
822
+        """
823
+        v = vault.Vault(phrase=self.phrase)
824
+        monkeypatch.setattr(
825
+            v,
826
+            "_estimate_sufficient_hash_length",
827
+            lambda *_args, **_kwargs: 1,
828
+        )
829
+        assert v.generate(service) == expected
830
+
813 831
     @Parametrize.BINARY_STRINGS
814 832
     @hypothesis.given(
815 833
         s=strategies.text().flatmap(
816 834