On Thu, Jul 6, 2023 at 12:32 PM Konstantin Kostiuk <kkost...@redhat.com>
wrote:

> Signed-off-by: Konstantin Kostiuk <kkost...@redhat.com>
>


Reviewed-by: Marc-André Lureau <marcandre.lur...@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
>
>
>

-- 
Marc-André Lureau

Reply via email to