in libazureinit/src/provision/ssh.rs [538:558]
fn test_update_sshd_config_change() -> io::Result<()> {
let temp_dir = TempDir::new()?;
let sshd_config_path = temp_dir.path().join("sshd_config");
{
let mut file = File::create(&sshd_config_path)?;
writeln!(file, "PasswordAuthentication no")?;
}
let ret: Result<(), io::Error> =
update_sshd_config(sshd_config_path.to_str().unwrap());
assert!(ret.is_ok());
let mut updated_content = String::new();
{
let mut file = File::open(&sshd_config_path)?;
file.read_to_string(&mut updated_content)?;
}
assert!(updated_content.contains("PasswordAuthentication yes"));
assert!(!updated_content.contains("PasswordAuthentication no"));
Ok(())
}