Add example for `Vault.phrase_from_signature`
Marco Ricci

Marco Ricci commited on 2024-06-08 19:06:56
Zeige 1 geänderte Dateien mit 19 Einfügungen und 0 Löschungen.


Though written in doctest format, the test itself is skipped because it
relies on a running SSH agent.  Such external setup is better suited to
an actual unit test suite.
... ...
@@ -291,6 +291,25 @@ class Vault:
291 291
                 Usually this means that the signature is not
292 292
                 deterministic.
293 293
 
294
+        Examples:
295
+            >>> # Actual test public key.
296
+            >>> public_key = bytes.fromhex('''
297
+            ... 00 00 00 0b 73 73 68 2d 65 64 32 35 35 31 39
298
+            ... 00 00 00 20
299
+            ... 81 78 81 68 26 d6 02 48 5f 0f ff 32 48 6f e4 c1
300
+            ... 30 89 dc 1c 6a 45 06 09 e9 09 0f fb c2 12 69 76
301
+            ... ''')
302
+            >>> expected_sig = bytes.fromhex('''
303
+            ... 00 00 00 0b 73 73 68 2d 65 64 32 35 35 31 39
304
+            ... 00 00 00 40
305
+            ... f0 98 19 80 6c 1a 97 d5 26 03 6e cc e3 65 8f 86
306
+            ... 66 07 13 19 13 09 21 33 33 f9 e4 36 53 1d af fd
307
+            ... 0d 08 1f ec f8 73 9b 8c 5f 55 39 16 7c 53 54 2c
308
+            ... 1e 52 bb 30 ed 7f 89 e2 2f 69 51 55 d8 9e a6 02
309
+            ... ''')
310
+            >>> Vault.phrase_from_signature(public_key) == expected_sig  # doctest:+SKIP
311
+            True
312
+
294 313
         """
295 314
         deterministic_signature_types = {
296 315
             'ssh-ed25519':
297 316