@@ -521,7 +521,7 @@ mod test {
521
521
let td = TempDir :: new( ) . unwrap( ) ;
522
522
let mut cfg = Config :: new( ) . unwrap( ) ;
523
523
cfg. add_file( & td. path( ) . join( "cfg" ) , ConfigLevel :: Highest , false ) . unwrap( ) ;
524
- $( cfg. set_str ( $k, $v) . unwrap( ) ; ) *
524
+ $( cfg. set_multivar ( $k, "DO_NO_MATCH_ANYTHING" , $v) . unwrap( ) ; ) *
525
525
cfg
526
526
} ) ) ;
527
527
@@ -696,6 +696,36 @@ echo password=$2
696
696
assert_eq ! ( p, "b" ) ;
697
697
}
698
698
699
+ #[ test]
700
+ fn credential_helper10 ( ) {
701
+ let cache_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
702
+ let cache_cmd = format ! (
703
+ "!f() {{ if [ \" $1\" = store ]; then cat > {}; fi; }}; f" ,
704
+ cache_file. path( ) . display( )
705
+ ) ;
706
+ let cfg = test_cfg ! (
707
+ // The output will be ignored in the store phase
708
+ "credential.helper" => "!f() { echo username=a; echo password=b; }; f" ,
709
+ "credential.helper" => & cache_cmd
710
+ ) ;
711
+ let ( u, p) = CredentialHelper :: new ( "https://example.com/foo/bar" )
712
+ . config ( & cfg)
713
+ . execute ( )
714
+ . unwrap ( ) ;
715
+ assert_eq ! ( u, "a" ) ;
716
+ assert_eq ! ( p, "b" ) ;
717
+
718
+ let mut cache_content = String :: new ( ) ;
719
+ cache_file
720
+ . as_file ( )
721
+ . read_to_string ( & mut cache_content)
722
+ . unwrap ( ) ;
723
+ assert ! ( cache_content. contains( "protocol=https\n " ) ) ;
724
+ assert ! ( cache_content. contains( "host=example.com\n " ) ) ;
725
+ assert ! ( cache_content. contains( "username=a\n " ) ) ;
726
+ assert ! ( cache_content. contains( "password=b\n " ) ) ;
727
+ }
728
+
699
729
#[ test]
700
730
#[ cfg( feature = "ssh" ) ]
701
731
fn ssh_key_from_memory ( ) {
0 commit comments