mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 03:50:10 +01:00
libnm/tests: convert test cases to use g_assert() instead of ASSERT() (test-secrets.c)
This commit is contained in:
parent
29aa13dc84
commit
fde5f7bfab
2 changed files with 69 additions and 237 deletions
|
|
@ -37,6 +37,7 @@
|
|||
#include "nm-setting-wireless.h"
|
||||
#include "nm-simple-connection.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-test-utils.h"
|
||||
|
||||
|
|
@ -44,16 +45,20 @@
|
|||
#define TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT TEST_CERT_DIR "/test_key_and_cert.pem"
|
||||
#define TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY TEST_CERT_DIR "/test_key_and_cert.pem"
|
||||
|
||||
static gboolean
|
||||
find_hints_item (GPtrArray *hints, const char *item)
|
||||
static void
|
||||
_assert_hints_has (GPtrArray *hints, const char *item)
|
||||
{
|
||||
int i;
|
||||
guint i;
|
||||
guint found = 0;
|
||||
|
||||
g_assert (hints);
|
||||
g_assert (item);
|
||||
for (i = 0; i < hints->len; i++) {
|
||||
if (!strcmp (item, (const char *) g_ptr_array_index (hints, i)))
|
||||
return TRUE;
|
||||
g_assert (hints->pdata[i]);
|
||||
if (strcmp (hints->pdata[i], item) == 0)
|
||||
found++;
|
||||
}
|
||||
return FALSE;
|
||||
g_assert_cmpint (found, ==, 1);
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
|
|
@ -100,18 +105,14 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set CA certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CA_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_client_cert (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
|
||||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set client certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_private_key (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
|
||||
|
|
@ -119,9 +120,7 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set private key '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
/* IP4 setting */
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
|
|
@ -129,9 +128,7 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
|
||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||
|
||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
||||
detail, "failed to verify connection: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
nmtst_assert_connection_verifies_and_normalizable (connection);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
|
@ -144,37 +141,19 @@ test_need_tls_secrets_path (void)
|
|||
GPtrArray *hints = NULL;
|
||||
|
||||
connection = make_tls_connection ("need-tls-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-secrets-path-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-secrets-path-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-secrets-path-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Connection is good; clear secrets and ensure private key password is then required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-secrets-path-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-secrets-path-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-secrets-path-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-secrets-path-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
@ -188,37 +167,19 @@ test_need_tls_secrets_blob (void)
|
|||
GPtrArray *hints = NULL;
|
||||
|
||||
connection = make_tls_connection ("need-tls-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-secrets-blob-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-secrets-blob-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-secrets-blob-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Clear secrets and ensure password is again required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
@ -270,18 +231,14 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set phase2 CA certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CA_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_phase2_client_cert (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
|
||||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set phase2 client certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
|
||||
|
|
@ -289,9 +246,7 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set phase2 private key '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
/* IP4 setting */
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
|
|
@ -299,10 +254,7 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
|
||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||
|
||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
||||
detail, "failed to verify connection: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
|
||||
nmtst_assert_connection_verifies_and_normalizable (connection);
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
|
@ -315,37 +267,19 @@ test_need_tls_phase2_secrets_path (void)
|
|||
|
||||
connection = make_tls_phase2_connection ("need-tls-phase2-secrets-path-key",
|
||||
NM_SETTING_802_1X_CK_SCHEME_PATH);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-phase2-secrets-path-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-phase2-secrets-path-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-phase2-secrets-path-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Connection is good; clear secrets and ensure private key password is then required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
@ -360,37 +294,19 @@ test_need_tls_phase2_secrets_blob (void)
|
|||
|
||||
connection = make_tls_phase2_connection ("need-tls-phase2-secrets-blob-key",
|
||||
NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-phase2-secrets-blob-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-phase2-secrets-blob-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-phase2-secrets-blob-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Connection is good; clear secrets and ensure private key password is then required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
|
|||
|
|
@ -44,16 +44,20 @@
|
|||
#define TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT TEST_CERT_DIR "/test_key_and_cert.pem"
|
||||
#define TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY TEST_CERT_DIR "/test_key_and_cert.pem"
|
||||
|
||||
static gboolean
|
||||
find_hints_item (GPtrArray *hints, const char *item)
|
||||
static void
|
||||
_assert_hints_has (GPtrArray *hints, const char *item)
|
||||
{
|
||||
int i;
|
||||
guint i;
|
||||
guint found = 0;
|
||||
|
||||
g_assert (hints);
|
||||
g_assert (item);
|
||||
for (i = 0; i < hints->len; i++) {
|
||||
if (!strcmp (item, (const char *) g_ptr_array_index (hints, i)))
|
||||
return TRUE;
|
||||
g_assert (hints->pdata[i]);
|
||||
if (!strcmp (item, hints->pdata[i]))
|
||||
found++;
|
||||
}
|
||||
return FALSE;
|
||||
g_assert_cmpint (found, ==, 1);
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
|
|
@ -100,18 +104,14 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set CA certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CA_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_client_cert (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
|
||||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set client certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_private_key (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
|
||||
|
|
@ -119,9 +119,7 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set private key '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
/* IP4 setting */
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
|
|
@ -129,9 +127,7 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
|
||||
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||
|
||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
||||
detail, "failed to verify connection: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
nmtst_assert_connection_verifies_and_normalizable (connection);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
|
@ -144,37 +140,19 @@ test_need_tls_secrets_path (void)
|
|||
GPtrArray *hints = NULL;
|
||||
|
||||
connection = make_tls_connection ("need-tls-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-secrets-path-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-secrets-path-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-secrets-path-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Connection is good; clear secrets and ensure private key password is then required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-secrets-path-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-secrets-path-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-secrets-path-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-secrets-path-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
@ -188,37 +166,19 @@ test_need_tls_secrets_blob (void)
|
|||
GPtrArray *hints = NULL;
|
||||
|
||||
connection = make_tls_connection ("need-tls-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-secrets-blob-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-secrets-blob-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-secrets-blob-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Clear secrets and ensure password is again required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-secrets-blob-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
@ -270,18 +230,14 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set phase2 CA certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CA_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_phase2_client_cert (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
|
||||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set phase2 client certificate '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
success = nm_setting_802_1x_set_phase2_private_key (s_8021x,
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
|
||||
|
|
@ -289,9 +245,7 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
scheme,
|
||||
NULL,
|
||||
&error);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to set phase2 private key '%s': %s",
|
||||
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY, error->message);
|
||||
nmtst_assert_success (success, error);
|
||||
|
||||
/* IP4 setting */
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
|
|
@ -299,9 +253,7 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
|
|||
|
||||
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
||||
|
||||
ASSERT (nm_connection_verify (connection, &error) == TRUE,
|
||||
detail, "failed to verify connection: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
nmtst_assert_connection_verifies_and_normalizable (connection);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
|
@ -315,37 +267,19 @@ test_need_tls_phase2_secrets_path (void)
|
|||
|
||||
connection = make_tls_phase2_connection ("need-tls-phase2-secrets-path-key",
|
||||
NM_SETTING_802_1X_CK_SCHEME_PATH);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-phase2-secrets-path-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-phase2-secrets-path-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-phase2-secrets-path-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Connection is good; clear secrets and ensure private key password is then required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-phase2-secrets-path-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
@ -360,37 +294,19 @@ test_need_tls_phase2_secrets_blob (void)
|
|||
|
||||
connection = make_tls_phase2_connection ("need-tls-phase2-secrets-blob-key",
|
||||
NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
||||
ASSERT (connection != NULL,
|
||||
"need-tls-phase2-secrets-blob-key",
|
||||
"error creating test connection");
|
||||
|
||||
/* Ensure we don't need any secrets since we just set up the connection */
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name == NULL,
|
||||
"need-tls-phase2-secrets-blob-key",
|
||||
"secrets are unexpectedly required");
|
||||
ASSERT (hints == NULL,
|
||||
"need-tls-phase2-secrets-blob-key",
|
||||
"hints should be NULL since no secrets were required");
|
||||
g_assert (!setting_name);
|
||||
g_assert (!hints);
|
||||
|
||||
/* Connection is good; clear secrets and ensure private key password is then required */
|
||||
nm_connection_clear_secrets (connection);
|
||||
|
||||
hints = NULL;
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
ASSERT (setting_name != NULL,
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"unexpected secrets success");
|
||||
ASSERT (strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME) == 0,
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"unexpected setting secrets required");
|
||||
|
||||
ASSERT (hints != NULL,
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"expected returned secrets hints");
|
||||
ASSERT (find_hints_item (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD),
|
||||
"need-tls-phase2-secrets-blob-key-password",
|
||||
"expected to require private key password, but it wasn't");
|
||||
g_assert_cmpstr (setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
||||
_assert_hints_has (hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
|
||||
|
||||
g_ptr_array_free (hints, TRUE);
|
||||
g_object_unref (connection);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue