A: use the shared temp-dir fixture in the config tests

This commit is contained in:
ari committed 2026-10-19 22:31:29 -04:00
1 parent 47868aa402
commit 80dec21afd
1 file changed
+2 -10
+2 -10
View File
@@ -531,8 +531,8 @@ mod tests {
#[test] #[test]
fn peers_env_overrides_scalars_and_keeps_file_entries() { fn peers_env_overrides_scalars_and_keeps_file_entries() {
Jail::expect_with(|jail| { Jail::expect_with(|jail| {
let token = jail.directory().join("peer.token"); let dir = crate::peers::testing::TempDir::new("config");
write_private_token(&token, "slinuxm_PEER_TOKEN_SHOULD_NOT_LEAK"); let token = dir.write("peer.token", b"slinuxm_PEER_TOKEN_SHOULD_NOT_LEAK", 0o600);
let file = format!( let file = format!(
"\ "\
[peers]\n\ [peers]\n\
@@ -580,12 +580,4 @@ mod tests {
Ok(()) Ok(())
}); });
} }
/// 0600 so a later permission check accepts the file. The contents are a
/// stand-in secret and must never show up in printed config.
fn write_private_token(path: &std::path::Path, contents: &str) {
use std::os::unix::fs::PermissionsExt;
std::fs::write(path, contents).unwrap();
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600)).unwrap();
}
} }