[remote] add a test

This commit is contained in:
Timothy Stack 2021-05-19 22:44:32 -07:00
parent c3dc668b69
commit 6ebd9f16a2
2 changed files with 30 additions and 9 deletions

View File

@ -32,6 +32,11 @@ remote/ssh_host_dsa_key:
mkdir -p remote
ssh-keygen -f remote/ssh_host_dsa_key -N '' -t dsa
remote/id_rsa:
mkdir -p remote
ssh-keygen -f remote/id_rsa -N '' -t rsa
cp -f remote/id_rsa.pub remote/authorized_keys
noinst_LIBRARIES = \
libtestdummy.a
@ -357,6 +362,7 @@ TESTS = \
test_log_accel \
test_logfile.sh \
test_reltime \
test_remote.sh \
test_scripts.sh \
test_sessions.sh \
test_shlexer.sh \
@ -417,7 +423,7 @@ DISTCLEANFILES = \
empty \
scripts-empty
all-local: remote/ssh_host_dsa_key remote/ssh_host_rsa_key
all-local: remote/ssh_host_dsa_key remote/ssh_host_rsa_key remote/id_rsa
distclean-local:
$(RM_V)rm -rf remote

View File

@ -1,26 +1,41 @@
#! /bin/bash
export HOME=${PWD}/remote
cat > remote/sshd_config <<EOF
Port 2222
UsePam no
AuthorizedKeysFile .ssh/authorized_keys
AuthorizedKeysFile ${PWD}/remote/authorized_keys
HostKey ${PWD}/remote/ssh_host_rsa_key
HostKey ${PWD}/remote/ssh_host_dsa_key
ChallengeResponseAuthentication no
PidFile ${PWD}/remote/sshd.pid
EOF
cat > remote/ssh_config <<EOF
Host *
Port 2222
IdentityFile ${PWD}/remote/id_rsa
EOF
SSHD_PATH=$(which sshd)
# trap 'kill $(cat remote/sshd.pid)' EXIT
trap 'kill $(cat remote/sshd.pid)' EXIT
$SSHD_PATH -E ${PWD}/remote/sshd.log -f remote/sshd_config
${lnav_test} -nN \
-c ":config /tuning/remote/ssh/options/p 2222" \
-c ":config /tuning/remote/ssh/flags vv"
run_test ${lnav_test} -d /tmp/lnav.err -n \
nonexistent-host:${test_dir}/logfile_access_log.0
run_test ${lnav_test} -d /tmp/lnav.err -n localhost:testdir
check_output "config write global var" <<EOF
check_error_output "no error for nonexistent-host?" <<EOF
error: unable to open file: nonexistent-host: -- failed to ssh to host: kex_exchange_identification: Connection closed by remote host
EOF
run_test ${lnav_test} -d /tmp/lnav.err -n \
localhost:${test_dir}/logfile_access_log.0
check_output "could not download remote file?" <<EOF
192.168.202.254 - - [20/Jul/2009:22:59:26 +0000] "GET /vmw/cgi/tramp HTTP/1.0" 200 134 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
EOF