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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#!/bin/sh
# vim: set filetype=sh :
# file: test.ssh_policy_remote-stdout
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2023)
# license: GNU General Public License, version 3
# description: test 4 policies with unexpected output 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-stdout
# (2) check ..-c ..-continue ..-remote-stdout
# (3) check ..-C ..-stop ..-remote-stdout
# (4) check ..-C ..-continue ..-remote-stdout
. ./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
exp1e=\
"--- output with ERROR from <example.ssh_policy/localhost:example.ssh_policy_remote> running <echo \"example.ssh_policy_remote: warning-stdout\"> ---
e:example.ssh_policy_remote: warning-stdout
Exit because of ERROR and no interactive question allowed.
--- 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-stdout\"> ---
e:exit=2
Exit because of ERROR and no interactive question allowed.
2"
exp1l=\
"--- output to LEARN from <example.ssh_policy/localhost:example.ssh_policy_remote> running <echo \"example.ssh_policy_remote: warning-stdout\"> ---
l:example.ssh_policy_remote: warning-stdout
0"
exp1s=\
"example.ssh_policy_remote: warning-stdout
0"
exp2=\
"|example.ssh_policy
|example.ssh_policy: start message
||example.ssh_policy/localhost:example.ssh_policy_remote
||example.ssh_policy_remote: start message"
exp3e=\
"||--- output with ERROR from <example.ssh_policy/localhost:example.ssh_policy_remote> running <echo \"example.ssh_policy_remote: warning-stdout\"> ---
||e:example.ssh_policy_remote: warning-stdout
||Exit because of ERROR and no interactive question allowed.
|--- 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-stdout\"> ---
|e:exit=2
|Exit because of ERROR and no interactive question allowed."
exp3l=\
"||--- output to LEARN from <example.ssh_policy/localhost:example.ssh_policy_remote> running <echo \"example.ssh_policy_remote: warning-stdout\"> ---
||l:example.ssh_policy_remote: warning-stdout
||example.ssh_policy_remote: end message
|example.ssh_policy: end message"
exp3s=\
"||s:example.ssh_policy_remote: warning-stdout
||example.ssh_policy_remote: end message
|example.ssh_policy: end message"
rm -f $ia_logfile
check "(1) check ..-c ..-stop ..-remote-stdout" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-c --policy-stop --testcase-remote-stdout; echo \$?; cat $ia_logfile" \
"$exp1e
$exp2
$exp3e"
rm -f $ia_logfile
check "(2) check ..-c ..-continue ..-remote-stdout" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-c --policy-continue --testcase-remote-stdout; echo \$?; cat $ia_logfile" \
"$exp1l
$exp2
$exp3l"
rm -f $ia_logfile
check "(3) check ..-C ..-stop ..-remote-stdout" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-C --policy-stop --testcase-remote-stdout; echo \$?; cat $ia_logfile" \
"$exp1s
$exp2
$exp3s"
rm -f $ia_logfile
check "(4) check ..-C ..-continue ..-remote-stdout" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-C --policy-continue --testcase-remote-stdout; echo \$?; cat $ia_logfile" \
"$exp1s
$exp2
$exp3s"
rm -f $ia_logfile
|