@@ -500,7 +500,7 @@ def test_missing_private_key_setting(tmp_path, datafiles, monkeypatch):
500500 result = runner .invoke (
501501 main ,
502502 ["check" , "--skip-git-fetch" , "--config" , env ["orchestrator_config_file" ]],
503- input = "simple_test \n " ,
503+ input = "simple_example \n " ,
504504 )
505505 re_search (r"You must set the 'private_key' value in the .* file" , result .output )
506506
@@ -524,7 +524,71 @@ def test_wrong_private_key_value(tmp_path, datafiles, monkeypatch):
524524 result = runner .invoke (
525525 main ,
526526 ["check" , "--skip-git-fetch" , "--config" , env ["orchestrator_config_file" ]],
527- input = "simple_test\n " ,
527+ input = "simple_example\n " ,
528+ )
529+ re_search (
530+ r"What would you like to change the 'private_key' value in the"
531+ r" .*example.cnf to\? \[" ,
532+ result .output ,
533+ )
534+
535+
536+ @pytest .mark .datafiles (FIXTURE_DIR / "example.csr" , FIXTURE_DIR / "example.cnf" )
537+ def test_using_test_private_key (tmp_path , datafiles , monkeypatch ):
538+ runner = CliRunner ()
539+ with runner .isolated_filesystem (tmp_path ):
540+ env = set_up_environment (tmp_path , datafiles , monkeypatch )
541+ repo_dir = env ["repo_dir" ]
542+ Path (repo_dir / "certificate-authorities" / "simple_test" ).mkdir ()
543+ Path (repo_dir / "certificate-authorities" / "simple_test" / "test" ).mkdir ()
544+ Path (
545+ repo_dir / "certificate-authorities" / "simple_test" / "test" / "test.crt"
546+ ).touch ()
547+ with Path (
548+ repo_dir / "certificate-authorities" / "simple_test" / "test" / "serial"
549+ ).open ("w" ) as f :
550+ f .write ("01" )
551+ with Path (
552+ repo_dir / "certificate-authorities" / "simple_test" / "test" / "index.txt"
553+ ).open ("w" ) as f :
554+ f .write (
555+ "V\t 22511013200827Z\t \t 01\t unknown\t /C=US/O=Mozilla"
556+ " Corporation/OU=Mozilla AMO Production Signing Service/CN=test"
557+ )
558+ with (
559+ Path (datafiles / "example.cnf" ).open ("r" ) as in_file ,
560+ env ["cnf_file" ].open ("w" ) as out_file ,
561+ ):
562+ for line in in_file :
563+ if line .startswith ("private_key" ):
564+ out_file .write ("private_key = simple_test # The private key\n " )
565+ else :
566+ out_file .write (line )
567+ result = runner .invoke (
568+ main ,
569+ ["check" , "--skip-git-fetch" , "--config" , env ["orchestrator_config_file" ]],
570+ input = "n\n " ,
571+ )
572+ re_search (
573+ r"The 'private_key' in the .* file is set to 'simple_test' which is a test"
574+ r" private key\. Would you like to change it to something different\?" ,
575+ result .output ,
576+ )
577+ re_search (
578+ r"What would you like to change the 'private_key' value in the"
579+ r" .*example.cnf to\? \[" ,
580+ result .output ,
581+ reverse = True ,
582+ )
583+ result = runner .invoke (
584+ main ,
585+ ["check" , "--skip-git-fetch" , "--config" , env ["orchestrator_config_file" ]],
586+ input = "y\n simple_example\n " ,
587+ )
588+ re_search (
589+ r"The 'private_key' in the .* file is set to 'simple_test' which is a test"
590+ r" private key\. Would you like to change it to something different\?" ,
591+ result .output ,
528592 )
529593 re_search (
530594 r"What would you like to change the 'private_key' value in the"
0 commit comments