aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
4 daystest: test coverage for SSH_BIND_OPTIONS_IMPORT_KEY_STR and ed25519 keysHEADmasterDebanga Sarma1-0/+57
Signed-off-by: Debanga Sarma <deb737@proton.me> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
4 daysreformatDebanga Sarma1-58/+146
Signed-off-by: Debanga Sarma <deb737@proton.me> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
10 dayskex: Avoid trailing comma in cipher listJakub Jelen1-5/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
10 daysReformat rest of torture_optionsJakub Jelen1-88/+130
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
10 daysAdd support for more options in ssh_options_get()Adam Kerrison1-17/+344
Signed-off-by: Adam Kerrison <adam_kerrison@bmc.com> Squashed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-22Fix shellcheck issuesJakub Jelen4-14/+17
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-19feat: Handle hostkeys like OpenSSHGauravsingh Sisodia2-9/+41
fix: memory leak fix: add defaults after parsing fix: set defaults in ssh_bind_listen tests: add test for checking default hostkey paths remove: null check for hostkey paths, can't happen since we set defaults now examples: ssh_server remove "no default keys", default hostkeys set in ssh_bind_listen Signed-off-by: Gauravsingh Sisodia <xaerru@gmail.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-19tests: Avoid hardcoding 64b arch path to pkcs11-spyJakub Jelen3-2/+18
Find the path to the library using cmake and enable this sort of logging only with TORTURE_PKCS11 environment variable. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-08Rework the coverage buildJakub Jelen3-8/+20
This reworks it to avoid a need to special build type and adding the flags only to the targets that need it (skipping testing wrappers which break with them). It also updates the CodeCoverage module from the following URL: https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-08tests: Introduce chown wrapper to avoid OpenSSH touching PTY ownershipJakub Jelen2-1/+33
The OpenSSH as part of the new test torture_request_pty_modes attempts to chown the pty to the faked user, which is obviously not permitted when the test does not run as a root. But since all the permissions for SSH are faked, just ignoring these requests should be safe enough giving expected results. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-08tests: Print content of channels to investigate random failuresJakub Jelen1-0/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-06Issue #157: Use the current TTY's settings by default.Daniel Evers2-14/+126
When opening a PTY on the server, try to use the current TTY's settings (i.e. based on STDIN). If that fails or STDIN isn't a TTY, use default modes that avoid any character translation. Don't rely on stdin to be a TTY (breaks CI). Instead, open a PTY and temporarily use that as "fake" stdin. Signed-off-by: Daniel Evers (daniel.evers@utimaco.com) Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-06Fix #157: Allow to set terminal modes for PTYsDaniel Evers2-0/+146
Added the new function `ssh_channel_request_pty_size_modes` which allows to pass additional encoded SSH terminal modes (see opcodes in RFC 4245). Signed-off-by: Daniel Evers (daniel.evers@utimaco.com) Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-02-22cmake: use imported targets for OpenSSL and zlibGregor Jasny4-7/+2
Imported targets are highly preferred over the individual variables for includes and libs because they will be used in a coherent way and any spelling mistakes or unavailability won't go unnoticed. Also it will prevent bugs like conan-io/conan-center-index#16900 or using mismatching header/libs combinations. Signed-off-by: Gregor Jasny <gjasny@googlemail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-02-13tests:pkd: Add missing includes for cmockaAndreas Schneider2-0/+2
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-26tests: Use /tmp for tmpdirs that contain socketsClemens Lang3-3/+3
Socket paths have a length limit, and depending on the working directory of the source code, these tests occasionally fail if the path is too long. Avoid this by using a template string that is absolute and in /tmp, which should avoid the socket path length issues. This fixes building libssh with pkcs11 provider support in 'fedpkg mockbuild'. Signed-off-by: Clemens Lang <cllang@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15torture: Add cases for username checksNorbert Pocs2-0/+9
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15misc: Add function to check username syntaxNorbert Pocs1-0/+34
Malicious code can be injected using the username with metacharacters, therefore the username must be validated before using it with any %u. Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15bench_sftp.c: Change sftp aio upload benchmarkEshan Kelkar1-19/+76
Following changes have been made: 1. The benchmark now expects sftp_aio_begin_write() to return a ssize_t indicating an error (or) the number of bytes for which it sent a write request. 2. If the user sets the chunk size > max limit for writing via CLI, the benchmark does not use the set chunk size and instead uses the max limit for writing as the chunk size 3. fprintf calls have been added to print the reason for failure if the benchmark fails. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15bench_sftp.c: Change sftp aio download benchmarkEshan Kelkar1-23/+84
Following changes have been made : 1. The benchmark now expects sftp_aio_begin_read() to return an ssize_t indicating an error (or) the number of bytes for which it sent a read request. 2. If the user sets a chunk size > max limit for the reading via CLI, the benchmark does not use the set chunk size and instead uses the max limit for reading as the chunk size for download. 3. fprintf calls have been introduced to print the reason for the failure if the benchmark fails. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15torture_sftp_aio.c: Change the tests according to aio api changesEshan Kelkar1-76/+241
The tests have been changed such that the return value of sftp_aio_begin_*() functions is expected to be a ssize_t which indicates the number of bytes for which the function sent a read/write request or error. Tests for trying to read/write bytes more than the max limit enforced by the API have also been added. The negative tests for reading and writing have also been seperated for the sake of clarity. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15torture_sftp_limits.c: Change the testEshan Kelkar1-8/+88
Test has been changed such that sftp_limits() is called when the limits@openssh.com extension is supported as well as when it is not supported. Also, a simple negative test has been added for NULL argument. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-22tests: Increase test coverage for IPv6 address parsing as hostnamesJakub Jelen2-0/+65
This was an issue in cockpit: https://github.com/cockpit-project/cockpit/issues/19772 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-12-18CVE-2023-6918: tests: Code coverage for ssh_get_pubkey_hash()Jakub Jelen1-0/+35
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-12-18CVE-2023-48795: tests: Adjust calculation to strict kexJakub Jelen1-24/+31
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-12-18CVE-2023-6004: torture_misc: Add tests for ipv6 link-localNorbert Pocs1-0/+20
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-18CVE-2023-6004: torture_misc: Add test for ssh_is_ipaddrNorbert Pocs1-0/+26
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-18CVE-2023-6004: torture_proxycommand: Add test for proxycommand injectionNorbert Pocs1-0/+53
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-18CVE-2023-6004: torture_misc: Add test for ssh_check_hostname_syntaxNorbert Pocs1-1/+74
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-18CVE-2023-6004: torture_config: Allow multiple '@' in usernamesNorbert Pocs1-23/+27
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-15Test coverage for file export and for PEM and OpenSSH formatsJakub Jelen3-91/+344
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-12-15tests: Do not use assert_trueJakub Jelen1-17/+17
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-12-05tests: Move the workaround to separate functionJakub Jelen1-22/+21
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05CommentsJakub Jelen2-0/+7
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Implement more certificate testsJakub Jelen2-3/+434
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Implement more negative auth testsJakub Jelen2-0/+16
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Convert key to PEM so we can not access public key directlyJakub Jelen1-28/+30
There are several tests that depended in the past on the fact that we can not read public key from private encrypted keys. This is no longer the case for some time as the OpenSSH file format has public key in plaintext. This change just converts the same key into the PEM Format, which should still be opaque for us and trigger code paths that enforce opening of the accompanied public key file. Converted using the following command: $ ssh-keygen -m PEM -p -N secret -P secret -f tests/keys/id_rsa_protected Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Cover failed logins with password/kbdintJakub Jelen1-22/+106
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Verify the certs in default location are used for authenticationJakub Jelen1-20/+324
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Move tests with certificates to separate userJakub Jelen8-208/+446
This avoids very-long test and false positives when using some auto-pubkey authentication from picking up default keys, which are available in bob's home directory when we want to test the certificate authentication. The separate file is also needed because once we change to bob's UID, we can not simply go back different UID and this sounds cleaner than setting up SSH_DIR to different users ... Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Coverage for certificate files config and optionsJakub Jelen2-4/+37
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: Cover recent changes for importing certs to keysJakub Jelen3-1/+32
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-05tests: replace assert_trueJakub Jelen2-126/+126
Mechanical edit in vim: %s/assert_true(rc == 0)/assert_return_code(rc, errno)/g %s/assert_true(rc == SSH_OK)/assert_return_code(rc, errno)/g %s/assert_true(rc == \(-*\d*\))/assert_int_equal(rc, \1)/g %s/assert_true(rc == \(.*\))/assert_int_equal(rc, \1)/g %s/assert_true(type == \(.*\))/assert_int_equal(type, \1)/g Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2023-12-04Add benchmark code for upload using the async sftp aio apiEshan Kelkar3-0/+145
benchmarks_async_sftp_aio_up() has been added in tests/benchmarks/bench_sftp.c to obtain the performance metrics of a upload using the low level async sftp aio api. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04Add benchmark code for download using the async sftp aio apiEshan Kelkar3-2/+167
benchmarks_async_sftp_aio_down() has been added in tests/benchmarks/bench_sftp.c to obtain the performance metrics of a download using the low level async sftp aio api. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04Link benchmark code statically with libsshEshan Kelkar2-2/+16
benchmark code present in tests/benchmarks/ directory was linked with libssh dynamically due to which it could use only the functions exposed in the public API of libssh. To be able to use those functions in the benchmark code which are a part of libssh api but not a part of the public api for libssh (examples of such functions are ssh_list api functions), the benchmark code needs to be linked statically to libssh. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04Fix error reporting in connect_host()Eshan Kelkar1-2/+5
This commit fixes connect_host() such that if ssh_new() fails, connect_host() fails and provides the reason for failure. Prior to this commit if ssh_new() failed, connect_host() failed but did not provide the reason for failure to connect to the host. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04Use helper variable in connect_host()Eshan Kelkar1-9/+26
According to libssh coding conventions, function return values must not be directly passed to if- or while- conditions. This rule was not being followed in connect_host(). A helper variable has been introduced which stores the return code of the functions which is then passed to the if- conditions. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04Reformat tests/benchmarks/benchmarks.cEshan Kelkar1-291/+321
tests/benchmarks/benchmarks.c has been reformatted according to current coding style. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04Add tests for sftp aio apiEshan Kelkar2-0/+370
torture_sftp_aio.c has been added in tests/client/ directory. It contains torture_sftp_aio_read(), torture_sftp_aio_write() and torture_sftp_aio_negative(). torture_sftp_aio_read() tests sftp_aio_begin_read() and sftp_aio_wait_read() to perform async reads. torture_sftp_aio_write() tests sftp_aio_begin_write() and sftp_aio_wait_write() to perform async writes. torture_sftp_aio_negative() performs negative tests on the sftp aio read/write API. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>