From: Ian Jackson Date: Tue, 1 Jun 2021 16:04:05 +0000 (+0100) Subject: apitest: Initial test of ssh X-Git-Tag: otter-0.7.0~136 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0d2c706fa687d4e1a1f67e34798f8ec43441eef6;p=otter.git apitest: Initial test of ssh Signed-off-by: Ian Jackson --- 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; $*"