summaryrefslogtreecommitdiff
path: root/libnm-core/tests
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-03-26 12:41:13 +0100
committerThomas Haller <thaller@redhat.com>2020-04-04 19:51:34 +0200
commit117cbd18949a197f663ef51e95535e76e99e387f (patch)
tree9b1b390632df31d164c6cf60edc3f2e487bd3f19 /libnm-core/tests
parent64da830b07d57f1c8ec5d72e990302d647ac3036 (diff)
downloadNetworkManager-117cbd18949a197f663ef51e95535e76e99e387f.tar.gz
libnm: allow setting empty vpn.secrets item
Like for data, now also allow empty secrets to be added to the VPN setting. For one, this avoids an assertion failure, where keyfile reader wouldn't check whether a secret key is set to the empty word. For data, it's more clear that we want to allow setting empty data values. VPN settings are only interpreted by the VPN plugin, so libnm and the daemon shouldn't prevent empty settings. It can be useful to distinguish between unset (NULL) and empty values. For secrets, it's less clear that empty secrets shall be allowed. I think it should. Of course, the empty secret likely isn't a correct nor valid secret. But libnm cannot validate the secrets anyway. It's up to the VPN plugin to handle this in any way they see fit. Also, already before, the user could set NM_SETTING_VPN_SECRETS to a string dictionary with empty passwords. So, the API didn't fully prevent that. Only certain API wouldn't play along.
Diffstat (limited to 'libnm-core/tests')
-rw-r--r--libnm-core/tests/test-general.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 5d3494d869..0301473bc9 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -1197,13 +1197,9 @@ test_setting_vpn_items (void)
nm_setting_vpn_add_secret (s_vpn, "", "");
g_test_assert_expected_messages ();
- NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (secret && secret[0]));
- nm_setting_vpn_add_secret (s_vpn, "foobar1", NULL);
- g_test_assert_expected_messages ();
-
- NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (secret && secret[0]));
nm_setting_vpn_add_secret (s_vpn, "foobar1", "");
- g_test_assert_expected_messages ();
+
+ nm_setting_vpn_add_secret (s_vpn, "foobar1", NULL);
NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (key && key[0]));
nm_setting_vpn_add_secret (s_vpn, NULL, "blahblah1");