aboutsummaryrefslogtreecommitdiff
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:04:46 +0100
commit3ba2e7ace7005203aaf1aa98234a6fcf325aeb34 (patch)
tree3cf6b43105e34825a8006560a770cb864d0b2e7b
parent15c64b2981df33e9d25cbbfe802eb1e61ddc0f71 (diff)
downloadlibssh-3ba2e7ace7005203aaf1aa98234a6fcf325aeb34.tar.gz
libssh-3ba2e7ace7005203aaf1aa98234a6fcf325aeb34.tar.xz
libssh-3ba2e7ace7005203aaf1aa98234a6fcf325aeb34.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.
-rw-r--r--tests/client/torture_auth.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c
index cf6da896..9e3d46f2 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);
@@ -267,14 +275,16 @@ static void torture_auth_password_nonblocking(void **state) {
assert_true(rc == SSH_OK);
ssh_set_blocking(session,0);
+ 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);
@@ -345,7 +355,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);