File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -345,7 +345,7 @@ fn http_store_keystore_passwords_in_secrets_dir_present() {
345
345
}
346
346
347
347
#[ test]
348
- fn http_token_path_flag ( ) {
348
+ fn http_token_path_flag_present ( ) {
349
349
let dir = TempDir :: new ( ) . expect ( "Unable to create temporary directory" ) ;
350
350
CommandLineTest :: new ( )
351
351
. flag ( "http" , None )
@@ -359,6 +359,19 @@ fn http_token_path_flag() {
359
359
} ) ;
360
360
}
361
361
362
+ #[ test]
363
+ fn http_token_path_default ( ) {
364
+ CommandLineTest :: new ( )
365
+ . flag ( "http" , None )
366
+ . run ( )
367
+ . with_config ( |config| {
368
+ assert_eq ! (
369
+ config. http_api. http_token_path,
370
+ config. validator_dir. join( "api-token.txt" )
371
+ ) ;
372
+ } ) ;
373
+ }
374
+
362
375
// Tests for Metrics flags.
363
376
#[ test]
364
377
fn metrics_flag ( ) {
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ pub struct Config {
106
106
107
107
impl Default for Config {
108
108
fn default ( ) -> Self {
109
+ // This value is always overridden when building config from CLI.
109
110
let http_token_path = dirs:: home_dir ( )
110
111
. unwrap_or_else ( || PathBuf :: from ( "." ) )
111
112
. join ( DEFAULT_ROOT_DIR )
Original file line number Diff line number Diff line change @@ -314,10 +314,11 @@ impl Config {
314
314
config. http_api . store_passwords_in_secrets_dir = true ;
315
315
}
316
316
317
- if cli_args. get_one :: < String > ( "http-token-path" ) . is_some ( ) {
318
- config. http_api . http_token_path = parse_required ( cli_args, "http-token-path" )
319
- // For backward compatibility, default to the path under the validator dir if not provided.
320
- . unwrap_or_else ( |_| config. validator_dir . join ( PK_FILENAME ) ) ;
317
+ if let Some ( http_token_path) = cli_args. get_one :: < String > ( "http-token-path" ) {
318
+ config. http_api . http_token_path = PathBuf :: from ( http_token_path) ;
319
+ } else {
320
+ // For backward compatibility, default to the path under the validator dir if not provided.
321
+ config. http_api . http_token_path = config. validator_dir . join ( PK_FILENAME ) ;
321
322
}
322
323
323
324
/*
You can’t perform that action at this time.
0 commit comments