Add native services and embeddable transport SDK
This commit is contained in:
+174
-1
@@ -760,7 +760,9 @@ fn native_doctor_checks_auth_without_opening_terminal() {
|
||||
assert!(output.status.success(), "stdout={stdout}\nstderr={stderr}");
|
||||
assert!(stdout.contains("[ok] native udp"), "stdout={stdout}");
|
||||
assert!(stdout.contains("[ok] native auth"), "stdout={stdout}");
|
||||
assert!(stdout.contains("[ok] forwarding policy"), "stdout={stdout}");
|
||||
assert!(stdout.contains("[ok] server policy"), "stdout={stdout}");
|
||||
assert!(stdout.contains("file_transfer=true"), "stdout={stdout}");
|
||||
assert!(stdout.contains("exec_command=true"), "stdout={stdout}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -868,6 +870,177 @@ fn native_local_forward_background_smoke() {
|
||||
assert_eq!(&buf[..n], b"dosh-background-forward-ping");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_file_copy_recursive_round_trip() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let port = free_udp_port();
|
||||
let config = write_server_config(&dir, port);
|
||||
write_native_client_auth(&dir, &config);
|
||||
let mut server = start_server(&dir, &config);
|
||||
let src = dir.path().join("srcdir");
|
||||
fs::create_dir_all(src.join("nested")).unwrap();
|
||||
fs::write(src.join("root.txt"), b"root file\n").unwrap();
|
||||
fs::write(src.join("nested/child.txt"), b"child file\n").unwrap();
|
||||
|
||||
let client_bin = env!("CARGO_BIN_EXE_dosh-client");
|
||||
let upload = Command::new(client_bin)
|
||||
.arg("--dosh-host")
|
||||
.arg("127.0.0.1")
|
||||
.arg("--dosh-port")
|
||||
.arg(port.to_string())
|
||||
.arg("cp")
|
||||
.arg("-r")
|
||||
.arg(&src)
|
||||
.arg("local:remote-copy")
|
||||
.env("HOME", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
upload.status.success(),
|
||||
"upload failed: stdout={} stderr={}",
|
||||
String::from_utf8_lossy(&upload.stdout),
|
||||
String::from_utf8_lossy(&upload.stderr)
|
||||
);
|
||||
|
||||
let remote_copy = Command::new(client_bin)
|
||||
.arg("--dosh-host")
|
||||
.arg("127.0.0.1")
|
||||
.arg("--dosh-port")
|
||||
.arg(port.to_string())
|
||||
.arg("cp")
|
||||
.arg("-r")
|
||||
.arg("local:remote-copy")
|
||||
.arg("local:remote-copy-2")
|
||||
.env("HOME", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
remote_copy.status.success(),
|
||||
"remote copy failed: stdout={} stderr={}",
|
||||
String::from_utf8_lossy(&remote_copy.stdout),
|
||||
String::from_utf8_lossy(&remote_copy.stderr)
|
||||
);
|
||||
|
||||
let list = Command::new(client_bin)
|
||||
.arg("--dosh-host")
|
||||
.arg("127.0.0.1")
|
||||
.arg("--dosh-port")
|
||||
.arg(port.to_string())
|
||||
.arg("ls")
|
||||
.arg("local:remote-copy-2")
|
||||
.env("HOME", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
list.status.success(),
|
||||
"ls failed: stdout={} stderr={}",
|
||||
String::from_utf8_lossy(&list.stdout),
|
||||
String::from_utf8_lossy(&list.stderr)
|
||||
);
|
||||
let list_stdout = String::from_utf8_lossy(&list.stdout);
|
||||
assert!(list_stdout.contains("root.txt"), "stdout={list_stdout}");
|
||||
assert!(list_stdout.contains("nested"), "stdout={list_stdout}");
|
||||
|
||||
let cat = Command::new(client_bin)
|
||||
.arg("--dosh-host")
|
||||
.arg("127.0.0.1")
|
||||
.arg("--dosh-port")
|
||||
.arg(port.to_string())
|
||||
.arg("cat")
|
||||
.arg("local:remote-copy-2/root.txt")
|
||||
.env("HOME", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
cat.status.success(),
|
||||
"cat failed: stdout={} stderr={}",
|
||||
String::from_utf8_lossy(&cat.stdout),
|
||||
String::from_utf8_lossy(&cat.stderr)
|
||||
);
|
||||
assert_eq!(String::from_utf8_lossy(&cat.stdout), "root file\n");
|
||||
|
||||
let downloaded = dir.path().join("downloaded");
|
||||
let download = Command::new(client_bin)
|
||||
.arg("--dosh-host")
|
||||
.arg("127.0.0.1")
|
||||
.arg("--dosh-port")
|
||||
.arg(port.to_string())
|
||||
.arg("cp")
|
||||
.arg("-r")
|
||||
.arg("local:remote-copy-2")
|
||||
.arg(&downloaded)
|
||||
.env("HOME", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
download.status.success(),
|
||||
"download failed: stdout={} stderr={}",
|
||||
String::from_utf8_lossy(&download.stdout),
|
||||
String::from_utf8_lossy(&download.stderr)
|
||||
);
|
||||
assert_eq!(
|
||||
fs::read_to_string(downloaded.join("root.txt")).unwrap(),
|
||||
"root file\n"
|
||||
);
|
||||
assert_eq!(
|
||||
fs::read_to_string(downloaded.join("nested/child.txt")).unwrap(),
|
||||
"child file\n"
|
||||
);
|
||||
|
||||
let remove = Command::new(client_bin)
|
||||
.arg("--dosh-host")
|
||||
.arg("127.0.0.1")
|
||||
.arg("--dosh-port")
|
||||
.arg(port.to_string())
|
||||
.arg("rm")
|
||||
.arg("-r")
|
||||
.arg("local:remote-copy")
|
||||
.env("HOME", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
remove.status.success(),
|
||||
"rm failed: stdout={} stderr={}",
|
||||
String::from_utf8_lossy(&remove.stdout),
|
||||
String::from_utf8_lossy(&remove.stderr)
|
||||
);
|
||||
|
||||
let _ = server.kill();
|
||||
let _ = server.wait();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_exec_command_smoke() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let port = free_udp_port();
|
||||
let config = write_server_config(&dir, port);
|
||||
write_native_client_auth(&dir, &config);
|
||||
let mut server = start_server(&dir, &config);
|
||||
let client_bin = env!("CARGO_BIN_EXE_dosh-client");
|
||||
let output = Command::new(client_bin)
|
||||
.arg("--dosh-host")
|
||||
.arg("127.0.0.1")
|
||||
.arg("--dosh-port")
|
||||
.arg(port.to_string())
|
||||
.arg("exec")
|
||||
.arg("local")
|
||||
.arg("printf out; printf err >&2")
|
||||
.env("HOME", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
let _ = server.kill();
|
||||
let _ = server.wait();
|
||||
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"exec failed: stdout={} stderr={}",
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
assert_eq!(String::from_utf8_lossy(&output.stdout), "out");
|
||||
assert_eq!(String::from_utf8_lossy(&output.stderr), "err");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_local_forward_bulk_load_does_not_delay_interactive_terminal() {
|
||||
use portable_pty::{CommandBuilder, NativePtySystem, PtySize, PtySystem};
|
||||
|
||||
Reference in New Issue
Block a user