From 0d2c706fa687d4e1a1f67e34798f8ec43441eef6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 1 Jun 2021 17:04:05 +0100 Subject: [PATCH] apitest: Initial test of ssh Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 18 ++++++++++++++++++ apitest/mock-ssh | 5 +++++ 2 files changed, 23 insertions(+) create mode 100755 apitest/mock-ssh diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 955e9322..f51b79bf 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -194,6 +194,23 @@ impl Ctx { let pieces = alice.pieces::()?; dbgc!(pieces); } + + #[throws(Explode)] + fn ssh_remote(&mut self) { + let ds = self.ds().also(&[ + ("config", PathResolveContext::default().resolve(&CONFIG)), + ]); + let mut command = ds.gss( + "--ssh-command=@src@/apitest/mock-ssh \ + --ssh nowhere \ + list-accounts" + )?; + command.insert(0, ds.subst( + "--ssh-proxy-command=@target@/debug/otter-ssh-proxy \ + --config @config@ mgmtchannel-proxy" + )?); + self.otter(&command)?; + } } #[throws(Explode)] @@ -203,6 +220,7 @@ fn tests(mut c: Ctx) { test!(c, "specs", c.chdir_root(|c| c.specs() )); test!(c, "put-back", c.put_back() ?); test!(c, "save-load", c.save_load() ?); + test!(c, "ssh-remote", c.ssh_remote() ?); } #[throws(Explode)] diff --git a/apitest/mock-ssh b/apitest/mock-ssh new file mode 100755 index 00000000..5d6c8ef0 --- /dev/null +++ b/apitest/mock-ssh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +echo >&2 "$0: user@host=$1"; shift +export USER=no-such-user +eval "set -x; $*" -- 2.30.2