//! Explicit checks of real saved data/network. Never runs automatically in CI. #![cfg(all(windows, debug_assertions))] use proxywarden_lib::{ component_catalog::ComponentId, component_packages::{ ComponentPackageService, NativePackageSignatureVerifier, ReqwestUpdateTransport, }, configuration_transaction::read_guard, privileged_jobs::{EpochClock, SystemEpochClock}, storage::{default_config_root, JsonStorage, StoragePaths}, subscription::{fetch_subscription_with_identity, SubscriptionFetchIdentity}, }; use std::path::PathBuf; #[test] #[ignore = "Real user data/network; requires an explicitly authorized operator action"] fn installed_singbox_data_check() { let action = std::env::var("PROXYWARDEN_LIVE_SINGBOX_ACTION") .expect("set the explicitly authorized action"); let storage = JsonStorage::new(default_config_root()); match action.as_str() { "recover" => { let _guard = read_guard(&storage).expect("recover saved configuration"); println!("Configuration recovery succeeded"); } "subscription" => { let config = { let _guard = read_guard(&storage).expect("read saved configuration"); storage .read_local_singbox_config() .expect("saved subscription settings") }; let identity = SubscriptionFetchIdentity::with_device_hwid(config.device_hwid.as_deref()); let result = fetch_subscription_with_identity( config .subscription_url .as_deref() .expect("saved subscription exists"), &identity, ); // Never include the subscription URL, response body, credentials or server names. assert!(result.is_ok(), "Saved subscription fetch/parse failed"); let cache = result.unwrap(); assert!( !cache.servers.is_empty(), "subscription returned no servers" ); println!( "Saved subscription fetched and parsed: {} servers", cache.servers.len() ); } "download" => { let packages = ComponentPackageService::open( PathBuf::from(r"C:\Program Files\ProxyWarden\bundled\components"), &StoragePaths::default(), ) .expect("installed offline catalog"); let transport = ReqwestUpdateTransport::new().expect("update transport"); let checked = packages .check_for_update( ComponentId::SingBox, SystemEpochClock.now_epoch_seconds(), &transport, ) .expect("release metadata and independent digest"); println!( "Latest release: {}; trust {:?}", checked.latest_known_version, checked.trust ); let package = packages .download_checked_update( ComponentId::SingBox, &transport, &NativePackageSignatureVerifier, ) .expect("verified download into application cache"); println!("Downloaded and verified sing-box {}", package.version); } _ => panic!("unsupported explicit data-check action"), } }