From 093f31744401522a832e9fa4685e410e291eddc9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 30 Nov 2023 20:13:29 +0000 Subject: [PATCH] containers test: Assert metadata still works after creator disconnected In some of the tests involving test_stop_server(), the creator of the server (the mock container engine) already disconnected from the bus, so it seems worthwhile to check that its credentials can still be retrieved via GetServerInfo() even though the connection itself is no longer there. Signed-off-by: Simon McVittie --- test/containers.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/containers.c b/test/containers.c index 96ec9239..a80db915 100644 --- a/test/containers.c +++ b/test/containers.c @@ -866,13 +866,20 @@ test_stop_server (Fixture *f, GSocketAddress *socket_address; GUnixFDList *fds = NULL; GVariant *tuple; + GVariant *creator; GVariant *parameters; + GVariant *asv; + GVariantDict dict; GVariantDict named_argument_builder; gchar *error_name; gchar *stringified_result; const gchar *confined_unique_name; const gchar *name_owner; + const char *type; + const char *app_id; + const char *instance_id; guint i; + guint32 uid; g_assert_nonnull (config); @@ -1198,6 +1205,19 @@ test_stop_server (Fixture *f, stringified_result = g_variant_print (tuple, TRUE); g_test_message ("GetServerInfo() -> %s", stringified_result); g_free (stringified_result); + g_assert_cmpstr (g_variant_get_type_string (tuple), ==, "(a{sv}sssa{sv})"); + g_variant_get (tuple, "(@a{sv}&s&s&s@a{sv})", + &creator, &type, &app_id, &instance_id, &asv); + g_variant_dict_init (&dict, creator); + g_assert_true (g_variant_dict_lookup (&dict, "UnixUserID", "u", &uid)); + g_assert_cmpuint (uid, ==, _dbus_getuid ()); + g_variant_dict_clear (&dict); + g_assert_cmpstr (type, ==, "com.example.NotFlatpak"); + g_assert_cmpstr (app_id, ==, "sample-app"); + g_assert_cmpstr (instance_id, ==, ""); + g_assert_cmpuint (g_variant_n_children (asv), ==, 0); + g_clear_pointer (&asv, g_variant_unref); + g_clear_pointer (&creator, g_variant_unref); g_clear_pointer (&tuple, g_variant_unref); /* Now disconnect the last confined connection, which will make the