@@ -440,19 +440,28 @@ mod tests {
440
440
#[ test]
441
441
fn test_ssh_program_configs ( ) -> Result < ( ) > {
442
442
let ( _tmp_dir, repo) = repo_init_empty ( ) ?;
443
+ let temp_file = tempfile:: NamedTempFile :: new ( )
444
+ . expect ( "failed to create temp file" ) ;
443
445
444
446
{
445
447
let mut config = repo. config ( ) ?;
446
- config. set_str ( "gpg.program" , "ssh" ) ?;
447
- config. set_str ( "user.signingKey" , "/tmp/key.pub" ) ?;
448
+ config. set_str ( "gpg.format" , "ssh" ) ?;
449
+ config. set_str (
450
+ "user.signingKey" ,
451
+ temp_file. path ( ) . to_str ( ) . unwrap ( ) ,
452
+ ) ?;
448
453
}
449
454
450
455
let sign =
451
456
SignBuilder :: from_gitconfig ( & repo, & repo. config ( ) ?) ?;
452
457
453
458
assert_eq ! ( "ssh-keygen" , sign. program( ) ) ;
454
- assert_eq ! ( "/tmp/key.pub" , sign. signing_key( ) ) ;
459
+ assert_eq ! (
460
+ temp_file. path( ) . to_str( ) . unwrap( ) ,
461
+ sign. signing_key( )
462
+ ) ;
455
463
464
+ drop ( temp_file) ;
456
465
Ok ( ( ) )
457
466
}
458
467
@@ -462,14 +471,14 @@ mod tests {
462
471
463
472
{
464
473
let mut config = repo. config ( ) ?;
465
- config. set_str ( "gpg.program " , "ssh" ) ?;
474
+ config. set_str ( "gpg.format " , "ssh" ) ?;
466
475
config. set_str ( "user.signingKey" , "ssh-ed25519 test" ) ?;
467
476
}
468
477
469
478
let sign =
470
479
SignBuilder :: from_gitconfig ( & repo, & repo. config ( ) ?) ?;
471
480
472
- assert_eq ! ( "ssh" , sign. program( ) ) ;
481
+ assert_eq ! ( "ssh-keygen " , sign. program( ) ) ;
473
482
assert_eq ! ( true , PathBuf :: from( sign. signing_key( ) ) . is_file( ) ) ;
474
483
475
484
Ok ( ( ) )
@@ -478,18 +487,27 @@ mod tests {
478
487
#[ test]
479
488
fn test_ssh_external_bin_config ( ) -> Result < ( ) > {
480
489
let ( _tmp_dir, repo) = repo_init_empty ( ) ?;
490
+ let temp_file = tempfile:: NamedTempFile :: new ( )
491
+ . expect ( "failed to create temp file" ) ;
481
492
482
493
{
483
494
let mut config = repo. config ( ) ?;
484
- config. set_str ( "gpg.program" , "/opt/ssh/signer" ) ?;
485
- config. set_str ( "user.signingKey" , "/tmp/key.pub" ) ?;
495
+ config. set_str ( "gpg.format" , "ssh" ) ?;
496
+ config. set_str ( "gpg.ssh.program" , "/opt/ssh/signer" ) ?;
497
+ config. set_str (
498
+ "user.signingKey" ,
499
+ temp_file. path ( ) . to_str ( ) . unwrap ( ) ,
500
+ ) ?;
486
501
}
487
502
488
503
let sign =
489
504
SignBuilder :: from_gitconfig ( & repo, & repo. config ( ) ?) ?;
490
505
491
506
assert_eq ! ( "/opt/ssh/signer" , sign. program( ) ) ;
492
- assert_eq ! ( "/tmp/key.pub" , sign. signing_key( ) ) ;
507
+ assert_eq ! (
508
+ temp_file. path( ) . to_str( ) . unwrap( ) ,
509
+ sign. signing_key( )
510
+ ) ;
493
511
494
512
Ok ( ( ) )
495
513
}
0 commit comments