aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-12-15 21:03:00 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-12-15 21:03:00 +0100
commit7f806b7c68e60cda6f312ea81dc135c05ac94a02 (patch)
tree41e8e0887c5e7f9b03d266e480bed95e3bf351c6 /tests
parenta6107f7432332c873812d558754654fac057fbd6 (diff)
downloadlibssh-7f806b7c68e60cda6f312ea81dc135c05ac94a02.tar.gz
libssh-7f806b7c68e60cda6f312ea81dc135c05ac94a02.tar.xz
libssh-7f806b7c68e60cda6f312ea81dc135c05ac94a02.zip
tests: Fix non-blocking auth tests.
The ssh_userauth_none() call should already be non-blocking. However this this function is broken in non-blocking mode. It should reveal the existing bug.
Diffstat (limited to 'tests')
-rw-r--r--tests/client/torture_auth.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c
index 3952b466..421047fc 100644
--- a/tests/client/torture_auth.c
+++ b/tests/client/torture_auth.c
@@ -88,14 +88,19 @@ static void torture_auth_autopubkey_nonblocking(void **state) {
rc = ssh_connect(session);
assert_true(rc == SSH_OK);
- rc = ssh_userauth_none(session,NULL);
+ 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_ERROR) {
assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
}
+
rc = ssh_userauth_list(session, NULL);
+ assert_true(rc & SSH_AUTH_METHOD_PUBLICKEY);
- ssh_set_blocking(session, 0);
do {
rc = ssh_userauth_publickey_auto(session, NULL, NULL);
} while (rc == SSH_AUTH_AGAIN);
@@ -174,7 +179,11 @@ static void torture_auth_kbdint_nonblocking(void **state) {
rc = ssh_connect(session);
assert_true(rc == SSH_OK);
- rc = ssh_userauth_none(session,NULL);
+ 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_ERROR) {
assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);
@@ -182,7 +191,6 @@ static void torture_auth_kbdint_nonblocking(void **state) {
rc = ssh_userauth_list(session, NULL);
assert_true(rc & SSH_AUTH_METHOD_INTERACTIVE);
- ssh_set_blocking(session,0);
do {
rc = ssh_userauth_kbdint(session, NULL, NULL);
} while (rc == SSH_AUTH_AGAIN);
@@ -266,18 +274,19 @@ static void torture_auth_password_nonblocking(void **state) {
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);
+ } 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);
}
+
rc = ssh_userauth_list(session, NULL);
assert_true(rc & SSH_AUTH_METHOD_PASSWORD);
- ssh_set_blocking(session,0);
do {
rc = ssh_userauth_password(session, NULL, password);
} while(rc==SSH_AUTH_AGAIN);
@@ -345,7 +354,6 @@ static void torture_auth_agent_nonblocking(void **state) {
rc = ssh_userauth_list(session, NULL);
assert_true(rc & SSH_AUTH_METHOD_PUBLICKEY);
- ssh_set_blocking(session, 0);
do {
rc = ssh_userauth_agent(session, NULL);
} while (rc == SSH_AUTH_AGAIN);