|
10 | 10 |
|
11 | 11 | import pytest |
12 | 12 |
|
13 | | -from tests.config_pydantic import CONFIG_TDF |
14 | 13 | from tests.support_cli_args import get_platform_url |
15 | 14 |
|
16 | 15 | original_env = os.environ.copy() |
@@ -65,7 +64,7 @@ def test_cli_decrypt_otdfctl_tdf(temp_credentials_file): |
65 | 64 | env=original_env, |
66 | 65 | ) |
67 | 66 |
|
68 | | - # If otdfctl fails, skip the test (might be server issues) |
| 67 | + # If otdfctl fails to encrypt, fail fast |
69 | 68 | if otdfctl_result.returncode != 0: |
70 | 69 | raise Exception(f"otdfctl encrypt failed: {otdfctl_result.stderr}") |
71 | 70 |
|
@@ -165,7 +164,7 @@ def test_otdfctl_decrypt_comparison(collect_server_logs, temp_credentials_file): |
165 | 164 | env=original_env, |
166 | 165 | ) |
167 | 166 |
|
168 | | - # If otdfctl encrypt fails, skip the test (might be server issues) |
| 167 | + # If otdfctl fails to encrypt, fail fast |
169 | 168 | if otdfctl_encrypt_result.returncode != 0: |
170 | 169 | raise Exception(f"otdfctl encrypt failed: {otdfctl_encrypt_result.stderr}") |
171 | 170 |
|
@@ -226,23 +225,9 @@ def test_otdfctl_decrypt_comparison(collect_server_logs, temp_credentials_file): |
226 | 225 |
|
227 | 226 | # Check that our CLI succeeded |
228 | 227 | if cli_decrypt_result.returncode != 0: |
229 | | - # Collect server logs for debugging |
230 | 228 | logs = collect_server_logs() |
231 | 229 | print(f"Server logs when Python CLI decrypt failed:\n{logs}") |
232 | | - |
233 | | - # Check if this is a server connectivity issue |
234 | | - if ( |
235 | | - "401 Unauthorized" in cli_decrypt_result.stderr |
236 | | - or "token endpoint discovery" in cli_decrypt_result.stderr |
237 | | - or "Issuer endpoint must be configured" in cli_decrypt_result.stderr |
238 | | - ): |
239 | | - pytest.skip( |
240 | | - f"Server connectivity or authentication issue: {cli_decrypt_result.stderr}" |
241 | | - ) |
242 | | - else: |
243 | | - assert cli_decrypt_result.returncode == 0, ( |
244 | | - f"Python CLI decrypt failed: {cli_decrypt_result.stderr}" |
245 | | - ) |
| 230 | + raise Exception(f"Python CLI decrypt failed: {cli_decrypt_result.stderr}") |
246 | 231 |
|
247 | 232 | # Verify both decrypted files were created |
248 | 233 | assert otdfctl_decrypt_output.exists(), "otdfctl did not create decrypted file" |
@@ -327,25 +312,9 @@ def test_otdfctl_encrypt_decrypt_roundtrip(collect_server_logs, temp_credentials |
327 | 312 | env=original_env, |
328 | 313 | ) |
329 | 314 |
|
330 | | - # If otdfctl encrypt fails, skip the test (might be server issues) |
| 315 | + # If otdfctl fails to encrypt, fail fast |
331 | 316 | if otdfctl_encrypt_result.returncode != 0: |
332 | | - # Collect server logs for debugging |
333 | | - logs = collect_server_logs() |
334 | | - print(f"Server logs when otdfctl encrypt failed:\n{logs}") |
335 | | - |
336 | | - # Check if this is a server connectivity issue |
337 | | - if ( |
338 | | - "401 Unauthorized" in otdfctl_encrypt_result.stderr |
339 | | - or "token endpoint discovery" in otdfctl_encrypt_result.stderr |
340 | | - or "Issuer endpoint must be configured" in otdfctl_encrypt_result.stderr |
341 | | - ): |
342 | | - pytest.skip( |
343 | | - f"Server connectivity or authentication issue: {otdfctl_encrypt_result.stderr}" |
344 | | - ) |
345 | | - else: |
346 | | - assert otdfctl_encrypt_result.returncode == 0, ( |
347 | | - f"otdfctl encrypt failed: {otdfctl_encrypt_result.stderr}" |
348 | | - ) |
| 317 | + raise Exception(f"otdfctl encrypt failed: {otdfctl_encrypt_result.stderr}") |
349 | 318 |
|
350 | 319 | # Verify the TDF file was created |
351 | 320 | assert otdfctl_tdf_output.exists(), "otdfctl did not create TDF file" |
@@ -378,25 +347,11 @@ def test_otdfctl_encrypt_decrypt_roundtrip(collect_server_logs, temp_credentials |
378 | 347 | env=original_env, |
379 | 348 | ) |
380 | 349 |
|
381 | | - # Check that otdfctl decrypt succeeded |
| 350 | + # If otdfctl fails to decrypt, fail fast |
382 | 351 | if otdfctl_decrypt_result.returncode != 0: |
383 | | - # Collect server logs for debugging |
384 | 352 | logs = collect_server_logs() |
385 | 353 | print(f"Server logs when otdfctl decrypt failed:\n{logs}") |
386 | | - |
387 | | - # Check if this is a server connectivity issue |
388 | | - if ( |
389 | | - "401 Unauthorized" in otdfctl_decrypt_result.stderr |
390 | | - or "token endpoint discovery" in otdfctl_decrypt_result.stderr |
391 | | - or "Issuer endpoint must be configured" in otdfctl_decrypt_result.stderr |
392 | | - ): |
393 | | - pytest.skip( |
394 | | - f"Server connectivity or authentication issue: {otdfctl_decrypt_result.stderr}" |
395 | | - ) |
396 | | - else: |
397 | | - assert otdfctl_decrypt_result.returncode == 0, ( |
398 | | - f"otdfctl decrypt failed: {otdfctl_decrypt_result.stderr}" |
399 | | - ) |
| 354 | + raise Exception(f"otdfctl decrypt failed: {otdfctl_decrypt_result.stderr}") |
400 | 355 |
|
401 | 356 | # Verify the decrypted file was created |
402 | 357 | assert otdfctl_decrypt_output.exists(), "otdfctl did not create decrypted file" |
@@ -429,14 +384,8 @@ def test_otdfctl_encrypt_decrypt_roundtrip(collect_server_logs, temp_credentials |
429 | 384 |
|
430 | 385 |
|
431 | 386 | @pytest.mark.integration |
432 | | -def test_cli_encrypt_integration(temp_credentials_file): |
| 387 | +def test_cli_encrypt_integration(collect_server_logs, temp_credentials_file): |
433 | 388 | """Integration test comparing our CLI with otdfctl""" |
434 | | - # Skip if OPENTDF_PLATFORM_URL is not set |
435 | | - platform_url = CONFIG_TDF.OPENTDF_PLATFORM_URL |
436 | | - if not platform_url: |
437 | | - raise Exception( |
438 | | - "OPENTDF_PLATFORM_URL must be set in config for integration tests" |
439 | | - ) |
440 | 389 |
|
441 | 390 | # Create temporary directory for work |
442 | 391 | with tempfile.TemporaryDirectory() as temp_dir: |
@@ -502,20 +451,9 @@ def test_cli_encrypt_integration(temp_credentials_file): |
502 | 451 |
|
503 | 452 | # Check that our CLI succeeded |
504 | 453 | if cli_result.returncode != 0: |
505 | | - # Check if this is a server connectivity issue |
506 | | - if ( |
507 | | - "401 Unauthorized" in cli_result.stderr |
508 | | - or "token endpoint discovery" in cli_result.stderr |
509 | | - or "Issuer endpoint must be configured" in cli_result.stderr |
510 | | - ): |
511 | | - pytest.skip( |
512 | | - f"Server connectivity or authentication issue: {cli_result.stderr}" |
513 | | - ) |
514 | | - |
515 | | - else: |
516 | | - assert cli_result.returncode == 0, ( |
517 | | - f"Python CLI failed: {cli_result.stderr}" |
518 | | - ) |
| 454 | + logs = collect_server_logs() |
| 455 | + print(f"Server logs when Python CLI encrypt failed:\n{logs}") |
| 456 | + raise Exception(f"Python CLI failed: {cli_result.stderr}") |
519 | 457 |
|
520 | 458 | # Both output files should exist |
521 | 459 | assert otdfctl_output.exists(), "otdfctl output file does not exist" |
|
0 commit comments