From 87d694d5ad5582cfe01cfcfec6f5173a8f8cef21 Mon Sep 17 00:00:00 2001 From: Norbert Pocs Date: Wed, 16 Nov 2022 11:03:30 +0100 Subject: [PATCH] tests: Use opts.identites_non_exp not opts.identities The configuration of identities are first saved to `opts.identities_non_exp`, then moved to `opts.identities` after calling ssh_options_apply and expanding the identity strings. These tests are testing against the proper configuration Signed-off-by: Norbert Pocs Reviewed-by: Jakub Jelen --- tests/client/torture_auth.c | 4 ++-- tests/client/torture_auth_pkcs11.c | 2 +- tests/unittests/torture_config.c | 3 ++- tests/unittests/torture_options.c | 14 +++++++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c index 88680a2b..a829126a 100644 --- a/tests/client/torture_auth.c +++ b/tests/client/torture_auth.c @@ -715,7 +715,7 @@ static void torture_auth_agent_identities_only(void **state) assert_int_equal(rc, SSH_OK); /* Remove the default identities */ - while ((id = ssh_list_pop_head(char *, session->opts.identity)) != NULL) { + while ((id = ssh_list_pop_head(char *, session->opts.identity_non_exp)) != NULL) { SAFE_FREE(id); } @@ -772,7 +772,7 @@ static void torture_auth_agent_identities_only_protected(void **state) assert_int_equal(rc, SSH_OK); /* Remove the default identities */ - while ((id = ssh_list_pop_head(char *, session->opts.identity)) != NULL) { + while ((id = ssh_list_pop_head(char *, session->opts.identity_non_exp)) != NULL) { SAFE_FREE(id); } diff --git a/tests/client/torture_auth_pkcs11.c b/tests/client/torture_auth_pkcs11.c index ee97bff4..e75fea0e 100644 --- a/tests/client/torture_auth_pkcs11.c +++ b/tests/client/torture_auth_pkcs11.c @@ -196,7 +196,7 @@ static void torture_auth_autopubkey(void **state, const char *obj_name, const ch rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, priv_uri); assert_int_equal(rc, SSH_OK); - assert_string_equal(session->opts.identity->root->data, priv_uri); + assert_string_equal(session->opts.identity_non_exp->root->data, priv_uri); rc = ssh_connect(session); assert_int_equal(rc, SSH_OK); diff --git a/tests/unittests/torture_config.c b/tests/unittests/torture_config.c index cbde56a4..ee7f17c3 100644 --- a/tests/unittests/torture_config.c +++ b/tests/unittests/torture_config.c @@ -2078,7 +2078,8 @@ static void torture_config_identity(void **state) _parse_config(session, NULL, LIBSSH_TESTCONFIG_STRING13, SSH_OK); - it = ssh_list_get_iterator(session->opts.identity); + /* The identities are first added to this temporary list before expanding */ + it = ssh_list_get_iterator(session->opts.identity_non_exp); assert_non_null(it); id = it->data; /* The identities are prepended to the list so we start with second one */ diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c index e40c5e26..7208ebf9 100644 --- a/tests/unittests/torture_options.c +++ b/tests/unittests/torture_options.c @@ -406,12 +406,12 @@ static void torture_options_set_identity(void **state) { rc = ssh_options_set(session, SSH_OPTIONS_ADD_IDENTITY, "identity1"); assert_true(rc == 0); - assert_string_equal(session->opts.identity->root->data, "identity1"); + assert_string_equal(session->opts.identity_non_exp->root->data, "identity1"); rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2"); assert_true(rc == 0); - assert_string_equal(session->opts.identity->root->data, "identity2"); - assert_string_equal(session->opts.identity->root->next->data, "identity1"); + assert_string_equal(session->opts.identity_non_exp->root->data, "identity2"); + assert_string_equal(session->opts.identity_non_exp->root->next->data, "identity1"); } static void torture_options_get_identity(void **state) { @@ -429,7 +429,7 @@ static void torture_options_get_identity(void **state) { rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2"); assert_int_equal(rc, SSH_OK); - assert_string_equal(session->opts.identity->root->data, "identity2"); + assert_string_equal(session->opts.identity_non_exp->root->data, "identity2"); rc = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &identity); assert_int_equal(rc, SSH_OK); assert_non_null(identity); @@ -867,9 +867,9 @@ static void torture_options_copy(void **state) assert_non_null(new); /* Check the identities match */ - it = ssh_list_get_iterator(session->opts.identity); + it = ssh_list_get_iterator(session->opts.identity_non_exp); assert_non_null(it); - it2 = ssh_list_get_iterator(new->opts.identity); + it2 = ssh_list_get_iterator(new->opts.identity_non_exp); assert_non_null(it2); while (it != NULL && it2 != NULL) { assert_string_equal(it->data, it2->data); @@ -956,7 +956,7 @@ static void torture_options_getopt(void **state) "aes128-ctr"); assert_string_equal(session->opts.wanted_methods[SSH_CRYPT_S_C], "aes128-ctr"); - assert_string_equal(session->opts.identity->root->data, "id_rsa"); + assert_string_equal(session->opts.identity_non_exp->root->data, "id_rsa"); #ifdef WITH_ZLIB assert_string_equal(session->opts.wanted_methods[SSH_COMP_C_S], "zlib@openssh.com,zlib,none");