From: Konstantin Kostiuk <kkostiuk@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Michael Roth" <michael.roth@amd.com>
Subject: [PATCH 3/3] qga: Add tests for --allow-rpcs option
Date: Thu, 6 Jul 2023 11:30:35 +0300 [thread overview]
Message-ID: <20230706083035.623802-4-kkostiuk@redhat.com> (raw)
In-Reply-To: <20230706083035.623802-1-kkostiuk@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
---
tests/unit/test-qga.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
index 360b4cab23..671e83cb86 100644
--- a/tests/unit/test-qga.c
+++ b/tests/unit/test-qga.c
@@ -665,6 +665,36 @@ static void test_qga_blockedrpcs(gconstpointer data)
fixture_tear_down(&fix, NULL);
}
+static void test_qga_allowedrpcs(gconstpointer data)
+{
+ TestFixture fix;
+ QDict *ret, *error;
+ const gchar *class, *desc;
+
+ fixture_setup(&fix, "-a guest-ping,guest-get-time", NULL);
+
+ /* check allowed RPCs */
+ ret = qmp_fd(fix.fd, "{'execute': 'guest-ping'}");
+ qmp_assert_no_error(ret);
+ qobject_unref(ret);
+
+ ret = qmp_fd(fix.fd, "{'execute': 'guest-get-time'}");
+ qmp_assert_no_error(ret);
+ qobject_unref(ret);
+
+ /* check something else */
+ ret = qmp_fd(fix.fd, "{'execute': 'guest-get-fsinfo'}");
+ g_assert_nonnull(ret);
+ error = qdict_get_qdict(ret, "error");
+ class = qdict_get_try_str(error, "class");
+ desc = qdict_get_try_str(error, "desc");
+ g_assert_cmpstr(class, ==, "CommandNotFound");
+ g_assert_nonnull(g_strstr_len(desc, -1, "has been disabled"));
+ qobject_unref(ret);
+
+ fixture_tear_down(&fix, NULL);
+}
+
static void test_qga_config(gconstpointer data)
{
GError *error = NULL;
@@ -1090,6 +1120,7 @@ int main(int argc, char **argv)
test_qga_fsfreeze_status);
g_test_add_data_func("/qga/blockedrpcs", NULL, test_qga_blockedrpcs);
+ g_test_add_data_func("/qga/allowedrpcs", NULL, test_qga_allowedrpcs);
g_test_add_data_func("/qga/config", NULL, test_qga_config);
g_test_add_data_func("/qga/guest-exec", &fix, test_qga_guest_exec);
g_test_add_data_func("/qga/guest-exec-separated", &fix,
--
2.34.1
next prev parent reply other threads:[~2023-07-06 8:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 8:30 [PATCH 0/3] qga: Add new option --allow-rpcs Konstantin Kostiuk
2023-07-06 8:30 ` [PATCH 1/3] qga: Rename ga_disable_not_allowed -> ga_disable_not_allowed_freeze Konstantin Kostiuk
2023-07-10 9:06 ` Marc-André Lureau
2023-07-06 8:30 ` [PATCH 2/3] qga: Add new option --allow-rpcs Konstantin Kostiuk
2023-07-10 9:15 ` Marc-André Lureau
2023-07-06 8:30 ` Konstantin Kostiuk [this message]
2023-07-10 9:18 ` [PATCH 3/3] qga: Add tests for --allow-rpcs option Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230706083035.623802-4-kkostiuk@redhat.com \
--to=kkostiuk@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=michael.roth@amd.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).