Marco Ricci commited on 2024-06-08 19:06:56
Zeige 3 geänderte Dateien mit 8 Einfügungen und 7 Löschungen.
These "emergency exits" are code paths rooted in defensive programming (of both code and of tests), and are not intended to be reached in practice.
... | ... |
@@ -264,7 +264,7 @@ class Vault: |
264 | 264 |
charset) |
265 | 265 |
pos = seq.generate(len(charset)) |
266 | 266 |
result.extend(charset[pos:pos+1]) |
267 |
- except sequin.SequinExhaustedException: |
|
267 |
+ except sequin.SequinExhaustedException: # pragma: no cover |
|
268 | 268 |
hash_length *= 2 |
269 | 269 |
else: |
270 | 270 |
return bytes(result) |
... | ... |
@@ -353,14 +353,14 @@ def test_sign_data_via_agent(keytype, data_dict): |
353 | 353 |
else: |
354 | 354 |
try: |
355 | 355 |
client = ssh_agent_client.SSHAgentClient() |
356 |
- except OSError: |
|
356 |
+ except OSError: # pragma: no cover |
|
357 | 357 |
pytest.skip('communication error with the SSH agent') |
358 | 358 |
with client: |
359 | 359 |
key_comment_pairs = {bytes(k): bytes(c) |
360 | 360 |
for k, c in client.list_keys()} |
361 | 361 |
public_key_data = data_dict['public_key_data'] |
362 | 362 |
expected_signature = data_dict['expected_signature'] |
363 |
- if public_key_data not in key_comment_pairs: |
|
363 |
+ if public_key_data not in key_comment_pairs: # pragma: no cover |
|
364 | 364 |
pytest.skip('prerequisite SSH key not loaded') |
365 | 365 |
signature = bytes(client.sign( |
366 | 366 |
payload=derivepassphrase.Vault._UUID, key=public_key_data)) |
... | ... |
@@ -380,22 +380,22 @@ def test_sign_data_via_agent_unsupported(keytype, data_dict): |
380 | 380 |
result = subprocess.run(['ssh-add', '-t', '30', '-q', '-'], |
381 | 381 |
input=private_key, check=True, |
382 | 382 |
capture_output=True) |
383 |
- except subprocess.CalledProcessError as e: |
|
384 |
- pytest.xfail( |
|
383 |
+ except subprocess.CalledProcessError as e: # pragma: no cover |
|
384 |
+ pytest.skip( |
|
385 | 385 |
f"uploading test key: {e!r}, stdout={e.stdout!r}, " |
386 | 386 |
f"stderr={e.stderr!r}" |
387 | 387 |
) |
388 | 388 |
else: |
389 | 389 |
try: |
390 | 390 |
client = ssh_agent_client.SSHAgentClient() |
391 |
- except OSError: |
|
391 |
+ except OSError: # pragma: no cover |
|
392 | 392 |
pytest.skip('communication error with the SSH agent') |
393 | 393 |
with client: |
394 | 394 |
key_comment_pairs = {bytes(k): bytes(c) |
395 | 395 |
for k, c in client.list_keys()} |
396 | 396 |
public_key_data = data_dict['public_key_data'] |
397 | 397 |
expected_signature = data_dict['expected_signature'] |
398 |
- if public_key_data not in key_comment_pairs: |
|
398 |
+ if public_key_data not in key_comment_pairs: # pragma: no cover |
|
399 | 399 |
pytest.skip('prerequisite SSH key not loaded') |
400 | 400 |
signature = bytes(client.sign( |
401 | 401 |
payload=derivepassphrase.Vault._UUID, key=public_key_data)) |
402 | 402 |