Skip to content

Commit 43942ce

Browse files
committed
tests: add test for configuration with deprecated env var name
Until it's updated in this repor and the Index repo you can overwrite the admin token using the new env var name and the old one (deprecated): - New: `TORRUST_TRACKER__HTTP_API__ACCESS_TOKENS__ADMIN` - Old (deprecated): `TORRUST_TRACKER_API_ADMIN_TOKEN` THe new one uses exactly the strcuture and atribute names in the toml file, using `__` as the separator for levels. We can remove the test when we remove the deprecated name.
1 parent b0c2f9f commit 43942ce

File tree

1 file changed

+20
-1
lines changed
  • packages/configuration/src/v1

1 file changed

+20
-1
lines changed

packages/configuration/src/v1/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ mod tests {
540540
}
541541

542542
#[test]
543-
fn configuration_should_allow_to_overwrite_the_default_tracker_api_token_for_admin() {
543+
fn configuration_should_allow_to_overwrite_the_default_tracker_api_token_for_admin_with_env_var() {
544544
figment::Jail::expect_with(|jail| {
545545
jail.set_env("TORRUST_TRACKER__HTTP_API__ACCESS_TOKENS__ADMIN", "NewToken");
546546

@@ -559,4 +559,23 @@ mod tests {
559559
Ok(())
560560
});
561561
}
562+
563+
#[test]
564+
fn configuration_should_allow_to_overwrite_the_default_tracker_api_token_for_admin_with_the_deprecated_env_var_name() {
565+
figment::Jail::expect_with(|_jail| {
566+
let info = Info {
567+
tracker_toml: default_config_toml(),
568+
api_admin_token: Some("NewToken".to_owned()),
569+
};
570+
571+
let configuration = Configuration::load(&info).expect("Could not load configuration from file");
572+
573+
assert_eq!(
574+
configuration.http_api.access_tokens.get("admin"),
575+
Some("NewToken".to_owned()).as_ref()
576+
);
577+
578+
Ok(())
579+
});
580+
}
562581
}

0 commit comments

Comments
 (0)