Refactor proxy routing and installer flows
This commit is contained in:
@@ -303,9 +303,10 @@ fn apply_generates_derived_config_and_records_activity_with_mock_helper() {
|
||||
storage
|
||||
.write_targets(&[external_socks5_target()])
|
||||
.expect("write targets");
|
||||
storage
|
||||
.write_components(&[proxyfier_running(), singbox_missing()])
|
||||
.expect("write components");
|
||||
write_json(
|
||||
&storage.paths().components_file,
|
||||
&[proxyfier_running(), singbox_missing()],
|
||||
);
|
||||
|
||||
let response = apply_profiles_with_services(
|
||||
&storage,
|
||||
@@ -345,9 +346,7 @@ fn apply_blocks_local_singbox_target_when_component_is_missing() {
|
||||
storage
|
||||
.write_targets(&[local_singbox_target()])
|
||||
.expect("write targets");
|
||||
storage
|
||||
.write_components(&[singbox_missing()])
|
||||
.expect("write components");
|
||||
write_json(&storage.paths().components_file, &[singbox_missing()]);
|
||||
|
||||
let error = apply_profiles_with_services(
|
||||
&storage,
|
||||
@@ -405,7 +404,7 @@ fn detected_proxy_apply_helper_writes_proxifyre_app_config() {
|
||||
.with_registry("ProxiFyre", &install_dir)
|
||||
.with_path(&install_dir)
|
||||
.with_path(&install_dir.join("ProxiFyre.exe"));
|
||||
let helper = DetectedProxyApplyHelper::new(host);
|
||||
let helper = DetectedProxyApplyHelper::from(host);
|
||||
|
||||
let result = helper
|
||||
.apply_proxy_config(HelperApplyRequest {
|
||||
@@ -438,7 +437,7 @@ fn detected_proxy_apply_helper_ignores_plain_proxifier_install() {
|
||||
.with_registry("Proxifier", &install_dir)
|
||||
.with_path(&install_dir)
|
||||
.with_path(&install_dir.join("Proxifier.exe"));
|
||||
let helper = DetectedProxyApplyHelper::new(host);
|
||||
let helper = DetectedProxyApplyHelper::from(host);
|
||||
|
||||
let result = helper
|
||||
.apply_proxy_config(HelperApplyRequest {
|
||||
@@ -554,6 +553,14 @@ fn cleanup(root: &Path) {
|
||||
let _ = fs::remove_dir_all(root);
|
||||
}
|
||||
|
||||
fn write_json<T: serde::Serialize + ?Sized>(path: &Path, value: &T) {
|
||||
if let Some(parent) = path.parent() {
|
||||
fs::create_dir_all(parent).expect("create json parent dir");
|
||||
}
|
||||
let contents = serde_json::to_vec_pretty(value).expect("serialize json");
|
||||
fs::write(path, contents).expect("write json");
|
||||
}
|
||||
|
||||
fn discord_profile(target_id: &str) -> Profile {
|
||||
Profile {
|
||||
id: "discord".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user