wolfssh/apps/wolfsshd/test
John Safranek 25cc12ecd2 tests: run wolfsftp in sshd_bad_sftp_test
The test quoted the whole wolfsftp command line as one word, so the
shell found no such program and its exit status 127 passed as the
expected refusal. Quote each argument instead, and fail when the client
can't be run.
2026-11-21 15:33:37 -06:00
..
README.md
…
create_authorized_test_file.sh
…
create_sshd_config.sh
…
error_return.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
port_lease.sh
…
run_all_sshd_tests.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
ssh_kex_algos.sh
…
sshd_authkeys_none_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_bad_sftp_test.sh tests: run wolfsftp in sshd_bad_sftp_test 2026-11-21 15:33:37 -06:00
sshd_bad_subsystem_test.sh
…
sshd_channel_close_test.sh
…
sshd_chroot_fail_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_chroot_none_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_chroot_preload.c
…
sshd_dash_d_test.ps1
…
sshd_empty_password_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_exec_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_exit_signal_test.sh
…
sshd_exit_status_test.sh
…
sshd_forcedcmd_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_fork_fail_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_fork_preload.c
…
sshd_large_sftp_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_login_grace_test.ps1
…
sshd_login_grace_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_long_shell_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_match_group_win_test.ps1
…
sshd_match_overlap_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_mldsa_composite_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_ossh_cert_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_permitroot_forced_cmd.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_permitroot_prohibit_password.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_permitroot_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_port_lease_test.sh
…
sshd_privdrop_fail_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_privdrop_preload.c
…
sshd_pubkey_reject_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_scp_fail.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_scp_home_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_sftp_idle_cpu_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_stderr_drain_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_stderr_eof_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_stdin_eof_test.sh
…
sshd_stdin_stall_test.sh
…
sshd_term_close_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_term_size_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_window_full_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_x509_test.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
sshd_x509_upn_fail.sh examples: check host keys against known_hosts 2026-11-21 15:33:37 -06:00
start_sshd.sh
…
test_configuration.c
…
wolfssh_options.sh
…

README.md

wolfSSHd Tests

These are separate from the tests in scripts directory because of the need for 'sudo' when starting up an SSHd server to test against.

Directory Permissions

wolfSSHd's StrictModes check refuses to read an authorized_keys file if any directory above it is group or world writable. A tree unpacked or cloned under a umask of 002, the default where each user has their own group, has mode 0775 directories, so no test can authenticate and the suite fails from the first test. run_all_sshd_tests.sh checks for this before it starts a daemon and names the offending directories; clear the bits with chmod g-w,o-w on each, or create the tree under umask 022.

Running Tests

To run all tests do:

$ cd apps/wolfsshd/test/

$ sudo ./run_all_sshd_tests.sh <user>
Running all wolfSSHd tests
Starting up local wolfSSHd for tests on 127.0.0.1:22222
SSHD running on PID 7979
sshd_exec_test.sh ... PASSED
Shutting down test wolfSSHd
Stopping SSHD, killing pid 7979
All tests ran, 1 run, 1 passed, 0 skipped

"run" counts every test reached, skips included. Passed plus skipped must equal run; the runner fails if they do not.

To run a specific test do:

startup wolfSSHd

$ cd ./apps/wolfsshd

$ sudo ./wolfsshd -D -d -f ./test/sshd_config_test
[PID 8049]: [SSHD] parsing config file ./test/sshd_config_test
[PID 8049]: [SSHD] Setting login grace time to 600
[PID 8049]: [SSHD] Turning off privilege separation!
[PID 8049]: [SSHD] Starting wolfSSH SSHD application
[PID 8049]: Entering wolfSSH_CTX_new()
[PID 8049]: Entering CtxInit()
[PID 8049]: Leaving wolfSSH_CTX_new(), ctx = 0x5574747f3520
[PID 8049]: Entering wolfSSH_CTX_SetBanner()
[PID 8049]:   setting banner to: "wolfSSHD
"
...
...
...

point the test to the host/port if needed

$ cd ./apps/wolfsshd/test

$ ./sshd_exec_test.sh 127.0.0.1 22222

Adding Tests

New tests should be added to a new .sh file if not related to any of the existing tests. The test should then be called from run_all_sshd_tests.sh once added, for example:

run_test "new_test.sh"

This would be added before the call to stop the SSHd server stop_wolfsshd and after the test files have been setup:

 48 # setup
 49 set -e
 50 ./create_authorized_test_file.sh
 51 ./create_sshd_config.sh
 52 set +e

The name also has to be listed in one of the two arrays at the top of run_all_sshd_tests.sh, or the run aborts with an error naming it. Use test_cases if the test runs against the shared daemon, in which case the loop over that array calls it and nothing else is needed. Use extra_test_cases if the test needs setup of its own -- a different daemon config, its own daemon, or the shared daemon stopped first -- and keep the run_test call where that setup happens. Both arrays drive --match and --exclude, so a test that is missing from them cannot be selected or skipped from the command line.

A test that can only run against a daemon the runner starts itself is skipped when --host and --port point at an external one. Pass its name to skip_local_only on that path, or add it to local_sshd_tests if it belongs in that block, so the external run still counts it as skipped.

Selecting Tests

--match <name> runs a single test and --exclude <name> drops one from a full run. Both take any name from the list the runner prints when it is given a name or an option it does not recognize, and an unrecognized name is an error rather than a silent no-op. --match runs the test where it sits in the suite, with the daemon it needs set up around it.