summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-03-23 16:04:54 +0100
committerThomas Haller <thaller@redhat.com>2016-03-26 12:10:54 +0100
commitdf405942ded81e756a5ef9c75a0b118996b33bc5 (patch)
tree2e000b806463621547acb202c795430425fb1da3
parent3d8776108c6cf2a2831d58e45e0f1b19a5e0634f (diff)
downloadNetworkManager-df405942ded81e756a5ef9c75a0b118996b33bc5.tar.gz
libnm-core/tests: refactor call to nm_simple_connection_new_from_dbus()
No actual change, let's just not directly call nm_simple_connection_new_from_dbus(). Instead, add a wrapper to define in once place the flags we use for loading the connection.
-rw-r--r--libnm-core/tests/test-general.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 6541834284..dcbcb88021 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -74,6 +74,12 @@ G_STATIC_ASSERT (sizeof (bool) <= sizeof (int));
/*****************************************************************************/
+static NMConnection *
+_connection_new_from_dbus (GVariant *dict, GError **error)
+{
+ return _nm_simple_connection_new_from_dbus (dict, NM_SETTING_PARSE_FLAGS_NORMALIZE, error);
+}
+
static void
vpn_check_func (const char *key, const char *value, gpointer user_data)
{
@@ -450,7 +456,7 @@ test_setting_ip4_config_labels (void)
NMTST_VARIANT_DROP_PROPERTY (NM_SETTING_IP4_CONFIG_SETTING_NAME,
"address-data");
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_no_error (error);
g_variant_unref (dict);
@@ -473,7 +479,7 @@ test_setting_ip4_config_labels (void)
NMTST_VARIANT_DROP_PROPERTY (NM_SETTING_IP4_CONFIG_SETTING_NAME,
"address-labels");
);
- conn = nm_simple_connection_new_from_dbus (dict2, &error);
+ conn = _connection_new_from_dbus (dict2, &error);
g_assert_no_error (error);
g_variant_unref (dict2);
@@ -603,7 +609,7 @@ test_setting_ip4_config_address_data (void)
g_object_unref (conn);
/* When we reserialize that dictionary as a client, 'address-data' will be preferred. */
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_no_error (error);
s_ip4 = nm_connection_get_setting_ip4_config (conn);
@@ -619,7 +625,7 @@ test_setting_ip4_config_address_data (void)
/* But on the server side, 'addresses' will have precedence. */
_nm_utils_is_manager_process = TRUE;
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
_nm_utils_is_manager_process = FALSE;
g_assert_no_error (error);
g_variant_unref (dict);
@@ -1188,7 +1194,7 @@ test_setting_new_from_dbus_bad (void)
g_object_unref (conn);
/* sanity-check */
- conn = nm_simple_connection_new_from_dbus (orig_dict, &error);
+ conn = _connection_new_from_dbus (orig_dict, &error);
g_assert_no_error (error);
g_assert (conn);
g_object_unref (conn);
@@ -1201,7 +1207,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_WIRELESS_RATE,
"i", 10);
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert (conn);
g_assert_no_error (error);
setting = nm_connection_get_setting (conn, NM_TYPE_SETTING_WIRELESS);
@@ -1216,7 +1222,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_IP6_CONFIG_IP6_PRIVACY,
"i", NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR);
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert (conn);
g_assert_no_error (error);
setting = nm_connection_get_setting (conn, NM_TYPE_SETTING_IP6_CONFIG);
@@ -1233,7 +1239,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_WIRELESS_RATE,
"s", "ten");
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "802-11-wireless.rate:"));
g_clear_error (&error);
@@ -1245,7 +1251,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_WIRELESS_MODE,
"b", FALSE);
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "802-11-wireless.mode:"));
g_clear_error (&error);
@@ -1257,7 +1263,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_WIRELESS_SSID,
"s", "fred");
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "802-11-wireless.ssid:"));
g_clear_error (&error);
@@ -1269,7 +1275,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_WIRELESS_BSSID,
"i", 42);
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "802-11-wireless.bssid:"));
g_clear_error (&error);
@@ -1281,7 +1287,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_IP6_CONFIG_IP6_PRIVACY,
"s", "private");
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "ipv6.ip6-privacy:"));
g_clear_error (&error);
@@ -1293,7 +1299,7 @@ test_setting_new_from_dbus_bad (void)
NM_SETTING_IP_CONFIG_ADDRESSES,
"s", "1234::5678");
);
- conn = nm_simple_connection_new_from_dbus (dict, &error);
+ conn = _connection_new_from_dbus (dict, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "ipv6.addresses:"));
g_clear_error (&error);
@@ -1561,7 +1567,7 @@ test_connection_new_from_dbus (void)
g_assert (new_settings);
/* Replace settings and test */
- connection = nm_simple_connection_new_from_dbus (new_settings, &error);
+ connection = _connection_new_from_dbus (new_settings, &error);
g_assert_no_error (error);
g_assert (connection);
@@ -3241,7 +3247,7 @@ test_connection_normalize_virtual_iface_name (void)
":::this-is-not-a-valid-interface-name:::");
);
- con = nm_simple_connection_new_from_dbus (connection_dict, &error);
+ con = _connection_new_from_dbus (connection_dict, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
g_clear_error (&error);
@@ -3253,7 +3259,7 @@ test_connection_normalize_virtual_iface_name (void)
IFACE_VIRT);
);
- con = nm_simple_connection_new_from_dbus (connection_dict, &error);
+ con = _connection_new_from_dbus (connection_dict, &error);
g_assert_no_error (error);
g_assert_cmpstr (nm_connection_get_interface_name (con), ==, IFACE_NAME);
@@ -3269,7 +3275,7 @@ test_connection_normalize_virtual_iface_name (void)
NM_SETTING_CONNECTION_INTERFACE_NAME);
);
- con = nm_simple_connection_new_from_dbus (connection_dict, &error);
+ con = _connection_new_from_dbus (connection_dict, &error);
g_assert_no_error (error);
g_assert_cmpstr (nm_connection_get_interface_name (con), ==, IFACE_VIRT);
@@ -3783,7 +3789,7 @@ test_setting_ip4_gateway (void)
"address-data");
);
- conn = nm_simple_connection_new_from_dbus (conn_dict, &error);
+ conn = _connection_new_from_dbus (conn_dict, &error);
g_assert_no_error (error);
s_ip4 = (NMSettingIPConfig *) nm_connection_get_setting_ip4_config (conn);
@@ -3805,7 +3811,7 @@ test_setting_ip4_gateway (void)
"addresses", "aau", &addrs_builder);
);
- conn = nm_simple_connection_new_from_dbus (conn_dict, &error);
+ conn = _connection_new_from_dbus (conn_dict, &error);
g_assert_no_error (error);
g_variant_unref (conn_dict);
@@ -3890,7 +3896,7 @@ test_setting_ip6_gateway (void)
"address-data");
);
- conn = nm_simple_connection_new_from_dbus (conn_dict, &error);
+ conn = _connection_new_from_dbus (conn_dict, &error);
g_assert_no_error (error);
s_ip6 = (NMSettingIPConfig *) nm_connection_get_setting_ip6_config (conn);
@@ -3918,7 +3924,7 @@ test_setting_ip6_gateway (void)
"addresses", "a(ayuay)", &addrs_builder);
);
- conn = nm_simple_connection_new_from_dbus (conn_dict, &error);
+ conn = _connection_new_from_dbus (conn_dict, &error);
g_assert_no_error (error);
g_variant_unref (conn_dict);