From 619271e0f6224190785187f0601d70e6769e241f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Jun 2017 15:11:47 +0100 Subject: [PATCH 42/49] test/containers: Check that GetContainerInstanceInfo stops working After the container instance is removed, the method should not work. Signed-off-by: Simon McVittie --- test/containers.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/containers.c b/test/containers.c index 49702ace..458ba927 100644 --- a/test/containers.c +++ b/test/containers.c @@ -54,6 +54,7 @@ typedef struct { GDBusConnection *confined_conn; GDBusConnection *observer_conn; + GDBusProxy *observer_proxy; GHashTable *containers_removed; guint removed_sub; } Fixture; @@ -493,6 +494,7 @@ test_stop_server (Fixture *f, GSocketAddress *socket_address; GVariant *tuple; GVariant *parameters; + gchar *error_name; gchar *path; gchar *socket_path; const gchar *confined_unique_name; @@ -513,6 +515,13 @@ test_stop_server (Fixture *f, DBUS_PATH_DBUS, DBUS_INTERFACE_CONTAINERS1, NULL, &f->error); g_assert_no_error (f->error); + f->observer_proxy = g_dbus_proxy_new_sync (f->observer_conn, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + NULL, DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_CONTAINERS1, NULL, + &f->error); + g_assert_no_error (f->error); /* Floating reference, call_..._sync takes ownership */ parameters = g_variant_new ("(ssa{sv}a{sv})", @@ -732,6 +741,17 @@ test_stop_server (Fixture *f, g_assert_cmpstr (name_owner, ==, DBUS_SERVICE_DBUS); g_clear_pointer (&tuple, g_variant_unref); + /* The container instance will not disappear from the bus + * until the confined connection goes away */ + tuple = g_dbus_proxy_call_sync (f->observer_proxy, + "GetContainerInstanceInfo", + g_variant_new ("(o)", path), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, + &f->error); + g_assert_no_error (f->error); + g_assert_nonnull (tuple); + g_clear_pointer (&tuple, g_variant_unref); + /* Now disconnect the last confined connection, which will make the * container instance go away */ g_test_message ("Closing confined connection..."); @@ -749,6 +769,18 @@ test_stop_server (Fixture *f, while (!g_hash_table_contains (f->containers_removed, path)) g_main_context_iteration (NULL, TRUE); + tuple = g_dbus_proxy_call_sync (f->observer_proxy, + "GetContainerInstanceInfo", + g_variant_new ("(o)", path), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, + &f->error); + g_assert_nonnull (f->error); + error_name = g_dbus_error_get_remote_error (f->error); + g_assert_cmpstr (error_name, ==, DBUS_ERROR_NOT_CONTAINER); + g_free (error_name); + g_assert_null (tuple); + g_clear_error (&f->error); + g_free (path); g_free (socket_path); -- 2.11.0