[network-manager-applet] applet: import existing user connections user-private system connections



commit aef601e290105056bffc123b8e0e19e9ad126704
Author: Dan Williams <dcbw redhat com>
Date:   Thu Mar 10 00:41:12 2011 -0600

    applet: import existing user connections user-private system connections
    
    Secrets are still stored in the user session.  Add a metric ton
    of testcases and test framework to let us verify upgrade more
    in the future, including an in-process re-implementation of GConf
    and gnome-keyring.  That was a shitload of work and now I'm tired.

 .gitignore                              |    1 +
 configure.ac                            |   19 +-
 src/applet.c                            |   29 +
 src/gconf-helpers/Makefile.am           |   34 +-
 src/gconf-helpers/gconf-helpers.c       |  227 ++++-----
 src/gconf-helpers/gconf-helpers.h       |   18 +-
 src/gconf-helpers/gconf-upgrade.c       |  166 ++++++-
 src/gconf-helpers/gconf-upgrade.h       |    4 +
 src/gconf-helpers/tests/08vpnc.xml      |  127 +++++
 src/gconf-helpers/tests/08wifi.xml      |   96 ++++
 src/gconf-helpers/tests/Makefile.am     |   30 +
 src/gconf-helpers/tests/fake-gconf.c    |  878 +++++++++++++++++++++++++++++++
 src/gconf-helpers/tests/fake-gconf.h    |   29 +
 src/gconf-helpers/tests/fake-keyring.c  |  429 +++++++++++++++
 src/gconf-helpers/tests/fake-keyring.h  |   27 +
 src/gconf-helpers/tests/test-import.xml |  207 ++++++++
 src/gconf-helpers/tests/test-upgrade.c  |  389 ++++++++++++++
 17 files changed, 2546 insertions(+), 164 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index df5f115..f6f83c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,4 +39,5 @@ src/marshallers/nma-marshal.[ch]
 src/nm-applet
 src/applet-dbus-bindings.h
 
+src/gconf-helpers/tests/test-upgrade
 
diff --git a/configure.ac b/configure.ac
index 71f7416..defb634 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,8 +72,7 @@ PKG_CHECK_MODULES(NMA,
 		 libnm-glib >= 0.8.995
 		 libnm-util >= 0.8.995
 		 libnm-glib-vpn >= 0.8.995
-		 gmodule-export-2.0
-		 libnotify >= 0.4.3])
+		 gmodule-export-2.0])
 
 PKG_CHECK_MODULES(GCONF, [gconf-2.0])
 AC_SUBST(GCONF_CFLAGS)
@@ -83,6 +82,15 @@ PKG_CHECK_MODULES(GNOME_KEYRING, [gnome-keyring-1])
 AC_SUBST(GNOME_KEYRING_CFLAGS)
 AC_SUBST(GNOME_KEYRING_LIBS)
 
+# Check for libnotify >= 0.7
+PKG_CHECK_MODULES(LIBNOTIFY_07, [libnotify >= 0.7], [have_libnotify_07=yes],[have_libnotify_07=no])
+if test x"$have_libnotify_07" = "xyes"; then
+	AC_DEFINE(HAVE_LIBNOTIFY_07, 1, [Define if you have libnotify 0.7 or later])
+fi
+PKG_CHECK_MODULES(NOTIFY, [libnotify >= 0.4.3])
+AC_SUBST(NOTIFY_CFLAGS)
+AC_SUBST(NOTIFY_LIBS)
+
 AC_ARG_WITH([gtkver], AS_HELP_STRING([--with-gtkver], [The major version of GTK+ to build with]),
             with_gtkver="$withval",with_gtkver=3)
 case "${with_gtkver}" in
@@ -132,12 +140,6 @@ esac
 
 AM_CONDITIONAL(HAVE_GBT, test x"$have_gbt" = "xyes")
 
-# Check for libnotify >= 0.7
-PKG_CHECK_MODULES(LIBNOTIFY_07, [libnotify >= 0.7], [have_libnotify_07=yes],[have_libnotify_07=no])
-if test x"$have_libnotify_07" = "xyes"; then
-	AC_DEFINE(HAVE_LIBNOTIFY_07, 1, [Define if you have libnotify 0.7 or later])
-fi
-
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 
 dnl GConf stuff
@@ -159,6 +161,7 @@ src/marshallers/Makefile
 src/utils/Makefile
 src/utils/tests/Makefile
 src/gconf-helpers/Makefile
+src/gconf-helpers/tests/Makefile
 src/wireless-security/Makefile
 src/connection-editor/Makefile
 src/gnome-bluetooth/Makefile
diff --git a/src/applet.c b/src/applet.c
index 088de7d..e0be9f9 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -78,6 +78,7 @@
 #include "wireless-dialog.h"
 #include "applet-vpn-request.h"
 #include "utils.h"
+#include "gconf-helpers.h"
 
 #define NOTIFY_CAPS_ACTIONS_KEY "actions"
 
@@ -3122,6 +3123,31 @@ dbus_setup (NMApplet *applet, GError **error)
 	return success;
 }
 
+static void
+add_cb (NMRemoteSettings *settings,
+        NMRemoteConnection *connection,
+        GError *error,
+        gpointer user_data)
+{
+	if (error) {
+		g_warning ("Failed to move connection '%s' to NetworkManager system settings: %s",
+		           nm_connection_get_id (NM_CONNECTION (connection)),
+		           error->message);
+	}
+}
+
+static void
+import_cb (NMConnection *connection, gpointer user_data)
+{
+	NMApplet *applet = user_data;
+
+	nm_connection_clear_secrets (connection);
+	if (!nm_remote_settings_add_connection (applet->settings, connection, add_cb, NULL)) {
+		g_warning ("Failed to move connection '%s' to NetworkManager system settings.",
+		           nm_connection_get_id (connection));
+	}
+}
+
 static GObject *
 constructor (GType type,
              guint n_props,
@@ -3177,6 +3203,9 @@ constructor (GType type,
 	}
 	applet->settings = nm_remote_settings_new (applet->bus);
 
+	/* Move user connections to the system */
+	nm_gconf_move_connections_to_system (import_cb, applet);
+
 	applet->agent = applet_agent_new ();
 	g_assert (applet->agent);
 	g_signal_connect (applet->agent, APPLET_AGENT_GET_SECRETS,
diff --git a/src/gconf-helpers/Makefile.am b/src/gconf-helpers/Makefile.am
index 321494c..1cf81f7 100644
--- a/src/gconf-helpers/Makefile.am
+++ b/src/gconf-helpers/Makefile.am
@@ -1,24 +1,44 @@
-noinst_LTLIBRARIES = libgconf-helpers.la
+SUBDIRS=. tests
 
-libgconf_helpers_la_SOURCES = \
+noinst_LTLIBRARIES = \
+	libgconf-helpers.la \
+	libgconf-helpers-test.la
+
+HELPERS_SOURCES = \
 	gconf-helpers.h \
 	gconf-helpers.c \
 	gconf-upgrade.h \
 	gconf-upgrade.c
 
+libgconf_helpers_la_SOURCES = $(HELPERS_SOURCES)
+
 libgconf_helpers_la_CPPFLAGS = \
 	$(GTK_CFLAGS) \
 	$(NMA_CFLAGS) \
 	$(GCONF_CFLAGS) \
 	$(GNOME_KEYRING_CFLAGS) \
-	$(DISABLE_DEPRECATED) \
-	-I${top_srcdir}/src \
-	-I${top_srcdir}/src/utils
+	$(DISABLE_DEPRECATED)
 
 libgconf_helpers_la_LIBADD = \
 	$(GTK_LIBS) \
 	$(NMA_LIBS) \
 	$(GCONF_LIBS) \
-	$(GNOME_KEYRING_LIBS) \
-	${top_builddir}/src/utils/libutils.la
+	$(GNOME_KEYRING_LIBS)
+
+#########################
+# Test library
+#########################
+
+libgconf_helpers_test_la_SOURCES = $(HELPERS_SOURCES)
+
+libgconf_helpers_test_la_CPPFLAGS = \
+	$(GTK_CFLAGS) \
+	$(NMA_CFLAGS) \
+	$(GCONF_CFLAGS) \
+	$(GNOME_KEYRING_CFLAGS) \
+	$(DISABLE_DEPRECATED)
+
+# no keyring or gconf libs since we'll override them
+libgconf_helpers_test_la_LIBADD = \
+	$(NMA_LIBS)
 
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index cd0963a..31fa8c7 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -45,11 +45,14 @@
 #include <nm-setting-8021x.h>
 #include <nm-setting-vpn.h>
 #include <nm-setting-ip4-config.h>
+#include <nm-setting-cdma.h>
+#include <nm-setting-gsm.h>
+#include <nm-setting-ppp.h>
+#include <nm-setting-pppoe.h>
 #include <nm-utils.h>
 
 #include "gconf-helpers.h"
 #include "gconf-upgrade.h"
-#include "utils.h"
 
 #define S390_OPT_KEY_PREFIX "s390-opt-"
 
@@ -69,6 +72,12 @@
 
 #define APPLET_PREFS_PATH "/apps/nm-applet"
 
+/* The stamp is a mechanism for determining which applet version last
+ * updated GConf for various GConf update tasks in newer applet versions.
+ */
+#define APPLET_CURRENT_STAMP 3
+#define APPLET_PREFS_STAMP "/apps/nm-applet/stamp"
+
 const char *applet_8021x_cert_keys[] = {
 	"ca-cert",
 	"client-cert",
@@ -84,6 +93,39 @@ const char *vpn_ignore_keys[] = {
 	NULL
 };
 
+static GnomeKeyringAttributeList *
+_create_keyring_add_attr_list (const char *connection_uuid,
+                               const char *connection_id,
+                               const char *setting_name,
+                               const char *setting_key,
+                               char **out_display_name)
+{
+	GnomeKeyringAttributeList *attrs = NULL;
+
+	g_return_val_if_fail (connection_uuid != NULL, NULL);
+	g_return_val_if_fail (connection_id != NULL, NULL);
+	g_return_val_if_fail (setting_name != NULL, NULL);
+	g_return_val_if_fail (setting_key != NULL, NULL);
+
+	if (out_display_name) {
+		*out_display_name = g_strdup_printf ("Network secret for %s/%s/%s",
+		                                     connection_id,
+		                                     setting_name,
+		                                     setting_key);
+	}
+
+	attrs = gnome_keyring_attribute_list_new ();
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_UUID_TAG,
+	                                            connection_uuid);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_SN_TAG,
+	                                            setting_name);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_SK_TAG,
+	                                            setting_key);
+	return attrs;
+}
 
 gboolean
 nm_gconf_get_int_helper (GConfClient *client,
@@ -1633,13 +1675,53 @@ nm_gconf_key_is_set (GConfClient *client,
 	return exists;
 }
 
-GSList *
-nm_gconf_get_all_connections (GConfClient *client)
+static void
+move_to_system (GConfClient *client,
+                GSList *connections,
+                AddToSettingsFunc add_func,
+                gpointer user_data)
+{
+	GSList *iter;
+	NMConnection *connection;
+	NMSettingConnection *s_con;
+
+	for (iter = connections; iter; iter = iter->next) {
+		connection = nm_gconf_read_connection (client, (const char *) iter->data);
+		if (!connection)
+			continue;
+
+		/* Set this connection visible only to this user */
+		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		g_assert (s_con);
+		nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+
+		/* Next, any secrets for the connection need to be marked user-owned */
+		nm_gconf_migrate_09_secret_flags (client, connection, NM_SETTING_802_1X_SETTING_NAME);
+		nm_gconf_migrate_09_secret_flags (client, connection, NM_SETTING_CDMA_SETTING_NAME);
+		nm_gconf_migrate_09_secret_flags (client, connection, NM_SETTING_GSM_SETTING_NAME);
+		nm_gconf_migrate_09_secret_flags (client, connection, NM_SETTING_PPP_SETTING_NAME);
+		nm_gconf_migrate_09_secret_flags (client, connection, NM_SETTING_PPPOE_SETTING_NAME);
+		nm_gconf_migrate_09_secret_flags (client, connection, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+		nm_gconf_migrate_09_secret_flags (client, connection, NM_SETTING_VPN_SETTING_NAME);
+
+		/* Now add the connection to the system settings service */
+		if (add_func)
+			add_func (connection, user_data);
+	}
+}
+
+void
+nm_gconf_move_connections_to_system (AddToSettingsFunc add_func, gpointer user_data)
 {
+	GConfClient *client;
 	GSList *connections;
 	guint32 stamp = 0;
 	GError *error = NULL;
 
+	client = gconf_client_get_default ();
+	if (!client)
+		return;
+
 	stamp = (guint32) gconf_client_get_int (client, APPLET_PREFS_STAMP, &error);
 	if (error) {
 		g_error_free (error);
@@ -1667,14 +1749,21 @@ nm_gconf_get_all_connections (GConfClient *client)
 	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
 	if (!connections) {
 		nm_gconf_migrate_0_6_connections (client);
+		/* Try again */
 		connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
 	}
 
+	if (connections) {
+		/* Move to system connections for 0.9 */
+		if (stamp < 3)
+			move_to_system (client, connections, add_func, user_data);
+		g_slist_foreach (connections, (GFunc) g_free, NULL);
+		g_slist_free (connections);
+	}
+
 	/* Update the applet GConf stamp */
 	if (stamp != APPLET_CURRENT_STAMP)
 		gconf_client_set_int (client, APPLET_PREFS_STAMP, APPLET_CURRENT_STAMP, NULL);
-
-	return connections;
 }
 
 static gboolean
@@ -1984,12 +2073,11 @@ nm_gconf_add_keyring_item (const char *connection_uuid,
 	g_return_if_fail (setting_key != NULL);
 	g_return_if_fail (secret != NULL);
 
-	attrs = utils_create_keyring_add_attr_list (NULL,
-	                                            connection_uuid,
-	                                            connection_name,
-	                                            setting_name,
-	                                            setting_key,
-	                                            &display_name);
+	attrs = _create_keyring_add_attr_list (connection_uuid,
+	                                       connection_name,
+	                                       setting_name,
+	                                       setting_key,
+	                                       &display_name);
 	g_assert (attrs);
 	ret = gnome_keyring_item_create_sync (NULL,
 	                                      GNOME_KEYRING_ITEM_GENERIC_SECRET,
@@ -2007,11 +2095,6 @@ nm_gconf_add_keyring_item (const char *connection_uuid,
 }
 
 static void
-delete_done (GnomeKeyringResult result, gpointer user_data)
-{
-}
-
-static void
 keyring_delete_item (const char *connection_uuid,
                      const char *setting_name,
                      const char *setting_key)
@@ -2036,11 +2119,7 @@ keyring_delete_item (const char *connection_uuid,
 		for (iter = found_list; iter != NULL; iter = g_list_next (iter)) {
 			GnomeKeyringFound *found = (GnomeKeyringFound *) iter->data;
 
-			gnome_keyring_item_delete (found->keyring,
-			                           found->item_id,
-			                           delete_done,
-			                           NULL,
-			                           NULL);
+			gnome_keyring_item_delete_sync (found->keyring, found->item_id);
 		}
 		gnome_keyring_found_list_free (found_list);
 	}
@@ -2668,7 +2747,10 @@ nm_gconf_write_connection (NMConnection *connection,
 {
 	NMSettingConnection *s_con;
 	CopyOneSettingValueInfo info;
-	gboolean ignore;
+
+	/* NOTE: as of 0.9, this method should only be called during upgrade of
+	 * NM 0.6 connections.
+	 */
 
 	g_return_if_fail (NM_IS_CONNECTION (connection));
 	g_return_if_fail (client != NULL);
@@ -2701,106 +2783,5 @@ nm_gconf_write_connection (NMConnection *connection,
 		                                      write_one_secret_to_keyring,
 		                                      &info);
 	}
-
-	/* Update ignore CA cert status */
-	ignore = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), IGNORE_CA_CERT_TAG));
-	nm_gconf_set_ignore_ca_cert (info.connection_uuid, FALSE, ignore);
-
-	ignore = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), IGNORE_PHASE2_CA_CERT_TAG));
-	nm_gconf_set_ignore_ca_cert (info.connection_uuid, TRUE, ignore);
-}
-
-static char *
-get_ignore_path (const char *uuid, gboolean phase2)
-{
-	return g_strdup_printf (APPLET_PREFS_PATH "/%s/%s",
-	                        phase2 ? "ignore-phase2-ca-cert" : "ignore-ca-cert",
-	                        uuid);
-}
-
-gboolean
-nm_gconf_get_ignore_ca_cert (const char *uuid, gboolean phase2)
-{
-	GConfClient *client;
-	char *key = NULL;
-	gboolean ignore = FALSE;
-
-	g_return_val_if_fail (uuid != NULL, FALSE);
-
-	client = gconf_client_get_default ();
-
-	key = get_ignore_path (uuid, phase2);
-	ignore = gconf_client_get_bool (client, key, NULL);
-	g_free (key);
-
-	g_object_unref (client);
-	return ignore;
-}
-
-void
-nm_gconf_set_ignore_ca_cert (const char *uuid, gboolean phase2, gboolean ignore)
-{
-	GConfClient *client;
-	char *key = NULL;
-
-	g_return_if_fail (uuid != NULL);
-
-	client = gconf_client_get_default ();
-
-	key = get_ignore_path (uuid, phase2);
-	if (ignore)
-		gconf_client_set_bool (client, key, ignore, NULL);
-	else
-		gconf_client_unset (client, key, NULL);
-	g_free (key);
-
-	g_object_unref (client);
 }
 
-#if 0
-static char *
-get_always_ask_path (const char *uuid)
-{
-	return g_strdup_printf (APPLET_PREFS_PATH "/8021x-password-always-ask/%s", uuid);
-}
-
-gboolean
-nm_gconf_get_8021x_password_always_ask (const char *uuid)
-{
-	GConfClient *client;
-	char *key = NULL;
-	gboolean ask = FALSE;
-
-	g_return_val_if_fail (uuid != NULL, FALSE);
-
-	client = gconf_client_get_default ();
-
-	key = get_always_ask_path (uuid);
-	ask = gconf_client_get_bool (client, key, NULL);
-	g_free (key);
-
-	g_object_unref (client);
-	return ask;
-}
-
-void
-nm_gconf_set_8021x_password_always_ask (const char *uuid, gboolean ask)
-{
-	GConfClient *client;
-	char *key = NULL;
-
-	g_return_if_fail (uuid != NULL);
-
-	client = gconf_client_get_default ();
-
-	key = get_always_ask_path (uuid);
-	if (ask)
-		gconf_client_set_bool (client, key, TRUE, NULL);
-	else
-		gconf_client_unset (client, key, NULL);
-	g_free (key);
-
-	g_object_unref (client);
-}
-
-#endif
diff --git a/src/gconf-helpers/gconf-helpers.h b/src/gconf-helpers/gconf-helpers.h
index 66bd020..132d1f9 100644
--- a/src/gconf-helpers/gconf-helpers.h
+++ b/src/gconf-helpers/gconf-helpers.h
@@ -29,15 +29,6 @@
 
 #define GCONF_PATH_CONNECTIONS "/system/networking/connections"
 
-/* The stamp is a mechanism for determining which applet version last
- * updated GConf for various GConf update tasks in newer applet versions.
- */
-#define APPLET_CURRENT_STAMP 1
-#define APPLET_PREFS_STAMP "/apps/nm-applet/stamp"
-
-#define IGNORE_CA_CERT_TAG "ignore-ca-cert"
-#define IGNORE_PHASE2_CA_CERT_TAG "ignore-phase2-ca-cert"
-
 #define KEYRING_UUID_TAG "connection-uuid"
 #define KEYRING_SN_TAG "setting-name"
 #define KEYRING_SK_TAG "setting-key"
@@ -251,9 +242,6 @@ nm_gconf_key_is_set (GConfClient *client,
                      const char *key,
                      const char *setting);
 
-GSList *
-nm_gconf_get_all_connections (GConfClient *client);
-
 NMConnection *
 nm_gconf_read_connection (GConfClient *client,
                           const char *dir);
@@ -271,8 +259,10 @@ nm_gconf_add_keyring_item (const char *connection_uuid,
                            const char *setting_key,
                            const char *secret);
 
-gboolean nm_gconf_get_ignore_ca_cert (const char *uuid, gboolean phase2);
-void nm_gconf_set_ignore_ca_cert (const char *uuid, gboolean phase2, gboolean ignore);
+typedef void (*AddToSettingsFunc) (NMConnection *connection, gpointer user_data);
+
+void nm_gconf_move_connections_to_system (AddToSettingsFunc add_func,
+                                          gpointer user_data);
 
 #endif	/* GCONF_HELPERS_H */
 
diff --git a/src/gconf-helpers/gconf-upgrade.c b/src/gconf-helpers/gconf-upgrade.c
index 73dcdfa..d700102 100644
--- a/src/gconf-helpers/gconf-upgrade.c
+++ b/src/gconf-helpers/gconf-upgrade.c
@@ -42,7 +42,9 @@
 #include "gconf-upgrade.h"
 #include "gconf-helpers.h"
 
-#include "nm-connection.h"
+#include <nm-connection.h>
+
+#define APPLET_PREFS_PATH "/apps/nm-applet"
 
 /* Old wireless.h defs */
 
@@ -596,12 +598,6 @@ nm_gconf_read_0_6_wireless_connection (GConfClient *client,
 }
 
 static void
-keyring_secret_save_cb (GnomeKeyringResult result, guint32 val, gpointer user_data)
-{
-	/* Ignore */
-}
-
-static void
 vpn_helpers_save_secret (const char *vpn_uuid,
                          const char *vpn_name,
                          const char *secret_name,
@@ -610,6 +606,7 @@ vpn_helpers_save_secret (const char *vpn_uuid,
 {
 	char *display_name;
 	GnomeKeyringAttributeList *attrs = NULL;
+	guint id;
 
 	display_name = g_strdup_printf ("VPN %s secret for %s/%s/" NM_SETTING_VPN_SETTING_NAME,
 	                                secret_name, vpn_name, vpn_service_name);
@@ -625,9 +622,8 @@ vpn_helpers_save_secret (const char *vpn_uuid,
 	                                            KEYRING_SK_TAG,
 	                                            secret_name);
 
-	gnome_keyring_item_create (NULL, GNOME_KEYRING_ITEM_GENERIC_SECRET,
-	                           display_name, attrs, secret, TRUE,
-	                           keyring_secret_save_cb, NULL, NULL);
+	gnome_keyring_item_create_sync (NULL, GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                display_name, attrs, secret, TRUE, &id);
 	gnome_keyring_attribute_list_free (attrs);
 	g_free (display_name);
 }
@@ -1858,6 +1854,20 @@ nm_gconf_migrate_0_7_autoconnect_default (GConfClient *client)
 	gconf_client_suggest_sync (client, NULL);
 }
 
+static void
+_set_ignore_ca_cert (GConfClient *client, const char *uuid, gboolean phase2)
+{
+	char *key = NULL;
+
+	g_return_if_fail (uuid != NULL);
+
+	key = g_strdup_printf (APPLET_PREFS_PATH "/%s/%s",
+	                       phase2 ? "ignore-phase2-ca-cert" : "ignore-ca-cert",
+	                       uuid);
+	gconf_client_set_bool (client, key, TRUE, NULL);
+	g_free (key);
+}
+
 void
 nm_gconf_migrate_0_7_ca_cert_ignore (GConfClient *client)
 {
@@ -1886,7 +1896,7 @@ nm_gconf_migrate_0_7_ca_cert_ignore (GConfClient *client)
 		                          NM_SETTING_802_1X_SETTING_NAME,
 		                          &ignore_ca_cert);
 		if (ignore_ca_cert)
-			nm_gconf_set_ignore_ca_cert (uuid, FALSE, TRUE);
+			_set_ignore_ca_cert (client, uuid, FALSE);
 		/* delete old key */
 		unset_one_setting_property (client, dir,
 		                            NM_SETTING_802_1X_SETTING_NAME,
@@ -1897,7 +1907,7 @@ nm_gconf_migrate_0_7_ca_cert_ignore (GConfClient *client)
 		                          NM_SETTING_802_1X_SETTING_NAME,
 		                          &ignore_phase2_ca_cert);
 		if (ignore_phase2_ca_cert)
-			nm_gconf_set_ignore_ca_cert (uuid, TRUE, TRUE);
+			_set_ignore_ca_cert (client, uuid, TRUE);
 		unset_one_setting_property (client, dir,
 		                            NM_SETTING_802_1X_SETTING_NAME,
 		                            NMA_PHASE2_CA_CERT_IGNORE_TAG);
@@ -2009,3 +2019,135 @@ nm_gconf_migrate_0_7_certs (GConfClient *client)
 	gconf_client_suggest_sync (client, NULL);
 }
 
+#define NM_VPNC_PW_TYPE_SAVE   "save"
+#define NM_VPNC_PW_TYPE_ASK    "ask"
+#define NM_VPNC_PW_TYPE_UNUSED "unused"
+
+static NMSettingSecretFlags
+vpnc_type_to_flag (const char *vpnc_type)
+{
+	if (g_strcmp0 (vpnc_type, NM_VPNC_PW_TYPE_SAVE))
+		return NM_SETTING_SECRET_FLAG_NONE;
+	if (g_strcmp0 (vpnc_type, NM_VPNC_PW_TYPE_ASK))
+		return NM_SETTING_SECRET_FLAG_NOT_SAVED;
+	if (g_strcmp0 (vpnc_type, NM_VPNC_PW_TYPE_UNUSED))
+		return NM_SETTING_SECRET_FLAG_NOT_REQUIRED;
+	return NM_SETTING_SECRET_FLAG_NONE;
+}
+
+#define NM_VPNC_KEY_SECRET "IPSec secret"
+#define NM_VPNC_KEY_SECRET_TYPE "ipsec-secret-type"
+#define NM_VPNC_KEY_XAUTH_PASSWORD "Xauth password"
+#define NM_VPNC_KEY_XAUTH_PASSWORD_TYPE "xauth-password-type"
+
+void
+nm_gconf_migrate_09_secret_flags (GConfClient *client,
+                                  NMConnection *connection,
+                                  const char *setting_name)
+{
+	GList *found_list = NULL, *iter;
+	GnomeKeyringResult ret;
+	GError *error = NULL;
+	NMSetting *setting;
+	const char *uuid = nm_connection_get_uuid (connection);
+	const char *id = nm_connection_get_id (connection);
+	gboolean pk_pw_handled = FALSE;
+
+	setting = nm_connection_get_setting_by_name (connection, setting_name);
+	if (!setting)
+		return;
+
+	/* Migrate vpnc secret flags */
+	if (NM_IS_SETTING_VPN (setting)) {
+		NMSettingSecretFlags flags;
+		NMSettingVPN *s_vpn = NM_SETTING_VPN (setting);
+		const char *tmp;
+
+		/* vpnc stuff */
+		tmp = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_SECRET_TYPE);
+		if (tmp) {
+			flags = vpnc_type_to_flag (tmp) | NM_SETTING_SECRET_FLAG_AGENT_OWNED;
+			nm_setting_set_secret_flags (setting, NM_VPNC_KEY_SECRET, flags, NULL);
+		}
+
+		tmp = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD_TYPE);
+		if (tmp) {
+			flags = vpnc_type_to_flag (tmp) | NM_SETTING_SECRET_FLAG_AGENT_OWNED;
+			nm_setting_set_secret_flags (setting, NM_VPNC_KEY_XAUTH_PASSWORD, flags, NULL);
+		}
+	}
+
+	/* 802.1x connections might be 'always-ask' */
+	if (NM_IS_SETTING_802_1X (setting)) {
+		char *path;
+		gboolean ask;
+
+		path = g_strdup_printf (APPLET_PREFS_PATH "/8021x-password-always-ask/%s", uuid);
+		ask = gconf_client_get_bool (client, path, NULL);
+		g_free (path);
+
+		if (ask) {
+			nm_setting_set_secret_flags (setting,
+			                             NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD,
+			                             NM_SETTING_SECRET_FLAG_NOT_SAVED,
+			                             NULL);
+			nm_setting_set_secret_flags (setting,
+			                             NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD,
+			                             NM_SETTING_SECRET_FLAG_NOT_SAVED,
+			                             NULL);
+			pk_pw_handled = TRUE;
+		}
+	}
+
+	/* Find all secrets in the keyring */
+	ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      &found_list,
+	                                      KEYRING_UUID_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+										  uuid,
+	                                      KEYRING_SN_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      setting_name,
+	                                      NULL);
+	if (ret != GNOME_KEYRING_RESULT_OK)
+		return;
+	if (g_list_length (found_list) == 0)
+		return;
+
+	/* For each secret found in the keyring, stuff it into the hash table
+	 * so we can update the connection's secrets.
+	 */
+	for (iter = found_list; iter != NULL; iter = g_list_next (iter)) {
+		GnomeKeyringFound *found = (GnomeKeyringFound *) iter->data;
+		GnomeKeyringAttribute *attr;
+		int i;
+
+		for (i = 0; i < found->attributes->len; i++) {
+			attr = &(gnome_keyring_attribute_list_index (found->attributes, i));
+			if (   (strcmp (attr->name, KEYRING_SK_TAG) == 0)
+			    && (attr->type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING)) {
+				const char *key = attr->value.string;
+
+				/* Ignore handling of private key passwords if it was handled above */
+				if (   NM_IS_SETTING_802_1X (setting)
+				    && pk_pw_handled
+				    && (   g_strcmp0 (key, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD) == 0
+				        || g_strcmp0 (key, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD) == 0))
+					continue;
+
+				if (!nm_setting_set_secret_flags (setting,
+				                                  key,
+				                                  NM_SETTING_SECRET_FLAG_AGENT_OWNED,
+				                                  &error)) {
+					g_warning ("%s: failed to set secret flags for %s/%s",
+							   id, setting_name, attr->value.string);
+					g_clear_error (&error);
+				}
+				break;
+			}
+		}
+	}
+
+	gnome_keyring_found_list_free (found_list);
+}
+
diff --git a/src/gconf-helpers/gconf-upgrade.h b/src/gconf-helpers/gconf-upgrade.h
index 868601c..e571058 100644
--- a/src/gconf-helpers/gconf-upgrade.h
+++ b/src/gconf-helpers/gconf-upgrade.h
@@ -52,5 +52,9 @@ void nm_gconf_migrate_0_7_ca_cert_ignore (GConfClient *client);
 
 void nm_gconf_migrate_0_7_certs (GConfClient *client);
 
+void nm_gconf_migrate_09_secret_flags (GConfClient *client,
+                                       NMConnection *connection,
+                                       const char *setting_name);
+
 #endif	/* GCONF_UPGRADE_H */
 
diff --git a/src/gconf-helpers/tests/08vpnc.xml b/src/gconf-helpers/tests/08vpnc.xml
new file mode 100644
index 0000000..c4c24ae
--- /dev/null
+++ b/src/gconf-helpers/tests/08vpnc.xml
@@ -0,0 +1,127 @@
+<gconfentryfile>
+  <entrylist base="/system/networking/connections">
+    <entry>
+      <key>15/connection/autoconnect</key>
+      <value>
+        <bool>false</bool>
+      </value>
+    </entry>
+    <entry>
+      <key>15/connection/id</key>
+      <value>
+        <string>Test VPN</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/connection/name</key>
+      <value>
+        <string>connection</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/connection/timestamp</key>
+      <value>
+        <string>1296748524</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/connection/type</key>
+      <value>
+        <string>vpn</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/connection/uuid</key>
+      <value>
+        <string>5a4f5e4b-bfae-4ffc-ba9c-f73653a5070b</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/ipv4/addresses</key>
+      <value>
+        <list type="int">
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>15/ipv4/dns</key>
+      <value>
+        <list type="int">
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>15/ipv4/method</key>
+      <value>
+        <string>auto</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/ipv4/name</key>
+      <value>
+        <string>ipv4</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/ipv4/never-default</key>
+      <value>
+        <bool>true</bool>
+      </value>
+    </entry>
+    <entry>
+      <key>15/ipv4/routes</key>
+      <value>
+        <list type="int">
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/DPD 32@idle 32@timeout 32@@40 our@32 side@41@</key>
+      <value>
+        <string>0</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/IPSec 32@ID</key>
+      <value>
+        <string>blahblah</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/IPSec 32@gateway</key>
+      <value>
+        <string>1.2.3.4</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/NAT 32@Traversal 32@Mode</key>
+      <value>
+        <string>force-natt</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/Xauth 32@username</key>
+      <value>
+        <string>bsmith</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/ipsec-secret-type</key>
+      <value>
+        <string>save</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/service-type</key>
+      <value>
+        <string>org.freedesktop.NetworkManager.vpnc</string>
+      </value>
+    </entry>
+    <entry>
+      <key>15/vpn/xauth-password-type</key>
+      <value>
+        <string>ask</string>
+      </value>
+    </entry>
+  </entrylist>
+</gconfentryfile>
diff --git a/src/gconf-helpers/tests/08wifi.xml b/src/gconf-helpers/tests/08wifi.xml
new file mode 100644
index 0000000..a9b09c8
--- /dev/null
+++ b/src/gconf-helpers/tests/08wifi.xml
@@ -0,0 +1,96 @@
+<gconfentryfile>
+  <entrylist base="/system/networking/connections">
+    <entry>
+      <key>1/802-11-wireless/mode</key>
+      <value>
+        <string>infrastructure</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/name</key>
+      <value>
+        <string>802-11-wireless</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/security</key>
+      <value>
+        <string>802-11-wireless-security</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/seen-bssids</key>
+      <value>
+        <list type="string">
+            <value>
+              <string>00:bb:cc:dd:ee:ff</string>
+            </value>
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/ssid</key>
+      <value>
+        <list type="int">
+            <value>
+              <int>97</int>
+            </value>
+            <value>
+              <int>98</int>
+            </value>
+            <value>
+              <int>99</int>
+            </value>
+            <value>
+              <int>100</int>
+            </value>
+            <value>
+              <int>101</int>
+            </value>
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless-security/key-mgmt</key>
+      <value>
+        <string>wpa-psk</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless-security/name</key>
+      <value>
+        <string>802-11-wireless-security</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/id</key>
+      <value>
+        <string>Auto abcde</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/name</key>
+      <value>
+        <string>connection</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/timestamp</key>
+      <value>
+        <string>1248908514</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/type</key>
+      <value>
+        <string>802-11-wireless</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/uuid</key>
+      <value>
+        <string>ca99c473-b0fb-4e16-82dd-a886f3edd099</string>
+      </value>
+    </entry>
+  </entrylist>
+</gconfentryfile>
diff --git a/src/gconf-helpers/tests/Makefile.am b/src/gconf-helpers/tests/Makefile.am
new file mode 100644
index 0000000..49aa0ec
--- /dev/null
+++ b/src/gconf-helpers/tests/Makefile.am
@@ -0,0 +1,30 @@
+INCLUDES = -I$(top_srcdir)/src/utils
+
+noinst_PROGRAMS = test-upgrade
+
+test_upgrade_SOURCES = \
+	test-upgrade.c \
+	fake-keyring.h \
+	fake-keyring.c \
+	fake-gconf.h \
+	fake-gconf.c
+
+test_upgrade_CPPFLAGS = \
+	-I ${srcdir}/../ \
+	-DTESTDIR=\"$(srcdir)\" \
+	$(NMA_CFLAGS) \
+	$(GCONF_CFLAGS) \
+	$(GNOME_KEYRING_CFLAGS)
+
+test_upgrade_LDADD = \
+	${builddir}/../libgconf-helpers-test.la \
+	$(NMA_LIBS)
+
+check-local: test-upgrade
+	$(abs_builddir)/test-upgrade
+
+EXTRA_DIST = \
+	test-import.xml \
+	08wifi.xml \
+	08vpnc.xml
+
diff --git a/src/gconf-helpers/tests/fake-gconf.c b/src/gconf-helpers/tests/fake-gconf.c
new file mode 100644
index 0000000..918f11e
--- /dev/null
+++ b/src/gconf-helpers/tests/fake-gconf.c
@@ -0,0 +1,878 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2011 Red Hat, Inc.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
+#include "fake-gconf.h"
+
+static GConfClient *singleton = NULL;
+
+G_DEFINE_TYPE (GConfClient, gconf_client, G_TYPE_OBJECT)
+
+#define GCONF_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+                                     GCONF_TYPE_CLIENT, \
+                                     GConfClientPrivate))
+
+typedef struct {
+	GHashTable *keys;
+} GConfClientPrivate;
+
+GQuark
+gconf_error_quark (void)
+{
+	static GQuark quark;
+
+	if (G_UNLIKELY (!quark))
+		quark = g_quark_from_static_string ("gconf-error-quark");
+	return quark;
+}
+
+/****************************************************************/
+
+typedef struct {
+	GConfValueType type;
+	GConfValueType list_type;
+	GSList *v_list;
+	char *v_str;
+	gint v_int;
+	double v_float;
+	gboolean v_bool;
+} Value;
+
+GConfValue *
+gconf_value_new (GConfValueType vtype)
+{
+	Value *val;
+
+	val = g_malloc0 (sizeof (Value));
+	val->type = vtype;
+	return (GConfValue *) val;
+}
+
+void
+gconf_value_free (GConfValue *gv)
+{
+	Value *value = (Value *) gv;
+
+	g_slist_foreach (value->v_list, (GFunc) gconf_value_free, NULL);
+	g_slist_free (value->v_list);
+	g_free (value->v_str);
+	g_free (value);
+}
+
+GConfValue *
+gconf_value_copy (const GConfValue *gv)
+{
+	Value *src = (Value *) gv;
+	Value *new;
+	GSList *iter;
+
+	new = (Value *) gconf_value_new (src->type);
+	new->v_str = g_strdup (src->v_str);
+	new->v_float = src->v_float;
+	new->v_int = src->v_int;
+	new->v_bool = src->v_bool;
+
+	new->list_type = src->list_type;
+	for (iter = src->v_list; iter; iter = g_slist_next (iter))
+		new->v_list = g_slist_append (new->v_list, gconf_value_copy (iter->data));
+
+	return (GConfValue *) new;
+}
+
+int
+gconf_value_get_int (const GConfValue *gv)
+{
+	Value *value = (Value *) gv;
+
+	g_return_val_if_fail (value->type == GCONF_VALUE_INT, 0);
+	return value->v_int;
+}
+
+double
+gconf_value_get_float (const GConfValue *gv)
+{
+	Value *value = (Value *) gv;
+
+	g_return_val_if_fail (value->type == GCONF_VALUE_FLOAT, 0);
+	return value->v_float;
+}
+
+const char *
+gconf_value_get_string (const GConfValue *gv)
+{
+	Value *value = (Value *) gv;
+
+	g_return_val_if_fail (value->type == GCONF_VALUE_STRING, NULL);
+	return value->v_str;
+}
+
+gboolean
+gconf_value_get_bool (const GConfValue *gv)
+{
+	Value *value = (Value *) gv;
+
+	g_return_val_if_fail (value->type == GCONF_VALUE_BOOL, FALSE);
+	return value->v_bool;
+}
+
+GConfValueType
+gconf_value_get_list_type (const GConfValue *gv)
+{
+	Value *value = (Value *) gv;
+
+	g_return_val_if_fail (value->type == GCONF_VALUE_LIST, GCONF_VALUE_INVALID);
+	return value->list_type;
+}
+
+GSList *
+gconf_value_get_list (const GConfValue *gv)
+{
+	Value *value = (Value *) gv;
+
+	g_return_val_if_fail (value->type == GCONF_VALUE_LIST, NULL);
+	return value->v_list;
+}
+
+/*********************************************************/
+
+typedef struct {
+	char *key;
+	const GConfValue *value;
+	guint32 refcount;
+} Entry;
+
+GConfEntry *
+gconf_entry_new (const char *key, const GConfValue *val)
+{
+	Entry *e;
+
+	g_return_val_if_fail (key != NULL, NULL);
+	g_return_val_if_fail (val != NULL, NULL);
+
+	e = g_malloc0 (sizeof (Entry));
+	e->refcount = 1;
+	e->key = g_strdup (key);
+	e->value = val;
+	return (GConfEntry *) e;
+}
+
+const char *
+gconf_entry_get_key (const GConfEntry *ge)
+{
+	Entry *entry = (Entry *) ge;
+
+	g_return_val_if_fail (entry != NULL, NULL);
+	return entry->key;
+}
+
+GConfValue *
+gconf_entry_get_value (const GConfEntry *ge)
+{
+	Entry *entry = (Entry *) ge;
+
+	g_return_val_if_fail (entry != NULL, NULL);
+	return (GConfValue *) entry->value;
+}
+
+void
+gconf_entry_unref (GConfEntry *ge)
+{
+	Entry *entry = (Entry *) ge;
+
+	g_return_if_fail (entry != NULL);
+	g_return_if_fail (entry->refcount > 0);
+
+	entry->refcount--;
+	if (entry->refcount == 0) {
+		g_free (entry->key);
+		memset (entry, 0, sizeof (Entry));
+		g_free (entry);
+	}
+}
+
+/****************************************************************/
+
+void
+gconf_client_suggest_sync (GConfClient *client, GError **error)
+{
+}
+
+GConfValue *
+gconf_client_get (GConfClient *client, const gchar* key, GError **error)
+{
+	Value *v;
+
+	g_return_val_if_fail (client != NULL, NULL);
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	return v ? gconf_value_copy ((GConfValue *) v) : NULL;
+}
+
+GConfValue *
+gconf_client_get_without_default (GConfClient *client, const gchar* key, GError **error)
+{
+	g_return_val_if_fail (client != NULL, NULL);
+	return gconf_client_get (client, key, error);
+}
+
+gboolean
+gconf_client_get_bool (GConfClient *client, const gchar* key, GError **error)
+{
+	Value *v;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	if (v) {
+		g_return_val_if_fail (v->type == GCONF_VALUE_BOOL, FALSE);
+		return v->v_bool;
+	}
+	return FALSE;
+}
+
+gboolean
+gconf_client_set_bool (GConfClient *client, const char *key, gboolean val, GError **error)
+{
+	Value *v;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	if (v) {
+		if (v->type != GCONF_VALUE_BOOL) {
+			g_set_error (error, GCONF_ERROR, GCONF_ERROR_TYPE_MISMATCH, "expected boolean type");
+			return FALSE;
+		}
+		v->v_bool = val;
+	} else {
+		v = (Value *) gconf_value_new (GCONF_VALUE_BOOL);
+		v->v_bool = val;
+		g_hash_table_insert (GCONF_CLIENT_GET_PRIVATE (client)->keys, g_strdup (key), v);
+	}
+	return TRUE;
+}
+
+int
+gconf_client_get_int (GConfClient *client, const gchar* key, GError **error)
+{
+	Value *v;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	if (v) {
+		g_return_val_if_fail (v->type == GCONF_VALUE_INT, FALSE);
+		return v->v_int;
+	}
+	return 0;
+}
+
+gboolean
+gconf_client_set_int (GConfClient *client, const char *key, int val, GError **error)
+{
+	Value *v;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	if (v) {
+		if (v->type != GCONF_VALUE_INT) {
+			g_set_error (error, GCONF_ERROR, GCONF_ERROR_TYPE_MISMATCH, "expected int type");
+			return FALSE;
+		}
+		v->v_int = val;
+	} else {
+		v = (Value *) gconf_value_new (GCONF_VALUE_INT);
+		v->v_int = val;
+		g_hash_table_insert (GCONF_CLIENT_GET_PRIVATE (client)->keys, g_strdup (key), v);
+	}
+	return TRUE;
+}
+
+gboolean
+gconf_client_set_string (GConfClient *client, const char *key, const char *val, GError **error)
+{
+	Value *v;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+	g_return_val_if_fail (val != NULL, FALSE);
+
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	if (v) {
+		if (v->type != GCONF_VALUE_STRING) {
+			g_set_error (error, GCONF_ERROR, GCONF_ERROR_TYPE_MISMATCH, "expected string type");
+			return FALSE;
+		}
+		g_free (v->v_str);
+		v->v_str = g_strdup (val);
+	} else {
+		v = (Value *) gconf_value_new (GCONF_VALUE_STRING);
+		v->v_str = g_strdup (val);
+		g_hash_table_insert (GCONF_CLIENT_GET_PRIVATE (client)->keys, g_strdup (key), v);
+	}
+	return TRUE;
+}
+
+gboolean
+gconf_client_set_float (GConfClient *client, const char *key, double val, GError **error)
+{
+	Value *v;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	if (v) {
+		if (v->type != GCONF_VALUE_FLOAT) {
+			g_set_error (error, GCONF_ERROR, GCONF_ERROR_TYPE_MISMATCH, "expected float type");
+			return FALSE;
+		}
+		v->v_float = val;
+	} else {
+		v = (Value *) gconf_value_new (GCONF_VALUE_FLOAT);
+		v->v_float = val;
+		g_hash_table_insert (GCONF_CLIENT_GET_PRIVATE (client)->keys, g_strdup (key), v);
+	}
+	return TRUE;
+}
+
+gboolean
+gconf_client_set_list (GConfClient *client,
+                       const char *key,
+                       GConfValueType list_type,
+                       GSList *list,
+                       GError **error)
+{
+	Value *v;
+	gboolean add = FALSE;
+	GSList *iter;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+	g_return_val_if_fail (list != NULL, FALSE);
+
+	v = g_hash_table_lookup (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	if (v) {
+		if (v->type != GCONF_VALUE_LIST) {
+			g_set_error (error, GCONF_ERROR, GCONF_ERROR_TYPE_MISMATCH, "expected string type");
+			return FALSE;
+		}
+		g_slist_foreach (v->v_list, (GFunc) gconf_value_free, NULL);
+		g_slist_free (v->v_list);
+
+		v->list_type = list_type;
+	} else {
+		v = (Value *) gconf_value_new (GCONF_VALUE_LIST);
+		v->list_type = list_type;
+		add = TRUE;
+	}
+
+	for (iter = list; iter; iter = g_slist_next (iter)) {
+		Value *nv = (Value *) gconf_value_new (list_type);
+
+		switch (list_type) {
+		case GCONF_VALUE_STRING:
+			nv->v_str = g_strdup (iter->data);
+			break;
+		case GCONF_VALUE_BOOL:
+			nv->v_bool = !!iter->data;
+			break;
+		case GCONF_VALUE_INT:
+			nv->v_int = GPOINTER_TO_INT (iter->data);
+			break;
+		default:
+			gconf_value_free ((GConfValue *) nv);
+			nv = NULL;
+			g_warn_if_reached ();
+			break;
+		}
+
+		if (nv)
+			v->v_list = g_slist_append (v->v_list, nv);
+	}
+
+	if (add)
+		g_hash_table_insert (GCONF_CLIENT_GET_PRIVATE (client)->keys, g_strdup (key), v);
+
+	return TRUE;
+}
+
+static gboolean
+find_in_list (GSList *list, const char *item)
+{
+	GSList *iter;
+
+	for (iter = list; iter; iter = g_slist_next (iter)) {
+		if (g_strcmp0 (iter->data, item) == 0)
+			return TRUE;
+	}
+	return FALSE;
+}
+
+GSList *
+gconf_client_all_dirs (GConfClient *client, const char *dir, GError **error)
+{
+	GHashTableIter iter;
+	const char *tmp = NULL;
+	GSList *dirs = NULL;
+	char *normalized;
+
+	g_return_val_if_fail (client != NULL, NULL);
+	g_return_val_if_fail (dir != NULL, NULL);
+
+	if (dir[strlen (dir) - 1] == '/')
+		normalized = g_strdup (dir);
+	else
+		normalized = g_strdup_printf ("%s/", dir);
+
+	g_hash_table_iter_init (&iter, GCONF_CLIENT_GET_PRIVATE (client)->keys);
+	while (g_hash_table_iter_next (&iter, (gpointer) &tmp, NULL)) {
+		char *foo, *z;
+
+		/* Is this key a child of the directory? */
+		if (strncmp (tmp, normalized, strlen (normalized)) != 0)
+			continue;
+
+		/* Dupe key and add to the list if it's a directory */
+		foo = g_strdup (tmp);
+		z = strchr (foo + strlen (normalized), '/');
+		if (z) {
+			*z = '\0';  /* chop at the / */
+			if (!find_in_list (dirs, foo))
+				dirs = g_slist_prepend (dirs, g_strdup (foo));
+		}
+		g_free (foo);
+	}
+
+	g_free (normalized);
+	return dirs;
+}
+
+static gint
+sort_func (gconstpointer a, gconstpointer b)
+{
+	const GConfEntry *ea = a;
+	const GConfEntry *eb = b;
+
+	if (ea == eb)
+		return 0;
+	if (ea && !eb)
+		return 1;
+	if (!ea && eb)
+		return -1;
+	g_assert (ea && eb);
+	return g_strcmp0 (ea->key, eb->key);
+}
+
+GSList *
+gconf_client_all_entries (GConfClient *client, const char *dir, GError **error)
+{
+	GHashTableIter iter;
+	const char *tmp = NULL;
+	GSList *entries = NULL;
+	GConfValue *val = NULL;
+	char *normalized;
+
+	g_return_val_if_fail (client != NULL, NULL);
+	g_return_val_if_fail (dir != NULL, NULL);
+
+	if (dir[strlen (dir) - 1] == '/')
+		normalized = g_strdup (dir);
+	else
+		normalized = g_strdup_printf ("%s/", dir);
+
+	g_hash_table_iter_init (&iter, GCONF_CLIENT_GET_PRIVATE (client)->keys);
+	while (g_hash_table_iter_next (&iter, (gpointer) &tmp, (gpointer) &val)) {
+		/* Is this key a child of the directory? */
+		if (strncmp (tmp, normalized, strlen (normalized)) == 0) {
+			/* only children won't have another / in the key name */
+			if (strchr (tmp + strlen (normalized), '/') == NULL) {
+				entries = g_slist_insert_sorted (entries,
+				                                 gconf_entry_new (tmp, val),
+				                                 sort_func);
+			}
+		}
+	}
+
+	return entries;
+}
+
+gboolean
+gconf_client_recursive_unset (GConfClient *client,
+                              const char *key,
+                              GConfUnsetFlags flags,
+                              GError **error)
+{
+	GConfClientPrivate *priv;
+	GHashTableIter iter;
+	char *others;
+	const char *tmp = NULL;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+	g_return_val_if_fail (key != NULL, FALSE);
+
+	priv = GCONF_CLIENT_GET_PRIVATE (client);
+	g_hash_table_remove (priv->keys, key);
+
+	/* Remove children of key too*/
+	if (key[strlen (key) - 1] == '/')
+		others = g_strdup (key);
+	else
+		others = g_strdup_printf ("%s/", key);
+
+	g_hash_table_iter_init (&iter, priv->keys);
+	while (g_hash_table_iter_next (&iter, (gpointer) &tmp, NULL)) {
+		if (strncmp (others, tmp, strlen (others)) == 0)
+			g_hash_table_iter_remove (&iter);
+	}
+	g_free (others);
+
+	return TRUE;
+}
+
+gboolean
+gconf_client_unset (GConfClient *client, const gchar *key, GError **error)
+{
+	g_hash_table_remove (GCONF_CLIENT_GET_PRIVATE (client)->keys, key);
+	return TRUE;
+}
+
+GConfClient *
+gconf_client_get_default (void)
+{
+	if (singleton)
+		g_object_ref (singleton);
+	else
+		singleton = g_object_new (GCONF_TYPE_CLIENT, NULL);\
+
+	return singleton;
+}
+
+static const gchar invalid_chars[] = " \t\r\n\"$&<>,+=#!()'|{}[]?~`;%\\";
+
+/* Copied from GConf */
+char*
+gconf_escape_key (const char *arbitrary_text,
+                  int         len)
+{
+  const char *p;
+  const char *end;
+  GString *retval;
+
+  g_return_val_if_fail (arbitrary_text != NULL, NULL);
+  
+  /* Nearly all characters we would normally use for escaping aren't allowed in key
+   * names, so we use @ for that.
+   *
+   * Invalid chars and @ itself are escaped as @xxx@ where xxx is the
+   * Latin-1 value in decimal
+   */
+
+  if (len < 0)
+    len = strlen (arbitrary_text);
+
+  retval = g_string_sized_new (len);
+
+  p = arbitrary_text;
+  end = arbitrary_text + len;
+  while (p != end)
+    {
+      if (*p == '/' || *p == '.' || *p == '@' || ((guchar) *p) > 127 ||
+          strchr (invalid_chars, *p))
+        {
+          g_string_append_printf (retval, "@%u@", (guchar) *p);
+        }
+      else
+        g_string_append_c (retval, *p);
+      
+      ++p;
+    }
+
+  return g_string_free (retval, FALSE);
+}
+
+/* Copied from GConf */
+char*
+gconf_unescape_key (const char *escaped_key,
+                    int         len)
+{
+  const char *p;
+  const char *end;
+  const char *start_seq;
+  GString *retval;
+
+  g_return_val_if_fail (escaped_key != NULL, NULL);
+  
+  if (len < 0)
+    len = strlen (escaped_key);
+
+  retval = g_string_new (NULL);
+
+  p = escaped_key;
+  end = escaped_key + len;
+  start_seq = NULL;
+  while (p != end)
+    {
+      if (start_seq)
+        {
+          if (*p == '@')
+            {
+              /* *p is the @ that ends a seq */
+              char *end_seq;
+              guchar val;
+              
+              val = strtoul (start_seq, &end_seq, 10);
+              if (start_seq != end_seq)
+                g_string_append_c (retval, val);
+              
+              start_seq = NULL;
+            }
+        }
+      else
+        {
+          if (*p == '@')
+            start_seq = p + 1;
+          else
+            g_string_append_c (retval, *p);
+        }
+
+      ++p;
+    }
+
+  return g_string_free (retval, FALSE);
+}
+
+/*********************************************************/
+
+static gboolean
+extract_item (char *line, const char *start, const char *end, char **val)
+{
+	char *p;
+
+	if (!g_str_has_prefix (line, start))
+		return FALSE;
+	line += strlen (start);
+	p = strstr (line, end);
+	g_return_val_if_fail (p != NULL, FALSE);
+	*p = '\0';
+	*val = g_strdup (line);
+	return TRUE;
+}
+
+#define LIST_TYPE_NONE 0
+#define LIST_TYPE_STR  1
+#define LIST_TYPE_INT  2
+
+gboolean
+fake_gconf_add_xml (GConfClient *client, const char *path_to_xml)
+{
+	GError *error = NULL;
+	char *contents = NULL;
+	char **lines, **iter;
+	gboolean found_start = FALSE;
+	gboolean found_base = FALSE;
+	gboolean in_entry = FALSE;
+	guint32 in_value = 0;
+	char *key = NULL;
+	guint list_type = LIST_TYPE_NONE;
+	GSList *list_val = NULL;
+	char *str_val = NULL;
+	int int_val = 0;
+	gboolean int_set = FALSE;
+	gboolean bool_val = FALSE;
+	gboolean bool_set = FALSE;
+	gboolean success = FALSE;
+
+	if (!g_file_get_contents (path_to_xml, &contents, NULL, &error)) {
+		g_warning ("%s: failed to load '%s': %s", __func__, path_to_xml, error->message);
+		g_clear_error (&error);
+		return FALSE;
+	}
+
+	lines = g_strsplit_set (contents, "\n\r", -1);
+	g_free (contents);
+	if (!lines) {
+		g_warning ("%s: failed to split '%s' contents", __func__, path_to_xml);
+		return FALSE;
+	}
+
+	for (iter = lines; iter && *iter; iter++) {
+		char *line = *iter;
+		char *tmp = NULL;
+
+		line = g_strstrip (line);
+		if (!strlen (line))
+			continue;
+
+		if (!found_start) {
+			if (g_str_has_prefix (line, "<gconfentryfile>")) {
+				found_start = TRUE;
+				continue;
+			} else {
+				g_warning ("%s: file does not start with <gconfentryfile>", __func__);
+				break;
+			}
+		}
+
+		if (!found_base) {
+			if (g_str_has_prefix (line, "<entrylist base=\"/system/networking/connections\">")) {
+				found_base = TRUE;
+				continue;
+			} else {
+				g_warning ("%s: did not find <entrylist ...> early enough", __func__);
+				break;
+			}
+		}
+
+		if (strcmp (line, "<entry>") == 0) {
+			in_entry = TRUE;
+			g_warn_if_fail (key == NULL);
+			continue;
+		}
+
+		if (strcmp (line, "</entry>") == 0) {
+			/* Write the entry */
+			g_warn_if_fail (in_entry == TRUE);
+			g_warn_if_fail (in_value == 0);
+			g_warn_if_fail (key != NULL);
+
+			if (list_type == LIST_TYPE_STR && list_val) {
+				gconf_client_set_list (client, key, GCONF_VALUE_STRING, list_val, NULL);
+				g_slist_foreach (list_val, (GFunc) g_free, NULL);
+			} else if (list_type == LIST_TYPE_INT && list_val)
+				gconf_client_set_list (client, key, GCONF_VALUE_INT, list_val, NULL);
+			else if (str_val) {
+				gconf_client_set_string (client, key, str_val, NULL);
+				g_free (str_val);
+				str_val = NULL;
+			} else if (int_set) {
+				gconf_client_set_int (client, key, int_val, NULL);
+				int_val = 0;
+				int_set = FALSE;
+			} else if (bool_set) {
+				gconf_client_set_bool (client, key, bool_val, NULL);
+				bool_set = FALSE;
+			}
+
+			g_slist_free (list_val);
+			list_val = NULL;
+			list_type = LIST_TYPE_NONE;
+			g_free (key);
+			key = NULL;
+			in_entry = FALSE;
+			continue;
+		}
+
+		if (strcmp (line, "<value>") == 0) {
+			in_value++;
+			continue;
+		}
+
+		if (strcmp (line, "</value>") == 0) {
+			in_value--;
+			continue;
+		}
+
+		if (strcmp (line, "<list type=\"string\">") == 0) {
+			list_type = LIST_TYPE_STR;
+			continue;
+		}
+
+		if (strcmp (line, "<list type=\"int\">") == 0) {
+			list_type = LIST_TYPE_INT;
+			continue;
+		}
+
+		if (strcmp (line, "</list>") == 0)
+			continue;
+
+		if (strcmp (line, "</gconfentryfile>") == 0) {
+			success = TRUE;
+			continue;
+		}
+
+		if (in_value == 0) {
+			if (extract_item (line, "<key>", "</key>", &tmp)) {
+				key = g_strdup_printf ("/system/networking/connections/%s", tmp);
+				continue;
+			}
+		} else if (in_value == 1 || in_value == 2) {
+			if (extract_item (line, "<string>", "</string>", &str_val)) {
+				if (list_type == LIST_TYPE_STR) {
+					list_val = g_slist_append (list_val, str_val);
+					str_val = NULL;
+				}
+				continue;
+			}
+			if (extract_item (line, "<int>", "</int>", &tmp)) {
+				int_val = (int) strtol (tmp, NULL, 10);
+				if (list_type == LIST_TYPE_INT)
+					list_val = g_slist_append (list_val, GINT_TO_POINTER (int_val));
+				else
+					int_set = TRUE;
+				continue;
+			}
+			if (g_str_has_prefix (line, "<bool>")) {
+				if (strcmp (line, "<bool>true</bool>") == 0)
+					bool_val = TRUE;
+				bool_set = TRUE;
+				continue;
+			}
+		}
+	}
+	g_strfreev (lines);
+
+	return success;
+}
+
+/*********************************************************/
+
+static void
+gconf_client_init (GConfClient *self)
+{
+	GConfClientPrivate *priv = GCONF_CLIENT_GET_PRIVATE (self);
+
+	priv->keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) gconf_value_free);
+}
+
+static void
+finalize (GObject *object)
+{
+	GConfClientPrivate *priv = GCONF_CLIENT_GET_PRIVATE (object);
+
+	g_hash_table_destroy (priv->keys);
+	G_OBJECT_CLASS (gconf_client_parent_class)->finalize (object);
+	singleton = NULL;
+}
+
+static void
+gconf_client_class_init (GConfClientClass *config_class)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (config_class);
+
+	g_type_class_add_private (config_class, sizeof (GConfClientPrivate));
+
+	/* virtual methods */
+	object_class->finalize = finalize;
+
+}
diff --git a/src/gconf-helpers/tests/fake-gconf.h b/src/gconf-helpers/tests/fake-gconf.h
new file mode 100644
index 0000000..85a1f68
--- /dev/null
+++ b/src/gconf-helpers/tests/fake-gconf.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2011 Red Hat, Inc.
+ */
+
+#ifndef _FAKE_GCONF_H
+
+#include <gconf/gconf-client.h>
+
+gboolean fake_gconf_add_xml (GConfClient *client, const char *path_to_xml);
+
+#endif  /* _FAKE_GCONF_H_ */
diff --git a/src/gconf-helpers/tests/fake-keyring.c b/src/gconf-helpers/tests/fake-keyring.c
new file mode 100644
index 0000000..57fd43a
--- /dev/null
+++ b/src/gconf-helpers/tests/fake-keyring.c
@@ -0,0 +1,429 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2011 Red Hat, Inc.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <glib.h>
+
+#include <gnome-keyring.h>
+
+static GSList *secrets = NULL;
+
+typedef struct {
+	guint32 item_id;
+	char *keyring;
+	GnomeKeyringItemType stype;
+	char *name;
+	char *secret;
+	GnomeKeyringAttributeList *attrs;
+	char *user;
+	char *server;
+	char *protocol;
+} Secret;
+
+static Secret *
+secret_new (GnomeKeyringItemType type,
+            const char *keyring,
+            const char *name,
+            const char *secret,
+            GnomeKeyringAttributeList *attrs,
+            const char *user,
+            const char *server,
+            const char *protocol)
+{
+	Secret *s;
+	static guint32 counter = 1;
+
+	s = g_malloc0 (sizeof (Secret));
+	s->item_id = counter++;
+	s->keyring = g_strdup (keyring);
+	s->name = g_strdup (name);
+	s->secret = g_strdup (secret);
+	s->stype = type;
+	s->attrs = gnome_keyring_attribute_list_copy (attrs);
+	s->user = g_strdup (user);
+	s->server = g_strdup (server);
+	s->protocol = g_strdup (protocol);
+	return s;
+}
+
+static void
+secret_free (Secret *s)
+{
+	g_free (s->keyring);
+	g_free (s->name);
+	g_free (s->secret);
+	gnome_keyring_attribute_list_free (s->attrs);
+	g_free (s->user);
+	g_free (s->server);
+	g_free (s->protocol);
+	memset (s, 0, sizeof (*s));
+	g_free (s);
+}
+
+static gboolean
+match_attribute (GnomeKeyringAttribute *needle, GnomeKeyringAttributeList *haystack)
+{
+	int i;
+
+	for (i = 0; i < haystack->len; i++) {
+		GnomeKeyringAttribute *cmp = &(gnome_keyring_attribute_list_index (haystack, i));
+
+		if (g_strcmp0 (needle->name, cmp->name))
+			continue;
+		if (needle->type != cmp->type)
+			continue;
+		if (needle->type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING) {
+			if (g_strcmp0 (needle->value.string, cmp->value.string))
+				continue;
+		} else if (needle->type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING) {
+			if (needle->value.integer != cmp->value.integer)
+				continue;
+		} else
+			g_assert_not_reached ();
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static Secret *
+find_one_secret (const char *keyring,
+                 GnomeKeyringItemType type,
+                 GnomeKeyringAttributeList *attributes)
+{
+	GSList *iter;
+
+	g_return_val_if_fail (attributes != NULL, NULL);
+
+	for (iter = secrets; iter; iter = g_slist_next (iter)) {
+		Secret *candidate = iter->data;
+		gboolean same = TRUE;
+		int i;
+
+		if (candidate->stype != type)
+			continue;
+		if (!candidate->attrs || (candidate->attrs->len != attributes->len))
+			continue;
+		if (g_strcmp0 (keyring, candidate->keyring))
+			continue;
+
+		/* match all attributes */
+		for (i = 0; i < attributes->len; i++) {
+			GnomeKeyringAttribute *attr = &(gnome_keyring_attribute_list_index (attributes, i));
+
+			if (!match_attribute (attr, candidate->attrs)) {
+				same = FALSE;
+				break;
+			}
+		}
+
+		if (same)
+			return candidate;
+	}
+	return NULL;
+}
+
+GnomeKeyringResult
+gnome_keyring_item_create_sync (const char *keyring,
+                                GnomeKeyringItemType type,
+                                const char *display_name,
+                                GnomeKeyringAttributeList *attributes,
+                                const char *secret,
+                                gboolean update_if_exists,
+                                guint32 *item_id)
+{
+	Secret *s;
+
+	s = find_one_secret (keyring, type, attributes);
+	if (s) {
+		if (!update_if_exists)
+			return GNOME_KEYRING_RESULT_OK;
+
+		g_free (s->name);
+		s->name = g_strdup (display_name);
+		g_free (s->secret);
+		s->secret = g_strdup (secret);
+	} else {
+		s = secret_new (type, keyring, display_name, secret, attributes, NULL, NULL, NULL);
+		secrets = g_slist_append (secrets, s);
+	}
+
+	if (item_id)
+		*item_id = s->item_id;
+
+	return GNOME_KEYRING_RESULT_OK;
+}
+
+GnomeKeyringResult
+gnome_keyring_item_delete_sync (const char *keyring, guint32 id)
+{
+	GSList *iter;
+
+	for (iter = secrets; iter; iter = g_slist_next (iter)) {
+		Secret *s = iter->data;
+
+		if (s->item_id == id) {
+			secrets = g_slist_remove (secrets, s);
+			secret_free (s);
+			break;
+		}
+	}
+
+	return GNOME_KEYRING_RESULT_OK;
+}
+
+/* Copied from gnome-keyring */
+static GnomeKeyringAttributeList *
+make_attribute_list_va (va_list args)
+{
+	GnomeKeyringAttributeList *attributes;
+	GnomeKeyringAttribute attribute;
+	char *str;
+	guint32 val;
+
+	attributes = g_array_new (FALSE, FALSE, sizeof (GnomeKeyringAttribute));
+
+	while ((attribute.name = va_arg (args, char *)) != NULL) {
+		attribute.type = va_arg (args, GnomeKeyringAttributeType);
+
+		switch (attribute.type) {
+		case GNOME_KEYRING_ATTRIBUTE_TYPE_STRING:
+			str = va_arg (args, char *);
+			attribute.value.string = str;
+			g_array_append_val (attributes, attribute);
+			break;
+		case GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32:
+			val = va_arg (args, guint32);
+			attribute.value.integer = val;
+			g_array_append_val (attributes, attribute);
+			break;
+		default:
+			g_array_free (attributes, TRUE);
+			return NULL;
+		}
+	}
+	return attributes;
+}
+
+GnomeKeyringResult
+gnome_keyring_find_itemsv_sync  (GnomeKeyringItemType type,
+                                 GList **found,
+                                 ...)
+{
+	GnomeKeyringAttributeList *attributes;
+	va_list args;
+	GSList *iter;
+
+	g_return_val_if_fail (found, GNOME_KEYRING_RESULT_BAD_ARGUMENTS);
+
+	va_start (args, found);
+	attributes = make_attribute_list_va (args);
+	va_end (args);
+
+	g_return_val_if_fail (attributes != NULL, GNOME_KEYRING_RESULT_BAD_ARGUMENTS);
+
+	for (iter = secrets; iter; iter = g_slist_next (iter)) {
+		Secret *candidate = iter->data;
+		gboolean same = TRUE;
+		int i;
+
+		if (candidate->stype != type)
+			continue;
+		if (!candidate->attrs)
+			continue;
+
+		/* match all attributes */
+		for (i = 0; i < attributes->len; i++) {
+			GnomeKeyringAttribute *attr = &(gnome_keyring_attribute_list_index (attributes, i));
+
+			if (!match_attribute (attr, candidate->attrs)) {
+				same = FALSE;
+				break;
+			}
+		}
+
+		if (same && found) {
+			GnomeKeyringFound *f;
+
+			f = g_malloc0 (sizeof (GnomeKeyringFound));
+			f->item_id = candidate->item_id;
+			f->keyring = g_strdup (candidate->keyring);
+			f->attributes = gnome_keyring_attribute_list_copy (candidate->attrs);
+			f->secret = g_strdup (candidate->secret);
+			*found = g_list_append (*found, f);
+		}
+	}
+	return GNOME_KEYRING_RESULT_OK;
+}
+
+GnomeKeyringResult
+gnome_keyring_find_network_password_sync (const char *user,
+                                          const char *domain,
+                                          const char *server,
+                                          const char *object,
+                                          const char *protocol,
+                                          const char *authtype,
+                                          guint32 port,
+                                          GList **results)
+{
+	GSList *iter;
+
+	g_return_val_if_fail (results != NULL, GNOME_KEYRING_RESULT_OK);
+
+	for (iter = secrets; iter; iter = g_slist_next (iter)) {
+		Secret *candidate = iter->data;
+		GnomeKeyringNetworkPasswordData *p;
+
+		if (candidate->stype != GNOME_KEYRING_ITEM_NETWORK_PASSWORD)
+			continue;
+		if (g_strcmp0 (candidate->user, user))
+			continue;
+		if (g_strcmp0 (candidate->server, server))
+			continue;
+		if (g_strcmp0 (candidate->protocol, protocol))
+			continue;
+
+		p = g_malloc0 (sizeof (GnomeKeyringNetworkPasswordData));
+		p->keyring = g_strdup (candidate->keyring);
+		p->item_id = candidate->item_id;
+		p->user = g_strdup (candidate->user);
+		p->server = g_strdup (candidate->server);
+		p->protocol = g_strdup (candidate->protocol);
+		p->password = g_strdup (candidate->secret);
+		*results = g_list_append (*results, p);
+	}
+
+	return GNOME_KEYRING_RESULT_OK;
+}
+
+/**********************************************************/
+/* This copied from gnome-keyring and is LGPLv2+ */
+
+void
+gnome_keyring_network_password_free (GnomeKeyringNetworkPasswordData *data)
+{
+	if (!data)
+		return;
+
+	g_free (data->keyring);
+	g_free (data->protocol);
+	g_free (data->server);
+	g_free (data->object);
+	g_free (data->authtype);
+	g_free (data->user);
+	g_free (data->domain);
+	g_free (data->password);
+
+	g_free (data);
+}
+
+void
+gnome_keyring_network_password_list_free (GList *list)
+{
+	g_list_foreach (list, (GFunc)gnome_keyring_network_password_free, NULL);
+	g_list_free (list);
+}
+
+GnomeKeyringAttributeList *
+gnome_keyring_attribute_list_copy (GnomeKeyringAttributeList *attributes)
+{
+	GnomeKeyringAttribute *array;
+	GnomeKeyringAttributeList *copy;
+	int i;
+
+	if (attributes == NULL)
+		return NULL;
+
+	copy = g_array_sized_new (FALSE, FALSE, sizeof (GnomeKeyringAttribute), attributes->len);
+
+	copy->len = attributes->len;
+	memcpy (copy->data, attributes->data, sizeof (GnomeKeyringAttribute) * attributes->len);
+
+	array = (GnomeKeyringAttribute *)copy->data;
+	for (i = 0; i < copy->len; i++) {
+		array[i].name = g_strdup (array[i].name);
+		if (array[i].type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING) {
+			array[i].value.string = g_strdup (array[i].value.string);
+		}
+	}
+	return copy;
+}
+
+void
+gnome_keyring_attribute_list_free (GnomeKeyringAttributeList *attributes)
+{
+	GnomeKeyringAttribute *array;
+	int i;
+
+	if (attributes == NULL)
+		return;
+
+	array = (GnomeKeyringAttribute *)attributes->data;
+	for (i = 0; i < attributes->len; i++) {
+		g_free (array[i].name);
+		if (array[i].type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING) {
+			g_free (array[i].value.string);
+		}
+	}
+
+	g_array_free (attributes, TRUE);
+}
+
+void
+gnome_keyring_attribute_list_append_string (GnomeKeyringAttributeList *attributes,
+                                            const char *name, const char *value)
+{
+	GnomeKeyringAttribute attribute;
+
+	g_return_if_fail (attributes);
+	g_return_if_fail (name);
+
+	attribute.name = g_strdup (name);
+	attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
+	attribute.value.string = g_strdup (value);
+
+	g_array_append_val (attributes, attribute);
+}
+
+void
+gnome_keyring_found_free (GnomeKeyringFound *found)
+{
+	if (found == NULL)
+		return;
+	g_free (found->keyring);
+	g_free (found->secret);
+	gnome_keyring_attribute_list_free (found->attributes);
+	g_free (found);
+}
+
+void
+gnome_keyring_found_list_free (GList *found_list)
+{
+	g_list_foreach (found_list, (GFunc) gnome_keyring_found_free, NULL);
+	g_list_free (found_list);
+}
+
+/* End copy from gnome-keyring */
+/******************************************************/
diff --git a/src/gconf-helpers/tests/fake-keyring.h b/src/gconf-helpers/tests/fake-keyring.h
new file mode 100644
index 0000000..f3e5d7f
--- /dev/null
+++ b/src/gconf-helpers/tests/fake-keyring.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2011 Red Hat, Inc.
+ */
+
+#ifndef _FAKE_KEYRING_H
+
+void fake_keyring_clear (void);
+
+#endif  /* _FAKE_KEYRING_H_ */
diff --git a/src/gconf-helpers/tests/test-import.xml b/src/gconf-helpers/tests/test-import.xml
new file mode 100644
index 0000000..bc42508
--- /dev/null
+++ b/src/gconf-helpers/tests/test-import.xml
@@ -0,0 +1,207 @@
+<gconfentryfile>
+  <entrylist base="/system/networking/connections">
+    <entry>
+      <key>1/802-11-wireless/mode</key>
+      <value>
+        <string>infrastructure</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/name</key>
+      <value>
+        <string>802-11-wireless</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/security</key>
+      <value>
+        <string>802-11-wireless-security</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/seen-bssids</key>
+      <value>
+        <list type="string">
+            <value>
+              <string>00:bb:cc:dd:ee:ff</string>
+            </value>
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless/ssid</key>
+      <value>
+        <list type="int">
+            <value>
+              <int>97</int>
+            </value>
+            <value>
+              <int>98</int>
+            </value>
+            <value>
+              <int>99</int>
+            </value>
+            <value>
+              <int>100</int>
+            </value>
+            <value>
+              <int>101</int>
+            </value>
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless-security/key-mgmt</key>
+      <value>
+        <string>wpa-psk</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/802-11-wireless-security/name</key>
+      <value>
+        <string>802-11-wireless-security</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/id</key>
+      <value>
+        <string>Auto abcde</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/name</key>
+      <value>
+        <string>connection</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/timestamp</key>
+      <value>
+        <string>1248908514</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/type</key>
+      <value>
+        <string>802-11-wireless</string>
+      </value>
+    </entry>
+    <entry>
+      <key>1/connection/uuid</key>
+      <value>
+        <string>ca99c473-b0fb-4e16-82dd-a886f3edd099</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/connection/autoconnect</key>
+      <value>
+        <bool>true</bool>
+      </value>
+    </entry>
+    <entry>
+      <key>17/connection/id</key>
+      <value>
+        <string>AT&amp;T MEdia Net</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/connection/name</key>
+      <value>
+        <string>connection</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/connection/timestamp</key>
+      <value>
+        <string>1288459781</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/connection/type</key>
+      <value>
+        <string>gsm</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/connection/uuid</key>
+      <value>
+        <string>783e0012-c787-4244-8dfe-c1834566ba86</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/gsm/apn</key>
+      <value>
+        <string>WAP.CINGULAR</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/gsm/name</key>
+      <value>
+        <string>gsm</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/gsm/number</key>
+      <value>
+        <string>*99#</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/gsm/username</key>
+      <value>
+        <string>WAP CINGULARGPRS COM</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/ipv4/addresses</key>
+      <value>
+        <list type="int">
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>17/ipv4/dns</key>
+      <value>
+        <list type="int">
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>17/ipv4/method</key>
+      <value>
+        <string>auto</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/ipv4/name</key>
+      <value>
+        <string>ipv4</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/ipv4/routes</key>
+      <value>
+        <list type="int">
+        </list>
+      </value>
+    </entry>
+    <entry>
+      <key>17/ppp/name</key>
+      <value>
+        <string>ppp</string>
+      </value>
+    </entry>
+    <entry>
+      <key>17/serial/baud</key>
+      <value>
+        <int>115200</int>
+      </value>
+    </entry>
+    <entry>
+      <key>17/serial/name</key>
+      <value>
+        <string>serial</string>
+      </value>
+    </entry>
+  </entrylist>
+</gconfentryfile>
diff --git a/src/gconf-helpers/tests/test-upgrade.c b/src/gconf-helpers/tests/test-upgrade.c
new file mode 100644
index 0000000..2152d09
--- /dev/null
+++ b/src/gconf-helpers/tests/test-upgrade.c
@@ -0,0 +1,389 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2011 Red Hat, Inc.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include <gnome-keyring.h>
+
+#include <nm-setting-wireless-security.h>
+#include <nm-setting-vpn.h>
+
+#include "gconf-helpers.h"
+#include "fake-gconf.h"
+#include "fake-keyring.h"
+
+#define BASE_PATH "/system/networking/connections/"
+
+static void
+test_import_xml (void)
+{
+	GConfClient *client;
+	GConfValue *val, *item;
+	GConfEntry *entry;
+	const char *tmp;
+	GSList *list;
+	gboolean success;
+
+	client = gconf_client_get_default ();
+	success = fake_gconf_add_xml (client, TESTDIR "/test-import.xml");
+	g_assert (success);
+
+	val = gconf_client_get (client, BASE_PATH "1/802-11-wireless/mode", NULL);
+	g_assert (val);
+	g_assert_cmpint (val->type, ==, GCONF_VALUE_STRING);
+	tmp = gconf_value_get_string (val);
+	g_assert (tmp);
+	g_assert_cmpstr (tmp, ==, "infrastructure");
+	gconf_value_free (val);
+
+	val = gconf_client_get (client, BASE_PATH "1/802-11-wireless/seen-bssids", NULL);
+	g_assert (val);
+	g_assert_cmpint (val->type, ==, GCONF_VALUE_LIST);
+	g_assert_cmpint (gconf_value_get_list_type (val), ==, GCONF_VALUE_STRING);
+	list = gconf_value_get_list (val);
+	g_assert_cmpint (g_slist_length (list), ==, 1);
+	item = g_slist_nth_data (list, 0);
+	g_assert_cmpint (item->type, ==, GCONF_VALUE_STRING);
+	g_assert_cmpstr (gconf_value_get_string (item), ==, "00:bb:cc:dd:ee:ff");
+	gconf_value_free (val);
+
+	val = gconf_client_get (client, BASE_PATH "1/802-11-wireless/ssid", NULL);
+	g_assert (val);
+	g_assert_cmpint (val->type, ==, GCONF_VALUE_LIST);
+	g_assert_cmpint (gconf_value_get_list_type (val), ==, GCONF_VALUE_INT);
+	list = gconf_value_get_list (val);
+	g_assert_cmpint (g_slist_length (list), ==, 5);
+	item = g_slist_nth_data (list, 0);
+	g_assert_cmpint (item->type, ==, GCONF_VALUE_INT);
+	g_assert_cmpint (gconf_value_get_int (item), ==, 97);
+	item = g_slist_nth_data (list, 1);
+	g_assert_cmpint (item->type, ==, GCONF_VALUE_INT);
+	g_assert_cmpint (gconf_value_get_int (item), ==, 98);
+	item = g_slist_nth_data (list, 2);
+	g_assert_cmpint (item->type, ==, GCONF_VALUE_INT);
+	g_assert_cmpint (gconf_value_get_int (item), ==, 99);
+	item = g_slist_nth_data (list, 3);
+	g_assert_cmpint (item->type, ==, GCONF_VALUE_INT);
+	g_assert_cmpint (gconf_value_get_int (item), ==, 100);
+	item = g_slist_nth_data (list, 4);
+	g_assert_cmpint (item->type, ==, GCONF_VALUE_INT);
+	g_assert_cmpint (gconf_value_get_int (item), ==, 101);
+	gconf_value_free (val);
+
+	val = gconf_client_get (client, BASE_PATH "17/connection/autoconnect", NULL);
+	g_assert (val);
+	g_assert_cmpint (val->type, ==, GCONF_VALUE_BOOL);
+	g_assert (gconf_value_get_bool (val) == TRUE);
+	gconf_value_free (val);
+
+	val = gconf_client_get (client, BASE_PATH "17/serial/baud", NULL);
+	g_assert (val);
+	g_assert_cmpint (val->type, ==, GCONF_VALUE_INT);
+	g_assert_cmpint (gconf_value_get_int (val), ==, 115200);
+	gconf_value_free (val);
+
+	list = gconf_client_all_dirs (client, BASE_PATH, NULL);
+	g_assert_cmpint (g_slist_length (list), ==, 2);
+	tmp = g_slist_nth_data (list, 0);
+	g_assert_cmpstr (tmp, ==, BASE_PATH "1");
+	tmp = g_slist_nth_data (list, 1);
+	g_assert_cmpstr (tmp, ==, BASE_PATH "17");
+	g_slist_foreach (list, (GFunc) g_free, NULL);
+	g_slist_free (list);
+
+	list = gconf_client_all_entries (client, BASE_PATH "1/802-11-wireless-security/", NULL);
+	g_assert_cmpint (g_slist_length (list), ==, 2);
+	entry = g_slist_nth_data (list, 0);
+	g_assert_cmpstr (entry->key, ==, BASE_PATH "1/802-11-wireless-security/key-mgmt");
+	g_assert (entry->value);
+	g_assert_cmpint (entry->value->type, ==, GCONF_VALUE_STRING);
+	g_assert_cmpstr (gconf_value_get_string (entry->value), ==, "wpa-psk");
+	entry = g_slist_nth_data (list, 1);
+	g_assert_cmpstr (entry->key, ==, BASE_PATH "1/802-11-wireless-security/name");
+	g_assert (entry->value);
+	g_assert_cmpint (entry->value->type, ==, GCONF_VALUE_STRING);
+	g_assert_cmpstr (gconf_value_get_string (entry->value), ==, "802-11-wireless-security");
+
+	g_object_unref (client);
+}
+
+static void
+test_keyring (void)
+{
+	GnomeKeyringAttributeList *attrs = NULL;
+	GnomeKeyringResult ret;
+	guint32 first_id = 0, second_id = 0;
+	GList *found_list = NULL;
+	GnomeKeyringFound *found;
+
+	/* Add an item to the keyring */
+	attrs = gnome_keyring_attribute_list_new ();
+	g_assert (attrs);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            "FOOBAR",
+	                                            "foobar-value");
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            "BAZ",
+	                                            "baz-value");
+	ret = gnome_keyring_item_create_sync (NULL,
+	                                      GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      "blah blah blah",
+	                                      attrs,
+	                                      "really secret password",
+	                                      TRUE,
+	                                      &first_id);
+	gnome_keyring_attribute_list_free (attrs);
+	g_assert_cmpint (ret, ==, GNOME_KEYRING_RESULT_OK);
+	g_assert_cmpint (first_id, !=, 0);
+
+	/* Add a second item */
+	attrs = gnome_keyring_attribute_list_new ();
+	g_assert (attrs);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            "BORKBORK",
+	                                            "borkbork-value");
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            "DENOODLEZ",
+	                                            "asdfasdf-value");
+	ret = gnome_keyring_item_create_sync (NULL,
+	                                      GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      "blahde blahde blah",
+	                                      attrs,
+	                                      "shh don't tell",
+	                                      TRUE,
+	                                      &second_id);
+	gnome_keyring_attribute_list_free (attrs);
+	g_assert_cmpint (ret, ==, GNOME_KEYRING_RESULT_OK);
+	g_assert_cmpint (second_id, !=, 0);
+
+	/* Find the first item */
+	ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      &found_list,
+	                                      "FOOBAR",
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      "foobar-value",
+	                                      "BAZ",
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      "baz-value",
+	                                      NULL);
+	g_assert_cmpint (ret, ==, GNOME_KEYRING_RESULT_OK);
+	g_assert (g_list_length (found_list) == 1);
+	found = found_list->data;
+	g_assert (found->keyring == NULL);
+	g_assert_cmpint (found->item_id, ==, first_id);
+	g_assert_cmpstr (found->secret, ==, "really secret password");
+
+	gnome_keyring_found_list_free (found_list);
+	found_list = NULL;
+
+	/* Make sure a bogus request is not found */
+	ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      &found_list,
+	                                      "asdfasdfasdf",
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      "asdfasdfasdf",
+	                                      "aagaegwge",
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      "ahawwujerj23",
+	                                      NULL);
+	g_assert_cmpint (ret, ==, GNOME_KEYRING_RESULT_OK);
+	g_assert (g_list_length (found_list) == 0);
+}
+
+#define KEYRING_UUID_TAG "connection-uuid"
+#define KEYRING_SN_TAG "setting-name"
+#define KEYRING_SK_TAG "setting-key"
+
+static GnomeKeyringAttributeList *
+_create_keyring_add_attr_list (const char *connection_uuid,
+                               const char *connection_id,
+                               const char *setting_name,
+                               const char *setting_key,
+                               char **out_display_name)
+{
+	GnomeKeyringAttributeList *attrs = NULL;
+
+	g_return_val_if_fail (connection_uuid != NULL, NULL);
+	g_return_val_if_fail (connection_id != NULL, NULL);
+	g_return_val_if_fail (setting_name != NULL, NULL);
+	g_return_val_if_fail (setting_key != NULL, NULL);
+
+	if (out_display_name) {
+		*out_display_name = g_strdup_printf ("Network secret for %s/%s/%s",
+		                                     connection_id,
+		                                     setting_name,
+		                                     setting_key);
+	}
+
+	attrs = gnome_keyring_attribute_list_new ();
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_UUID_TAG,
+	                                            connection_uuid);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_SN_TAG,
+	                                            setting_name);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_SK_TAG,
+	                                            setting_key);
+	return attrs;
+}
+
+static void
+upgrade_08_wifi_cb (NMConnection *connection, gpointer user_data)
+{
+	NMSettingWirelessSecurity *s_wsec;
+	NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
+
+	/* And check to make sure we've got our wpa-psk flags */
+	s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
+	g_assert (s_wsec);
+	g_object_get (s_wsec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, &flags, NULL);
+	g_assert_cmpint (flags, ==, NM_SETTING_SECRET_FLAG_AGENT_OWNED);
+
+	/* and make sure the password isn't in the connection */
+	g_assert (nm_setting_wireless_security_get_psk (s_wsec) == NULL);
+}
+
+static void
+test_upgrade_08_wifi (void)
+{
+	GConfClient *client;
+	gboolean success;
+	GnomeKeyringAttributeList *attrs;
+	char *display_name = NULL;
+	GnomeKeyringResult ret;
+
+	client = gconf_client_get_default ();
+	success = fake_gconf_add_xml (client, TESTDIR "/08wifi.xml");
+	g_assert (success);
+
+	/* Add the WPA passphrase */
+	attrs = _create_keyring_add_attr_list ("ca99c473-b0fb-4e16-82dd-a886f3edd099",
+	                                       "Auto abcde",
+	                                       NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
+	                                       NM_SETTING_WIRELESS_SECURITY_PSK,
+	                                       &display_name);
+	g_assert (attrs);
+	ret = gnome_keyring_item_create_sync (NULL,
+	                                      GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      display_name,
+	                                      attrs,
+	                                      "really secret wpa passphrase",
+	                                      TRUE,
+	                                      NULL);
+	g_assert_cmpint (ret, ==, GNOME_KEYRING_RESULT_OK);
+	gnome_keyring_attribute_list_free (attrs);
+	g_free (display_name);
+
+	/* Now do the conversion */
+	nm_gconf_move_connections_to_system (upgrade_08_wifi_cb, NULL);
+}
+
+static void
+upgrade_08_vpn_cb (NMConnection *connection, gpointer user_data)
+{
+	NMSettingVPN *s_vpn;
+	NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
+	gboolean success;
+
+	/* And check to make sure we've got our wpa-psk flags */
+	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+	g_assert (s_vpn);
+
+	success = nm_setting_get_secret_flags (NM_SETTING (s_vpn),
+	                                       "IPSec secret",
+	                                       &flags,
+	                                       NULL);
+	g_assert (success);
+	g_assert_cmpint (flags, ==, NM_SETTING_SECRET_FLAG_AGENT_OWNED);
+
+	success = nm_setting_get_secret_flags (NM_SETTING (s_vpn),
+	                                       "XAuth password",
+	                                       &flags,
+	                                       NULL);
+	g_assert (success);
+	g_assert_cmpint (flags, ==, NM_SETTING_SECRET_FLAG_AGENT_OWNED | NM_SETTING_SECRET_FLAG_NOT_SAVED);
+}
+
+static void
+test_upgrade_08_vpnc (void)
+{
+	GConfClient *client;
+	gboolean success;
+	GnomeKeyringAttributeList *attrs;
+	char *display_name = NULL;
+	GnomeKeyringResult ret;
+
+	client = gconf_client_get_default ();
+	success = fake_gconf_add_xml (client, TESTDIR "/08vpnc.xml");
+	g_assert (success);
+
+	/* Add the WPA passphrase */
+	attrs = _create_keyring_add_attr_list ("5a4f5e4b-bfae-4ffc-ba9c-f73653a5070b",
+	                                       "Test VPN",
+	                                       NM_SETTING_VPN_SETTING_NAME,
+	                                       "IPSec secret",
+	                                       &display_name);
+	g_assert (attrs);
+	ret = gnome_keyring_item_create_sync (NULL,
+	                                      GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      display_name,
+	                                      attrs,
+	                                      "group password",
+	                                      TRUE,
+	                                      NULL);
+	g_assert_cmpint (ret, ==, GNOME_KEYRING_RESULT_OK);
+	gnome_keyring_attribute_list_free (attrs);
+	g_free (display_name);
+
+	/* Now do the conversion */
+	nm_gconf_move_connections_to_system (upgrade_08_vpn_cb, NULL);
+}
+
+/*******************************************/
+
+#if GLIB_CHECK_VERSION(2,25,12)
+typedef GTestFixtureFunc TCFunc;
+#else
+typedef void (*TCFunc)(void);
+#endif
+
+#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL)
+
+int main (int argc, char **argv)
+{
+	GTestSuite *suite;
+
+	g_test_init (&argc, &argv, NULL);
+	g_type_init ();
+
+	suite = g_test_get_root ();
+
+	g_test_suite_add (suite, TESTCASE (test_import_xml, NULL));
+	g_test_suite_add (suite, TESTCASE (test_keyring, NULL));
+
+	g_test_suite_add (suite, TESTCASE (test_upgrade_08_wifi, NULL));
+	g_test_suite_add (suite, TESTCASE (test_upgrade_08_vpnc, NULL));
+
+	return g_test_run ();
+}
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]