From: Ian Jackson Date: Wed, 2 Jun 2021 17:03:05 +0000 (+0100) Subject: sshkeys: Tests a restricted command, refactor X-Git-Tag: otter-0.7.0~95 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=af14fe54d43e9af8ce6f3c4c141a1a695c8bafc4;p=otter.git sshkeys: Tests a restricted command, refactor Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 2afe522a..6d826e85 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -246,11 +246,14 @@ impl Ctx { .lines().nth(2).unwrap().unwrap(), STATIC_TEST.strip_suffix("\n").unwrap() ); - let mk_restricted = |account|{ - let mut command = ds.also(&[("account",account)]).gss( + let mk_restricted = |account, rhs|{ + let mut command = ds.also(&[ + ("account",account), + ("rhs", rhs), + ]).gss( "--account @account@ \ --ssh nowhere \ - list-accounts" + @rhs@" )?; command.insert(0, ds.subst( "--ssh-command=@src@/apitest/mock-ssh-restricted \ @@ -259,9 +262,10 @@ impl Ctx { Ok::<_,Explode>(command) }; - self.otter(&mk_restricted("ssh:test:sub")?)?; - self.otter(&mk_restricted("ssh:other:")?).expect_err("unath"); - self.otter(&mk_restricted("ssh:test:")?)?; + self.otter(&mk_restricted("ssh:test:sub", "list-accounts")?)?; + self.otter(&mk_restricted("ssh:other:", "list-accounts")?) + .expect_err("unath"); + self.otter(&mk_restricted("ssh:test:", "list-accounts")?)?; } }