From 80dec21afdaad99df91852999e9c4121bb933bbb Mon Sep 17 00:00:00 2001 From: ari Date: Mon, 19 Oct 2026 21:09:50 -0400 Subject: [PATCH] A: use the shared temp-dir fixture in the config tests --- src/config.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4573453..3c940e0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -531,8 +531,8 @@ mod tests { #[test] fn peers_env_overrides_scalars_and_keeps_file_entries() { Jail::expect_with(|jail| { - let token = jail.directory().join("peer.token"); - write_private_token(&token, "slinuxm_PEER_TOKEN_SHOULD_NOT_LEAK"); + let dir = crate::peers::testing::TempDir::new("config"); + let token = dir.write("peer.token", b"slinuxm_PEER_TOKEN_SHOULD_NOT_LEAK", 0o600); let file = format!( "\ [peers]\n\ @@ -580,12 +580,4 @@ mod tests { 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(); - } }