1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-01 11:26:52 +03:00

add client test for no-more-sessions

Signed-off-by: Ahsen Kamal <itsahsenkamal@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Ahsen Kamal
2023-03-20 11:57:13 +05:30
committed by Jakub Jelen
parent 08a6996103
commit bfa7a94b83

View File

@ -218,6 +218,39 @@ static void torture_max_sessions(void **state)
#undef MAX_CHANNELS
}
static void torture_no_more_sessions(void **state)
{
struct torture_state *s = *state;
ssh_session session = s->ssh.session;
ssh_channel channels[2];
int rc;
/* Open a channel session */
channels[0] = ssh_channel_new(session);
assert_non_null(channels[0]);
rc = ssh_channel_open_session(channels[0]);
assert_ssh_return_code(session, rc);
/* Send no-more-sessions@openssh.com global request */
rc = ssh_request_no_more_sessions(session);
assert_ssh_return_code(session, rc);
/* Try to open an extra session and expect failure */
channels[1] = ssh_channel_new(session);
assert_non_null(channels[1]);
rc = ssh_channel_open_session(channels[1]);
assert_int_equal(rc, SSH_ERROR);
/* Free the unused channel */
ssh_channel_free(channels[1]);
/* Close and free open channel */
ssh_channel_close(channels[0]);
ssh_channel_free(channels[0]);
}
static void torture_channel_delayed_close(void **state)
{
struct torture_state *s = *state;
@ -406,6 +439,9 @@ int torture_run_tests(void) {
cmocka_unit_test_setup_teardown(torture_max_sessions,
session_setup,
session_teardown),
cmocka_unit_test_setup_teardown(torture_no_more_sessions,
session_setup,
session_teardown),
cmocka_unit_test_setup_teardown(torture_channel_delayed_close,
session_setup,
session_teardown),