aboutsummaryrefslogtreecommitdiff
path: root/tests/client
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2011-01-16 21:57:11 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2011-01-16 23:42:19 +0100
commit6b52aaff1c7128f4221632e0eb7fc1fd6a916b7c (patch)
tree53a231553784bc96180c3ac3eacebdca6ae74172 /tests/client
parent227764a8033c773397bc997239bfad1f85ef40a5 (diff)
downloadlibssh-6b52aaff1c7128f4221632e0eb7fc1fd6a916b7c.tar.gz
libssh-6b52aaff1c7128f4221632e0eb7fc1fd6a916b7c.tar.xz
libssh-6b52aaff1c7128f4221632e0eb7fc1fd6a916b7c.zip
ssh_auth_password made nonblocking
Diffstat (limited to 'tests/client')
-rw-r--r--tests/client/torture_auth.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c
index adcf708..3637a6a 100644
--- a/tests/client/torture_auth.c
+++ b/tests/client/torture_auth.c
@@ -142,7 +142,7 @@ static void torture_auth_password(void **state) {
rc = ssh_userauth_none(session, NULL);
/* This request should return a SSH_REQUEST_DENIED error */
- if (rc == SSH_ERROR) {
+ if (rc == SSH_AUTH_ERROR) {
assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
}
assert_true(ssh_auth_list(session) & SSH_AUTH_METHOD_PASSWORD);
@@ -151,11 +151,55 @@ static void torture_auth_password(void **state) {
assert_true(rc == SSH_AUTH_SUCCESS);
}
+static void torture_auth_password_nonblocking(void **state) {
+ ssh_session session = *state;
+ char *user = getenv("TORTURE_USER");
+ char *password = getenv("TORTURE_PASSWORD");
+ int rc;
+
+ if (user == NULL) {
+ print_message("*** Please set the environment variable TORTURE_USER"
+ " to enable this test!!\n");
+ return;
+ }
+
+ if (password == NULL) {
+ print_message("*** Please set the environment variable "
+ "TORTURE_PASSWORD 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);
+ ssh_set_blocking(session,0);
+
+ do {
+ rc = ssh_userauth_none(session, NULL);
+ } while (rc==SSH_AUTH_AGAIN);
+
+ /* This request should return a SSH_REQUEST_DENIED error */
+ if (rc == SSH_AUTH_ERROR) {
+ assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
+ }
+ assert_true(ssh_auth_list(session) & SSH_AUTH_METHOD_PASSWORD);
+
+ do {
+ rc = ssh_userauth_password(session, NULL, password);
+ } while(rc==SSH_AUTH_AGAIN);
+
+ assert_true(rc == SSH_AUTH_SUCCESS);
+}
+
+
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {
unit_test_setup_teardown(torture_auth_kbdint, setup, teardown),
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),
};