mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 18:08:05 +02:00
test: add nmtst_create_connection_from_keyfile()
This commit is contained in:
parent
c9a8764ad2
commit
997fc07ca5
2 changed files with 37 additions and 0 deletions
|
|
@ -1061,6 +1061,36 @@ nmtst_assert_hwaddr_equals (gconstpointer hwaddr1, gssize hwaddr1_len, const cha
|
||||||
nmtst_assert_hwaddr_equals (hwaddr1, hwaddr1_len, expected, G_STRLOC)
|
nmtst_assert_hwaddr_equals (hwaddr1, hwaddr1_len, expected, G_STRLOC)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__) && defined(__NM_KEYFILE_INTERNAL_H__)
|
||||||
|
|
||||||
|
inline static NMConnection *
|
||||||
|
nmtst_create_connection_from_keyfile (const char *keyfile_str, const char *keyfile_name, const char *base_dir)
|
||||||
|
{
|
||||||
|
GKeyFile *keyfile;
|
||||||
|
GError *error = NULL;
|
||||||
|
gboolean success;
|
||||||
|
NMConnection *con;
|
||||||
|
|
||||||
|
g_assert (keyfile_str);
|
||||||
|
|
||||||
|
keyfile = g_key_file_new ();
|
||||||
|
success = g_key_file_load_from_data (keyfile, keyfile_str, strlen (keyfile_str), G_KEY_FILE_NONE, &error);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_assert (success);
|
||||||
|
|
||||||
|
con = nm_keyfile_read (keyfile, keyfile_name, base_dir, NULL, NULL, &error);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_assert (NM_IS_CONNECTION (con));
|
||||||
|
|
||||||
|
g_key_file_unref (keyfile);
|
||||||
|
|
||||||
|
nmtst_connection_normalize (con);
|
||||||
|
|
||||||
|
return con;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __NM_CONNECTION_H__
|
#ifdef __NM_CONNECTION_H__
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
||||||
|
|
@ -345,6 +345,13 @@ test_8021x_cert_read (void)
|
||||||
gs_unref_object NMConnection *con = NULL;
|
gs_unref_object NMConnection *con = NULL;
|
||||||
NMSetting8021x *s_8021x;
|
NMSetting8021x *s_8021x;
|
||||||
|
|
||||||
|
con = nmtst_create_connection_from_keyfile (
|
||||||
|
"[connection]\n"
|
||||||
|
"type=ethernet",
|
||||||
|
"/test_8021x_cert_read/test0", NULL);
|
||||||
|
CLEAR (&con, &keyfile);
|
||||||
|
|
||||||
|
|
||||||
keyfile = _keyfile_load_from_data (
|
keyfile = _keyfile_load_from_data (
|
||||||
"[connection]\n"
|
"[connection]\n"
|
||||||
"type=ethernet"
|
"type=ethernet"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue