aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2014-01-06 16:48:58 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2014-01-06 16:52:35 +0100
commit8f1a350b6e3087baf93c6d42b90d6a6caadd7483 (patch)
tree72e3b6127a13d554f1fb5d7099eab806a475e64c
parent15ed51cf2003f93c29dbb395a62685968311f1c0 (diff)
downloadlibssh-8f1a350b6e3087baf93c6d42b90d6a6caadd7483.tar.gz
libssh-8f1a350b6e3087baf93c6d42b90d6a6caadd7483.tar.xz
libssh-8f1a350b6e3087baf93c6d42b90d6a6caadd7483.zip
test: test case for async auth_none
This test currently fails
-rw-r--r--tests/client/torture_auth.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c
index d8c74515..92c84273 100644
--- a/tests/client/torture_auth.c
+++ b/tests/client/torture_auth.c
@@ -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();