A: use the shared temp-dir fixture in the config tests
This commit is contained in:
1 parent
47868aa402
commit
80dec21afd
1 file changed
+2
-10
+2
-10
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user