mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-09 15:41:10 +03:00
Reformat rest of torture_options
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
@@ -91,12 +91,14 @@ static void torture_options_set_host(void **state) {
|
|||||||
assert_ssh_return_code_equal(session, rc, SSH_ERROR);
|
assert_ssh_return_code_equal(session, rc, SSH_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_ciphers(void **state) {
|
static void torture_options_set_ciphers(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Test known ciphers */
|
/* Test known ciphers */
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S,
|
rc = ssh_options_set(session,
|
||||||
|
SSH_OPTIONS_CIPHERS_C_S,
|
||||||
"aes128-ctr,aes192-ctr,aes256-ctr");
|
"aes128-ctr,aes192-ctr,aes256-ctr");
|
||||||
assert_ssh_return_code(session, rc);
|
assert_ssh_return_code(session, rc);
|
||||||
assert_non_null(session->opts.wanted_methods[SSH_CRYPT_C_S]);
|
assert_non_null(session->opts.wanted_methods[SSH_CRYPT_C_S]);
|
||||||
@@ -277,7 +279,8 @@ static void torture_options_get_key_exchange(void **state)
|
|||||||
ssh_string_free_char(value);
|
ssh_string_free_char(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_hostkey(void **state) {
|
static void torture_options_set_hostkey(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -289,10 +292,10 @@ static void torture_options_set_hostkey(void **state) {
|
|||||||
assert_non_null(session->opts.wanted_methods[SSH_HOSTKEYS]);
|
assert_non_null(session->opts.wanted_methods[SSH_HOSTKEYS]);
|
||||||
if (ssh_fips_mode()) {
|
if (ssh_fips_mode()) {
|
||||||
assert_string_equal(session->opts.wanted_methods[SSH_HOSTKEYS],
|
assert_string_equal(session->opts.wanted_methods[SSH_HOSTKEYS],
|
||||||
"ecdsa-sha2-nistp384");
|
"ecdsa-sha2-nistp384");
|
||||||
} else {
|
} else {
|
||||||
assert_string_equal(session->opts.wanted_methods[SSH_HOSTKEYS],
|
assert_string_equal(session->opts.wanted_methods[SSH_HOSTKEYS],
|
||||||
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test one unknown host key */
|
/* Test one unknown host key */
|
||||||
@@ -369,7 +372,8 @@ static void torture_options_get_hostkey(void **state)
|
|||||||
ssh_string_free_char(value);
|
ssh_string_free_char(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_pubkey_accepted_types(void **state) {
|
static void torture_options_set_pubkey_accepted_types(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
enum ssh_digest_e type;
|
enum ssh_digest_e type;
|
||||||
@@ -461,7 +465,8 @@ static void torture_options_get_pubkey_accepted_types(void **state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void torture_options_set_macs(void **state) {
|
static void torture_options_set_macs(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -474,20 +479,30 @@ static void torture_options_set_macs(void **state) {
|
|||||||
/* Test multiple known MACs */
|
/* Test multiple known MACs */
|
||||||
rc = ssh_options_set(session,
|
rc = ssh_options_set(session,
|
||||||
SSH_OPTIONS_HMAC_S_C,
|
SSH_OPTIONS_HMAC_S_C,
|
||||||
"hmac-sha1-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha1,hmac-sha2-256");
|
"hmac-sha1-etm@openssh.com,"
|
||||||
|
"hmac-sha2-256-etm@openssh.com,"
|
||||||
|
"hmac-sha1,hmac-sha2-256");
|
||||||
assert_ssh_return_code(session, rc);
|
assert_ssh_return_code(session, rc);
|
||||||
assert_non_null(session->opts.wanted_methods[SSH_MAC_S_C]);
|
assert_non_null(session->opts.wanted_methods[SSH_MAC_S_C]);
|
||||||
assert_string_equal(session->opts.wanted_methods[SSH_MAC_S_C],
|
assert_string_equal(session->opts.wanted_methods[SSH_MAC_S_C],
|
||||||
"hmac-sha1-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha1,hmac-sha2-256");
|
"hmac-sha1-etm@openssh.com,"
|
||||||
|
"hmac-sha2-256-etm@openssh.com,"
|
||||||
|
"hmac-sha1,hmac-sha2-256");
|
||||||
|
|
||||||
/* Test unknown MACs */
|
/* Test unknown MACs */
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, "unknown-crap@example.com,hmac-sha1-etm@openssh.com,unknown@example.com");
|
rc = ssh_options_set(session,
|
||||||
|
SSH_OPTIONS_HMAC_S_C,
|
||||||
|
"unknown-crap@example.com,hmac-sha1-etm@openssh.com,"
|
||||||
|
"unknown@example.com");
|
||||||
assert_ssh_return_code(session, rc);
|
assert_ssh_return_code(session, rc);
|
||||||
assert_non_null(session->opts.wanted_methods[SSH_MAC_S_C]);
|
assert_non_null(session->opts.wanted_methods[SSH_MAC_S_C]);
|
||||||
assert_string_equal(session->opts.wanted_methods[SSH_MAC_S_C], "hmac-sha1-etm@openssh.com");
|
assert_string_equal(session->opts.wanted_methods[SSH_MAC_S_C],
|
||||||
|
"hmac-sha1-etm@openssh.com");
|
||||||
|
|
||||||
/* Test all unknown MACs */
|
/* Test all unknown MACs */
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, "unknown-crap@example.com");
|
rc = ssh_options_set(session,
|
||||||
|
SSH_OPTIONS_HMAC_S_C,
|
||||||
|
"unknown-crap@example.com");
|
||||||
assert_false(rc == 0);
|
assert_false(rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,7 +655,8 @@ static void torture_options_get_host(void **state)
|
|||||||
ssh_string_free_char(host);
|
ssh_string_free_char(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_port(void **state) {
|
static void torture_options_set_port(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
unsigned int port = 42;
|
unsigned int port = 42;
|
||||||
@@ -661,32 +677,37 @@ static void torture_options_set_port(void **state) {
|
|||||||
assert_true(rc == -1);
|
assert_true(rc == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_get_port(void **state) {
|
static void torture_options_get_port(void **state)
|
||||||
ssh_session session = *state;
|
{
|
||||||
unsigned int given_port = 1234;
|
ssh_session session = *state;
|
||||||
unsigned int port_container;
|
unsigned int given_port = 1234;
|
||||||
int rc;
|
unsigned int port_container;
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_PORT, &given_port);
|
int rc;
|
||||||
assert_true(rc == 0);
|
|
||||||
rc = ssh_options_get_port(session, &port_container);
|
rc = ssh_options_set(session, SSH_OPTIONS_PORT, &given_port);
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
assert_int_equal(port_container, 1234);
|
rc = ssh_options_get_port(session, &port_container);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
assert_int_equal(port_container, 1234);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_get_user(void **state) {
|
static void torture_options_get_user(void **state)
|
||||||
ssh_session session = *state;
|
{
|
||||||
char* user = NULL;
|
ssh_session session = *state;
|
||||||
int rc;
|
char *user = NULL;
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_USER, "magicaltrevor");
|
int rc;
|
||||||
assert_int_equal(rc, SSH_OK);
|
|
||||||
rc = ssh_options_get(session, SSH_OPTIONS_USER, &user);
|
rc = ssh_options_set(session, SSH_OPTIONS_USER, "magicaltrevor");
|
||||||
assert_int_equal(rc, SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
assert_non_null(user);
|
rc = ssh_options_get(session, SSH_OPTIONS_USER, &user);
|
||||||
assert_string_equal(user, "magicaltrevor");
|
assert_int_equal(rc, SSH_OK);
|
||||||
ssh_string_free_char(user);
|
assert_non_null(user);
|
||||||
|
assert_string_equal(user, "magicaltrevor");
|
||||||
|
ssh_string_free_char(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_fd(void **state) {
|
static void torture_options_set_fd(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
socket_t fd = 42;
|
socket_t fd = 42;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -700,7 +721,8 @@ static void torture_options_set_fd(void **state) {
|
|||||||
assert_true(session->opts.fd == SSH_INVALID_SOCKET);
|
assert_true(session->opts.fd == SSH_INVALID_SOCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_user(void **state) {
|
static void torture_options_set_user(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@@ -732,29 +754,26 @@ static void torture_options_set_user(void **state) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO */
|
static void torture_options_set_identity(void **state)
|
||||||
#if 0
|
|
||||||
static voidtorture_options_set_sshdir)
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void torture_options_set_identity(void **state) {
|
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_ADD_IDENTITY, "identity1");
|
rc = ssh_options_set(session, SSH_OPTIONS_ADD_IDENTITY, "identity1");
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
assert_string_equal(session->opts.identity_non_exp->root->data, "identity1");
|
assert_string_equal(session->opts.identity_non_exp->root->data,
|
||||||
|
"identity1");
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2");
|
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2");
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
assert_string_equal(session->opts.identity_non_exp->root->data, "identity2");
|
assert_string_equal(session->opts.identity_non_exp->root->data,
|
||||||
assert_string_equal(session->opts.identity_non_exp->root->next->data, "identity1");
|
"identity2");
|
||||||
|
assert_string_equal(session->opts.identity_non_exp->root->next->data,
|
||||||
|
"identity1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_get_identity(void **state) {
|
static void torture_options_get_identity(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
char *identity = NULL;
|
char *identity = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -769,7 +788,8 @@ static void torture_options_get_identity(void **state) {
|
|||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2");
|
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2");
|
||||||
assert_int_equal(rc, SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
assert_string_equal(session->opts.identity_non_exp->root->data, "identity2");
|
assert_string_equal(session->opts.identity_non_exp->root->data,
|
||||||
|
"identity2");
|
||||||
rc = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &identity);
|
rc = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &identity);
|
||||||
assert_int_equal(rc, SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
assert_non_null(identity);
|
assert_non_null(identity);
|
||||||
@@ -874,7 +894,8 @@ static void torture_options_proxycommand(void **state) {
|
|||||||
assert_null(session->opts.ProxyCommand);
|
assert_null(session->opts.ProxyCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_control_master (void **state) {
|
static void torture_options_control_master (void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
int rc, val = SSH_CONTROL_MASTER_NO;
|
int rc, val = SSH_CONTROL_MASTER_NO;
|
||||||
|
|
||||||
@@ -919,13 +940,16 @@ static void torture_options_control_master (void **state) {
|
|||||||
assert_int_equal(rc, SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_control_path(void **state) {
|
static void torture_options_control_path(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Set Control Path */
|
/* Set Control Path */
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_CONTROL_PATH, "/tmp/ssh-%r@%h:%p");
|
rc = ssh_options_set(session,
|
||||||
|
SSH_OPTIONS_CONTROL_PATH,
|
||||||
|
"/tmp/ssh-%r@%h:%p");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
|
|
||||||
assert_string_equal(session->opts.control_path, "/tmp/ssh-%r@%h:%p");
|
assert_string_equal(session->opts.control_path, "/tmp/ssh-%r@%h:%p");
|
||||||
@@ -942,7 +966,8 @@ static void torture_options_control_path(void **state) {
|
|||||||
SSH_STRING_FREE_CHAR(str);
|
SSH_STRING_FREE_CHAR(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_config_host(void **state) {
|
static void torture_options_config_host(void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
FILE *config = NULL;
|
FILE *config = NULL;
|
||||||
|
|
||||||
@@ -1747,7 +1772,8 @@ static void torture_options_caret_sign(void **state)
|
|||||||
free(awaited);
|
free(awaited);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_apply (void **state) {
|
static void torture_options_apply (void **state)
|
||||||
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
struct ssh_list *awaited_list = NULL;
|
struct ssh_list *awaited_list = NULL;
|
||||||
struct ssh_iterator *it1 = NULL, *it2 = NULL;
|
struct ssh_iterator *it1 = NULL, *it2 = NULL;
|
||||||
@@ -2435,13 +2461,16 @@ static void torture_bind_options_set_macs(void **state)
|
|||||||
/* Test unknown MACs */
|
/* Test unknown MACs */
|
||||||
rc = ssh_bind_options_set(bind,
|
rc = ssh_bind_options_set(bind,
|
||||||
SSH_BIND_OPTIONS_HMAC_S_C,
|
SSH_BIND_OPTIONS_HMAC_S_C,
|
||||||
"unknown-crap@example.com,hmac-sha1,unknown@example.com");
|
"unknown-crap@example.com,"
|
||||||
|
"hmac-sha1,unknown@example.com");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->wanted_methods[SSH_MAC_S_C]);
|
assert_non_null(bind->wanted_methods[SSH_MAC_S_C]);
|
||||||
assert_string_equal(bind->wanted_methods[SSH_MAC_S_C], "hmac-sha1");
|
assert_string_equal(bind->wanted_methods[SSH_MAC_S_C], "hmac-sha1");
|
||||||
|
|
||||||
/* Test all unknown MACs */
|
/* Test all unknown MACs */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_S_C, "unknown-crap@example.com");
|
rc = ssh_bind_options_set(bind,
|
||||||
|
SSH_BIND_OPTIONS_HMAC_S_C,
|
||||||
|
"unknown-crap@example.com");
|
||||||
assert_int_not_equal(rc, 0);
|
assert_int_not_equal(rc, 0);
|
||||||
|
|
||||||
/* Test known MACs */
|
/* Test known MACs */
|
||||||
@@ -2462,13 +2491,16 @@ static void torture_bind_options_set_macs(void **state)
|
|||||||
/* Test unknown MACs */
|
/* Test unknown MACs */
|
||||||
rc = ssh_bind_options_set(bind,
|
rc = ssh_bind_options_set(bind,
|
||||||
SSH_BIND_OPTIONS_HMAC_C_S,
|
SSH_BIND_OPTIONS_HMAC_C_S,
|
||||||
"unknown-crap@example.com,hmac-sha1,unknown@example.com");
|
"unknown-crap@example.com,"
|
||||||
|
"hmac-sha1,unknown@example.com");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->wanted_methods[SSH_MAC_C_S]);
|
assert_non_null(bind->wanted_methods[SSH_MAC_C_S]);
|
||||||
assert_string_equal(bind->wanted_methods[SSH_MAC_C_S], "hmac-sha1");
|
assert_string_equal(bind->wanted_methods[SSH_MAC_C_S], "hmac-sha1");
|
||||||
|
|
||||||
/* Test all unknown MACs */
|
/* Test all unknown MACs */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_C_S, "unknown-crap@example.com");
|
rc = ssh_bind_options_set(bind,
|
||||||
|
SSH_BIND_OPTIONS_HMAC_C_S,
|
||||||
|
"unknown-crap@example.com");
|
||||||
assert_int_not_equal(rc, 0);
|
assert_int_not_equal(rc, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2495,7 +2527,8 @@ static void torture_bind_options_parse_config(void **state)
|
|||||||
assert_non_null(bind->config_dir);
|
assert_non_null(bind->config_dir);
|
||||||
assert_string_equal(bind->config_dir, cwd);
|
assert_string_equal(bind->config_dir, cwd);
|
||||||
|
|
||||||
rc = ssh_bind_options_parse_config(bind, "%d/"LIBSSH_CUSTOM_BIND_CONFIG_FILE);
|
rc = ssh_bind_options_parse_config(bind,
|
||||||
|
"%d/" LIBSSH_CUSTOM_BIND_CONFIG_FILE);
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_int_equal(bind->bindport, 42);
|
assert_int_equal(bind->bindport, 42);
|
||||||
|
|
||||||
@@ -2544,8 +2577,9 @@ static void torture_bind_options_set_pubkey_accepted_key_types(void **state)
|
|||||||
bind = test_state->bind;
|
bind = test_state->bind;
|
||||||
|
|
||||||
/* Test known Pubkey Types */
|
/* Test known Pubkey Types */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
rc = ssh_bind_options_set(bind,
|
||||||
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
||||||
|
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->pubkey_accepted_key_types);
|
assert_non_null(bind->pubkey_accepted_key_types);
|
||||||
if (ssh_fips_mode()) {
|
if (ssh_fips_mode()) {
|
||||||
@@ -2559,8 +2593,9 @@ static void torture_bind_options_set_pubkey_accepted_key_types(void **state)
|
|||||||
SAFE_FREE(bind->pubkey_accepted_key_types);
|
SAFE_FREE(bind->pubkey_accepted_key_types);
|
||||||
|
|
||||||
/* Test with some unknown type */
|
/* Test with some unknown type */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
rc = ssh_bind_options_set(bind,
|
||||||
"ecdsa-sha2-nistp384,unknown-type,rsa-sha2-256");
|
SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
||||||
|
"ecdsa-sha2-nistp384,unknown-type,rsa-sha2-256");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->pubkey_accepted_key_types);
|
assert_non_null(bind->pubkey_accepted_key_types);
|
||||||
assert_string_equal(bind->pubkey_accepted_key_types,
|
assert_string_equal(bind->pubkey_accepted_key_types,
|
||||||
@@ -2569,26 +2604,27 @@ static void torture_bind_options_set_pubkey_accepted_key_types(void **state)
|
|||||||
SAFE_FREE(bind->pubkey_accepted_key_types);
|
SAFE_FREE(bind->pubkey_accepted_key_types);
|
||||||
|
|
||||||
/* Test with only unknown type */
|
/* Test with only unknown type */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
rc = ssh_bind_options_set(bind,
|
||||||
"unknown-type");
|
SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
||||||
|
"unknown-type");
|
||||||
assert_int_equal(rc, -1);
|
assert_int_equal(rc, -1);
|
||||||
assert_null(bind->pubkey_accepted_key_types);
|
assert_null(bind->pubkey_accepted_key_types);
|
||||||
|
|
||||||
/* Test with something set and then try unknown type */
|
/* Test with something set and then try unknown type */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
rc = ssh_bind_options_set(bind,
|
||||||
"ecdsa-sha2-nistp384");
|
SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
||||||
|
"ecdsa-sha2-nistp384");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->pubkey_accepted_key_types);
|
assert_non_null(bind->pubkey_accepted_key_types);
|
||||||
assert_string_equal(bind->pubkey_accepted_key_types,
|
assert_string_equal(bind->pubkey_accepted_key_types, "ecdsa-sha2-nistp384");
|
||||||
"ecdsa-sha2-nistp384");
|
rc = ssh_bind_options_set(bind,
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
||||||
"unknown-type");
|
"unknown-type");
|
||||||
assert_int_equal(rc, -1);
|
assert_int_equal(rc, -1);
|
||||||
|
|
||||||
/* Check that nothing changed */
|
/* Check that nothing changed */
|
||||||
assert_non_null(bind->pubkey_accepted_key_types);
|
assert_non_null(bind->pubkey_accepted_key_types);
|
||||||
assert_string_equal(bind->pubkey_accepted_key_types,
|
assert_string_equal(bind->pubkey_accepted_key_types, "ecdsa-sha2-nistp384");
|
||||||
"ecdsa-sha2-nistp384");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_bind_options_set_hostkey_algorithms(void **state)
|
static void torture_bind_options_set_hostkey_algorithms(void **state)
|
||||||
@@ -2604,57 +2640,63 @@ static void torture_bind_options_set_hostkey_algorithms(void **state)
|
|||||||
bind = test_state->bind;
|
bind = test_state->bind;
|
||||||
|
|
||||||
/* Test known Pubkey Types */
|
/* Test known Pubkey Types */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
rc = ssh_bind_options_set(bind,
|
||||||
|
SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
||||||
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
||||||
if (ssh_fips_mode()) {
|
if (ssh_fips_mode()) {
|
||||||
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
||||||
"ecdsa-sha2-nistp384");
|
"ecdsa-sha2-nistp384");
|
||||||
} else {
|
} else {
|
||||||
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
||||||
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
"ssh-ed25519,ecdsa-sha2-nistp384,ssh-rsa");
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_FREE(bind->wanted_methods[SSH_HOSTKEYS]);
|
SAFE_FREE(bind->wanted_methods[SSH_HOSTKEYS]);
|
||||||
|
|
||||||
/* Test with some unknown type */
|
/* Test with some unknown type */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
rc = ssh_bind_options_set(bind,
|
||||||
"ecdsa-sha2-nistp384,unknown-type");
|
SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
||||||
|
"ecdsa-sha2-nistp384,unknown-type");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
||||||
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
||||||
"ecdsa-sha2-nistp384");
|
"ecdsa-sha2-nistp384");
|
||||||
|
|
||||||
SAFE_FREE(bind->wanted_methods[SSH_HOSTKEYS]);
|
SAFE_FREE(bind->wanted_methods[SSH_HOSTKEYS]);
|
||||||
|
|
||||||
/* Test with only unknown type */
|
/* Test with only unknown type */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
rc = ssh_bind_options_set(bind,
|
||||||
"unknown-type");
|
SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
||||||
|
"unknown-type");
|
||||||
assert_int_equal(rc, -1);
|
assert_int_equal(rc, -1);
|
||||||
assert_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
assert_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
||||||
|
|
||||||
/* Test with something set and then try unknown type */
|
/* Test with something set and then try unknown type */
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
rc = ssh_bind_options_set(bind,
|
||||||
"ecdsa-sha2-nistp384");
|
SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
||||||
|
"ecdsa-sha2-nistp384");
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
||||||
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
||||||
"ecdsa-sha2-nistp384");
|
"ecdsa-sha2-nistp384");
|
||||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
rc = ssh_bind_options_set(bind,
|
||||||
"unknown-type");
|
SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
||||||
|
"unknown-type");
|
||||||
assert_int_equal(rc, -1);
|
assert_int_equal(rc, -1);
|
||||||
|
|
||||||
/* Check that nothing changed */
|
/* Check that nothing changed */
|
||||||
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
assert_non_null(bind->wanted_methods[SSH_HOSTKEYS]);
|
||||||
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
assert_string_equal(bind->wanted_methods[SSH_HOSTKEYS],
|
||||||
"ecdsa-sha2-nistp384");
|
"ecdsa-sha2-nistp384");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
|
|
||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void)
|
||||||
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct CMUnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_host, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_host, setup, teardown),
|
||||||
|
|||||||
Reference in New Issue
Block a user