use std::path::Path; use tempfile::TempDir; pub fn setup_test_environment() -> TempDir { let temp_dir = TempDir::new().unwrap(); let content_path = temp_dir.path().join("content"); // Create content directory and file std::fs::create_dir(&content_path).unwrap(); std::fs::write(content_path.join("test.gmi"), "# Test Gemini content\n").unwrap(); // Generate test certificates generate_test_certificates(temp_dir.path()); temp_dir } fn generate_test_certificates(temp_dir: &Path) { use std::process::Command; let cert_path = temp_dir.join("cert.pem"); let key_path = temp_dir.join("key.pem"); let status = Command::new("openssl") .args(&[ "req", "-x509", "-newkey", "rsa:2048", "-keyout", &key_path.to_string_lossy(), "-out", &cert_path.to_string_lossy(), "-days", "1", "-nodes", "-subj", "/CN=localhost" ]) .status() .unwrap(); assert!(status.success(), "Failed to generate test certificates"); }