Skip to content

Commit fe25b4e

Browse files
authored
Merge pull request #746 from JacobBarthelmeh/testing
add CI test against master and last two wolfSSL releases
2 parents 11fa704 + b78fad7 commit fe25b4e

File tree

10 files changed

+165
-49
lines changed

10 files changed

+165
-49
lines changed

.github/workflows/os-check.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,28 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13-
env:
14-
WOLFSSL_REF: v5.7.0-stable
15-
1613
jobs:
14+
create_matrix:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
versions: ${{ steps.json.outputs.versions }}
18+
steps:
19+
- name: Create wolfSSL version matrix
20+
id: json
21+
run: |
22+
current=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -1`
23+
last=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -2 | tail -1`
24+
VERSIONS=$(echo "[ \"master\", \"$current\", \"$last\" ]")
25+
echo "wolfSSL versions found: $VERSIONS"
26+
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
27+
1728
build_wolfssl:
29+
needs: create_matrix
1830
strategy:
1931
fail-fast: false
2032
matrix:
2133
os: [ ubuntu-latest, macos-latest ]
34+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
2235
name: Build wolfssl
2336
runs-on: ${{ matrix.os }}
2437
timeout-minutes: 4
@@ -28,25 +41,32 @@ jobs:
2841
id: cache-wolfssl
2942
with:
3043
path: build-dir/
31-
key: wolfssh-os-check-wolfssl-${{ env.WOLFSSL_REF }}-${{ matrix.os }}
44+
key: wolfssh-os-check-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
3245
lookup-only: true
3346

47+
- name: debug
48+
run: echo wolfssl version ${{ matrix.wolfssl }}
49+
3450
- name: Checkout, build, and install wolfssl
3551
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
3652
uses: wolfSSL/actions-build-autotools-project@v1
3753
with:
3854
repository: wolfssl/wolfssl
39-
ref: ${{ env.WOLFSSL_REF }}
55+
ref: ${{ matrix.wolfssl }}
4056
path: wolfssl
4157
configure: --enable-all
4258
check: false
4359
install: true
4460

4561
build_wolfssh:
62+
needs:
63+
- build_wolfssl
64+
- create_matrix
4665
strategy:
4766
fail-fast: false
4867
matrix:
4968
os: [ ubuntu-latest, macos-latest ]
69+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
5070
config: [
5171
'',
5272
'--enable-all',
@@ -57,13 +77,12 @@ jobs:
5777
name: Build wolfssh
5878
runs-on: ${{ matrix.os }}
5979
timeout-minutes: 4
60-
needs: build_wolfssl
6180
steps:
6281
- name: Checking cache for wolfssl
6382
uses: actions/cache@v4
6483
with:
6584
path: build-dir/
66-
key: wolfssh-os-check-wolfssl-${{ env.WOLFSSL_REF }}-${{ matrix.os }}
85+
key: wolfssh-os-check-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
6786
fail-on-cache-miss: true
6887

6988
- name: Checkout, build, and test wolfssh

.github/workflows/sshd-test.yml

Lines changed: 87 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,94 @@ on:
66
pull_request:
77
branches: [ '*' ]
88

9-
jobs:
10-
build:
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
1112

13+
jobs:
14+
create_matrix:
1215
runs-on: ubuntu-latest
16+
outputs:
17+
versions: ${{ steps.json.outputs.versions }}
18+
steps:
19+
- name: Create wolfSSL version matrix
20+
id: json
21+
run: |
22+
current=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -1`
23+
last=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -2 | tail -1`
24+
VERSIONS=$(echo "[ \"master\", \"$current\", \"$last\" ]")
25+
echo "wolfSSL versions found: $VERSIONS"
26+
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
27+
28+
build_wolfssl:
29+
needs: create_matrix
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
os: [ ubuntu-latest ]
34+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
35+
name: Build wolfssl
36+
runs-on: ${{ matrix.os }}
37+
timeout-minutes: 4
38+
steps:
39+
- name: Checking cache for wolfssl
40+
uses: actions/cache@v4
41+
id: cache-wolfssl
42+
with:
43+
path: build-dir/
44+
key: wolfssh-sshd-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
45+
lookup-only: true
46+
47+
- name: Checkout, build, and install wolfssl
48+
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
49+
uses: wolfSSL/actions-build-autotools-project@v1
50+
with:
51+
repository: wolfssl/wolfssl
52+
ref: ${{ matrix.wolfssl }}
53+
path: wolfssl
54+
configure: --enable-all
55+
check: false
56+
install: true
1357

58+
build_wolfssh:
59+
needs:
60+
- build_wolfssl
61+
- create_matrix
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
os: [ ubuntu-latest ]
66+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
67+
name: Build and test wolfsshd
68+
runs-on: ${{ matrix.os }}
69+
timeout-minutes: 10
1470
steps:
15-
- uses: actions/checkout@v2
16-
with:
17-
repository: wolfSSL/wolfssl.git
18-
ref: master
19-
- name: build wolfSSL
20-
run: ./autogen.sh && ./configure --enable-all --prefix=/usr && make && sudo make install
21-
- uses: actions/checkout@v2
22-
- name: autogen
23-
run: ./autogen.sh
24-
- name: configure
25-
run: ./configure --enable-all CPPFLAGS="-DWOLFSSH_NO_FPKI -DWOLFSSH_NO_SFTP_TIMEOUT -DWOLFSSH_MAX_SFTP_RW=4000000"
26-
- name: make
27-
run: make
28-
- name: make check
29-
run: make check
30-
- name: run wolfSSHd tests
31-
run: sudo ./run_all_sshd_tests.sh root
32-
working-directory: ./apps/wolfsshd/test
71+
- name: Checking cache for wolfssl
72+
uses: actions/cache@v4
73+
with:
74+
path: build-dir/
75+
key: wolfssh-sshd-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
76+
fail-on-cache-miss: true
77+
78+
- uses: actions/checkout@v4
79+
with:
80+
path: wolfssh/
81+
82+
- name: autogen
83+
working-directory: ./wolfssh/
84+
run: ./autogen.sh
85+
86+
- name: configure
87+
working-directory: ./wolfssh/
88+
run : |
89+
./configure --enable-all LDFLAGS="-L${{ github.workspace }}/build-dir/lib" CPPFLAGS="-I${{ github.workspace }}/build-dir/include -DWOLFSSH_NO_FPKI -DWOLFSSH_NO_SFTP_TIMEOUT -DWOLFSSH_MAX_SFTP_RW=4000000 -DMAX_PATH_SZ=120"
90+
91+
- name: make check
92+
working-directory: ./wolfssh/
93+
run: make check
94+
95+
- name: Run wolfSSHd tests
96+
working-directory: ./wolfssh/apps/wolfsshd/test
97+
run: |
98+
git log -3
99+
sudo ./run_all_sshd_tests.sh

.github/workflows/zephyr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
config:
1515
- zephyr-ref: v3.4.0
1616
zephyr-sdk: 0.16.1
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-22.04
1818
# This should be a safe limit for the tests to run.
1919
timeout-minutes: 20
2020
steps:

apps/wolfsshd/test/sshd_forcedcmd_test.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
if [ -z "$1" ] || [ -z "$2" ]; then
66
echo "expecting host and port as arguments"
7-
echo "./sshd_exec_test.sh 127.0.0.1 22222"
7+
echo "$0 127.0.0.1 22222"
88
exit 1
99
fi
1010

@@ -37,8 +37,9 @@ TEST_SFTP="./examples/sftpclient/wolfsftp"
3737
PRIVATE_KEY="./keys/hansel-key-ecc.der"
3838
PUBLIC_KEY="./keys/hansel-key-ecc.pub"
3939

40-
RESULT=`$TEST_CLIENT -c 'echo bob' -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h $TEST_HOST -p $TEST_PORT`
41-
cat $RESULT | grep bob
40+
RESULT=$( $TEST_CLIENT -c 'echo bob' -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h $TEST_HOST -p $TEST_PORT )
41+
echo $RESULT
42+
echo $RESULT | grep bob
4243
RESULT=$?
4344
if [ "$RESULT" == 0 ]; then
4445
echo "Shell login should fail with forced command"

apps/wolfsshd/test/sshd_term_size_test.sh

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,36 @@ if [ -z "$1" ] || [ -z "$2" ]; then
1515
exit 1
1616
fi
1717

18-
set -e
18+
# Check if tmux is available
19+
which tmux
20+
RESULT=$?
21+
if [ ${RESULT} = 1 ]; then
22+
echo "tmux is not installed!!"
23+
exit 1
24+
fi
25+
1926
echo "Creating tmux session at $PWD with command :"
20-
tmux new-session -d -s test "$TEST_CLIENT -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \"$1\" -p \"$2\""
27+
echo "tmux new-session -d -s test \"$TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \"$1\" -p \"$2\"\""
28+
tmux new-session -d -s test "$TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \"$1\" -p \"$2\""
29+
echo "Result of tmux new-session = $?"
2130

2231
# give the command a second to establish SSH connection
23-
sleep 0.5
32+
sleep 1
2433

2534
COL=`tmux display -p -t test '#{pane_width}'`
2635
ROW=`tmux display -p -t test '#{pane_height}'`
36+
echo "tmux 'test' session has COL = ${COL} and ROW = ${ROW}"
2737

2838
# get the terminals columns and lines
2939
tmux send-keys -t test 'echo;echo $COLUMNS $LINES;echo'
3040
tmux send-keys -t test 'ENTER'
41+
42+
# give the command a second to run
43+
sleep 1
44+
3145
tmux capture-pane -t test
3246
RESULT=$(tmux show-buffer | grep '^[0-9]* [0-9]*$')
47+
tmux show-buffer
3348

3449
echo "$RESULT"
3550
echo ""
@@ -55,25 +70,32 @@ fi
5570
# close down the SSH session
5671
tmux send-keys -t test 'exit'
5772
tmux send-keys -t test 'ENTER'
58-
set +e
5973

6074
# kill off the session if it's still running, but don't error out if the session
6175
# has already closed down
6276
tmux kill-session -t test
6377
set -e
6478

65-
tmux new-session -d -x 50 -y 10 -s test "$TEST_CLIENT -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \"$1\" -p \"$2\""
79+
echo "Starting another session with a smaller window size"
80+
echo "tmux new-session -d -x 50 -y 10 -s test \"$TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \"$1\" -p \"$2\"\""
81+
tmux new-session -d -x 50 -y 10 -s test "$TEST_CLIENT -q -t -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -h \"$1\" -p \"$2\""
6682

6783
# give the command a second to establish SSH connection
68-
sleep 0.5
84+
sleep 1
6985

86+
echo "Sending keys to tmux session for displaying column/rows"
7087
tmux send-keys -t test 'echo;echo $COLUMNS $LINES;echo'
7188
tmux send-keys -t test 'ENTER'
7289
tmux capture-pane -t test
7390
RESULT=$(tmux show-buffer | grep '^[0-9]* [0-9]*$')
7491

75-
ROW_FOUND=$(echo "$RESULT" | sed -e 's/[0-9]* \([0-9]*\)/\1/')
76-
COL_FOUND=$(echo "$RESULT" | sed -e 's/\([0-9]*\) [0-9]*/\1/')
92+
ROW_FOUND=$( echo "$RESULT" | sed -e 's/[0-9]* \([0-9]*\)/\1/' )
93+
COL_FOUND=$( echo "$RESULT" | sed -e 's/\([0-9]*\) [0-9]*/\1/' )
94+
95+
#remove any newlines, tabs, or returns
96+
ROW_FOUND=$( tr -d '\n\t\r ' <<<"$ROW_FOUND" )
97+
COL_FOUND=$( tr -d '\n\t\r ' <<<"$COL_FOUND" )
98+
7799

78100
if [ "50" != "$COL_FOUND" ]; then
79101
echo "Col found was $COL_FOUND which does not match expected 50"

apps/wolfsshd/test/sshd_window_full_test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ PUBLIC_KEY="./keys/hansel-key-ecc.pub"
4242
head -c 1G /dev/urandom > random-test.txt
4343

4444
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
45+
echo "$TEST_CLIENT -q -c \"cd $PWD; $TEST_CLIENT -q -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+
$TEST_CLIENT -q -c "cd $PWD; $TEST_CLIENT -q -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
48+
49+
ls -la random-test*
4650

4751
diff random-test.txt random-test-result.txt
4852
RESULT=$?

apps/wolfsshd/test/sshd_x509_test.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd ../../..
77

88
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
99
echo "expecting host, port and user as arguments"
10-
echo "./sshd_x509_text.sh 127.0.0.1 22222 user"
10+
echo "$0 127.0.0.1 22222 user"
1111
exit 1
1212
fi
1313

@@ -17,13 +17,13 @@ PUBLIC_KEY="./keys/$3-cert.der"
1717
CA_CERT="./keys/ca-cert-ecc.der"
1818

1919
set -e
20-
echo "$TEST_CLIENT -c 'pwd' -u $3 -i $PRIVATE_KEY -J $PUBLIC_KEY -A $CA_CERT -h \"$1\" -p \"$2\""
21-
$TEST_CLIENT -c 'pwd' -u $3 -i "$PRIVATE_KEY" -J "$PUBLIC_KEY" -A "$CA_CERT" -h "$1" -p "$2"
20+
echo "$TEST_CLIENT -X -c 'pwd' -u $3 -i $PRIVATE_KEY -J $PUBLIC_KEY -A $CA_CERT -h \"$1\" -p \"$2\""
21+
$TEST_CLIENT -X -c 'pwd' -u $3 -i "$PRIVATE_KEY" -J "$PUBLIC_KEY" -A "$CA_CERT" -h "$1" -p "$2"
2222
set +e
2323

2424
rm -f error.txt
25-
echo "$TEST_CLIENT -c 'ls error' -u $3 -i $PRIVATE_KEY -J $PUBLIC_KEY -A $CA_CERT -h \"$1\" -p \"$2\" 2> error.txt"
26-
$TEST_CLIENT -c 'ls error' -u $3 -i "$PRIVATE_KEY" -J "$PUBLIC_KEY" -A "$CA_CERT" -h "$1" -p "$2" 2> error.txt
25+
echo "$TEST_CLIENT -X -c 'ls error' -u $3 -i $PRIVATE_KEY -J $PUBLIC_KEY -A $CA_CERT -h \"$1\" -p \"$2\" 2> error.txt"
26+
$TEST_CLIENT -X -c 'ls error' -u $3 -i "$PRIVATE_KEY" -J "$PUBLIC_KEY" -A "$CA_CERT" -h "$1" -p "$2" 2> error.txt
2727

2828
# check stderr output was caught
2929
if [ ! -s error.txt ]; then
@@ -36,4 +36,3 @@ rm -f error.txt
3636
cd $PWD
3737
exit 0
3838

39-

examples/client/client.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static void ShowUsage(void)
120120
#endif
121121
printf(" -E List all possible algos\n");
122122
printf(" -k set the list of key algos to use\n");
123+
printf(" -q turn off debugging output\n");
123124
}
124125

125126

@@ -658,7 +659,7 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
658659

659660
(void)keepOpen;
660661

661-
while ((ch = mygetopt(argc, argv, "?ac:h:i:j:p:tu:xzNP:RJ:A:XeEk:")) != -1) {
662+
while ((ch = mygetopt(argc, argv, "?ac:h:i:j:p:tu:xzNP:RJ:A:XeEk:q")) != -1) {
662663
switch (ch) {
663664
case 'h':
664665
host = myoptarg;
@@ -671,6 +672,10 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
671672
#endif
672673
break;
673674

675+
case 'q':
676+
wolfSSH_Debugging_OFF();
677+
break;
678+
674679
case 'e':
675680
userEcc = 1;
676681
break;

keys/renewcerts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ else
66
USER_NAME=$1
77
cp fred-key.der $USER_NAME-key.der
88
cp fred-key.pem $USER_NAME-key.pem
9-
sed -i "s/fred/$USER_NAME/g" renewcerts.cnf
9+
sed -i.bak "s/fred/$USER_NAME/g" renewcerts.cnf
1010
fi
1111

1212
# renew CA

src/internal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14053,7 +14053,6 @@ int SendUserAuthRequest(WOLFSSH* ssh, byte authType, int addSig)
1405314053

1405414054
payloadSz = MSG_ID_SZ + (LENGTH_SZ * 3) +
1405514055
ssh->userNameSz + serviceNameSz + authNameSz;
14056-
1405714056
if (authId == ID_USERAUTH_PASSWORD)
1405814057
ret = PrepareUserAuthRequestPassword(ssh, &payloadSz, &authData);
1405914058
else if (authId == ID_USERAUTH_PUBLICKEY && !ssh->userAuthPkDone) {

0 commit comments

Comments
 (0)