Skip to content

Commit 46832e4

Browse files
add test case
1 parent 2722cb9 commit 46832e4

3 files changed

Lines changed: 59 additions & 2 deletions

File tree

apps/wolfsshd/test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To run all tests do:
1010
```
1111
$ cd apps/wolfsshd/test/
1212
13-
$ sudo ./run_all_sshd_tests.sh
13+
$ sudo ./run_all_sshd_tests.sh <user>
1414
Running all wolfSSHd tests
1515
Starting up local wolfSSHd for tests on 127.0.0.1:22222
1616
SSHD running on PID 7979

apps/wolfsshd/test/run_all_sshd_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ fi
7676
# these tests require setting up an sshd
7777
if [ "$USING_LOCAL_HOST" == 1 ]; then
7878
run_test "sshd_forcedcmd_test.sh"
79+
run_test "sshd_window_full_test.sh"
7980
else
8081
printf "Skipping tests that need to setup local SSHD\n"
81-
SKIPPED=$((SKIPPED+1))
82+
SKIPPED=$((SKIPPED+2))
8283
fi
8384

8485
# these tests run with X509 sshd-config loaded
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# sshd local test
4+
5+
if [ -z "$1" ] || [ -z "$2" ]; then
6+
echo "expecting host and port as arguments"
7+
echo "./sshd_exec_test.sh 127.0.0.1 22222"
8+
exit 1
9+
fi
10+
11+
PWD=`pwd`
12+
13+
if [ ! -z "$3" ]; then
14+
USER="$3"
15+
else
16+
USER=`whoami`
17+
fi
18+
TEST_PORT="$2"
19+
TEST_HOST="$1"
20+
source ./start_sshd.sh
21+
cat <<EOF > sshd_config_test_window
22+
Port $TEST_PORT
23+
Protocol 2
24+
LoginGraceTime 600
25+
PermitRootLogin yes
26+
PasswordAuthentication yes
27+
PermitEmptyPasswords no
28+
UsePrivilegeSeparation no
29+
UseDNS no
30+
HostKey $PWD/../../../keys/server-key.pem
31+
AuthorizedKeysFile $PWD/authorized_keys_test
32+
EOF
33+
34+
start_wolfsshd "sshd_config_test_forcedcmd"
35+
cd ../../..
36+
37+
TEST_CLIENT="./examples/client/client"
38+
TEST_SFTP="./examples/sftpclient/wolfsftp"
39+
PRIVATE_KEY="./keys/hansel-key-ecc.der"
40+
PUBLIC_KEY="./keys/hansel-key-ecc.pub"
41+
42+
head -c 1G /dev/urandom > random-test.txt
43+
44+
PWD=`pwd`
45+
$TEST_CLIENT -c "cd $PWD; $TEST_CLIENT -c \"cat $PWD/random-test.txt\" -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h $TEST_HOST -p $TEST_PORT" -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h $TEST_HOST -p $TEST_PORT > random-test-result.txt
46+
47+
diff random-test.txt random-test-result.txt
48+
RESULT=$?
49+
if [ "$RESULT" != 0 ]; then
50+
echo "cat did not pass through all expected data"
51+
exit 1
52+
fi
53+
54+
stop_wolfsshd
55+
exit 0
56+

0 commit comments

Comments
 (0)