Expose dev subscription headers without HWID

This commit is contained in:
2026-07-08 21:51:45 +03:00
parent a2581187da
commit 4d859dc0a6
7 changed files with 143 additions and 21 deletions

View File

@@ -3,9 +3,9 @@ use proxywarden_lib::adapters::singbox::{
};
use proxywarden_lib::commands::{
fetch_singbox_subscription_with_fetcher, forget_singbox_subscription_in_storage,
generate_singbox_config_with_services, save_singbox_subscription_to_storage,
select_singbox_server_in_storage, Clock, SaveSingBoxSubscriptionInputDto,
SelectSingBoxServerInputDto, SubscriptionFetcher,
generate_singbox_config_with_services, read_singbox_status,
save_singbox_subscription_to_storage, select_singbox_server_in_storage, Clock,
SaveSingBoxSubscriptionInputDto, SelectSingBoxServerInputDto, SubscriptionFetcher,
};
use proxywarden_lib::models::{
ActivityLevel, ComponentId, LocalSingBoxConfig, ProxyProtocol, SubscriptionCache,
@@ -49,6 +49,39 @@ fn saves_subscription_url_without_exposing_secret_query() {
cleanup(&root);
}
#[cfg(debug_assertions)]
#[test]
fn singbox_status_exposes_dev_subscription_headers_without_hwid() {
let root = test_root("dev-subscription-identity");
let storage = JsonStorage::new(root.clone());
let status = read_singbox_status(&storage).expect("read sing-box status");
let headers = status
.subscription_identity
.headers
.iter()
.map(|header| (header.name.clone(), header.value.clone()))
.collect::<Vec<_>>();
let expected_headers = subscription::SubscriptionFetchIdentity::default()
.request_headers_without_device_hwid()
.into_iter()
.map(|(name, value)| (name.to_string(), value))
.collect::<Vec<_>>();
assert_eq!(headers, expected_headers);
assert!(headers
.iter()
.all(|(name, _)| !name.eq_ignore_ascii_case("x-hwid")));
let serialized = serde_json::to_value(&status).expect("serialize status");
assert!(serialized.get("subscriptionIdentity").is_some());
assert!(!serialized
.to_string()
.to_ascii_lowercase()
.contains("x-hwid"));
cleanup(&root);
}
#[test]
fn rejects_non_http_subscription_url() {
let root = test_root("invalid-subscription");

View File

@@ -139,6 +139,7 @@ fn fetch_subscription_sends_device_hwid_header_when_identity_is_set() {
assert!(request.contains("x-app-name: proxywarden"));
assert!(request.contains("x-device-os:"));
assert!(request.contains("x-device-os-version: windows 11 pro | 25h2 | build 26200.8655"));
assert!(request.contains("x-ver-os: windows 11 pro | 25h2 | build 26200.8655"));
assert!(request.contains("x-device-model: proxywarden"));
}