From 27dea3560806b5e797207147d18a40b006d740a4 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Sun, 11 Sep 2011 11:35:34 +0200 Subject: Test: added torture_auth_autopubkey_nonblocking --- tests/client/torture_auth.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c index ceeb2f3..b716693 100644 --- a/tests/client/torture_auth.c +++ b/tests/client/torture_auth.c @@ -69,6 +69,37 @@ static void torture_auth_autopubkey(void **state) { assert_true(rc == SSH_AUTH_SUCCESS); } +static void torture_auth_autopubkey_nonblocking(void **state) { + ssh_session session = *state; + char *user = getenv("TORTURE_USER"); + int rc; + + if (user == NULL) { + print_message("*** Please set the environment variable TORTURE_USER" + " to enable this test!!\n"); + return; + } + + rc = ssh_options_set(session, SSH_OPTIONS_USER, user); + assert_true(rc == SSH_OK); + + rc = ssh_connect(session); + assert_true(rc == SSH_OK); + + rc = ssh_userauth_none(session,NULL); + /* This request should return a SSH_REQUEST_DENIED error */ + if (rc == SSH_ERROR) { + assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED); + } + assert_true(ssh_auth_list(session) & SSH_AUTH_METHOD_PUBLICKEY); + + ssh_set_blocking(session, 0); + do { + rc = ssh_userauth_autopubkey(session, NULL); + } while (rc == SSH_AUTH_AGAIN); + assert_true(rc == SSH_AUTH_SUCCESS); +} + static void torture_auth_kbdint(void **state) { ssh_session session = *state; char *user = getenv("TORTURE_USER"); @@ -258,6 +289,7 @@ int torture_run_tests(void) { unit_test_setup_teardown(torture_auth_password, setup, teardown), unit_test_setup_teardown(torture_auth_password_nonblocking, setup, teardown), unit_test_setup_teardown(torture_auth_autopubkey, setup, teardown), + unit_test_setup_teardown(torture_auth_autopubkey_nonblocking, setup, teardown), unit_test_setup_teardown(torture_auth_agent, setup, teardown), unit_test_setup_teardown(torture_auth_agent_nonblocking, setup, teardown), }; -- cgit v1.2.3