From 7a3df8f1982ff867aae6b73a527626c3f22d8482 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Sun, 5 Nov 2023 20:28:24 -0800 Subject: [PATCH] add error return test case --- apps/wolfsshd/test/error_return.sh | 30 ++++++++++++++++++++++++ apps/wolfsshd/test/run_all_sshd_tests.sh | 1 + 2 files changed, 31 insertions(+) create mode 100755 apps/wolfsshd/test/error_return.sh diff --git a/apps/wolfsshd/test/error_return.sh b/apps/wolfsshd/test/error_return.sh new file mode 100755 index 000000000..25d2a581b --- /dev/null +++ b/apps/wolfsshd/test/error_return.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# sshd local test + +PWD=`pwd` +cd ../../.. + +TEST_CLIENT="./examples/client/client" +USER=`whoami` +PRIVATE_KEY="./keys/hansel-key-ecc.der" +PUBLIC_KEY="./keys/hansel-key-ecc.pub" + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "expecting host and port as arguments" + echo "./error_return.sh 127.0.0.1 22222" + exit -1 +fi + +echo "$TEST_CLIENT -c 'ls error' -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \"$1\" -p \"$2\"" +$TEST_CLIENT -c 'ls error' -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h "$1" -p "$2" +if [ $? != 2 ]; then + echo "Expecting error return value of 2 for failed ls command" + cd $PWD + exit 1 +fi + +cd $PWD +exit 0 + + diff --git a/apps/wolfsshd/test/run_all_sshd_tests.sh b/apps/wolfsshd/test/run_all_sshd_tests.sh index 4c082d2cd..7e03e61bf 100755 --- a/apps/wolfsshd/test/run_all_sshd_tests.sh +++ b/apps/wolfsshd/test/run_all_sshd_tests.sh @@ -52,6 +52,7 @@ run_test() { run_test "sshd_exec_test.sh" run_test "sshd_term_size_test.sh" +run_test "error_return.sh" # add aditional tests here, check on var USING_LOCAL_HOST if can make sshd # server start/restart with changes