network-manager-vpnc r19 - in trunk: . properties properties/tests properties/tests/pcf
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-vpnc r19 - in trunk: . properties properties/tests properties/tests/pcf
- Date: Thu, 5 Feb 2009 23:59:39 +0000 (UTC)
Author: dcbw
Date: Thu Feb 5 23:59:39 2009
New Revision: 19
URL: http://svn.gnome.org/viewvc/network-manager-vpnc?rev=19&view=rev
Log:
2009-02-05 Dan Williams <dcbw redhat com>
* configure.in
- Add configure-time option for running test cases on 'make check'
* properties/pcf-file.c
properties/pcf-file.h
- (pcf_file_lookup_string, pcf_file_lookup_bool, pcf_file_lookup_int):
add helper functions to look up specific value types
* properties/nm-vpnc.c
- (import): use new value types helper functions; fix interpretation of
"EnableNat" and ensure default is Cisco NAT traversal; import
"DHGroup"
- (export): export "DHGroup" and "SaveUserPassword"; fix export of
static routes
* properties/tests/*
nm-test-helpers.h
Makefile.am
- Add testcases for .pcf file import/export
Added:
trunk/nm-test-helpers.h
trunk/properties/tests/
trunk/properties/tests/Makefile.am
trunk/properties/tests/pcf/
trunk/properties/tests/pcf/Makefile.am
trunk/properties/tests/pcf/always-ask.pcf
trunk/properties/tests/pcf/basic.pcf
trunk/properties/tests/pcf/everything-via-vpn.pcf
trunk/properties/tests/pcf/no-natt.pcf
trunk/properties/tests/test-import-export.c
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.in
trunk/properties/Makefile.am
trunk/properties/nm-vpnc.c
trunk/properties/pcf-file.c
trunk/properties/pcf-file.h
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Thu Feb 5 23:59:39 2009
@@ -31,7 +31,8 @@
$(icon_DATA) \
intltool-extract.in \
intltool-merge.in \
- intltool-update.in
+ intltool-update.in \
+ nm-test-helpers.h
CLEANFILES = $(nmvpnservice_DATA) $(desktop_DATA) *~
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Feb 5 23:59:39 2009
@@ -115,11 +115,27 @@
AC_MSG_RESULT(no)
fi
+dnl
+dnl Tests
+dnl
+AC_ARG_WITH(tests, AC_HELP_STRING([--with-tests], [Build NetworkManager tests]))
+AM_CONDITIONAL(WITH_TESTS, test "x$with_tests" = "xyes")
+case $with_tests in
+ yes)
+ with_tests=yes
+ ;;
+ *)
+ with_tests=no
+ ;;
+esac
+
AC_OUTPUT([
Makefile
src/Makefile
common-gnome/Makefile
auth-dialog/Makefile
properties/Makefile
+properties/tests/Makefile
+properties/tests/pcf/Makefile
po/Makefile.in
])
Added: trunk/nm-test-helpers.h
==============================================================================
--- (empty file)
+++ trunk/nm-test-helpers.h Thu Feb 5 23:59:39 2009
@@ -0,0 +1,51 @@
+/* NetworkManager -- Network link manager
+ *
+ * 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 2008 Red Hat, Inc.
+ */
+
+#ifndef NM_TEST_HELPERS_H
+#define NM_TEST_HELPERS_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+static void
+FAIL(const char *test_name, const char *fmt, ...)
+{
+ va_list args;
+ char buf[500];
+
+ snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt);
+
+ va_start (args, fmt);
+ vfprintf (stderr, buf, args);
+ va_end (args);
+ _exit (1);
+}
+
+#define ASSERT(x, test_name, fmt, ...) \
+{ \
+ if (!(x)) { \
+ FAIL (test_name, fmt, ## __VA_ARGS__); \
+ } \
+}
+
+#endif /* NM_TEST_HELPERS_H */
+
Modified: trunk/properties/Makefile.am
==============================================================================
--- trunk/properties/Makefile.am (original)
+++ trunk/properties/Makefile.am Thu Feb 5 23:59:39 2009
@@ -1,3 +1,5 @@
+SUBDIRS=. tests
+
INCLUDES = -I${top_srcdir}
plugindir = $(libdir)/NetworkManager
@@ -31,6 +33,7 @@
$(GTK_LIBS) \
$(GCONF_LIBS) \
$(NM_UTILS_LIBS) \
+ $(GNOMEKEYRING_LIBS) \
$(top_builddir)/common-gnome/libnm-vpnc-common-gnome.la
libnm_vpnc_properties_la_LDFLAGS = \
Modified: trunk/properties/nm-vpnc.c
==============================================================================
--- trunk/properties/nm-vpnc.c (original)
+++ trunk/properties/nm-vpnc.c Thu Feb 5 23:59:39 2009
@@ -974,9 +974,9 @@
NMSettingVPN *s_vpn;
GHashTable *pcf;
const char *buf;
- gboolean have_value;
+ gboolean bool_value;
NMSettingIP4Config *s_ip4;
- long int val;
+ gint val;
pcf = pcf_file_load (path);
if (!pcf) {
@@ -997,7 +997,7 @@
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
/* Connection name */
- if ((buf = pcf_file_lookup_value (pcf, "main", "Description")))
+ if (pcf_file_lookup_string (pcf, "main", "Description", &buf))
g_object_set (s_con, NM_SETTING_CONNECTION_ID, buf, NULL);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN connection (parse failed)",
@@ -1007,7 +1007,7 @@
}
/* Gateway */
- if ((buf = pcf_file_lookup_value (pcf, "main", "Host")))
+ if (pcf_file_lookup_string (pcf, "main", "Host", &buf))
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_GATEWAY, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN connection (no Host)",
@@ -1017,7 +1017,7 @@
}
/* Group name */
- if ((buf = pcf_file_lookup_value (pcf, "main", "GroupName")))
+ if (pcf_file_lookup_string (pcf, "main", "GroupName", &buf))
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_ID, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN connection (no GroupName)",
@@ -1028,37 +1028,25 @@
/* Optional settings */
- buf = pcf_file_lookup_value (pcf, "main", "UserName");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value)
+ if (pcf_file_lookup_string (pcf, "main", "UserName", &buf))
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER, buf);
- buf = pcf_file_lookup_value (pcf, "main", "UserPassword");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value)
+ if (pcf_file_lookup_string (pcf, "main", "UserPassword", &buf))
nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD, buf);
- buf = pcf_file_lookup_value (pcf, "main", "SaveUserPassword");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value) {
- errno = 0;
- val = strtol (buf, NULL, 10);
- if ((errno == 0) && (val == 1)) {
+ if (pcf_file_lookup_bool (pcf, "main", "SaveUserPassword", &bool_value)) {
+ if (bool_value) {
nm_setting_vpn_add_data_item (s_vpn,
NM_VPNC_KEY_XAUTH_PASSWORD_TYPE,
NM_VPNC_PW_TYPE_SAVE);
}
}
- buf = pcf_file_lookup_value (pcf, "main", "GroupPwd");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value)
+ if (pcf_file_lookup_string (pcf, "main", "GroupPwd", &buf))
nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_SECRET, buf);
else {
/* Handle encrypted passwords */
- buf = pcf_file_lookup_value (pcf, "main", "enc_GroupPwd");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value) {
+ if (pcf_file_lookup_string (pcf, "main", "enc_GroupPwd", &buf)) {
char *decrypted;
decrypted = decrypt_cisco_key (buf);
@@ -1070,50 +1058,55 @@
}
}
- buf = pcf_file_lookup_value (pcf, "main", "NTDomain");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value)
+ if (pcf_file_lookup_string (pcf, "main", "NTDomain", &buf))
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DOMAIN, buf);
- buf = pcf_file_lookup_value (pcf, "main", "SingleDES");
- have_value = (buf == NULL ? FALSE : strcmp (buf, "0") != 0);
- if (have_value)
- nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES, "yes");
+ if (pcf_file_lookup_bool (pcf, "main", "SingleDES", &bool_value)) {
+ if (bool_value)
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES, "yes");
+ }
/* Default is enabled, only disabled if explicit EnableNat=0 exists */
- buf = pcf_file_lookup_value (pcf, "main", "EnableNat");
- have_value = (buf ? strncmp (buf, "0", 1) == 0 : FALSE);
- if (have_value)
- nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE, NM_VPNC_NATT_MODE_NATT);
-
- if ((buf = pcf_file_lookup_value (pcf, "main", "PeerTimeout"))) {
- errno = 0;
- val = strtol (buf, NULL, 10);
- if ((errno == 0) && ((val == 0) || ((val >= 10) && (val <= 86400)))) {
+ if (pcf_file_lookup_bool (pcf, "main", "EnableNat", &bool_value)) {
+ if (!bool_value) {
+ nm_setting_vpn_add_data_item (s_vpn,
+ NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
+ NM_VPNC_NATT_MODE_NONE);
+ }
+ }
+
+ /* Default to Cisco UDP */
+ if (!nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE)) {
+ nm_setting_vpn_add_data_item (s_vpn,
+ NM_VPNC_KEY_NAT_TRAVERSAL_MODE,
+ NM_VPNC_NATT_MODE_CISCO);
+ }
+
+ if (pcf_file_lookup_int (pcf, "main", "PeerTimeout", &val)) {
+ if ((val == 0) || ((val >= 10) && (val <= 86400))) {
char *tmp = g_strdup_printf ("%d", (gint) val);
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT, tmp);
g_free (tmp);
}
}
- buf = pcf_file_lookup_value (pcf, "main", "EnableLocalLAN");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value) {
- errno = 0;
- val = strtol (buf, NULL, 10);
- if ((errno == 0) && (val == 1))
+ if (pcf_file_lookup_bool (pcf, "main", "EnableLocalLAN", &bool_value)) {
+ if (bool_value)
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, TRUE, NULL);
}
- buf = pcf_file_lookup_value (pcf, "main", "X-NM-Routes");
- have_value = buf == NULL ? FALSE : strlen (buf) > 0;
- if (have_value)
+ if (pcf_file_lookup_string (pcf, "main", "DHGroup", &buf)) {
+ if (!strcmp (buf, "1") || !strcmp (buf, "2") || !strcmp (buf, "5"))
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DHGROUP, buf);
+ }
+
+ if (pcf_file_lookup_string (pcf, "main", "X-NM-Routes", &buf))
add_routes (s_ip4, buf);
- if ((buf = pcf_file_lookup_value (pcf, "main", "TunnelingMode"))) {
+ if (pcf_file_lookup_int (pcf, "main", "TunnelingMode", &val)) {
/* If applicable, put up warning that TCP tunneling will be disabled */
- if (strncmp (buf, "1", 1) == 0) {
+ if (val == 1) {
GtkWidget *dialog;
char *basename;
@@ -1152,8 +1145,11 @@
const char *username = NULL;
const char *domain = NULL;
const char *peertimeout = NULL;
+ const char *dhgroup = NULL;
GString *routes = NULL;
gboolean success = FALSE;
+ guint32 routes_count = 0;
+ gboolean save_password = FALSE;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
@@ -1188,7 +1184,7 @@
value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_DOMAIN);
if (value && strlen (value))
- domain = value;
+ domain = value;
value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES);
if (value && !strcmp (value, "yes"))
@@ -1202,7 +1198,17 @@
if (value && strlen (value))
peertimeout = value;
- routes = g_string_new ("");
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_DHGROUP);
+ if (value && strlen (value))
+ dhgroup = value;
+
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD_TYPE);
+ if (value && strlen (value)) {
+ if (!strcmp (value, NM_VPNC_PW_TYPE_SAVE))
+ save_password = TRUE;
+ }
+
+ routes = g_string_new ("X-NM-Routes=");
if (s_ip4 && nm_setting_ip4_config_get_num_routes (s_ip4)) {
int i;
@@ -1211,14 +1217,20 @@
char str_addr[INET_ADDRSTRLEN + 1];
struct in_addr num_addr;
- if (routes->len)
+ if (routes_count)
g_string_append_c (routes, ' ');
num_addr.s_addr = nm_ip4_route_get_dest (route);
if (inet_ntop (AF_INET, &num_addr, &str_addr[0], INET_ADDRSTRLEN + 1))
g_string_append_printf (routes, "%s/%d", str_addr, nm_ip4_route_get_prefix (route));
+
+ routes_count++;
}
}
+ if (!routes_count) {
+ g_string_free (routes, TRUE);
+ routes = NULL;
+ }
fprintf (f,
"[main]\n"
@@ -1232,7 +1244,7 @@
"ISPConnect=\n"
"ISPCommand=\n"
"Username=%s\n"
- "SaveUserPassword=0\n"
+ "SaveUserPassword=%s\n"
"EnableBackup=0\n"
"BackupServer=\n"
"EnableNat=%s\n"
@@ -1241,7 +1253,7 @@
"CertPath=\n"
"CertSubjectName=\n"
"CertSerialHash=\n"
- "DHGroup=2\n"
+ "DHGroup=%s\n"
"ForceKeepAlives=0\n"
"enc_GroupPwd=\n"
"UserPassword=\n"
@@ -1258,16 +1270,18 @@
"EnableSplitDNS=1\n"
"SingleDES=%s\n"
"SPPhonebook=\n"
- "%s",
- /* Description */ nm_setting_connection_get_id (s_con),
- /* Host */ gateway,
- /* GroupName */ groupname,
- /* Username */ username != NULL ? username : "",
- /* EnableNat */ enablenat ? "1" : "0",
- /* NTDomain */ domain != NULL ? domain : "",
- /* PeerTimeout */ peertimeout != NULL ? peertimeout : "0",
- /* SingleDES */ singledes ? "1" : "0",
- /* X-NM-Routes */ routes->str ? routes->str : "");
+ "%s\n",
+ /* Description */ nm_setting_connection_get_id (s_con),
+ /* Host */ gateway,
+ /* GroupName */ groupname,
+ /* Username */ username != NULL ? username : "",
+ /* Save Password */ save_password ? "1" : "0",
+ /* EnableNat */ enablenat ? "1" : "0",
+ /* DHGroup */ dhgroup != NULL ? dhgroup : "2",
+ /* NTDomain */ domain != NULL ? domain : "",
+ /* PeerTimeout */ peertimeout != NULL ? peertimeout : "0",
+ /* SingleDES */ singledes ? "1" : "0",
+ /* X-NM-Routes */ (routes && routes->str) ? routes->str : "");
success = TRUE;
Modified: trunk/properties/pcf-file.c
==============================================================================
--- trunk/properties/pcf-file.c (original)
+++ trunk/properties/pcf-file.c Thu Feb 5 23:59:39 2009
@@ -23,6 +23,7 @@
#include <string.h>
#include <errno.h>
#include <ctype.h>
+#include <stdlib.h>
#include "pcf-file.h"
@@ -92,6 +93,7 @@
g_hash_table_insert (pcf, g_utf8_strdown (s+1, -1), group);
} else {
PcfEntry *entry;
+ char *key;
/* Normal assignment */
if (!(e = strchr (s, '='))) {
@@ -111,13 +113,15 @@
entry->value = g_strdup (e);
if (*s == '!') {
- entry->key = g_utf8_strdown (s+1, -1);
+ key = g_utf8_strdown (s+1, -1);
entry->read_only = TRUE;
} else {
- entry->key = g_utf8_strdown (s, -1);
+ key = g_utf8_strdown (s, -1);
entry->read_only = FALSE;
}
+ entry->key = g_strdup (g_strstrip (key));
+ g_free (key);
g_hash_table_insert (group, entry->key, entry);
}
}
@@ -139,8 +143,8 @@
PcfEntry *
pcf_file_lookup (GHashTable *pcf_file,
- const char *group,
- const char *key)
+ const char *group,
+ const char *key)
{
gpointer section;
PcfEntry *entry = NULL;
@@ -164,16 +168,94 @@
return entry;
}
-const char *
-pcf_file_lookup_value (GHashTable *pcf_file,
- const char *group,
- const char *key)
+gboolean
+pcf_file_lookup_string (GHashTable *pcf_file,
+ const char *group,
+ const char *key,
+ const char **value)
{
PcfEntry *entry;
+ g_return_val_if_fail (pcf_file != NULL, FALSE);
+ g_return_val_if_fail (group != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ *value = NULL;
entry = pcf_file_lookup (pcf_file, group, key);
- if (entry)
- return entry->value;
+ if (!entry || !entry->value || !strlen (entry->value))
+ return FALSE;
+
+ *value = entry->value;
+ return TRUE;
+}
+
+gboolean
+pcf_file_lookup_bool (GHashTable *pcf_file,
+ const char *group,
+ const char *key,
+ gboolean *value)
+{
+ const char *buf = NULL;
+ gboolean success = FALSE;
+
+ g_return_val_if_fail (pcf_file != NULL, FALSE);
+ g_return_val_if_fail (group != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ *value = FALSE;
+ if (!pcf_file_lookup_string (pcf_file, group, key, &buf))
+ return FALSE;
+
+ if (strlen (buf) == 1) {
+ if (strcmp (buf, "1") == 0) {
+ *value = TRUE;
+ success = TRUE;
+ } else if (strcmp (buf, "0") == 0) {
+ *value = FALSE;
+ success = TRUE;
+ }
+ } else {
+ if ( !strncasecmp (buf, "yes", 3)
+ || !strncasecmp (buf, "true", 4)) {
+ *value = TRUE;
+ success = TRUE;
+ } else if ( !strncasecmp (buf, "no", 2)
+ || !strncasecmp (buf, "false", 5)) {
+ *value = FALSE;
+ success = TRUE;
+ }
+ }
- return NULL;
+ return success;
}
+
+gboolean
+pcf_file_lookup_int (GHashTable *pcf_file,
+ const char *group,
+ const char *key,
+ gint *value)
+{
+ const char *buf = NULL;
+ long int tmp;
+
+ g_return_val_if_fail (pcf_file != NULL, FALSE);
+ g_return_val_if_fail (group != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ *value = 0;
+ if (!pcf_file_lookup_string (pcf_file, group, key, &buf))
+ return FALSE;
+
+ errno = 0;
+ tmp = strtol (buf, NULL, 10);
+ if ((errno == 0) && (tmp > G_MININT) && (tmp < G_MAXINT)) {
+ *value = (gint) tmp;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
Modified: trunk/properties/pcf-file.h
==============================================================================
--- trunk/properties/pcf-file.h (original)
+++ trunk/properties/pcf-file.h Thu Feb 5 23:59:39 2009
@@ -34,11 +34,23 @@
GHashTable *pcf_file_load (const char *fname);
PcfEntry *pcf_file_lookup (GHashTable *pcf_file,
- const char *group,
- const char *key);
+ const char *group,
+ const char *key);
-const char *pcf_file_lookup_value (GHashTable *pcf_file,
- const char *group,
- const char *key);
+gboolean pcf_file_lookup_string (GHashTable *pcf_file,
+ const char *group,
+ const char *key,
+ const char **value);
+
+gboolean pcf_file_lookup_bool (GHashTable *pcf_file,
+ const char *group,
+ const char *key,
+ gboolean *value);
+
+gboolean pcf_file_lookup_int (GHashTable *pcf_file,
+ const char *group,
+ const char *key,
+ gint *value);
#endif /* PCF_FILE_H */
+
Added: trunk/properties/tests/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/properties/tests/Makefile.am Thu Feb 5 23:59:39 2009
@@ -0,0 +1,35 @@
+SUBDIRS=pcf
+
+INCLUDES = -I${top_srcdir}
+
+noinst_PROGRAMS = test-import-export
+
+test_import_export_SOURCES = \
+ test-import-export.c
+
+test_import_export_CPPFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(GLADE_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(GCONF_CFLAGS) \
+ $(GNOMEKEYRING_CFLAGS) \
+ $(NM_UTILS_CFLAGS) \
+ $(DBUS_CFLAGS)
+
+test_import_export_LDADD = \
+ $(GTHREAD_LIBS) \
+ $(GLADE_LIBS) \
+ $(GTK_LIBS) \
+ $(GCONF_LIBS) \
+ $(GNOMEKEYRING_LIBS) \
+ $(DBUS_LIBS) \
+ $(NM_UTILS_LIBS) \
+ $(top_builddir)/properties/.libs/libnm-vpnc-properties.a
+
+if WITH_TESTS
+
+check-local: test-import-export
+ $(abs_builddir)/test-import-export $(abs_srcdir)/pcf
+
+endif
+
Added: trunk/properties/tests/pcf/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/properties/tests/pcf/Makefile.am Thu Feb 5 23:59:39 2009
@@ -0,0 +1,6 @@
+EXTRA_DIST = \
+ basic.pcf \
+ everything-via-vpn.pcf \
+ no-natt.pcf \
+ always-ask.pcf
+
Added: trunk/properties/tests/pcf/always-ask.pcf
==============================================================================
--- (empty file)
+++ trunk/properties/tests/pcf/always-ask.pcf Thu Feb 5 23:59:39 2009
@@ -0,0 +1,38 @@
+[main]
+Description=Always Ask For Password
+!Host=10.20.30.40
+!AuthType=1
+!GroupName=blahblah
+!GroupPwd=my-group-password
+!enc_GroupPwd=
+EnableISPConnect=0
+ISPConnectType=0
+ISPConnect=
+ISPCommand=
+Username=bsmith
+SaveUserPassword=0
+UserPassword=my-user-password
+enc_UserPassword=
+!NTDomain=COMPANY
+!EnableBackup=0
+!BackupServer=
+!EnableMSLogon=1
+!MSLogonType=0
+!EnableNat=1
+!TunnelingMode=0
+!TcpTunnelingPort=10000
+CertStore=0
+CertName=
+CertPath=
+CertSubjectName=
+CertSerialHash=00000000000000000000000000000000
+SendCertChain=0
+VerifyCertDN=
+DHGroup=2
+ForceKeepAlives=1
+PeerTimeout=90
+!EnableLocalLAN=1
+!EnableSplitDNS=1
+ISPPhonebook=
+X-NM-Routes=10.0.0.0/8 172.16.0.0/16
+
Added: trunk/properties/tests/pcf/basic.pcf
==============================================================================
--- (empty file)
+++ trunk/properties/tests/pcf/basic.pcf Thu Feb 5 23:59:39 2009
@@ -0,0 +1,38 @@
+[main]
+Description=Basic VPN
+!Host=10.20.30.40
+!AuthType=1
+!GroupName=blahblah
+!GroupPwd=my-group-password
+!enc_GroupPwd=
+EnableISPConnect=0
+ISPConnectType=0
+ISPConnect=
+ISPCommand=
+Username=bsmith
+SaveUserPassword=1
+UserPassword=my-user-password
+enc_UserPassword=
+!NTDomain=COMPANY
+!EnableBackup=0
+!BackupServer=
+!EnableMSLogon=1
+!MSLogonType=0
+!EnableNat=1
+!TunnelingMode=0
+!TcpTunnelingPort=10000
+CertStore=0
+CertName=
+CertPath=
+CertSubjectName=
+CertSerialHash=00000000000000000000000000000000
+SendCertChain=0
+VerifyCertDN=
+DHGroup=2
+ForceKeepAlives=1
+PeerTimeout=90
+!EnableLocalLAN=1
+!EnableSplitDNS=1
+ISPPhonebook=
+X-NM-Routes=10.0.0.0/8 172.16.0.0/16
+
Added: trunk/properties/tests/pcf/everything-via-vpn.pcf
==============================================================================
--- (empty file)
+++ trunk/properties/tests/pcf/everything-via-vpn.pcf Thu Feb 5 23:59:39 2009
@@ -0,0 +1,37 @@
+[main]
+Description=All your traffic are belong to VPN
+!Host=10.20.30.40
+!AuthType=1
+!GroupName=blahblah
+!GroupPwd=my-group-password
+!enc_GroupPwd=
+EnableISPConnect=0
+ISPConnectType=0
+ISPConnect=
+ISPCommand=
+Username=bsmith
+SaveUserPassword=1
+UserPassword=my-user-password
+enc_UserPassword=
+!NTDomain=COMPANY
+!EnableBackup=0
+!BackupServer=
+!EnableMSLogon=1
+!MSLogonType=0
+!EnableNat=1
+!TunnelingMode=0
+!TcpTunnelingPort=10000
+CertStore=0
+CertName=
+CertPath=
+CertSubjectName=
+CertSerialHash=00000000000000000000000000000000
+SendCertChain=0
+VerifyCertDN=
+DHGroup=2
+ForceKeepAlives=1
+PeerTimeout=90
+!EnableLocalLAN=0
+!EnableSplitDNS=0
+ISPPhonebook=
+
Added: trunk/properties/tests/pcf/no-natt.pcf
==============================================================================
--- (empty file)
+++ trunk/properties/tests/pcf/no-natt.pcf Thu Feb 5 23:59:39 2009
@@ -0,0 +1,38 @@
+[main]
+Description=No NAT Traversal
+!Host=10.20.30.40
+!AuthType=1
+!GroupName=blahblah
+!GroupPwd=my-group-password
+!enc_GroupPwd=
+EnableISPConnect=0
+ISPConnectType=0
+ISPConnect=
+ISPCommand=
+Username=bsmith
+SaveUserPassword=1
+UserPassword=my-user-password
+enc_UserPassword=
+!NTDomain=COMPANY
+!EnableBackup=0
+!BackupServer=
+!EnableMSLogon=1
+!MSLogonType=0
+!EnableNat=0
+!TunnelingMode=0
+!TcpTunnelingPort=10000
+CertStore=0
+CertName=
+CertPath=
+CertSubjectName=
+CertSerialHash=00000000000000000000000000000000
+SendCertChain=0
+VerifyCertDN=
+DHGroup=2
+ForceKeepAlives=1
+PeerTimeout=90
+!EnableLocalLAN=1
+!EnableSplitDNS=1
+ISPPhonebook=
+X-NM-Routes=10.0.0.0/8 172.16.0.0/16
+
Added: trunk/properties/tests/test-import-export.c
==============================================================================
--- (empty file)
+++ trunk/properties/tests/test-import-export.c Thu Feb 5 23:59:39 2009
@@ -0,0 +1,469 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2009 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.
+ *
+ */
+
+#include <string.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <nm-utils.h>
+#include <nm-setting-connection.h>
+#include <nm-setting-ip4-config.h>
+#include <nm-setting-vpn.h>
+
+#define NM_VPN_API_SUBJECT_TO_CHANGE
+#include <nm-vpn-plugin-ui-interface.h>
+
+#include "nm-test-helpers.h"
+#include "properties/nm-vpnc.h"
+#include "src/nm-vpnc-service.h"
+
+typedef struct {
+ const char *name;
+ const char *value;
+} Item;
+
+static void
+item_count_func (const char *key, const char *value, gpointer user_data)
+{
+ (* (guint32 *) user_data)++;
+}
+
+static void
+test_items (const char *detail, NMSettingVPN *s_vpn, Item *test_items, gboolean secrets)
+{
+ Item *iter;
+ guint32 expected_count = 0, actual_count = 0;
+ const char *value;
+
+ for (iter = test_items; iter->name; iter++) {
+ if (secrets)
+ value = nm_setting_vpn_get_secret (s_vpn, iter->name);
+ else
+ value = nm_setting_vpn_get_data_item (s_vpn, iter->name);
+
+ if (!iter->value) {
+ ASSERT (value == NULL, detail, "unexpected item '%s'", iter->name);
+ } else {
+ ASSERT (value != NULL, detail, "unexpected missing value for item %s", iter->name);
+ ASSERT (strcmp (value, iter->value) == 0, detail, "unexpected value for item %s", iter->name);
+ expected_count++;
+ }
+ }
+
+ if (secrets)
+ nm_setting_vpn_foreach_secret (s_vpn, item_count_func, &actual_count);
+ else
+ nm_setting_vpn_foreach_data_item (s_vpn, item_count_func, &actual_count);
+
+ ASSERT (actual_count == expected_count,
+ detail, "unexpected number of items (got %d, expected %d", actual_count, expected_count);
+}
+
+
+static Item basic_items[] = {
+ { NM_VPNC_KEY_GATEWAY, "10.20.30.40" },
+ { NM_VPNC_KEY_ID, "blahblah" },
+ { NM_VPNC_KEY_SECRET_TYPE, NULL },
+ { NM_VPNC_KEY_XAUTH_USER, "bsmith" },
+ { NM_VPNC_KEY_XAUTH_PASSWORD_TYPE, NM_VPNC_PW_TYPE_SAVE },
+ { NM_VPNC_KEY_DOMAIN, "COMPANY" },
+ { NM_VPNC_KEY_DHGROUP, "2" },
+ { NM_VPNC_KEY_PERFECT_FORWARD, NULL },
+ { NM_VPNC_KEY_APP_VERSION, NULL },
+ { NM_VPNC_KEY_SINGLE_DES, NULL },
+ { NM_VPNC_KEY_NO_ENCRYPTION, NULL },
+ { NM_VPNC_KEY_NAT_TRAVERSAL_MODE, NM_VPNC_NATT_MODE_CISCO },
+ { NM_VPNC_KEY_DPD_IDLE_TIMEOUT, "90" },
+ { NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT, NULL },
+ { NULL, NULL }
+};
+
+static Item basic_secrets[] = {
+ { NM_VPNC_KEY_SECRET, "my-group-password" },
+ { NM_VPNC_KEY_XAUTH_PASSWORD, "my-user-password" },
+ { NULL, NULL }
+};
+
+static NMConnection *
+get_basic_connection (const char *detail,
+ NMVpnPluginUiInterface *plugin,
+ const char *dir,
+ const char *filename)
+{
+ NMConnection *connection;
+ GError *error = NULL;
+ char *pcf;
+
+ pcf = g_build_path ("/", dir, filename, NULL);
+ ASSERT (pcf != NULL,
+ "basic", "failed to create pcf path");
+
+ connection = nm_vpn_plugin_ui_interface_import (plugin, pcf, &error);
+ if (error)
+ FAIL ("basic", "error importing %s: %s", pcf, error->message);
+ ASSERT (connection != NULL,
+ "basic", "error importing %s: (unknown)", pcf);
+
+ g_free (pcf);
+ return connection;
+}
+
+static void
+test_basic_import (NMVpnPluginUiInterface *plugin, const char *dir)
+{
+ NMConnection *connection;
+ NMSettingConnection *s_con;
+ NMSettingIP4Config *s_ip4;
+ NMSettingVPN *s_vpn;
+ NMIP4Route *route;
+ struct in_addr tmp;
+ const char *expected_id = "Basic VPN";
+ const char *expected_route1_dest = "10.0.0.0";
+ const char *expected_route1_gw = "0.0.0.0";
+ const char *expected_route2_dest = "172.16.0.0";
+ const char *expected_route2_gw = "0.0.0.0";
+ const char *value;
+
+ connection = get_basic_connection ("basic-import", plugin, dir, "basic.pcf");
+ ASSERT (connection != NULL, "basic-import", "failed to import connection");
+
+ /* Connection setting */
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+ ASSERT (s_con != NULL,
+ "basic-import", "missing 'connection' setting");
+
+ ASSERT (strcmp (nm_setting_connection_get_id (s_con), expected_id) == 0,
+ "basic-import", "unexpected connection ID");
+
+ ASSERT (nm_setting_connection_get_uuid (s_con) == NULL,
+ "basic-import", "unexpected valid UUID");
+
+ /* IP4 setting */
+ s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
+ ASSERT (s_con != NULL,
+ "basic-import", "missing 'ip4-config' setting");
+
+ ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 0,
+ "basic-import", "unexpected addresses");
+
+ ASSERT (nm_setting_ip4_config_get_never_default (s_ip4) == TRUE,
+ "basic-import", "never-default unexpectedly FALSE");
+
+ ASSERT (nm_setting_ip4_config_get_method (s_ip4) == NULL,
+ "basic-import", "unexpected IPv4 method");
+
+ ASSERT (nm_setting_ip4_config_get_dhcp_client_id (s_ip4) == NULL,
+ "basic-import", "unexpected valid DHCP client ID");
+
+ ASSERT (nm_setting_ip4_config_get_dhcp_hostname (s_ip4) == NULL,
+ "basic-import", "unexpected valid DHCP hostname");
+
+ ASSERT (nm_setting_ip4_config_get_num_dns_searches (s_ip4) == 0,
+ "basic-import", "unexpected DNS searches");
+
+ ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 0,
+ "basic-import", "unexpected DNS servers");
+
+ ASSERT (nm_setting_ip4_config_get_num_routes (s_ip4) == 2,
+ "basic-import", "unexpected number of routes");
+
+ /* Route #1 */
+ route = nm_setting_ip4_config_get_route (s_ip4, 0);
+ ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
+ "basic-import", "couldn't convert expected route destination #1");
+ ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
+ "basic-import", "unexpected route #1 destination");
+
+ ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
+ "basic-import", "couldn't convert expected route next hop #1");
+ ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
+ "basic-import", "unexpected route #1 next hop");
+
+ ASSERT (nm_ip4_route_get_prefix (route) == 8,
+ "basic-import", "unexpected route #1 prefix");
+ ASSERT (nm_ip4_route_get_metric (route) == 0,
+ "basic-import", "unexpected route #1 metric");
+
+ /* Route #2 */
+ route = nm_setting_ip4_config_get_route (s_ip4, 1);
+ ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0,
+ "basic-import", "couldn't convert expected route destination #2");
+ ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
+ "basic-import", "unexpected route #2 destination");
+
+ ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0,
+ "basic-import", "couldn't convert expected route next hop #2");
+ ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
+ "basic-import", "unexpected route #2 next hop");
+
+ ASSERT (nm_ip4_route_get_prefix (route) == 16,
+ "basic-import", "unexpected route #2 prefix");
+ ASSERT (nm_ip4_route_get_metric (route) == 0,
+ "basic-import", "unexpected route #2 metric");
+
+ /* VPN setting */
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+ ASSERT (s_vpn != NULL,
+ "basic-import", "missing 'vpn' setting");
+
+ /* Data items */
+ test_items ("basic-import-data", s_vpn, &basic_items[0], FALSE);
+
+ /* Secrets */
+ test_items ("basic-import-secrets", s_vpn, &basic_secrets[0], TRUE);
+
+ g_object_unref (connection);
+}
+
+static void
+save_one_key (const char *key, const char *value, gpointer user_data)
+{
+ GSList **list = user_data;
+
+ *list = g_slist_append (*list, g_strdup (key));
+}
+
+static void
+remove_secrets (NMConnection *connection)
+{
+ NMSettingVPN *s_vpn;
+ GSList *keys = NULL, *iter;
+
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+ if (!s_vpn)
+ return;
+
+ nm_setting_vpn_foreach_secret (s_vpn, save_one_key, &keys);
+ for (iter = keys; iter; iter = g_slist_next (iter))
+ nm_setting_vpn_remove_secret (s_vpn, (const char *) iter->data);
+
+ g_slist_foreach (keys, (GFunc) g_free, NULL);
+ g_slist_free (keys);
+}
+
+#define EXPORTED_NAME "basic-export-test.pcf"
+static void
+test_basic_export (NMVpnPluginUiInterface *plugin, const char *dir)
+{
+ NMConnection *connection;
+ NMConnection *reimported;
+ char *path;
+ gboolean success;
+ GError *error = NULL;
+ int ret;
+
+ connection = get_basic_connection ("basic-export", plugin, dir, "basic.pcf");
+ ASSERT (connection != NULL, "basic-export", "failed to import connection");
+
+ path = g_build_path ("/", dir, EXPORTED_NAME, NULL);
+ success = nm_vpn_plugin_ui_interface_export (plugin, path, connection, &error);
+ if (!success) {
+ if (!error)
+ FAIL ("basic-export", "export failed with missing error");
+ else
+ FAIL ("basic-export", "export failed: %s", error->message);
+ }
+
+ /* Now re-import it and compare the connections to ensure they are the same */
+ reimported = get_basic_connection ("basic-export", plugin, dir, EXPORTED_NAME);
+ ret = unlink (path);
+ ASSERT (connection != NULL, "basic-export", "failed to re-import connection");
+
+ /* Clear secrets first, since they don't get exported, and thus would
+ * make the connection comparison below fail.
+ */
+ remove_secrets (connection);
+
+ ASSERT (nm_connection_compare (connection, reimported, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
+ "basic-export", "original and reimported connection differ");
+
+ g_object_unref (reimported);
+ g_object_unref (connection);
+ g_free (path);
+}
+
+
+static void
+test_everything_via_vpn (NMVpnPluginUiInterface *plugin, const char *dir)
+{
+ NMConnection *connection;
+ NMSettingConnection *s_con;
+ NMSettingIP4Config *s_ip4;
+ GError *error = NULL;
+ char *pcf;
+ const char *expected_id = "All your traffic are belong to VPN";
+ const char *value;
+
+ pcf = g_build_path ("/", dir, "everything-via-vpn.pcf", NULL);
+ ASSERT (pcf != NULL,
+ "everything-via-vpn", "failed to create pcf path");
+
+ connection = nm_vpn_plugin_ui_interface_import (plugin, pcf, &error);
+ if (error)
+ FAIL ("everything-via-vpn", "error importing %s: %s", pcf, error->message);
+ ASSERT (connection != NULL,
+ "everything-via-vpn", "error importing %s: (unknown)", pcf);
+
+ /* Connection setting */
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+ ASSERT (s_con != NULL,
+ "everything-via-vpn", "missing 'connection' setting");
+
+ ASSERT (strcmp (nm_setting_connection_get_id (s_con), expected_id) == 0,
+ "everything-via-vpn", "unexpected connection ID");
+
+ /* IP4 setting */
+ s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
+ ASSERT (s_con != NULL,
+ "everything-via-vpn", "missing 'ip4-config' setting");
+
+ ASSERT (nm_setting_ip4_config_get_never_default (s_ip4) == FALSE,
+ "everything-via-vpn", "never-default unexpectedly FALSE");
+
+ ASSERT (nm_setting_ip4_config_get_num_routes (s_ip4) == 0,
+ "everything-via-vpn", "unexpected number of routes");
+
+ g_free (pcf);
+}
+
+static void
+test_no_natt (NMVpnPluginUiInterface *plugin, const char *dir)
+{
+ NMConnection *connection;
+ NMSettingConnection *s_con;
+ NMSettingVPN *s_vpn;
+ GError *error = NULL;
+ char *pcf;
+ const char *expected_id = "No NAT Traversal";
+ const char *value;
+
+ pcf = g_build_path ("/", dir, "no-natt.pcf", NULL);
+ ASSERT (pcf != NULL,
+ "no-natt", "failed to create pcf path");
+
+ connection = nm_vpn_plugin_ui_interface_import (plugin, pcf, &error);
+ if (error)
+ FAIL ("no-natt", "error importing %s: %s", pcf, error->message);
+ ASSERT (connection != NULL,
+ "no-natt", "error importing %s: (unknown)", pcf);
+
+ /* Connection setting */
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+ ASSERT (s_con != NULL,
+ "no-natt", "missing 'connection' setting");
+
+ ASSERT (strcmp (nm_setting_connection_get_id (s_con), expected_id) == 0,
+ "no-natt", "unexpected connection ID");
+
+ /* VPN setting */
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+ ASSERT (s_vpn != NULL,
+ "no-natt", "missing 'vpn' setting");
+
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
+ ASSERT (value != NULL,
+ "no-natt", "unexpected missing value for item %s", NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
+ ASSERT (strcmp (value, NM_VPNC_NATT_MODE_NONE) == 0,
+ "no-natt", "unexpected value for item %s", NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
+
+ g_free (pcf);
+}
+
+static void
+test_always_ask (NMVpnPluginUiInterface *plugin, const char *dir)
+{
+ NMConnection *connection;
+ NMSettingConnection *s_con;
+ NMSettingVPN *s_vpn;
+ GError *error = NULL;
+ char *pcf;
+ const char *expected_id = "Always Ask For Password";
+ const char *value;
+
+ pcf = g_build_path ("/", dir, "always-ask.pcf", NULL);
+ ASSERT (pcf != NULL,
+ "always-ask", "failed to create pcf path");
+
+ connection = nm_vpn_plugin_ui_interface_import (plugin, pcf, &error);
+ if (error)
+ FAIL ("always-ask", "error importing %s: %s", pcf, error->message);
+ ASSERT (connection != NULL,
+ "always-ask", "error importing %s: (unknown)", pcf);
+
+ /* Connection setting */
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+ ASSERT (s_con != NULL,
+ "always-ask", "missing 'connection' setting");
+
+ ASSERT (strcmp (nm_setting_connection_get_id (s_con), expected_id) == 0,
+ "always-ask", "unexpected connection ID");
+
+ /* VPN setting */
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+ ASSERT (s_vpn != NULL,
+ "always-ask", "missing 'vpn' setting");
+
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD_TYPE);
+ ASSERT (value == NULL,
+ "always-ask", "unexpected value for item %s", NM_VPNC_KEY_XAUTH_PASSWORD_TYPE);
+
+ g_free (pcf);
+}
+
+int main (int argc, char **argv)
+{
+ GError *error = NULL;
+ DBusGConnection *bus;
+ char *basename;
+ NMVpnPluginUiInterface *plugin = NULL;
+
+ if (argc != 2)
+ FAIL ("args", "usage: %s <pcf path>", argv[0]);
+
+ g_type_init ();
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+ if (!nm_utils_init (&error))
+ FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message);
+
+ plugin = nm_vpn_plugin_ui_factory (&error);
+ if (error)
+ FAIL ("plugin-init", "failed to initialize UI plugin: %s", error->message);
+ ASSERT (plugin != NULL,
+ "plugin-init", "failed to initialize UI plugin");
+
+ /* The tests */
+ test_basic_import (plugin, argv[1]);
+ test_everything_via_vpn (plugin, argv[1]);
+ test_no_natt (plugin, argv[1]);
+ test_always_ask (plugin, argv[1]);
+
+ test_basic_export (plugin, argv[1]);
+
+ g_object_unref (plugin);
+
+ basename = g_path_get_basename (argv[0]);
+ fprintf (stdout, "%s: SUCCESS\n", basename);
+ g_free (basename);
+ return 0;
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]