1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#!/bin/sh
# vim: set filetype=sh :
# file: test.ssh_policy_remote-bad-exit
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2023)
# license: GNU General Public License, version 3
# description: test 4 policies with exit != 0 on remote host
# policy-A: --check-mode-c and --policy-stop
# policy-B: --check-mode-c and --policy-continue
# policy-C: --check-mode-C and --policy-stop
# policy-D: --check-mode-C and --policy-continue
# see also: example.ssh_policy and symlink example.ssh_policy_remote
# The following tests are included:
# (1) check ..-c ..-stop ..-remote-bad-exit
# (2) check ..-c ..-continue ..-remote-bad-exit
# (3) check ..-C ..-stop ..-remote-bad-exit
# (4) check ..-C ..-continue ..-remote-bad-exit
. ./tstlib
if ./sshd2222 should-work; then
sshd2222opts="$(./sshd2222 options)"
fi
export testdir="$(realpath .)"
shell=""
while [ $# -ne 0 ]; do
if [ "$1" = "-s" ]; then
shell="$2"
shift 2
else
echo "ERROR $0: unknown option <$1>" >&2
exit 1
fi
done
[ "$shell" ] && set -- "$@" -s "$shell"
cmd="$(dirname $0)/example.ssh_policy"
ia_logfile="$(mktemp)"
export ia_logfile
exp1ec=\
"ERROR: ia premature exit of <exit 14>
--- output with ERROR from <example.ssh_policy> running <ia_ssh $sshd2222opts localhost \"cd $testdir; ./tests/example.ssh_policy_remote --check-mode-c --policy-stop --testcase-remote-bad-exit\"> ---
e:exit=14
Exit because of ERROR and no interactive question allowed.
14"
exp1eC="$(echo "$exp1ec" | sed "s/--check-mode-c/--check-mode-C/g")"
exp1l=\
"ERROR: ia premature exit of <exit 14>
0"
exp2=\
"|example.ssh_policy
|example.ssh_policy: start message
||example.ssh_policy/localhost:example.ssh_policy_remote
||example.ssh_policy_remote: start message"
exp3ec=\
"|--- output with ERROR from <example.ssh_policy> running <ia_ssh $sshd2222opts localhost \"cd $testdir; ./tests/example.ssh_policy_remote --check-mode-c --policy-stop --testcase-remote-bad-exit\"> ---
|e:exit=14
|Exit because of ERROR and no interactive question allowed."
exp3eC="$(echo "$exp3ec" | sed "s/--check-mode-c/--check-mode-C/g")"
exp3l=\
"|example.ssh_policy: end message"
rm -f $ia_logfile
check "(1) check ..-c ..-stop ..-remote-bad-exit" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-c --policy-stop --testcase-remote-bad-exit; echo \$?; cat $ia_logfile" \
"$exp1ec
$exp2
$exp3ec"
rm -f $ia_logfile
check "(2) check ..-c ..-continue ..-remote-bad-exit" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-c --policy-continue --testcase-remote-bad-exit; echo \$?; cat $ia_logfile" \
"$exp1l
$exp2
$exp3l"
rm -f $ia_logfile
check "(3) check ..-C ..-stop ..-remote-bad-exit" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-C --policy-stop --testcase-remote-bad-exit; echo \$?; cat $ia_logfile" \
"$exp1eC
$exp2
$exp3eC"
rm -f $ia_logfile
check "(4) check ..-C ..-continue ..-remote-bad-exit" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-C --policy-continue --testcase-remote-bad-exit; echo \$?; cat $ia_logfile" \
"$exp1l
$exp2
$exp3l"
rm -f $ia_logfile
|