summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-04-03 02:33:31 +0000
committerDamien Miller <djm@mindrot.org>2020-04-03 13:43:10 +1100
commitd5318a784d016478fc8da90a38d9062c51c10432 (patch)
treea67e29391881e3539b09ee9a05d744dcae8618a3 /regress
parent663e84bb53de2a60e56a44d538d25b8152b5c1cc (diff)
upstream: Add regression test for percent expansions where possible.
OpenBSD-Regress-ID: 7283be8b2733ac1cbefea3048a23d02594485288
Diffstat (limited to 'regress')
-rw-r--r--regress/percent.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/regress/percent.sh b/regress/percent.sh
new file mode 100644
index 000000000..84999fd0f
--- /dev/null
+++ b/regress/percent.sh
@@ -0,0 +1,65 @@
1# $OpenBSD: percent.sh,v 1.1 2020/04/03 02:33:31 dtucker Exp $
2# Placed in the Public Domain.
3
4tid="percent expansions"
5
6USER=`id -u -n`
7USERID=`id -u`
8HOST=`hostname -s`
9HOSTNAME=`hostname`
10
11# Localcommand is evaluated after connection because %T is not available
12# until then. Because of this we use a different method of exercising it,
13# and we can't override the remote user otherwise authentication will fail.
14# We also have to explicitly enable it.
15echo "permitlocalcommand yes" >> $OBJ/ssh_proxy
16
17trial()
18{
19 opt="$1"; arg="$2"; expect="$3"
20
21 trace "test $opt=$arg $expect"
22 if [ "$opt" = "localcommand" ]; then
23 ${SSH} -F $OBJ/ssh_proxy -o $opt="echo '$arg' >$OBJ/actual" \
24 somehost true
25 got=`cat $OBJ/actual`
26 else
27 got=`${SSH} -F $OBJ/ssh_proxy -o $opt="$arg" -G \
28 remuser@somehost | awk '$1=="'$opt'"{print $2}'`
29 fi
30 if [ "$got" != "$expect" ]; then
31 fail "$opt=$arg expect $expect got $got"
32 else
33 trace "$opt=$arg expect $expect got $got"
34 fi
35}
36
37for i in localcommand remotecommand controlpath identityagent forwardagent; do
38 if [ "$i" = "localcommand" ]; then
39 HASH=94237ca18fe6b187dccf57e5593c0bb0a29cc302
40 REMUSER=$USER
41 trial $i '%T' NONE
42 else
43 HASH=dbc43d45c7f8c0ecd0a65c0da484c03b6903622e
44 REMUSER=remuser
45 fi
46 trial $i '%%' '%'
47 trial $i '%C' $HASH
48 trial $i '%i' $USERID
49 trial $i '%h' 127.0.0.1
50 trial $i '%d' $HOME
51 trial $i '%L' $HOST
52 trial $i '%l' $HOSTNAME
53 trial $i '%n' somehost
54 trial $i '%p' $PORT
55 trial $i '%r' $REMUSER
56 trial $i '%u' $USER
57 trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \
58 "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER"
59done
60
61# A subset of options support tilde expansion
62for i in controlpath identityagent forwardagent; do
63 trial $i '~' $HOME/
64 trial $i '~/.ssh' $HOME/.ssh
65done