fn test_pre_existing_authorized_keys()

in libazureinit/src/provision/ssh.rs [492:520]


    fn test_pre_existing_authorized_keys() {
        let user = get_test_user_with_home_dir(true);
        let keys = vec![
            PublicKeys {
                key_data: "not-a-real-key abc123".to_string(),
                path: "unused".to_string(),
            },
            PublicKeys {
                key_data: "not-a-real-key xyz987".to_string(),
                path: "unused".to_string(),
            },
        ];

        let authorized_keys_path = user.dir.join(".ssh/xauthorized_keys");

        provision_ssh(&user, &keys[1..], authorized_keys_path.clone(), false)
            .unwrap();

        provision_ssh(&user, &keys[1..], authorized_keys_path.clone(), false)
            .unwrap();

        let mut auth_file =
            std::fs::File::open(user.dir.join(".ssh/xauthorized_keys"))
                .unwrap();
        let mut buf = String::new();
        auth_file.read_to_string(&mut buf).unwrap();

        assert_eq!("not-a-real-key xyz987\n", buf);
    }