#[cfg(feature = "ssh")]
mod ssh_supabase {
use bashkit::{Bash, SshConfig};
fn bash_with_supabase() -> Bash {
Bash::builder()
.ssh(
SshConfig::new()
.allow("supabase.sh")
.strict_host_key_checking(false),
)
.build()
}
#[tokio::test]
async fn ssh_supabase_connects() {
let mut last_stderr = String::new();
for attempt in 1..=3 {
let mut bash = bash_with_supabase();
let result = bash.exec("ssh supabase.sh").await.unwrap();
if result.exit_code == 0 {
return;
}
last_stderr = result.stderr;
if attempt < 3 {
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
}
}
panic!("ssh supabase.sh failed after 3 attempts: {last_stderr}");
}
#[tokio::test]
async fn ssh_blocked_host_rejected() {
let mut bash = bash_with_supabase();
let result = bash.exec("ssh evil.com 'id'").await.unwrap();
assert_ne!(result.exit_code, 0);
assert!(
result.stderr.contains("not in allowlist"),
"expected allowlist error, got: {}",
result.stderr
);
}
}