|
Packit Service |
87a54e |
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-default.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-setting-8021x.h"
|
|
Packit |
5756e2 |
#include "nm-setting-cdma.h"
|
|
Packit |
5756e2 |
#include "nm-setting-connection.h"
|
|
Packit |
5756e2 |
#include "nm-setting-gsm.h"
|
|
Packit |
5756e2 |
#include "nm-setting-ip4-config.h"
|
|
Packit |
5756e2 |
#include "nm-setting-ppp.h"
|
|
Packit |
5756e2 |
#include "nm-setting-pppoe.h"
|
|
Packit |
5756e2 |
#include "nm-setting-vpn.h"
|
|
Packit |
5756e2 |
#include "nm-setting-wired.h"
|
|
Packit |
5756e2 |
#include "nm-setting-wireless-security.h"
|
|
Packit |
5756e2 |
#include "nm-setting-wireless.h"
|
|
Packit |
5756e2 |
#include "nm-simple-connection.h"
|
|
Packit |
5756e2 |
#include "nm-utils.h"
|
|
Packit |
5756e2 |
#include "nm-core-internal.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-utils/nm-test-utils.h"
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define TEST_CERT_DIR NM_BUILD_SRCDIR "/libnm-core/tests/certs"
|
|
Packit |
5756e2 |
#define TEST_NEED_SECRETS_EAP_TLS_CA_CERT TEST_CERT_DIR "/test_ca_cert.pem"
|
|
Packit |
5756e2 |
#define TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT TEST_CERT_DIR "/test_key_and_cert.pem"
|
|
Packit |
5756e2 |
#define TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY TEST_CERT_DIR "/test_key_and_cert.pem"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
_assert_hints_has(GPtrArray *hints, const char *item)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
guint i;
|
|
Packit Service |
a1bd4f |
guint found = 0;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(hints);
|
|
Packit Service |
a1bd4f |
g_assert(item);
|
|
Packit Service |
a1bd4f |
for (i = 0; i < hints->len; i++) {
|
|
Packit Service |
a1bd4f |
g_assert(hints->pdata[i]);
|
|
Packit Service |
a1bd4f |
if (strcmp(hints->pdata[i], item) == 0)
|
|
Packit Service |
a1bd4f |
found++;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(found, ==, 1);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMConnection *
|
|
Packit Service |
a1bd4f |
make_tls_connection(const char *detail, NMSetting8021xCKScheme scheme)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection * connection;
|
|
Packit Service |
a1bd4f |
NMSettingConnection *s_con;
|
|
Packit Service |
a1bd4f |
NMSetting8021x * s_8021x;
|
|
Packit Service |
a1bd4f |
NMSettingWired * s_wired;
|
|
Packit Service |
a1bd4f |
NMSettingIP4Config * s_ip4;
|
|
Packit Service |
a1bd4f |
char * uuid;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = nm_simple_connection_new();
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Connection setting */
|
|
Packit Service |
a1bd4f |
s_con = (NMSettingConnection *) nm_setting_connection_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_con));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
uuid = nm_utils_uuid_generate();
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"Test Need TLS Secrets",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
uuid,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_AUTOCONNECT,
|
|
Packit Service |
a1bd4f |
TRUE,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
g_free(uuid);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wired setting */
|
|
Packit Service |
a1bd4f |
s_wired = (NMSettingWired *) nm_setting_wired_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_wired));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wireless security setting */
|
|
Packit Service |
a1bd4f |
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_8021x));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_setting_802_1x_add_eap_method(s_8021x, "tls");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_802_1x_set_ca_cert(s_8021x,
|
|
Packit Service |
a1bd4f |
TEST_NEED_SECRETS_EAP_TLS_CA_CERT,
|
|
Packit Service |
a1bd4f |
scheme,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_802_1x_set_client_cert(s_8021x,
|
|
Packit Service |
a1bd4f |
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
|
|
Packit Service |
a1bd4f |
scheme,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_802_1x_set_private_key(s_8021x,
|
|
Packit Service |
a1bd4f |
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
|
|
Packit Service |
a1bd4f |
"test",
|
|
Packit Service |
a1bd4f |
scheme,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_set_secret_flags(NM_SETTING(s_8021x),
|
|
Packit Service |
a1bd4f |
NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD,
|
|
Packit Service |
a1bd4f |
NM_SETTING_SECRET_FLAG_AGENT_OWNED,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* IP4 setting */
|
|
Packit Service |
a1bd4f |
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_ip4));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_and_normalizable(connection);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return connection;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_need_tls_secrets_path(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
const char * setting_name;
|
|
Packit Service |
a1bd4f |
GPtrArray * hints = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
connection = make_tls_connection("need-tls-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Ensure we don't need any secrets since we just set up the connection */
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert(!setting_name);
|
|
Packit Service |
a1bd4f |
g_assert(!hints);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Connection is good; clear secrets and ensure private key password is then required */
|
|
Packit Service |
a1bd4f |
nm_connection_clear_secrets(connection);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
hints = NULL;
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
|
Packit Service |
a1bd4f |
_assert_hints_has(hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_ptr_array_free(hints, TRUE);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_need_tls_secrets_blob(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
const char * setting_name;
|
|
Packit Service |
a1bd4f |
GPtrArray * hints = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
connection = make_tls_connection("need-tls-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Ensure we don't need any secrets since we just set up the connection */
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert(!setting_name);
|
|
Packit Service |
a1bd4f |
g_assert(!hints);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Clear secrets and ensure password is again required */
|
|
Packit Service |
a1bd4f |
nm_connection_clear_secrets(connection);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
hints = NULL;
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
|
Packit Service |
a1bd4f |
_assert_hints_has(hints, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_ptr_array_free(hints, TRUE);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMConnection *
|
|
Packit Service |
a1bd4f |
make_tls_phase2_connection(const char *detail, NMSetting8021xCKScheme scheme)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection * connection;
|
|
Packit Service |
a1bd4f |
NMSettingConnection *s_con;
|
|
Packit Service |
a1bd4f |
NMSetting8021x * s_8021x;
|
|
Packit Service |
a1bd4f |
NMSettingWired * s_wired;
|
|
Packit Service |
a1bd4f |
NMSettingIP4Config * s_ip4;
|
|
Packit Service |
a1bd4f |
char * uuid;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = nm_simple_connection_new();
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Connection setting */
|
|
Packit Service |
a1bd4f |
s_con = (NMSettingConnection *) nm_setting_connection_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_con));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
uuid = nm_utils_uuid_generate();
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"Test Need TLS Secrets",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
uuid,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_AUTOCONNECT,
|
|
Packit Service |
a1bd4f |
TRUE,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
g_free(uuid);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wired setting */
|
|
Packit Service |
a1bd4f |
s_wired = (NMSettingWired *) nm_setting_wired_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_wired));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wireless security setting */
|
|
Packit Service |
a1bd4f |
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_8021x));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, "blahblah", NULL);
|
|
Packit Service |
a1bd4f |
g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_setting_802_1x_add_eap_method(s_8021x, "ttls");
|
|
Packit Service |
a1bd4f |
g_object_set(s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, "tls", NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_802_1x_set_phase2_ca_cert(s_8021x,
|
|
Packit Service |
a1bd4f |
TEST_NEED_SECRETS_EAP_TLS_CA_CERT,
|
|
Packit Service |
a1bd4f |
scheme,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_802_1x_set_phase2_client_cert(s_8021x,
|
|
Packit Service |
a1bd4f |
TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT,
|
|
Packit Service |
a1bd4f |
scheme,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_802_1x_set_phase2_private_key(s_8021x,
|
|
Packit Service |
a1bd4f |
TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY,
|
|
Packit Service |
a1bd4f |
"test",
|
|
Packit Service |
a1bd4f |
scheme,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_setting_set_secret_flags(NM_SETTING(s_8021x),
|
|
Packit Service |
a1bd4f |
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD,
|
|
Packit Service |
a1bd4f |
NM_SETTING_SECRET_FLAG_AGENT_OWNED,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
nmtst_assert_success(success, error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* IP4 setting */
|
|
Packit Service |
a1bd4f |
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new();
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_ip4));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_and_normalizable(connection);
|
|
Packit Service |
a1bd4f |
return connection;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_need_tls_phase2_secrets_path(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
const char * setting_name;
|
|
Packit Service |
a1bd4f |
GPtrArray * hints = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
connection = make_tls_phase2_connection("need-tls-phase2-secrets-path-key",
|
|
Packit Service |
a1bd4f |
NM_SETTING_802_1X_CK_SCHEME_PATH);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Ensure we don't need any secrets since we just set up the connection */
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert(!setting_name);
|
|
Packit Service |
a1bd4f |
g_assert(!hints);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Connection is good; clear secrets and ensure private key password is then required */
|
|
Packit Service |
a1bd4f |
nm_connection_clear_secrets(connection);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
hints = NULL;
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
|
Packit Service |
a1bd4f |
_assert_hints_has(hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_ptr_array_free(hints, TRUE);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_need_tls_phase2_secrets_blob(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
const char * setting_name;
|
|
Packit Service |
a1bd4f |
GPtrArray * hints = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
connection = make_tls_phase2_connection("need-tls-phase2-secrets-blob-key",
|
|
Packit Service |
a1bd4f |
NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Ensure we don't need any secrets since we just set up the connection */
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert(!setting_name);
|
|
Packit Service |
a1bd4f |
g_assert(!hints);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Connection is good; clear secrets and ensure private key password is then required */
|
|
Packit Service |
a1bd4f |
nm_connection_clear_secrets(connection);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
hints = NULL;
|
|
Packit Service |
a1bd4f |
setting_name = nm_connection_need_secrets(connection, &hints);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(setting_name, ==, NM_SETTING_802_1X_SETTING_NAME);
|
|
Packit Service |
a1bd4f |
_assert_hints_has(hints, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_ptr_array_free(hints, TRUE);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMConnection *
|
|
Packit Service |
a1bd4f |
wifi_connection_new(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection * connection;
|
|
Packit Service |
a1bd4f |
NMSettingConnection * s_con;
|
|
Packit Service |
a1bd4f |
NMSettingWireless * s_wifi;
|
|
Packit Service |
a1bd4f |
NMSettingWirelessSecurity *s_wsec;
|
|
Packit Service |
a1bd4f |
unsigned char tmpssid[] = {0x31, 0x33, 0x33, 0x37};
|
|
Packit Service |
a1bd4f |
char * uuid;
|
|
Packit Service |
a1bd4f |
GBytes * ssid;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = nm_simple_connection_new();
|
|
Packit Service |
a1bd4f |
g_assert(connection);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Connection setting */
|
|
Packit Service |
a1bd4f |
s_con = (NMSettingConnection *) nm_setting_connection_new();
|
|
Packit Service |
a1bd4f |
g_assert(s_con);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
uuid = nm_utils_uuid_generate();
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"Test Wireless",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
uuid,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_AUTOCONNECT,
|
|
Packit Service |
a1bd4f |
FALSE,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
g_free(uuid);
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_con));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wireless setting */
|
|
Packit Service |
a1bd4f |
s_wifi = (NMSettingWireless *) nm_setting_wireless_new();
|
|
Packit Service |
a1bd4f |
g_assert(s_wifi);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ssid = g_bytes_new(tmpssid, sizeof(tmpssid));
|
|
Packit Service |
a1bd4f |
g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
|
Packit Service |
a1bd4f |
g_bytes_unref(ssid);
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_wifi));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wifi security */
|
|
Packit Service |
a1bd4f |
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new();
|
|
Packit Service |
a1bd4f |
g_assert(s_wsec);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(G_OBJECT(s_wsec), NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NULL);
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(connection, NM_SETTING(s_wsec));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return connection;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static GVariant *
|
|
Packit Service |
a1bd4f |
build_wep_secrets(const char *wepkey)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
GVariantBuilder builder;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
|
|
Packit Service |
a1bd4f |
g_variant_builder_add(&builder,
|
|
Packit Service |
a1bd4f |
"{sv}",
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SECURITY_WEP_KEY0,
|
|
Packit Service |
a1bd4f |
g_variant_new_string(wepkey));
|
|
Packit Service |
a1bd4f |
g_variant_builder_add(&builder,
|
|
Packit Service |
a1bd4f |
"{sv}",
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE,
|
|
Packit Service |
a1bd4f |
g_variant_new_uint32(NM_WEP_KEY_TYPE_KEY));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return g_variant_builder_end(&builder);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_wifi_single_setting(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection * connection;
|
|
Packit Service |
a1bd4f |
NMSettingWirelessSecurity *s_wsec;
|
|
Packit Service |
a1bd4f |
GVariant * secrets;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
const char * wepkey = "11111111111111111111111111";
|
|
Packit Service |
a1bd4f |
const char * tmp;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Test update with a hashed setting of 802-11-wireless secrets */
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
secrets = build_wep_secrets(wepkey);
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
secrets,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(success);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_unref(secrets);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Make sure the secret is now in the connection */
|
|
Packit Service |
a1bd4f |
s_wsec = nm_connection_get_setting_wireless_security(connection);
|
|
Packit Service |
a1bd4f |
g_assert(s_wsec);
|
|
Packit Service |
a1bd4f |
tmp = nm_setting_wireless_security_get_wep_key(s_wsec, 0);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(tmp, ==, wepkey);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_wifi_full_hash(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection * connection;
|
|
Packit Service |
a1bd4f |
NMSettingWirelessSecurity *s_wsec;
|
|
Packit Service |
a1bd4f |
GVariantBuilder builder;
|
|
Packit Service |
a1bd4f |
GVariant * all;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
const char * wepkey = "11111111111111111111111111";
|
|
Packit Service |
a1bd4f |
const char * tmp;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Test update with a hashed connection containing only 802-11-wireless
|
|
Packit Service |
a1bd4f |
* setting and secrets.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_builder_init(&builder, NM_VARIANT_TYPE_CONNECTION);
|
|
Packit Service |
a1bd4f |
g_variant_builder_add(&builder,
|
|
Packit Service |
a1bd4f |
"{s@a{sv}}",
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
build_wep_secrets(wepkey));
|
|
Packit Service |
a1bd4f |
all = g_variant_builder_end(&builder);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
all,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(success);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_unref(all);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Make sure the secret is now in the connection */
|
|
Packit Service |
a1bd4f |
s_wsec = nm_connection_get_setting_wireless_security(connection);
|
|
Packit Service |
a1bd4f |
g_assert(s_wsec);
|
|
Packit Service |
a1bd4f |
tmp = nm_setting_wireless_security_get_wep_key(s_wsec, 0);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(tmp, ==, wepkey);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_wifi_bad_setting_name(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
GVariant * secrets;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
const char * wepkey = "11111111111111111111111111";
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Test that passing an invalid setting name to
|
|
Packit Service |
a1bd4f |
* nm_connection_update_secrets() fails with the correct error.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
secrets = build_wep_secrets(wepkey);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection, "asdfasdfasdfasf", secrets, &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND);
|
|
Packit Service |
a1bd4f |
g_assert(success == FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit Service |
a1bd4f |
g_variant_unref(secrets);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_whole_connection(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection * connection;
|
|
Packit Service |
a1bd4f |
NMSettingWirelessSecurity *s_wsec;
|
|
Packit Service |
a1bd4f |
GVariant * secrets;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
const char * wepkey = "11111111111111111111111111";
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Test calling nm_connection_update_secrets() with an entire hashed
|
|
Packit Service |
a1bd4f |
* connection including non-secrets.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Build up the secrets dictionary */
|
|
Packit Service |
a1bd4f |
secrets = nm_connection_to_dbus(connection, NM_CONNECTION_SERIALIZE_ALL);
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_EDITOR(secrets,
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_ADD_PROPERTY(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SECURITY_WEP_KEY0,
|
|
Packit Service |
a1bd4f |
"s",
|
|
Packit Service |
a1bd4f |
wepkey););
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection, NULL, secrets, &error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(success == TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_unref(secrets);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
s_wsec = nm_connection_get_setting_wireless_security(connection);
|
|
Packit Service |
a1bd4f |
g_assert(s_wsec);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_setting_wireless_security_get_wep_key(s_wsec, 0), ==, wepkey);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_whole_connection_empty_hash(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
GVariant * secrets;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Test that updating secrets with an empty connection hash returns success */
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit Service |
a1bd4f |
secrets = g_variant_new_array(G_VARIANT_TYPE("{sa{sv}}"), NULL, 0);
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection, NULL, secrets, &error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(success == TRUE);
|
|
Packit Service |
a1bd4f |
g_variant_unref(secrets);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_whole_connection_bad_setting(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection * connection;
|
|
Packit Service |
a1bd4f |
NMSettingWirelessSecurity *s_wsec;
|
|
Packit Service |
a1bd4f |
GVariant * secrets, *copy, *setting_hash;
|
|
Packit Service |
a1bd4f |
const char * setting_name;
|
|
Packit Service |
a1bd4f |
GVariantBuilder conn_builder;
|
|
Packit Service |
a1bd4f |
GVariantIter conn_iter;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
const char * wepkey = "11111111111111111111111111";
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Test that sending a hashed connection containing an invalid setting
|
|
Packit Service |
a1bd4f |
* name fails with the right error.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit Service |
a1bd4f |
s_wsec = nm_connection_get_setting_wireless_security(connection);
|
|
Packit Service |
a1bd4f |
g_assert(s_wsec != NULL);
|
|
Packit Service |
a1bd4f |
g_object_set(G_OBJECT(s_wsec), NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wepkey, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Build up the secrets hash */
|
|
Packit Service |
a1bd4f |
secrets = nm_connection_to_dbus(connection, NM_CONNECTION_SERIALIZE_ALL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Copy the dict, renaming the wireless-security setting in the process
|
|
Packit Service |
a1bd4f |
* (so we ensure libnm is returning the right error when it finds an entry
|
|
Packit Service |
a1bd4f |
* in the connection hash that doesn't match any setting in the connection).
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
g_variant_builder_init(&conn_builder, NM_VARIANT_TYPE_CONNECTION);
|
|
Packit Service |
a1bd4f |
g_variant_iter_init(&conn_iter, secrets);
|
|
Packit Service |
a1bd4f |
while (g_variant_iter_next(&conn_iter, "{&s@a{sv}}", &setting_name, &setting_hash)) {
|
|
Packit Service |
a1bd4f |
if (strcmp(setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) == 0)
|
|
Packit Service |
a1bd4f |
setting_name = "asdfasdfasdfasdf";
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_builder_add(&conn_builder, "{s@a{sv}}", setting_name, setting_hash);
|
|
Packit Service |
a1bd4f |
g_variant_unref(setting_hash);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
copy = g_variant_builder_end(&conn_builder);
|
|
Packit Service |
a1bd4f |
g_variant_unref(secrets);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection, NULL, copy, &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND);
|
|
Packit Service |
a1bd4f |
g_assert(success == FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit Service |
a1bd4f |
g_variant_unref(copy);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_whole_connection_empty_base_setting(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
GVariant * secrets, *setting;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Test that a hashed connection which does not have any hashed secrets
|
|
Packit Service |
a1bd4f |
* for the requested setting returns success.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit Service |
a1bd4f |
secrets = nm_connection_to_dbus(connection, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(g_variant_n_children(secrets), ==, 3);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
setting = g_variant_lookup_value(secrets, NM_SETTING_WIRELESS_SETTING_NAME, NULL);
|
|
Packit Service |
a1bd4f |
g_assert(setting != NULL);
|
|
Packit Service |
a1bd4f |
g_variant_unref(setting);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
secrets,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(success);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_variant_unref(secrets);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_update_secrets_null_setting_name_with_setting_hash(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMConnection *connection;
|
|
Packit Service |
a1bd4f |
GVariant * secrets;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gboolean success;
|
|
Packit Service |
a1bd4f |
const char * wepkey = "11111111111111111111111111";
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Ensure that a NULL setting name and only a hashed setting fails */
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
connection = wifi_connection_new();
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
secrets = build_wep_secrets(wepkey);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NMTST_EXPECT_LIBNM_CRITICAL(NMTST_G_RETURN_MSG(setting_name || full_connection));
|
|
Packit Service |
a1bd4f |
success = nm_connection_update_secrets(connection, NULL, secrets, &error);
|
|
Packit Service |
a1bd4f |
g_test_assert_expected_messages();
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(!success);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_variant_unref(secrets);
|
|
Packit Service |
a1bd4f |
g_object_unref(connection);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NMTST_DEFINE();
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
int
|
|
Packit Service |
a1bd4f |
main(int argc, char **argv)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtst_init(&argc, &argv, TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* The tests */
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/need_tls_secrets_path", test_need_tls_secrets_path);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/need_tls_secrets_blob", test_need_tls_secrets_blob);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/need_tls_phase2_secrets_path", test_need_tls_phase2_secrets_path);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/need_tls_phase2_secrets_blob", test_need_tls_phase2_secrets_blob);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_wifi_single_setting",
|
|
Packit Service |
a1bd4f |
test_update_secrets_wifi_single_setting);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_wifi_full_hash", test_update_secrets_wifi_full_hash);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_wifi_bad_setting_name",
|
|
Packit Service |
a1bd4f |
test_update_secrets_wifi_bad_setting_name);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_whole_connection", test_update_secrets_whole_connection);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_whole_connection_empty_hash",
|
|
Packit Service |
a1bd4f |
test_update_secrets_whole_connection_empty_hash);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_whole_connection_bad_setting",
|
|
Packit Service |
a1bd4f |
test_update_secrets_whole_connection_bad_setting);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_whole_connection_empty_base_setting",
|
|
Packit Service |
a1bd4f |
test_update_secrets_whole_connection_empty_base_setting);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/update_secrets_null_setting_name_with_setting_hash",
|
|
Packit Service |
a1bd4f |
test_update_secrets_null_setting_name_with_setting_hash);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return g_test_run();
|
|
Packit |
5756e2 |
}
|