chiark / gitweb /
apitest: Initial test of ssh
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 16:04:05 +0000 (17:04 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 17:04:57 +0000 (18:04 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs
apitest/mock-ssh [new file with mode: 0755]

index 955e93227d59d92bc504f1ceb8a4d8f5002166e3..f51b79bfcf24d8810c8e33aa5d43f125d90687f1 100644 (file)
@@ -194,6 +194,23 @@ impl Ctx {
     let pieces = alice.pieces::<PIA>()?;
     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 (executable)
index 0000000..5d6c8ef
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+set -e
+echo >&2 "$0: user@host=$1"; shift
+export USER=no-such-user
+eval "set -x; $*"