diff options
| author | Michael Biebl <biebl@debian.org> | 2018-06-04 00:07:45 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-06-04 00:07:45 +0200 |
| commit | 04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (patch) | |
| tree | d10c354b1b980ca8a7b9e48ec9019e8ed88bde2b /src/settings/plugins/keyfile | |
| parent | ee9c73a923909e23a649407be77e25235d769e25 (diff) | |
New upstream version 1.11.4 upstream/1.11.4
Diffstat (limited to 'src/settings/plugins/keyfile')
5 files changed, 63 insertions, 99 deletions
diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/settings/plugins/keyfile/nms-keyfile-plugin.c index e6299d1e..3723db94 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-plugin.c +++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.c @@ -436,7 +436,7 @@ read_connections (NMSettingsPlugin *config) return; } - alive_connections = g_hash_table_new (NULL, NULL); + alive_connections = g_hash_table_new (nm_direct_hash, NULL); filenames = g_ptr_array_new_with_free_func (g_free); while ((item = g_dir_read_name (dir))) { @@ -562,28 +562,6 @@ get_unmanaged_specs (NMSettingsPlugin *config) /*****************************************************************************/ static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, NMS_KEYFILE_PLUGIN_NAME); - break; - case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, NMS_KEYFILE_PLUGIN_INFO); - break; - case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nms_keyfile_plugin_init (NMSKeyfilePlugin *plugin) { NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (plugin); @@ -644,19 +622,6 @@ nms_keyfile_plugin_class_init (NMSKeyfilePluginClass *req_class) object_class->constructed = constructed; object_class->dispose = dispose; - object_class->get_property = get_property; - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_NAME, - NM_SETTINGS_PLUGIN_NAME); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_INFO, - NM_SETTINGS_PLUGIN_INFO); - - g_object_class_override_property (object_class, - NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, - NM_SETTINGS_PLUGIN_CAPABILITIES); } static void diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.h b/src/settings/plugins/keyfile/nms-keyfile-utils.h index be7d668a..cd3f42b9 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-utils.h +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.h @@ -23,9 +23,6 @@ #include "NetworkManagerUtils.h" -#define NMS_KEYFILE_PLUGIN_NAME "keyfile" -#define NMS_KEYFILE_PLUGIN_INFO "(c) 2007 - 2016 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." - #define NMS_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") #define NMS_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")" #define NMS_KEYFILE_CONNECTION_LOG_ARG(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection b/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection index 5cb4d726..1e62f4b3 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection @@ -15,7 +15,7 @@ mtu=1400 [ipv4] method=manual -dns=4.2.2.1;4.2.2.2; +dns=4.2.2.1;bogus;4.2.2.2; addresses1=192.168.0.5;24;192.168.0.1; addresses2=1.2.3.4;16;1.2.1.1; address=2.3.4.5/24,2.3.4.6 @@ -26,15 +26,21 @@ routes1=1.2.3.0/24,2.3.4.8,99 route=5.6.7.8/32 routes2=1.1.1.2/12, routes3=1.1.1.3/13,, +routes7=1.1.1.7/17,0.0.0.0 routes4=1.1.1.4/14,2.2.2.4 +address30=1.2.3.130/24 routes5=1.1.1.5/15,2.2.2.5, routes6=1.1.1.6/16,2.2.2.6,0 -routes7=1.1.1.7/17,0.0.0.0 routes8=1.1.1.8/18,0.0.0.0, routes9=1.1.1.9/19,0.0.0.0,0 +route10=1.1.1.10/21,,0 routes10=1.1.1.10/20,,0 routes11=1.1.1.11/21,,21 routes11_options=cwnd=10,lock-cwnd=true,mtu=1430,src=7.7.7.7 +address30=1.2.3.30/24 +addresses30=1.2.3.30/25 +addresses31=1.2.3.31/25 +address31=1.2.3.31/24 ignore-auto-routes=false ignore-auto-dns=false diff --git a/src/settings/plugins/keyfile/tests/meson.build b/src/settings/plugins/keyfile/tests/meson.build new file mode 100644 index 00000000..33aaa264 --- /dev/null +++ b/src/settings/plugins/keyfile/tests/meson.build @@ -0,0 +1,16 @@ +test_unit = 'test-keyfile' + +test_keyfiles_dir = join_paths(meson.current_source_dir(), 'keyfiles') + +exe = executable( + test_unit, + test_unit + '.c', + dependencies: test_nm_dep, + c_args: nm_build_cflags, +) + +test( + 'keyfile/' + test_unit, + test_script, + args: test_args + [exe.full_path()] +) diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index f27efddd..a3045f7d 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -37,6 +37,9 @@ #include "nm-test-utils-core.h" +#define TEST_KEYFILES_DIR NM_BUILD_SRCDIR"/src/settings/plugins/keyfile/tests/keyfiles" +#define TEST_SCRATCH_DIR NM_BUILD_BUILDDIR"/src/settings/plugins/keyfile/tests/keyfiles" + /*****************************************************************************/ static void @@ -231,34 +234,21 @@ test_read_valid_wired_connection (void) char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; gboolean success; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.addresses:*semicolon at the end*addresses1*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.addresses:*semicolon at the end*addresses2*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*missing prefix length*address4*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*missing prefix length*address5*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.routes*semicolon at the end*routes2*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.routes*semicolon at the end*routes3*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.routes*semicolon at the end*routes5*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.routes*semicolon at the end*routes8*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*missing prefix length*address4*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv6.address*semicolon at the end*address5*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*missing prefix length*address5*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv6.address*semicolon at the end*address7*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv6.routes*semicolon at the end*routes1*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv6.route*semicolon at the end*route6*"); + NMTST_EXPECT_NM_INFO ("*ipv4.addresses:*semicolon at the end*addresses1*"); + NMTST_EXPECT_NM_INFO ("*ipv4.addresses:*semicolon at the end*addresses2*"); + NMTST_EXPECT_NM_WARN ("*missing prefix length*address4*"); + NMTST_EXPECT_NM_WARN ("*missing prefix length*address5*"); + NMTST_EXPECT_NM_WARN ("*ipv4.dns: ignoring invalid DNS server IPv4 address 'bogus'*"); + NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes2*"); + NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes3*"); + NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes5*"); + NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes8*"); + NMTST_EXPECT_NM_WARN ("*missing prefix length*address4*"); + NMTST_EXPECT_NM_INFO ("*ipv6.address*semicolon at the end*address5*"); + NMTST_EXPECT_NM_WARN ("*missing prefix length*address5*"); + NMTST_EXPECT_NM_INFO ("*ipv6.address*semicolon at the end*address7*"); + NMTST_EXPECT_NM_INFO ("*ipv6.routes*semicolon at the end*routes1*"); + NMTST_EXPECT_NM_INFO ("*ipv6.route*semicolon at the end*route6*"); connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", &error); g_assert_no_error (error); g_test_assert_expected_messages (); @@ -294,19 +284,23 @@ test_read_valid_wired_connection (void) g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 1), ==, "4.2.2.2"); /* IPv4 addresses */ - g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 6); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 10); check_ip_address (s_ip4, 0, "2.3.4.5", 24); check_ip_address (s_ip4, 1, "192.168.0.5", 24); check_ip_address (s_ip4, 2, "1.2.3.4", 16); check_ip_address (s_ip4, 3, "3.4.5.6", 16); check_ip_address (s_ip4, 4, "4.5.6.7", 24); check_ip_address (s_ip4, 5, "5.6.7.8", 24); + check_ip_address (s_ip4, 6, "1.2.3.30", 24); + check_ip_address (s_ip4, 7, "1.2.3.30", 25); + check_ip_address (s_ip4, 8, "1.2.3.31", 24); + check_ip_address (s_ip4, 9, "1.2.3.31", 25); /* IPv4 gateway */ g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, "2.3.4.6"); /* IPv4 routes */ - g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 12); + g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 13); check_ip_route (s_ip4, 0, "5.6.7.8", 32, NULL, -1); check_ip_route (s_ip4, 1, "1.2.3.0", 24, "2.3.4.8", 99); check_ip_route (s_ip4, 2, "1.1.1.2", 12, NULL, -1); @@ -317,11 +311,12 @@ test_read_valid_wired_connection (void) check_ip_route (s_ip4, 7, "1.1.1.7", 17, NULL, -1); check_ip_route (s_ip4, 8, "1.1.1.8", 18, NULL, -1); check_ip_route (s_ip4, 9, "1.1.1.9", 19, NULL, 0); - check_ip_route (s_ip4, 10, "1.1.1.10", 20, NULL, 0); - check_ip_route (s_ip4, 11, "1.1.1.11", 21, NULL, 21); + check_ip_route (s_ip4, 10, "1.1.1.10", 21, NULL, 0); + check_ip_route (s_ip4, 11, "1.1.1.10", 20, NULL, 0); + check_ip_route (s_ip4, 12, "1.1.1.11", 21, NULL, 21); /* Route attributes */ - route = nm_setting_ip_config_get_route (s_ip4, 11); + route = nm_setting_ip_config_get_route (s_ip4, 12); g_assert (route); nmtst_assert_route_attribute_uint32 (route, NM_IP_ROUTE_ATTRIBUTE_CWND, 10); @@ -408,7 +403,6 @@ add_one_ip_route (NMSettingIPConfig *s_ip, nm_ip_route_unref (route); } - static void test_write_wired_connection (void) { @@ -649,12 +643,9 @@ test_read_wired_mac_case (void) char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55 }; gboolean success; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.addresses*semicolon at the end*addresses1*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv4.addresses*semicolon at the end*addresses2*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, - "*ipv6.routes*semicolon at the end*routes1*"); + NMTST_EXPECT_NM_INFO ("*ipv4.addresses*semicolon at the end*addresses1*"); + NMTST_EXPECT_NM_INFO ("*ipv4.addresses*semicolon at the end*addresses2*"); + NMTST_EXPECT_NM_INFO ("*ipv6.routes*semicolon at the end*routes1*"); connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL); g_test_assert_expected_messages (); g_assert (connection); @@ -1415,10 +1406,8 @@ test_read_wired_8021x_tls_blob_connection (void) gboolean success; GBytes *blob; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); + NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); + NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error); g_assert_no_error (error); g_assert (connection); @@ -1447,8 +1436,7 @@ test_read_wired_8021x_tls_blob_connection (void) g_assert_cmpint (nm_setting_802_1x_get_ca_cert_scheme (s_8021x), ==, NM_SETTING_802_1X_CK_SCHEME_BLOB); /* Make sure it's not a path, since it's a blob */ - g_test_expect_message ("libnm", G_LOG_LEVEL_CRITICAL, - NMTST_G_RETURN_MSG (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)); + NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)); tmp = nm_setting_802_1x_get_ca_cert_path (s_8021x); g_test_assert_expected_messages (); g_assert (tmp == NULL); @@ -1476,8 +1464,7 @@ test_read_wired_8021x_tls_bad_path_connection (void) char *tmp2; gboolean success; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*does not exist*"); + NMTST_EXPECT_NM_WARN ("*does not exist*"); connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error); g_test_assert_expected_messages (); g_assert_no_error (error); @@ -1530,12 +1517,9 @@ test_read_wired_8021x_tls_old_connection (void) const char *tmp; gboolean success; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*<warn> * keyfile: 802-1x.ca-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/CA/eaptest_ca_cert.pem' does not exist*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, - "*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); + NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.ca-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/CA/eaptest_ca_cert.pem' does not exist*"); + NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); + NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error); g_assert_no_error (error); g_assert (connection); @@ -2433,7 +2417,6 @@ test_read_minimal (void) &s_con); nmtst_connection_normalize (con_archetype); - connection = keyfile_read_connection_from_file (TEST_KEYFILES_DIR"/Test_minimal_1"); g_object_set (s_con, NM_SETTING_CONNECTION_ID, nm_connection_get_id (connection), @@ -2442,7 +2425,6 @@ test_read_minimal (void) nmtst_assert_connection_equals (con_archetype, FALSE, connection, FALSE); g_clear_object (&connection); - connection = keyfile_read_connection_from_file (TEST_KEYFILES_DIR"/Test_minimal_2"); g_object_set (s_con, NM_SETTING_CONNECTION_ID, nm_connection_get_id (connection), @@ -2469,7 +2451,6 @@ test_read_minimal_slave (void) NULL); nmtst_connection_normalize (con_archetype); - connection = keyfile_read_connection_from_file (TEST_KEYFILES_DIR"/Test_minimal_slave_1"); g_object_set (s_con, NM_SETTING_CONNECTION_ID, nm_connection_get_id (connection), @@ -2478,7 +2459,6 @@ test_read_minimal_slave (void) nmtst_assert_connection_equals (con_archetype, FALSE, connection, FALSE); g_clear_object (&connection); - connection = keyfile_read_connection_from_file (TEST_KEYFILES_DIR"/Test_minimal_slave_2"); g_object_set (s_con, NM_SETTING_CONNECTION_ID, nm_connection_get_id (connection), |