Skip to content

Commit

Permalink
qga: Add tests for --allow-rpcs option
Browse files Browse the repository at this point in the history
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
  • Loading branch information
kostyanf14 committed Jul 10, 2023
1 parent 133789e commit fcd1ab3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/unit/test-qga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit fcd1ab3

Please sign in to comment.