summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-03-26 13:47:30 +0100
committerThomas Haller <thaller@redhat.com>2016-03-26 14:01:41 +0100
commit48d6821cde5139cf3ffbbe34ab4e9f79b22f22b7 (patch)
tree6d9222d78591b7316a1a5f0ed4e34870459e6d48
parent72ea4bf2d73fb4b25b37df1bff423492316c2f96 (diff)
downloadNetworkManager-th/invalid-connections-bgo760907.tar.gz
libnm-glib: allow non-verifiable NMRemoteConnection in libnm-glibth/invalid-connections-bgo760907
-rw-r--r--libnm-glib/nm-remote-connection.c30
-rw-r--r--libnm-glib/tests/test-nm-client.c33
2 files changed, 20 insertions, 43 deletions
diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c
index 132032f488..a4dc638adc 100644
--- a/libnm-glib/nm-remote-connection.c
+++ b/libnm-glib/nm-remote-connection.c
@@ -31,6 +31,7 @@
#include "nm-object-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-dbus-helpers-private.h"
+#include "nm-setting-private.h"
#define NM_REMOTE_CONNECTION_BUS "bus"
#define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection"
@@ -447,24 +448,6 @@ nm_remote_connection_get_unsaved (NMRemoteConnection *connection)
/****************************************************************/
static void
-replace_settings (NMRemoteConnection *self, GHashTable *new_settings)
-{
- GError *error = NULL;
-
- if (nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error))
- g_signal_emit (self, signals[UPDATED], 0, new_settings);
- else {
- g_warning ("%s: error updating connection %s settings: %s",
- __func__,
- nm_connection_get_path (NM_CONNECTION (self)),
- error->message);
- g_clear_error (&error);
-
- g_signal_emit (self, signals[REMOVED], 0);
- }
-}
-
-static void
updated_get_settings_cb (DBusGProxy *proxy,
DBusGProxyCall *call,
gpointer user_data)
@@ -488,7 +471,7 @@ updated_get_settings_cb (DBusGProxy *proxy,
* object.
*/
hash = g_hash_table_new (g_str_hash, g_str_equal);
- nm_connection_replace_settings (NM_CONNECTION (self), hash, NULL);
+ _nm_connection_replace_settings (NM_CONNECTION (self), hash);
g_hash_table_destroy (hash);
priv->visible = FALSE;
@@ -497,7 +480,8 @@ updated_get_settings_cb (DBusGProxy *proxy,
gs_unref_object NMConnection *self_alive = NULL;
self_alive = g_object_ref (self);
- replace_settings (self, new_settings);
+ _nm_connection_replace_settings (NM_CONNECTION (self), new_settings);
+ g_signal_emit (self, signals[UPDATED], 0, new_settings);
g_hash_table_destroy (new_settings);
/* Settings service will handle announcing the connection to clients */
@@ -628,7 +612,8 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
return FALSE;
priv->visible = TRUE;
self_alive = g_object_ref (initable);
- replace_settings (NM_REMOTE_CONNECTION (initable), hash);
+ _nm_connection_replace_settings (NM_CONNECTION (initable), hash);
+ g_signal_emit (initable, signals[UPDATED], 0, hash);
g_hash_table_destroy (hash);
/* Get properties */
@@ -703,7 +688,8 @@ init_get_settings_cb (DBusGProxy *proxy,
priv->visible = TRUE;
self_alive = g_object_ref (init_data->connection);
- replace_settings (init_data->connection, settings);
+ _nm_connection_replace_settings (NM_CONNECTION (init_data->connection), settings);
+ g_signal_emit (init_data->connection, signals[UPDATED], 0, settings);
g_hash_table_destroy (settings);
/* Grab properties */
diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c
index da2e39e04f..0da93c3fd3 100644
--- a/libnm-glib/tests/test-nm-client.c
+++ b/libnm-glib/tests/test-nm-client.c
@@ -955,12 +955,8 @@ test_connection_invalid (void)
settings = nmtstc_nm_remote_settings_new ();
- g_test_expect_message ("libnm-glib", G_LOG_LEVEL_WARNING, "*replace_settings: error updating connection*");
-
nmtst_main_loop_run (loop, 100);
- g_test_assert_expected_messages ();
-
_slist_to_array (&connections, nm_remote_settings_list_connections (settings));
g_assert_cmpint (connections->len, ==, 2);
@@ -991,12 +987,8 @@ test_connection_invalid (void)
FALSE,
&path2);
- g_test_expect_message ("libnm-glib", G_LOG_LEVEL_WARNING, "*replace_settings: error updating connection*");
-
nmtst_main_loop_run (loop, 100);
- g_test_assert_expected_messages ();
-
_slist_to_array (&connections, nm_remote_settings_list_connections (settings));
g_assert_cmpint (connections->len, ==, 3);
@@ -1027,15 +1019,11 @@ test_connection_invalid (void)
connection,
FALSE);
- g_test_expect_message ("libnm-glib", G_LOG_LEVEL_WARNING, "*replace_settings: error updating connection*");
-
nmtst_main_loop_run (loop, 100);
- g_test_assert_expected_messages ();
-
_slist_to_array (&connections, nm_remote_settings_list_connections (settings));
- g_assert_cmpint (connections->len, ==, 2);
+ g_assert_cmpint (connections->len, ==, 3);
n_found = nmtst_find_all_indexes (connections->pdata,
connections->len,
(gpointer *) ((const char *[]) { path0, path1, path2 }),
@@ -1043,12 +1031,13 @@ test_connection_invalid (void)
_test_connection_invalid_find_connections,
NULL,
idx);
- g_assert_cmpint (n_found, ==, 2);
+ g_assert_cmpint (n_found, ==, 3);
ASSERT_IDX (0);
ASSERT_IDX (1);
- g_assert_cmpint (idx[2], ==, -1);
+ ASSERT_IDX (2);
nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
nmtst_assert_connection_unnormalizable (connections->pdata[idx[1]], 0, 0);
+ nmtst_assert_connection_unnormalizable (connections->pdata[idx[2]], 0, 0);
/**************************************************************************
* Modify the invalid connection again. Note that the connection stays
@@ -1073,7 +1062,7 @@ test_connection_invalid (void)
_slist_to_array (&connections, nm_remote_settings_list_connections (settings));
- g_assert_cmpint (connections->len, ==, 2);
+ g_assert_cmpint (connections->len, ==, 3);
n_found = nmtst_find_all_indexes (connections->pdata,
connections->len,
(gpointer *) ((const char *[]) { path0, path1, path2 }),
@@ -1081,12 +1070,13 @@ test_connection_invalid (void)
_test_connection_invalid_find_connections,
NULL,
idx);
- g_assert_cmpint (n_found, ==, 2);
+ g_assert_cmpint (n_found, ==, 3);
ASSERT_IDX (0);
ASSERT_IDX (1);
- g_assert_cmpint (idx[2], ==, -1);
+ ASSERT_IDX (2);
nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
nmtst_assert_connection_unnormalizable (connections->pdata[idx[1]], 0, 0);
+ nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[2]]);
/**************************************************************************
@@ -1111,7 +1101,7 @@ test_connection_invalid (void)
_slist_to_array (&connections, nm_remote_settings_list_connections (settings));
- g_assert_cmpint (connections->len, ==, 2);
+ g_assert_cmpint (connections->len, ==, 3);
n_found = nmtst_find_all_indexes (connections->pdata,
connections->len,
(gpointer *) ((const char *[]) { path0, path1, path2 }),
@@ -1119,12 +1109,13 @@ test_connection_invalid (void)
_test_connection_invalid_find_connections,
NULL,
idx);
- g_assert_cmpint (n_found, ==, 2);
+ g_assert_cmpint (n_found, ==, 3);
ASSERT_IDX (0);
ASSERT_IDX (1);
- g_assert_cmpint (idx[2], ==, -1);
+ ASSERT_IDX (2);
nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[0]]);
nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[1]]);
+ nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[2]]);
g_assert_cmpstr ("test-connection-invalid-1x", ==, nm_connection_get_id (connections->pdata[idx[1]]));
#undef ASSERT_IDX