libnm-glib: allow non-verifiable NMRemoteConnection in libnm-glib
authorThomas Haller <thaller@redhat.com>
Sat, 26 Mar 2016 12:47:30 +0000 (13:47 +0100)
committerThomas Haller <thaller@redhat.com>
Tue, 29 Mar 2016 09:56:27 +0000 (11:56 +0200)
libnm-glib/nm-remote-connection.c
libnm-glib/tests/test-nm-client.c

index 132032f..a4dc638 100644 (file)
@@ -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"
@@ -446,24 +447,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,
@@ -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 */
index da2e39e..0da93c3 100644 (file)
@@ -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