mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
tests: Add torture_proxyjump_multiple_users_sshd_jump with Doe
Tests proxyjump with two servers and two users. Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
b14cde6d2a
commit
6b9a6529bd
@@ -302,8 +302,9 @@ if (CLIENT_TESTING OR SERVER_TESTING)
|
||||
file(COPY keys/id_ed25519 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/home/bob/.ssh/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
|
||||
file(COPY keys/id_ed25519.pub DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/home/bob/.ssh/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
|
||||
|
||||
# Allow to auth with bob's public keys on alice account
|
||||
# Allow to auth with bob's public keys on alice and doe account
|
||||
configure_file(keys/id_rsa.pub ${CMAKE_CURRENT_BINARY_DIR}/home/alice/.ssh/authorized_keys @ONLY)
|
||||
configure_file(keys/id_rsa.pub ${CMAKE_CURRENT_BINARY_DIR}/home/doe/.ssh/authorized_keys @ONLY)
|
||||
|
||||
# append ECDSA public key
|
||||
file(READ keys/id_ecdsa.pub CONTENTS)
|
||||
|
||||
@@ -222,6 +222,55 @@ torture_proxyjump_multiple_sshd_jump(void **state)
|
||||
torture_teardown_sshd_server1(state);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_proxyjump_multiple_sshd_users_jump(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
char proxyjump_buf[500] = {0};
|
||||
const char *address = torture_server_address(AF_INET6);
|
||||
const char *address1 = torture_server1_address(AF_INET);
|
||||
int rc;
|
||||
socket_t fd;
|
||||
|
||||
struct ssh_jump_callbacks_struct c = {
|
||||
.before_connection = before_connection,
|
||||
.verify_knownhost = verify_knownhost,
|
||||
.authenticate = authenticate,
|
||||
};
|
||||
|
||||
torture_setup_sshd_servers(state, false);
|
||||
|
||||
rc = snprintf(proxyjump_buf,
|
||||
sizeof(proxyjump_buf),
|
||||
"doe@%s:22,alice@%s:22",
|
||||
address,
|
||||
address1);
|
||||
if (rc < 0 || rc >= (int)sizeof(proxyjump_buf)) {
|
||||
fail_msg("snprintf failed");
|
||||
}
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYJUMP, proxyjump_buf);
|
||||
assert_ssh_return_code(session, rc);
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND, &c);
|
||||
assert_ssh_return_code(session, rc);
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND, &c);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
fd = ssh_get_fd(session);
|
||||
assert_int_not_equal(fd, SSH_INVALID_SOCKET);
|
||||
|
||||
rc = fcntl(fd, F_GETFL);
|
||||
assert_int_equal(rc & O_RDWR, O_RDWR);
|
||||
|
||||
rc = ssh_userauth_publickey_auto(session, NULL, NULL);
|
||||
assert_int_equal(rc, SSH_AUTH_SUCCESS);
|
||||
|
||||
torture_teardown_sshd_server1(state);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_proxyjump_invalid_jump(void **state)
|
||||
{
|
||||
@@ -259,6 +308,10 @@ torture_run_tests(void)
|
||||
cmocka_unit_test_setup_teardown(torture_proxyjump_multiple_sshd_jump,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
torture_proxyjump_multiple_sshd_users_jump,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_proxyjump_invalid_jump,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
|
||||
Reference in New Issue
Block a user