From b1a31dbfae77c22f9ed0628e054e7c8c0cec2ebb Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 30 Jun 2022 19:12:34 +0100 Subject: [PATCH] Include the plugin name in the FwupdSecurityAttr GVariant --- libfwupd/fwupd-security-attr.c | 6 ++++++ libfwupd/fwupd-self-test.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/libfwupd/fwupd-security-attr.c b/libfwupd/fwupd-security-attr.c index ddd3fd28c..903d54567 100644 --- a/libfwupd/fwupd-security-attr.c +++ b/libfwupd/fwupd-security-attr.c @@ -777,6 +777,12 @@ fwupd_security_attr_to_variant(FwupdSecurityAttr *self) FWUPD_RESULT_KEY_NAME, g_variant_new_string(priv->name)); } + if (priv->plugin != NULL) { + g_variant_builder_add(&builder, + "{sv}", + FWUPD_RESULT_KEY_PLUGIN, + g_variant_new_string(priv->plugin)); + } if (priv->url != NULL) { g_variant_builder_add(&builder, "{sv}", diff --git a/libfwupd/fwupd-self-test.c b/libfwupd/fwupd-self-test.c index f4bb00c3d..7ef782689 100644 --- a/libfwupd/fwupd-self-test.c +++ b/libfwupd/fwupd-self-test.c @@ -837,10 +837,13 @@ fwupd_security_attr_func(void) gboolean ret; g_autofree gchar *str1 = NULL; g_autofree gchar *str2 = NULL; + g_autofree gchar *str3 = NULL; g_autofree gchar *json = NULL; g_autoptr(FwupdSecurityAttr) attr1 = fwupd_security_attr_new("org.fwupd.hsi.bar"); g_autoptr(FwupdSecurityAttr) attr2 = fwupd_security_attr_new(NULL); + g_autoptr(FwupdSecurityAttr) attr3 = NULL; g_autoptr(GError) error = NULL; + g_autoptr(GVariant) data = NULL; g_autoptr(JsonParser) parser = json_parser_new(); for (guint i = 1; i < FWUPD_SECURITY_ATTR_RESULT_LAST; i++) { @@ -901,6 +904,25 @@ fwupd_security_attr_func(void) g_assert_no_error(error); g_assert_true(ret); + /* roundtrip GVariant */ + data = fwupd_security_attr_to_variant(attr1); + attr3 = fwupd_security_attr_from_variant(data); + fwupd_security_attr_set_created(attr3, 0); + str3 = fwupd_security_attr_to_string(attr3); + ret = fu_test_compare_lines(str3, + " AppstreamId: org.fwupd.hsi.baz\n" + " HsiLevel: 2\n" + " HsiResult: enabled\n" + " Flags: success\n" + " Name: DCI\n" + " Plugin: uefi-capsule\n" + " Uri: https://foo.bar\n" + " Guid: af3fc12c-d090-5783-8a67-845b90d3cfec\n" + " KEY: VALUE\n", + &error); + g_assert_no_error(error); + g_assert_true(ret); + /* to JSON */ json = fwupd_security_attr_to_json_string(attr1, &error); g_assert_no_error(error);