3333 otdfctl_flags = ["--tls-no-verify" ]
3434
3535
36- def _create_test_credentials (temp_path : Path ) -> Path :
37- """Create a test credentials file in the given temporary directory."""
38- creds_file = temp_path / "test-creds.json"
39- creds_data = {"clientId" : "opentdf" , "clientSecret" : "secret" }
40- with open (creds_file , "w" ) as f :
41- json .dump (creds_data , f )
42- return creds_file
43-
44-
4536def _create_test_input_file (temp_path : Path , content : str ) -> Path :
4637 """Create a test input file with the given content."""
4738 input_file = temp_path / "input.txt"
@@ -381,15 +372,14 @@ def _run_python_cli_decrypt(
381372
382373
383374@pytest .mark .integration
384- def test_otdfctl_encrypt_with_validation (collect_server_logs ):
375+ def test_otdfctl_encrypt_with_validation (collect_server_logs , temp_credentials_file ):
385376 """Integration test that uses otdfctl for encryption and validates the TDF thoroughly."""
386377
387378 # Create temporary directory for work
388379 with tempfile .TemporaryDirectory () as temp_dir :
389380 temp_path = Path (temp_dir )
390381
391382 # Create test files
392- creds_file = _create_test_credentials (temp_path )
393383 input_content = "Hello, World! This is test content for otdfctl encryption."
394384 input_file = _create_test_input_file (temp_path , input_content )
395385
@@ -403,7 +393,7 @@ def test_otdfctl_encrypt_with_validation(collect_server_logs):
403393 "--host" ,
404394 platform_url ,
405395 "--with-client-creds-file" ,
406- str (creds_file ),
396+ str (temp_credentials_file ),
407397 * otdfctl_flags ,
408398 "--mime-type" ,
409399 "text/plain" ,
@@ -433,7 +423,7 @@ def test_otdfctl_encrypt_with_validation(collect_server_logs):
433423 _run_otdfctl_decrypt (
434424 otdfctl_tdf_output ,
435425 platform_url ,
436- creds_file ,
426+ temp_credentials_file ,
437427 temp_path ,
438428 collect_server_logs ,
439429 input_content ,
@@ -444,15 +434,14 @@ def test_otdfctl_encrypt_with_validation(collect_server_logs):
444434
445435
446436@pytest .mark .integration
447- def test_python_encrypt (collect_server_logs ):
437+ def test_python_encrypt (collect_server_logs , temp_credentials_file ):
448438 """Integration test that uses Python CLI for encryption only and verifies the TDF can be inspected"""
449439
450440 # Create temporary directory for work
451441 with tempfile .TemporaryDirectory () as temp_dir :
452442 temp_path = Path (temp_dir )
453443
454444 # Create test files
455- creds_file = _create_test_credentials (temp_path )
456445 input_content = "Hello, World! This is test content for Python CLI encryption."
457446 input_file = _create_test_input_file (temp_path , input_content )
458447
@@ -469,7 +458,7 @@ def test_python_encrypt(collect_server_logs):
469458 "--platform-url" ,
470459 platform_url ,
471460 "--with-client-creds-file" ,
472- str (creds_file ),
461+ str (temp_credentials_file ),
473462 * cli_flags ,
474463 "encrypt" ,
475464 "--mime-type" ,
@@ -500,7 +489,7 @@ def test_python_encrypt(collect_server_logs):
500489 _run_otdfctl_decrypt (
501490 python_tdf_output ,
502491 platform_url ,
503- creds_file ,
492+ temp_credentials_file ,
504493 temp_path ,
505494 collect_server_logs ,
506495 input_content ,
@@ -513,15 +502,14 @@ def test_python_encrypt(collect_server_logs):
513502
514503
515504@pytest .mark .integration
516- def test_cross_tool_compatibility (collect_server_logs ):
505+ def test_cross_tool_compatibility (collect_server_logs , temp_credentials_file ):
517506 """Test that TDFs created by one tool can be decrypted by the other."""
518507
519508 # Create temporary directory for work
520509 with tempfile .TemporaryDirectory () as temp_dir :
521510 temp_path = Path (temp_dir )
522511
523512 # Create test files
524- creds_file = _create_test_credentials (temp_path )
525513 input_content = "Cross-tool compatibility test content. Testing 123!"
526514 input_file = _create_test_input_file (temp_path , input_content )
527515
@@ -535,7 +523,7 @@ def test_cross_tool_compatibility(collect_server_logs):
535523 "--host" ,
536524 platform_url ,
537525 "--with-client-creds-file" ,
538- str (creds_file ),
526+ str (temp_credentials_file ),
539527 * otdfctl_flags ,
540528 "--mime-type" ,
541529 "text/plain" ,
@@ -562,7 +550,7 @@ def test_cross_tool_compatibility(collect_server_logs):
562550 _run_python_cli_decrypt (
563551 otdfctl_tdf_output ,
564552 platform_url ,
565- creds_file ,
553+ temp_credentials_file ,
566554 temp_path ,
567555 collect_server_logs ,
568556 input_content ,
@@ -581,7 +569,7 @@ def test_cross_tool_compatibility(collect_server_logs):
581569 "--platform-url" ,
582570 platform_url ,
583571 "--with-client-creds-file" ,
584- str (creds_file ),
572+ str (temp_credentials_file ),
585573 * cli_flags ,
586574 "encrypt" ,
587575 "--mime-type" ,
@@ -609,7 +597,7 @@ def test_cross_tool_compatibility(collect_server_logs):
609597 _run_otdfctl_decrypt (
610598 python_tdf_output ,
611599 platform_url ,
612- creds_file ,
600+ temp_credentials_file ,
613601 temp_path ,
614602 collect_server_logs ,
615603 input_content ,
@@ -621,7 +609,7 @@ def test_cross_tool_compatibility(collect_server_logs):
621609
622610
623611@pytest .mark .integration
624- def test_different_content_types (collect_server_logs ):
612+ def test_different_content_types (collect_server_logs , temp_credentials_file ):
625613 """Test encryption/decryption with different types of content."""
626614
627615 test_cases = [
@@ -634,7 +622,6 @@ def test_different_content_types(collect_server_logs):
634622 # Create temporary directory for work
635623 with tempfile .TemporaryDirectory () as temp_dir :
636624 temp_path = Path (temp_dir )
637- creds_file = _create_test_credentials (temp_path )
638625
639626 for filename , content in test_cases :
640627 print (f"\n --- Testing { filename } (content length: { len (content )} ) ---" )
@@ -657,7 +644,7 @@ def test_different_content_types(collect_server_logs):
657644 "--platform-url" ,
658645 platform_url ,
659646 "--with-client-creds-file" ,
660- str (creds_file ),
647+ str (temp_credentials_file ),
661648 * cli_flags ,
662649 "encrypt" ,
663650 "--mime-type" ,
@@ -688,7 +675,7 @@ def test_different_content_types(collect_server_logs):
688675 _run_otdfctl_decrypt (
689676 python_tdf_output ,
690677 platform_url ,
691- creds_file ,
678+ temp_credentials_file ,
692679 temp_path ,
693680 collect_server_logs ,
694681 content ,
@@ -701,7 +688,7 @@ def test_different_content_types(collect_server_logs):
701688
702689@pytest .mark .skip ("Skipping test for now due to known issues with empty content" )
703690@pytest .mark .integration
704- def test_different_content_types_empty (collect_server_logs ):
691+ def test_different_content_types_empty (collect_server_logs , temp_credentials_file ):
705692 """Test encryption/decryption with different types of content."""
706693
707694 test_cases = [
@@ -711,7 +698,6 @@ def test_different_content_types_empty(collect_server_logs):
711698 # Create temporary directory for work
712699 with tempfile .TemporaryDirectory () as temp_dir :
713700 temp_path = Path (temp_dir )
714- creds_file = _create_test_credentials (temp_path )
715701
716702 for filename , content in test_cases :
717703 print (f"\n --- Testing { filename } (content length: { len (content )} ) ---" )
@@ -734,7 +720,7 @@ def test_different_content_types_empty(collect_server_logs):
734720 "--platform-url" ,
735721 platform_url ,
736722 "--with-client-creds-file" ,
737- str (creds_file ),
723+ str (temp_credentials_file ),
738724 * cli_flags ,
739725 "encrypt" ,
740726 "--mime-type" ,
@@ -765,7 +751,7 @@ def test_different_content_types_empty(collect_server_logs):
765751 _run_otdfctl_decrypt (
766752 python_tdf_output ,
767753 platform_url ,
768- creds_file ,
754+ temp_credentials_file ,
769755 temp_path ,
770756 collect_server_logs ,
771757 content ,
0 commit comments