diff options
author | Thomas Haller <thaller@redhat.com> | 2020-03-26 12:41:13 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-04 19:51:34 +0200 |
commit | 64da830b07d57f1c8ec5d72e990302d647ac3036 (patch) | |
tree | 106f6d925599f3c2e20287f26c4069553c28af6d /libnm-core/tests | |
parent | 8280c85fac44276dab8ffe5dd0de8b21b77fd7c8 (diff) | |
download | NetworkManager-64da830b07d57f1c8ec5d72e990302d647ac3036.tar.gz |
libnm: allow setting empty vpn.data item
Until now, nm_setting_vpn_add_data_item() would reject empty data values.
This leads for example to an assertion failure, if you write a keyfile
that assigns an empty value to a key. Keyfile reader would not check that
the value is non-empty before calling nm_setting_vpn_add_data_item().
Anyway, I think we should not require having non-empty data elements. It's
an unnecessary and sometimes harmful restriction. NetworkManager doesn't understand
not care about the content of the vpn data. That is up the VPN plugins. Sometimes
and empty value may be desirable.
Also, the NM_SETTING_VPN_DATA property setter wouldn't filter out empty
values either. So it was always possible to use some libnm API to set data
with empty values. The restriction in nm_setting_vpn_add_data_item() was
inconsistent.
Diffstat (limited to 'libnm-core/tests')
-rw-r--r-- | libnm-core/tests/test-general.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index e0d0d55fa2..5d3494d869 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -1172,13 +1172,11 @@ test_setting_vpn_items (void) nm_setting_vpn_add_data_item (s_vpn, "", ""); g_test_assert_expected_messages (); - NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (item && item[0])); - nm_setting_vpn_add_data_item (s_vpn, "foobar1", NULL); - g_test_assert_expected_messages (); - - NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (item && item[0])); nm_setting_vpn_add_data_item (s_vpn, "foobar1", ""); - g_test_assert_expected_messages (); + g_assert_cmpstr (nm_setting_vpn_get_data_item (s_vpn, "foobar1"), ==, ""); + + nm_setting_vpn_add_data_item (s_vpn, "foobar1", NULL); + g_assert_cmpstr (nm_setting_vpn_get_data_item (s_vpn, "foobar1"), ==, NULL); NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (key && key[0])); nm_setting_vpn_add_data_item (s_vpn, NULL, "blahblah1"); |