fix: resolve all Dependabot security vulnerabilities (#316)
Run `cargo update` to bump transitive dependencies, fixing 10 of 11 alerts (h2, ring, idna, mio, tokio, bytes, time, quinn-proto, rustls-webpki, unsafe-libyaml). Replace deprecated `tempdir` dev-dependency with `tempfile` to eliminate the `remove_dir_all` vulnerability (the last alert).
This commit is contained in:
+1
-1
@@ -70,7 +70,7 @@ mock_instant = "0.5.1"
|
||||
# Gives #[serial] attribute for locking all of our shorebird_init
|
||||
# tests to a single thread so they don't conflict with each other.
|
||||
serial_test = "3.2.0"
|
||||
tempdir = "0.3.7"
|
||||
tempfile = "3"
|
||||
|
||||
# <https://github.com/eqrion/cbindgen/blob/master/docs.md#buildrs>
|
||||
[build-dependencies]
|
||||
|
||||
@@ -211,7 +211,7 @@ pub fn libapp_path_from_settings(original_libapp_paths: &[String]) -> Result<Pat
|
||||
mod tests {
|
||||
use std::fs::File;
|
||||
use std::path::{Path, PathBuf};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
use zip::write::SimpleFileOptions;
|
||||
use zip::ZipWriter;
|
||||
|
||||
@@ -239,7 +239,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn find_and_open_lib_test() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let error = super::find_and_open_lib(tmp_dir.path(), "libapp.so").unwrap_err();
|
||||
assert_error_is_file_not_found(&error);
|
||||
|
||||
@@ -263,7 +263,7 @@ mod tests {
|
||||
#[test]
|
||||
fn find_and_open_lib_base_apk() {
|
||||
// Create a valid apk (zip) with an empty libapp.so with the right path.
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
let base_apk_path = tmp_dir.path().join("base.apk");
|
||||
let arch = super::android_arch_names();
|
||||
@@ -283,7 +283,7 @@ mod tests {
|
||||
fn find_and_open_lib_split_apk() {
|
||||
// Create a valid apk (zip) with an empty libapp.so with the right path
|
||||
// and a base apk with the wrong path.
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Write a base.apk with the wrong arch.
|
||||
let base_apk_path = tmp_dir.path().join("base.apk");
|
||||
@@ -323,7 +323,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn open_base_lib_test() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let error = super::open_base_lib(tmp_dir.path(), "libapp.so").unwrap_err();
|
||||
assert_error_is_file_not_found(&error);
|
||||
}
|
||||
|
||||
+13
-13
@@ -395,7 +395,7 @@ mod test {
|
||||
};
|
||||
use anyhow::Ok;
|
||||
use serial_test::serial;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
use updater::testing_reset_config;
|
||||
|
||||
use std::{ffi::CString, ptr::null_mut};
|
||||
@@ -500,7 +500,7 @@ mod test {
|
||||
#[test]
|
||||
fn init_with_bad_yaml() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let c_params = parameters(&tmp_dir, "/dir/lib/arm64/libapp.so");
|
||||
let c_yaml = c_string("bad yaml");
|
||||
assert!(!shorebird_init(&c_params, FileCallbacks::new(), c_yaml));
|
||||
@@ -512,7 +512,7 @@ mod test {
|
||||
#[test]
|
||||
fn init_with_invalid_patch_verification() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let c_params = parameters(&tmp_dir, "/dir/lib/arm64/libapp.so");
|
||||
let c_yaml = c_string("app_id: foo\npatch_verification: bogus_mode");
|
||||
// Invalid patch_verification causes init to fail and return false
|
||||
@@ -525,7 +525,7 @@ mod test {
|
||||
#[test]
|
||||
fn yaml_parsing() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let c_params = parameters(&tmp_dir, "/dir/lib/arm64/libapp.so");
|
||||
let c_yaml = c_string(
|
||||
"
|
||||
@@ -544,7 +544,7 @@ mod test {
|
||||
#[test]
|
||||
fn empty_state_no_update() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let c_params = parameters(&tmp_dir, "/dir/lib/arm64/libapp.so");
|
||||
// app_id is required or shorebird_init will fail.
|
||||
let c_yaml = c_string("app_id: foo");
|
||||
@@ -568,7 +568,7 @@ mod test {
|
||||
#[test]
|
||||
fn patch_success() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Generated by `string_patch "hello world" "hello tests"`
|
||||
let base = "hello world";
|
||||
@@ -633,7 +633,7 @@ mod test {
|
||||
#[test]
|
||||
fn patch_success_with_result() -> anyhow::Result<()> {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Generated by `string_patch "hello world" "hello tests"`
|
||||
let base = "hello world";
|
||||
@@ -705,7 +705,7 @@ mod test {
|
||||
#[test]
|
||||
fn patch_check_no_patch_with_result() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Generated by `string_patch "hello world" "hello tests"`
|
||||
let base = "hello world";
|
||||
@@ -745,7 +745,7 @@ mod test {
|
||||
#[test]
|
||||
fn patch_check_failure_with_result() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Generated by `string_patch "hello world" "hello tests"`
|
||||
let base = "hello world";
|
||||
@@ -786,7 +786,7 @@ mod test {
|
||||
#[test]
|
||||
fn patch_download_failure_with_result() -> anyhow::Result<()> {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Generated by `string_patch "hello world" "hello tests"`
|
||||
let base = "hello world";
|
||||
@@ -841,7 +841,7 @@ mod test {
|
||||
#[test]
|
||||
fn current_boot_patch_set_after_reporting_launch_start() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Generated by `string_patch "hello world" "hello tests"`
|
||||
let base = "hello world";
|
||||
@@ -922,7 +922,7 @@ mod test {
|
||||
// thread local for the storage, but it should test the same idea.
|
||||
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
let fake_libapp_path = tmp_dir.path().join("lib/arch/libapp.so");
|
||||
let c_params = parameters(&tmp_dir, fake_libapp_path.to_str().unwrap());
|
||||
@@ -951,7 +951,7 @@ mod test {
|
||||
// request.
|
||||
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
let fake_libapp_path = tmp_dir.path().join("lib/arch/libapp.so");
|
||||
let c_params = parameters(&tmp_dir, fake_libapp_path.to_str().unwrap());
|
||||
|
||||
Vendored
+3
-3
@@ -55,7 +55,7 @@ mod test {
|
||||
use std::path::Path;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use anyhow::{Ok, Result};
|
||||
|
||||
@@ -71,7 +71,7 @@ mod test {
|
||||
a: 1,
|
||||
b: "hello".to_string(),
|
||||
};
|
||||
let temp_dir = TempDir::new("test")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let path = temp_dir.path().join("test.json");
|
||||
super::write(&test_struct, &path)?;
|
||||
let read_struct: TestStruct = super::read(&path)?;
|
||||
@@ -88,7 +88,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn read_errs_if_struct_cannot_be_deserialized() -> Result<()> {
|
||||
let temp_dir = TempDir::new("test")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let path = &temp_dir.path().join("test.json");
|
||||
std::fs::write(path, "junk")?;
|
||||
|
||||
|
||||
Vendored
+48
-48
@@ -12,7 +12,7 @@ use std::{
|
||||
#[cfg(test)]
|
||||
use mockall::automock;
|
||||
#[cfg(test)]
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
const PATCHES_DIR_NAME: &str = "patches";
|
||||
const PATCHES_STATE_FILE_NAME: &str = "patches_state.json";
|
||||
@@ -573,14 +573,14 @@ impl PatchManager {
|
||||
|
||||
#[cfg(test)]
|
||||
mod debug_tests {
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use super::PatchManager;
|
||||
use crate::yaml::PatchVerificationMode;
|
||||
|
||||
#[test]
|
||||
fn manage_patches_is_debug() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let patch_manager: Box<dyn super::ManagePatches> =
|
||||
Box::new(PatchManager::manager_for_test(&temp_dir));
|
||||
assert_eq!(format!("{:?}", patch_manager), "ManagePatches");
|
||||
@@ -588,7 +588,7 @@ mod debug_tests {
|
||||
|
||||
#[test]
|
||||
fn patch_manager_is_debug() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let patch_manager = PatchManager::new(
|
||||
temp_dir.path().to_owned(),
|
||||
Some("public_key"),
|
||||
@@ -603,11 +603,11 @@ mod debug_tests {
|
||||
mod add_patch_tests {
|
||||
use super::*;
|
||||
use std::path::Path;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn errs_if_file_path_does_not_exist() {
|
||||
let mut manager = PatchManager::manager_for_test(&TempDir::new("patch_manager").unwrap());
|
||||
let mut manager = PatchManager::manager_for_test(&TempDir::new().unwrap());
|
||||
assert!(manager
|
||||
.add_patch(
|
||||
1,
|
||||
@@ -622,7 +622,7 @@ mod add_patch_tests {
|
||||
fn adds_patch_successfully() {
|
||||
let patch_number = 1;
|
||||
let patch_file_contents = "patch contents";
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
let file_path = &temp_dir.path().join("patch1.vmcode");
|
||||
@@ -669,7 +669,7 @@ mod add_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn install_only_errs_if_public_key_is_invalid() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some("not a valid key"),
|
||||
@@ -687,7 +687,7 @@ mod add_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn install_only_errs_if_signature_is_missing_when_public_key_configured() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some(PUBLIC_KEY),
|
||||
@@ -705,7 +705,7 @@ mod add_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn install_only_errs_if_signature_is_invalid() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some(PUBLIC_KEY),
|
||||
@@ -725,7 +725,7 @@ mod add_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn install_only_succeeds_with_valid_signature() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some(PUBLIC_KEY),
|
||||
@@ -743,7 +743,7 @@ mod add_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn install_only_succeeds_with_any_signature_if_no_public_key() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
None, // No public key configured
|
||||
@@ -763,11 +763,11 @@ mod add_patch_tests {
|
||||
#[cfg(test)]
|
||||
mod last_successfully_booted_patch_tests {
|
||||
use super::*;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn returns_none_if_no_patch_has_been_booted() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
manager.add_patch_for_test(&temp_dir, 1)?;
|
||||
assert!(manager.last_successfully_booted_patch().is_none());
|
||||
@@ -777,7 +777,7 @@ mod last_successfully_booted_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn returns_value_from_patches_state() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
manager.add_patch_for_test(&temp_dir, 1)?;
|
||||
|
||||
@@ -795,18 +795,18 @@ mod last_successfully_booted_patch_tests {
|
||||
#[cfg(test)]
|
||||
mod next_boot_patch_tests {
|
||||
use super::*;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn returns_none_if_no_next_boot_patch() {
|
||||
let temp_dir = TempDir::new("patch_manager").unwrap();
|
||||
let temp_dir = TempDir::new().unwrap();
|
||||
let manager = PatchManager::manager_for_test(&temp_dir);
|
||||
assert!(manager.next_boot_patch().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_none_patch_if_first_patch_failed_to_boot() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Add a first patch and pretend it failed to boot.
|
||||
@@ -824,7 +824,7 @@ mod next_boot_patch_tests {
|
||||
#[test]
|
||||
fn falls_back_to_last_booted_patch_if_still_bootable() -> Result<()> {
|
||||
let patch_file_contents = "patch contents";
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
let file_path = &temp_dir.path().join("patch1.vmcode");
|
||||
std::fs::write(file_path, patch_file_contents)?;
|
||||
@@ -851,7 +851,7 @@ mod next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn adding_patch_deletes_unbooted_patch_not_last_booted() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Add patch 1 and boot it successfully.
|
||||
@@ -884,7 +884,7 @@ mod next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn returns_last_booted_patch_if_next_patch_failed_to_boot() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Add a first patch and pretend it booted successfully.
|
||||
@@ -910,11 +910,11 @@ mod next_boot_patch_tests {
|
||||
mod validate_next_boot_patch_tests {
|
||||
use super::*;
|
||||
use anyhow::Result;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn does_nothing_if_no_next_boot_patch() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
assert!(manager.validate_next_boot_patch().is_ok());
|
||||
Ok(())
|
||||
@@ -922,7 +922,7 @@ mod validate_next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn clears_next_boot_patch_if_it_is_not_bootable() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
manager.add_patch_for_test(&temp_dir, 1)?;
|
||||
|
||||
@@ -947,7 +947,7 @@ mod validate_next_boot_patch_tests {
|
||||
#[test]
|
||||
fn clears_current_and_next_on_boot_failure_if_they_are_the_same() -> Result<()> {
|
||||
let patch_file_contents = "patch contents";
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
let file_path = &temp_dir.path().join("patch1.vmcode");
|
||||
std::fs::write(file_path, patch_file_contents)?;
|
||||
@@ -975,7 +975,7 @@ mod validate_next_boot_patch_tests {
|
||||
#[test]
|
||||
fn does_not_fall_back_to_last_booted_patch_if_corrupted() -> Result<()> {
|
||||
let patch_file_contents = "patch contents";
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
let file_path = &temp_dir.path().join("patch1.vmcode");
|
||||
std::fs::write(file_path, patch_file_contents)?;
|
||||
@@ -1033,7 +1033,7 @@ mod validate_next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn strict_mode_succeeds_with_valid_signature_at_boot_time() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some(PUBLIC_KEY),
|
||||
@@ -1056,7 +1056,7 @@ mod validate_next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn succeeds_with_arbitrary_signature_if_no_public_key() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
// Create a PatchManager without a public key - signature verification is skipped.
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
@@ -1079,7 +1079,7 @@ mod validate_next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn strict_mode_fails_boot_validation_if_signature_missing() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some(PUBLIC_KEY),
|
||||
@@ -1099,7 +1099,7 @@ mod validate_next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn strict_mode_fails_boot_validation_if_signature_invalid() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some(PUBLIC_KEY),
|
||||
@@ -1124,7 +1124,7 @@ mod validate_next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn strict_mode_fails_boot_validation_if_public_key_invalid() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some("not a valid key"),
|
||||
@@ -1144,7 +1144,7 @@ mod validate_next_boot_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn strict_mode_detects_tampered_patch_at_boot_time() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::new(
|
||||
temp_dir.path().to_path_buf(),
|
||||
Some(PUBLIC_KEY),
|
||||
@@ -1173,7 +1173,7 @@ mod fall_back_tests {
|
||||
|
||||
#[test]
|
||||
fn does_nothing_if_no_patch_exists() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
assert!(manager.patches_state.last_booted_patch.is_none());
|
||||
@@ -1189,7 +1189,7 @@ mod fall_back_tests {
|
||||
|
||||
#[test]
|
||||
fn sets_next_patch_to_latest_patch_if_both_are_present() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Download and successfully boot from patch 1
|
||||
@@ -1210,7 +1210,7 @@ mod fall_back_tests {
|
||||
|
||||
#[test]
|
||||
fn clears_next_and_last_patches_if_both_fail_validation() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Download and successfully boot from patch 1, and then corrupt it on disk.
|
||||
@@ -1234,7 +1234,7 @@ mod fall_back_tests {
|
||||
|
||||
#[test]
|
||||
fn does_not_clear_next_patch_if_changed_since_boot_start() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Simulate a situation where we download both patches 1 and 2.
|
||||
@@ -1267,7 +1267,7 @@ mod fall_back_tests {
|
||||
|
||||
#[test]
|
||||
fn succeeds_if_deleting_artifacts_fails() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Download and successfully boot from patch 1, and then corrupt it on disk.
|
||||
@@ -1297,11 +1297,11 @@ mod fall_back_tests {
|
||||
mod record_boot_success_for_patch_tests {
|
||||
use super::*;
|
||||
use anyhow::{Ok, Result};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn errs_if_no_next_boot_patch() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// This should fail because no patches have been added.
|
||||
@@ -1314,7 +1314,7 @@ mod record_boot_success_for_patch_tests {
|
||||
fn errs_if_patch_number_does_not_match_next_patch() -> Result<()> {
|
||||
let patch_number = 1;
|
||||
let patch_file_contents = "patch contents";
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
let file_path = &temp_dir.path().join("patch1.vmcode");
|
||||
std::fs::write(file_path, patch_file_contents)?;
|
||||
@@ -1330,7 +1330,7 @@ mod record_boot_success_for_patch_tests {
|
||||
fn succeeds_when_provided_next_boot_patch_number() -> Result<()> {
|
||||
let patch_number = 1;
|
||||
let patch_file_contents = "patch contents";
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
let file_path = &temp_dir.path().join("patch1.vmcode");
|
||||
std::fs::write(file_path, patch_file_contents)?;
|
||||
@@ -1346,7 +1346,7 @@ mod record_boot_success_for_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn deletes_other_patch_artifacts() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Download patches 1, 2, and 3 before we start booting from patch 2.
|
||||
@@ -1378,7 +1378,7 @@ mod record_boot_success_for_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn deletes_unrecognized_directories_in_patches_dir() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
|
||||
// Add a junk directory to the patches directory.
|
||||
@@ -1401,11 +1401,11 @@ mod record_boot_success_for_patch_tests {
|
||||
mod record_boot_failure_for_patch_tests {
|
||||
use super::*;
|
||||
use anyhow::{Ok, Result};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn deletes_failed_patch_artifacts() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
manager.add_patch_for_test(&temp_dir, 1)?;
|
||||
assert!(manager.record_boot_start_for_patch(1).is_ok());
|
||||
@@ -1430,7 +1430,7 @@ mod record_boot_failure_for_patch_tests {
|
||||
|
||||
#[test]
|
||||
fn clears_last_booted_patch_if_it_is_the_failed_patch() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
manager.add_patch_for_test(&temp_dir, 1)?;
|
||||
let patch_artifact_path = manager.patch_artifact_path(1);
|
||||
@@ -1459,11 +1459,11 @@ mod record_boot_failure_for_patch_tests {
|
||||
mod reset_tests {
|
||||
use super::*;
|
||||
use anyhow::{Ok, Result};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn deletes_patches_dir_and_resets_patches_state() -> Result<()> {
|
||||
let temp_dir = TempDir::new("patch_manager")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let mut manager = PatchManager::manager_for_test(&temp_dir);
|
||||
manager.add_patch_for_test(&temp_dir, 1)?;
|
||||
let path_artifacts_dir = manager.patches_dir();
|
||||
|
||||
Vendored
+2
-2
@@ -74,7 +74,7 @@ mod tests {
|
||||
use std::io::Write;
|
||||
|
||||
use anyhow::Result;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn errs_if_file_does_not_exist() {
|
||||
@@ -86,7 +86,7 @@ mod tests {
|
||||
#[test]
|
||||
fn hashes_file_contents() -> Result<()> {
|
||||
// Write "hello, world!" to a file.
|
||||
let temp_dir = TempDir::new("signing")?;
|
||||
let temp_dir = TempDir::new()?;
|
||||
let file_path = temp_dir.path().join("test.txt");
|
||||
let mut file = std::fs::File::create(&file_path)?;
|
||||
file.write_all("hello, world!".as_bytes())?;
|
||||
|
||||
Vendored
+17
-17
@@ -303,7 +303,7 @@ impl UpdaterState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::cache::patch_manager::MockManagePatches;
|
||||
|
||||
@@ -334,7 +334,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn release_version_changed_resets_patches() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let mut patch_manager = PatchManager::manager_for_test(&tmp_dir);
|
||||
let file_path = &tmp_dir.path().join("patch1.vmcode");
|
||||
std::fs::write(file_path, "patch file contents").unwrap();
|
||||
@@ -357,7 +357,7 @@ mod tests {
|
||||
fn is_file_not_found_test() {
|
||||
use anyhow::Context;
|
||||
assert!(!super::is_file_not_found(&anyhow::anyhow!("")));
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let path = tmp_dir.path().join("does_not_exist");
|
||||
let result = std::fs::File::open(path).context("foo");
|
||||
assert!(result.is_err());
|
||||
@@ -366,7 +366,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn creates_updater_state_with_client_id() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let state = UpdaterState::load_or_new_on_error(tmp_dir.path(), "1.0.0+1", None, PatchVerificationMode::default());
|
||||
let saved_state = UpdaterState::load_or_new_on_error(tmp_dir.path(), "1.0.0+1", None, PatchVerificationMode::default());
|
||||
assert_eq!(
|
||||
@@ -379,7 +379,7 @@ mod tests {
|
||||
// the client_id should remain the same.
|
||||
#[test]
|
||||
fn client_id_does_not_change_if_release_version_changes() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
let state = test_state(&tmp_dir, PatchManager::manager_for_test(&tmp_dir));
|
||||
let original_loaded = UpdaterState::load_or_new_on_error(
|
||||
@@ -399,7 +399,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn does_not_save_cache_dir() {
|
||||
let original_tmp_dir = TempDir::new("example").unwrap();
|
||||
let original_tmp_dir = TempDir::new().unwrap();
|
||||
let original_state = UpdaterState {
|
||||
cache_dir: original_tmp_dir.path().to_path_buf(),
|
||||
patch_manager: Box::new(PatchManager::manager_for_test(&original_tmp_dir)),
|
||||
@@ -411,7 +411,7 @@ mod tests {
|
||||
};
|
||||
original_state.save().unwrap();
|
||||
|
||||
let new_tmp_dir = TempDir::new("example_2").unwrap();
|
||||
let new_tmp_dir = TempDir::new().unwrap();
|
||||
let original_state_path = original_tmp_dir.path().join(STATE_FILE_NAME);
|
||||
let new_state_path = new_tmp_dir.path().join(STATE_FILE_NAME);
|
||||
std::fs::rename(original_state_path, new_state_path).unwrap();
|
||||
@@ -423,7 +423,7 @@ mod tests {
|
||||
#[test]
|
||||
fn record_boot_failure_for_patch_forwards_to_patch_manager() {
|
||||
let patch_number = 1;
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
mock_manage_patches
|
||||
.expect_record_boot_failure_for_patch()
|
||||
@@ -435,7 +435,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn record_boot_success_for_patch_forwards_to_patch_manager() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
mock_manage_patches
|
||||
.expect_record_boot_success()
|
||||
@@ -447,7 +447,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn last_successfully_booted_patch_forwards_from_patch_manager() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch = fake_patch(&tmp_dir, 1);
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
mock_manage_patches
|
||||
@@ -459,7 +459,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn current_boot_patch_returns_currently_booting_patch_if_present() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch1 = fake_patch(&tmp_dir, 1);
|
||||
let patch2 = fake_patch(&tmp_dir, 2);
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
@@ -475,7 +475,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn current_boot_patch_returns_last_successfully_booted_patch_if_no_patch_is_booting() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch = fake_patch(&tmp_dir, 1);
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
mock_manage_patches
|
||||
@@ -491,7 +491,7 @@ mod tests {
|
||||
#[test]
|
||||
fn next_boot_patch_forwards_from_patch_manager() {
|
||||
let patch_number = 1;
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch = fake_patch(&tmp_dir, patch_number);
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
mock_manage_patches
|
||||
@@ -503,7 +503,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn validate_next_boot_patch_forwards_to_patch_manager() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
mock_manage_patches
|
||||
.expect_validate_next_boot_patch()
|
||||
@@ -515,7 +515,7 @@ mod tests {
|
||||
#[test]
|
||||
fn install_patch_forwards_to_patch_manager() {
|
||||
let patch_number = 1;
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch = fake_patch(&tmp_dir, patch_number);
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
let cloned_patch = patch.clone();
|
||||
@@ -537,7 +537,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn is_known_bad_patch_returns_value_from_patch_manager() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let mut mock_manage_patches = MockManagePatches::new();
|
||||
mock_manage_patches
|
||||
.expect_is_known_bad_patch()
|
||||
@@ -554,7 +554,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn load_or_new_on_error_clears_patch_state_on_error() -> Result<()> {
|
||||
let tmp_dir = TempDir::new("example")?;
|
||||
let tmp_dir = TempDir::new()?;
|
||||
|
||||
// Create a new state, add a patch, and save it.
|
||||
let mut state = UpdaterState::load_or_new_on_error(&tmp_dir.path(), "1.0.0+1", None, PatchVerificationMode::default());
|
||||
|
||||
+1
-1
@@ -30,4 +30,4 @@ mod test_utils;
|
||||
pub use self::updater::*;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate tempdir;
|
||||
extern crate tempfile;
|
||||
|
||||
+37
-37
@@ -789,7 +789,7 @@ pub fn start_update_thread() {
|
||||
mod tests {
|
||||
use serial_test::serial;
|
||||
use std::{fs, thread, time::Duration};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::{
|
||||
cache::UpdaterState,
|
||||
@@ -839,7 +839,7 @@ mod tests {
|
||||
#[serial]
|
||||
#[test]
|
||||
fn subsequent_init_calls_do_not_update_config() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
testing_reset_config();
|
||||
let cache_dir = tmp_dir.path().to_str().unwrap().to_string();
|
||||
@@ -892,7 +892,7 @@ mod tests {
|
||||
#[serial]
|
||||
#[test]
|
||||
fn ignore_version_after_marked_bad() -> anyhow::Result<()> {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
|
||||
// Install a fake patch.
|
||||
@@ -923,7 +923,7 @@ mod tests {
|
||||
#[serial]
|
||||
#[test]
|
||||
fn reports_patch_install_failure_if_patch_was_booting() -> anyhow::Result<()> {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
|
||||
install_fake_patch(1)?;
|
||||
@@ -964,7 +964,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn hash_matches() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
let input_path = tmp_dir.path().join("input");
|
||||
fs::write(&input_path, "hello world").unwrap();
|
||||
@@ -1003,7 +1003,7 @@ mod tests {
|
||||
#[serial]
|
||||
#[test]
|
||||
fn init_missing_yaml() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let cache_dir = tmp_dir.path().to_str().unwrap().to_string();
|
||||
assert_eq!(
|
||||
crate::init(
|
||||
@@ -1027,7 +1027,7 @@ mod tests {
|
||||
#[test]
|
||||
fn init_invalid_patch_verification() {
|
||||
testing_reset_config();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let cache_dir = tmp_dir.path().to_str().unwrap().to_string();
|
||||
let yaml = r#"
|
||||
app_id: test_app
|
||||
@@ -1106,7 +1106,7 @@ patch_verification: bogus_mode
|
||||
.to_string(),
|
||||
))
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
// Install the base apk to allow the "downloaded" patch 1 to successfully inflate and install.
|
||||
@@ -1168,7 +1168,7 @@ patch_verification: bogus_mode
|
||||
.mock("POST", "/api/v1/patches/events")
|
||||
.with_status(503)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
// Install the base apk to allow the "downloaded" patch 1 to successfully inflate and install.
|
||||
@@ -1195,7 +1195,7 @@ patch_verification: bogus_mode
|
||||
#[serial]
|
||||
#[test]
|
||||
fn report_launch_result_with_no_current_patch() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
assert!(crate::report_launch_start().is_ok());
|
||||
assert_eq!(
|
||||
@@ -1214,7 +1214,7 @@ patch_verification: bogus_mode
|
||||
use crate::cache::UpdaterState;
|
||||
use crate::config::with_config;
|
||||
let patch_number = 1;
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
|
||||
// Install a fake patch.
|
||||
@@ -1245,7 +1245,7 @@ patch_verification: bogus_mode
|
||||
fn report_launch_failure_with_patch() {
|
||||
use crate::cache::UpdaterState;
|
||||
use crate::config::with_config;
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
|
||||
// Install a fake patch.
|
||||
@@ -1278,7 +1278,7 @@ patch_verification: bogus_mode
|
||||
|
||||
#[test]
|
||||
fn validate_compressed_patch_rejects_empty_file() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch_path = tmp_dir.path().join("empty.patch");
|
||||
fs::write(&patch_path, b"").unwrap();
|
||||
|
||||
@@ -1294,7 +1294,7 @@ patch_verification: bogus_mode
|
||||
|
||||
#[test]
|
||||
fn validate_compressed_patch_rejects_too_small_file() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch_path = tmp_dir.path().join("small.patch");
|
||||
fs::write(&patch_path, b"abc").unwrap();
|
||||
|
||||
@@ -1310,7 +1310,7 @@ patch_verification: bogus_mode
|
||||
|
||||
#[test]
|
||||
fn validate_compressed_patch_rejects_bad_magic() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch_path = tmp_dir.path().join("bad_magic.patch");
|
||||
fs::write(&patch_path, b"not_zstd_data_here").unwrap();
|
||||
|
||||
@@ -1326,7 +1326,7 @@ patch_verification: bogus_mode
|
||||
|
||||
#[test]
|
||||
fn validate_compressed_patch_accepts_valid_zstd_magic() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch_path = tmp_dir.path().join("valid.patch");
|
||||
// Write zstd magic bytes followed by some data
|
||||
let mut data = vec![0x28, 0xB5, 0x2F, 0xFD];
|
||||
@@ -1338,7 +1338,7 @@ patch_verification: bogus_mode
|
||||
|
||||
#[test]
|
||||
fn inflate_fails_with_corrupt_zstd_data() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch_path = tmp_dir.path().join("corrupt.patch");
|
||||
// Valid zstd magic but garbage content — passes validation but
|
||||
// fails during decompression or patch reading.
|
||||
@@ -1366,7 +1366,7 @@ patch_verification: bogus_mode
|
||||
use comde::com::Compressor;
|
||||
use comde::zstd::ZstdCompressor;
|
||||
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
||||
// Build a fake uncompressed patch that starts with a valid bipatch
|
||||
// header (magic 0xB1DF, version 0x1000 as little-endian u32s) so
|
||||
@@ -1407,7 +1407,7 @@ patch_verification: bogus_mode
|
||||
|
||||
#[test]
|
||||
fn inflate_rejects_invalid_magic() {
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
let patch_path = tmp_dir.path().join("bad.patch");
|
||||
fs::write(&patch_path, b"not zstd at all").unwrap();
|
||||
|
||||
@@ -1444,7 +1444,7 @@ patch_verification: bogus_mode
|
||||
.with_status(200)
|
||||
.with_body(check_response_body)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
let mut updater_state = with_config(|config| {
|
||||
@@ -1493,7 +1493,7 @@ patch_verification: bogus_mode
|
||||
.with_status(200)
|
||||
.with_body(check_response_body)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
install_fake_patch(patch_number)?;
|
||||
@@ -1529,7 +1529,7 @@ patch_verification: bogus_mode
|
||||
.mock("POST", "/api/v1/patches/events")
|
||||
.with_status(201)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
with_config(|config| {
|
||||
@@ -1583,7 +1583,7 @@ patch_verification: bogus_mode
|
||||
fn no_config_lock_contention_when_waiting_for_patch_check() {
|
||||
static mut HAS_FINISHED_CONFIG: bool = false;
|
||||
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
|
||||
// Set up the network hooks to sleep for 10 seconds on a patch check request
|
||||
@@ -1635,7 +1635,7 @@ patch_verification: bogus_mode
|
||||
mod rollback_tests {
|
||||
use anyhow::Result;
|
||||
use serial_test::serial;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::{
|
||||
network::PatchCheckResponse,
|
||||
@@ -1693,7 +1693,7 @@ mod rollback_tests {
|
||||
],
|
||||
)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
let base = "hello world";
|
||||
@@ -1744,7 +1744,7 @@ mod rollback_tests {
|
||||
.with_status(200)
|
||||
.with_body(check_response_body)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
install_fake_patch(1)?;
|
||||
@@ -1783,7 +1783,7 @@ mod rollback_tests {
|
||||
.with_status(200)
|
||||
.with_body(check_response_body)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
install_fake_patch(1)?;
|
||||
@@ -1841,7 +1841,7 @@ mod rollback_tests {
|
||||
],
|
||||
)
|
||||
.create();
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
// Install the base apk to allow the "downloaded" patch 1 to successfully inflate and install.
|
||||
@@ -1882,7 +1882,7 @@ mod check_for_downloadable_update_tests {
|
||||
|
||||
use anyhow::Result;
|
||||
use serial_test::serial;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::{
|
||||
network::PatchCheckResponse, report_launch_failure, report_launch_start,
|
||||
@@ -1920,7 +1920,7 @@ mod check_for_downloadable_update_tests {
|
||||
#[test]
|
||||
fn returns_false_if_no_patch_is_available() -> Result<()> {
|
||||
let server = mock_server(None, None);
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
let is_update_available = crate::check_for_downloadable_update(None)?;
|
||||
@@ -1934,7 +1934,7 @@ mod check_for_downloadable_update_tests {
|
||||
fn returns_false_if_patch_is_already_installed() -> Result<()> {
|
||||
let patch_number = 1;
|
||||
let server = mock_server(Some(patch_number), None);
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
install_fake_patch(patch_number)?;
|
||||
@@ -1950,7 +1950,7 @@ mod check_for_downloadable_update_tests {
|
||||
fn returns_false_if_patch_is_known_bad() -> Result<()> {
|
||||
let patch_number = 1;
|
||||
let server = mock_server(Some(patch_number), None);
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
install_fake_patch(patch_number)?;
|
||||
@@ -1968,7 +1968,7 @@ mod check_for_downloadable_update_tests {
|
||||
fn returns_true_if_patch_has_no_issues() -> Result<()> {
|
||||
let patch_number = 1;
|
||||
let server = mock_server(Some(patch_number), None);
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
let is_update_available = crate::check_for_downloadable_update(None)?;
|
||||
@@ -1982,7 +1982,7 @@ mod check_for_downloadable_update_tests {
|
||||
fn rolls_back_patches_if_needed() -> Result<()> {
|
||||
let patch_number = 1;
|
||||
let server = mock_server(None, Some(vec![patch_number]));
|
||||
let tmp_dir = TempDir::new("example").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, Some(&server.url()));
|
||||
|
||||
install_fake_patch(patch_number)?;
|
||||
@@ -2013,7 +2013,7 @@ mod check_for_downloadable_update_tests {
|
||||
mod multi_engine_tests {
|
||||
use anyhow::Result;
|
||||
use serial_test::serial;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::{
|
||||
network::{testing_set_network_hooks, PatchCheckResponse},
|
||||
@@ -2060,7 +2060,7 @@ mod multi_engine_tests {
|
||||
#[serial]
|
||||
#[test]
|
||||
fn multi_engine_false_positive_rollback() -> Result<()> {
|
||||
let tmp_dir = TempDir::new("multi_engine_test").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
set_noop_network_hooks();
|
||||
|
||||
@@ -2160,7 +2160,7 @@ mod multi_engine_tests {
|
||||
#[serial]
|
||||
#[test]
|
||||
fn interleaved_boot_calls_success_clears_flag() -> Result<()> {
|
||||
let tmp_dir = TempDir::new("interleaved_test").unwrap();
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
init_for_testing(&tmp_dir, None);
|
||||
set_noop_network_hooks();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user