Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
test: refuse to run the live tests against a non-local instance
tonhowtfca6cbb3c0215
diff --git a/src-tauri/omnidisc-media/tests/stream_e2e.rs b/src-tauri/omnidisc-media/tests/stream_e2e.rsindex 811e2f6b..48584180 100644--- a/src-tauri/omnidisc-media/tests/stream_e2e.rs+++ b/src-tauri/omnidisc-media/tests/stream_e2e.rs@@ -16,6 +16,24 @@ use std::sync::Arc;use std::time::{Duration, Instant};use tokio_tungstenite::tungstenite::Message;+/// Refuses to run against anything but a throwaway instance unless told+/// otherwise. These tests create real accounts, and pointing them at a live+/// server litters it — which is exactly what happened to the production+/// instance before this guard existed.+fn allow_target(base: &str) -> bool {+ if std::env::var_os("OMNIDISC_TEST_ALLOW_REMOTE").is_some() {+ return true;+ }+ let local = base.contains("localhost") || base.contains("127.0.0.1") || base.contains("[::1]");+ if !local {+ eprintln!(+ "refusing to run against {base}: it is not a local instance. Set \+ OMNIDISC_TEST_ALLOW_REMOTE=1 if that is really what you want."+ );+ }+ local+}+/// A password nobody can guess from the repository.////// These tests register real accounts on whatever instance `OMNIDISC_TEST_URL`@@ -155,6 +173,9 @@ async fn stream_publish_and_watch() {return;};let base = url.trim().trim_end_matches('/').to_string();+ if !allow_target(&base) {+ return;+ }let http = reqwest::Client::builder().timeout(Duration::from_secs(15)).build()diff --git a/src-tauri/omnidisc-media/tests/voice_e2e.rs b/src-tauri/omnidisc-media/tests/voice_e2e.rsindex 00c30cce..71cfe15f 100644--- a/src-tauri/omnidisc-media/tests/voice_e2e.rs+++ b/src-tauri/omnidisc-media/tests/voice_e2e.rs@@ -16,6 +16,24 @@ use std::sync::Arc;use std::time::{Duration, Instant};use tokio_tungstenite::tungstenite::Message;+/// Refuses to run against anything but a throwaway instance unless told+/// otherwise. These tests create real accounts, and pointing them at a live+/// server litters it — which is exactly what happened to the production+/// instance before this guard existed.+fn allow_target(base: &str) -> bool {+ if std::env::var_os("OMNIDISC_TEST_ALLOW_REMOTE").is_some() {+ return true;+ }+ let local = base.contains("localhost") || base.contains("127.0.0.1") || base.contains("[::1]");+ if !local {+ eprintln!(+ "refusing to run against {base}: it is not a local instance. Set \+ OMNIDISC_TEST_ALLOW_REMOTE=1 if that is really what you want."+ );+ }+ local+}+/// A password nobody can guess from the repository.////// These tests register real accounts on whatever instance `OMNIDISC_TEST_URL`@@ -364,6 +382,12 @@ async fn tone_reaches_the_other_side(base: &str, label: &str, room_key: Option<R}fn test_url() -> Option<String> {+ let picked = real_test_url();+ return picked.filter(|b| allow_target(b));+}++#[allow(dead_code)]+fn real_test_url() -> Option<String> {match std::env::var("OMNIDISC_TEST_URL") {Ok(url) => Some(url.trim().trim_end_matches('/').to_string()),Err(_) => {diff --git a/src-tauri/src/commands/omnidisc/e2e_test.rs b/src-tauri/src/commands/omnidisc/e2e_test.rsindex 29cdbaf1..08239f86 100644--- a/src-tauri/src/commands/omnidisc/e2e_test.rs+++ b/src-tauri/src/commands/omnidisc/e2e_test.rs@@ -13,6 +13,24 @@ use std::time::Duration;use tokio::sync::mpsc;use tokio_util::sync::CancellationToken;+/// Refuses to run against anything but a throwaway instance unless told+/// otherwise. These tests create real accounts, and pointing them at a live+/// server litters it — which is exactly what happened to the production+/// instance before this guard existed.+fn allow_target(base: &str) -> bool {+ if std::env::var_os("OMNIDISC_TEST_ALLOW_REMOTE").is_some() {+ return true;+ }+ let local = base.contains("localhost") || base.contains("127.0.0.1") || base.contains("[::1]");+ if !local {+ eprintln!(+ "refusing to run against {base}: it is not a local instance. Set \+ OMNIDISC_TEST_ALLOW_REMOTE=1 if that is really what you want."+ );+ }+ local+}+/// A password nobody can guess from the repository.////// These tests register real accounts on whatever instance `OMNIDISC_TEST_URL`@@ -91,6 +109,9 @@ async fn register_gateway_ready_send_receive() {return;};let base = super::normalize_instance_url(&url).expect("valid url");+ if !allow_target(&base) {+ return;+ }let _session_dir = super::e2e_lock::SessionDirGuard::acquire();let alice_name = unique("alice");diff --git a/src-tauri/src/commands/omnidisc/e2ee_e2e_test.rs b/src-tauri/src/commands/omnidisc/e2ee_e2e_test.rsindex e1fbf7cf..07b29d8e 100644--- a/src-tauri/src/commands/omnidisc/e2ee_e2e_test.rs+++ b/src-tauri/src/commands/omnidisc/e2ee_e2e_test.rs@@ -22,6 +22,24 @@ use serde_json::{json, Value};use sha2::{Digest, Sha256};use std::path::PathBuf;+/// Refuses to run against anything but a throwaway instance unless told+/// otherwise. These tests create real accounts, and pointing them at a live+/// server litters it — which is exactly what happened to the production+/// instance before this guard existed.+fn allow_target(base: &str) -> bool {+ if std::env::var_os("OMNIDISC_TEST_ALLOW_REMOTE").is_some() {+ return true;+ }+ let local = base.contains("localhost") || base.contains("127.0.0.1") || base.contains("[::1]");+ if !local {+ eprintln!(+ "refusing to run against {base}: it is not a local instance. Set \+ OMNIDISC_TEST_ALLOW_REMOTE=1 if that is really what you want."+ );+ }+ local+}+/// A password nobody can guess from the repository.////// These tests register real accounts on whatever instance `OMNIDISC_TEST_URL`@@ -150,6 +168,9 @@ async fn two_devices_exchange_an_encrypted_message_and_an_encrypted_file() {.with_max_level(tracing::Level::WARN).try_init();let base = super::normalize_instance_url(&url).expect("valid url");+ if !allow_target(&base) {+ return;+ }let _session_dir = SessionDirGuard::acquire();let alice = register_side(&base, "alicee").await;