mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-29 13:01:13 +03:00
test: test case for async auth_none
This test currently fails
This commit is contained in:
@ -362,6 +362,63 @@ static void torture_auth_agent_nonblocking(void **state) {
|
||||
assert_true(rc == SSH_AUTH_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static void torture_auth_none(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);
|
||||
|
||||
assert_true(rc == SSH_ERROR);
|
||||
/* This request should return a SSH_REQUEST_DENIED error */
|
||||
if (rc == SSH_ERROR) {
|
||||
assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
|
||||
}
|
||||
}
|
||||
|
||||
static void torture_auth_none_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);
|
||||
|
||||
/* This request should return a SSH_REQUEST_DENIED error */
|
||||
if (rc == SSH_ERROR) {
|
||||
assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
|
||||
}
|
||||
|
||||
ssh_set_blocking(session,0);
|
||||
|
||||
do {
|
||||
rc = ssh_userauth_none(session,NULL);
|
||||
} while (rc == SSH_AUTH_AGAIN);
|
||||
assert_true(rc == SSH_AUTH_ERROR);
|
||||
assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
|
||||
|
||||
}
|
||||
|
||||
int torture_run_tests(void) {
|
||||
int rc;
|
||||
const UnitTest tests[] = {
|
||||
@ -373,6 +430,8 @@ int torture_run_tests(void) {
|
||||
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),
|
||||
unit_test_setup_teardown(torture_auth_none, setup, teardown),
|
||||
unit_test_setup_teardown(torture_auth_none_nonblocking, setup, teardown),
|
||||
};
|
||||
|
||||
ssh_init();
|
||||
|
Reference in New Issue
Block a user