Files
leleka/desktop-core/tests/tunnel_bootstrap.rs
T
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

75 lines
2.3 KiB
Rust

use std::{process::Stdio, time::Duration};
use tokio::{
io::{AsyncBufReadExt, AsyncWriteExt, BufReader},
process::Command,
};
#[tokio::test]
async fn owned_tunnel_bootstrap_ends_at_parent_eof() {
let mut child = Command::new(env!("CARGO_BIN_EXE_strata-desktop"))
.args(["ssh-tunnel", "--stdio-lifetime"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::null())
.kill_on_drop(true)
.spawn()
.unwrap();
let mut input = child.stdin.take().unwrap();
input.write_all(br#"{"schema_version":1,"ssh":{"schema_version":1,"id":"fixture","host":"localhost"},"listen":"127.0.0.1:0","remote_port":19999,"max_connections":1}
"#).await.unwrap();
let mut line = String::new();
tokio::time::timeout(
Duration::from_secs(5),
BufReader::new(child.stdout.take().unwrap()).read_line(&mut line),
)
.await
.unwrap()
.unwrap();
let descriptor: serde_json::Value = serde_json::from_str(&line).unwrap();
assert_eq!(descriptor["transport"], "ssh");
assert_eq!(
descriptor["readiness"],
"requires_authenticated_node_handshake"
);
let endpoint = descriptor["endpoint"]
.as_str()
.unwrap()
.strip_prefix("http://")
.unwrap();
assert!(std::net::TcpListener::bind(endpoint).is_err());
drop(input);
assert!(
tokio::time::timeout(Duration::from_secs(5), child.wait())
.await
.unwrap()
.unwrap()
.success()
);
assert!(std::net::TcpListener::bind(endpoint).is_ok());
}
#[tokio::test]
async fn incomplete_bootstrap_is_not_an_open_listener() {
let mut child = Command::new(env!("CARGO_BIN_EXE_strata-desktop"))
.args(["ssh-tunnel", "--stdio-lifetime"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::null())
.kill_on_drop(true)
.spawn()
.unwrap();
child
.stdin
.take()
.unwrap()
.write_all(b"{\"schema_version\":1}")
.await
.unwrap();
let result = tokio::time::timeout(Duration::from_secs(5), child.wait_with_output())
.await
.unwrap()
.unwrap();
assert!(!result.status.success());
assert!(result.stdout.is_empty());
}