diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c index d3e71d9e..fa58c14a 100644 --- a/tests/client/torture_auth.c +++ b/tests/client/torture_auth.c @@ -296,9 +296,21 @@ static void torture_auth_pubkey(void **state) { rc = ssh_pki_import_privkey_file(bob_ssh_key, NULL, NULL, NULL, &privkey); assert_int_equal(rc, SSH_OK); + /* negative tests */ + rc = ssh_userauth_try_publickey(NULL, NULL, privkey); + assert_int_equal(rc, SSH_AUTH_ERROR); + rc = ssh_userauth_try_publickey(session, NULL, NULL); + assert_int_equal(rc, SSH_AUTH_ERROR); + rc = ssh_userauth_try_publickey(session, NULL, privkey); assert_int_equal(rc, SSH_AUTH_SUCCESS); + /* negative tests */ + rc = ssh_userauth_publickey(NULL, NULL, privkey); + assert_int_equal(rc, SSH_AUTH_ERROR); + rc = ssh_userauth_publickey(session, NULL, NULL); + assert_int_equal(rc, SSH_AUTH_ERROR); + rc = ssh_userauth_publickey(session, NULL, privkey); assert_int_equal(rc, SSH_AUTH_SUCCESS); diff --git a/tests/client/torture_auth_common.c b/tests/client/torture_auth_common.c index 15e407ab..8a4f2854 100644 --- a/tests/client/torture_auth_common.c +++ b/tests/client/torture_auth_common.c @@ -52,6 +52,10 @@ void torture_auth_agent(void **state) rc = ssh_userauth_list(session, NULL); assert_true(rc & SSH_AUTH_METHOD_PUBLICKEY); + /* negative test case */ + rc = ssh_userauth_agent(NULL, NULL); + assert_int_equal(rc, SSH_AUTH_ERROR); + rc = ssh_userauth_agent(session, NULL); assert_ssh_return_code(session, rc); }