mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
tests: Add a basic test for require-same-user D-Bus auth flag
It’s not feasible to test that the require-same-user flag can cause authentication to fail, as that would require the build environment to have two users available. We can, however, test that it passes when authenticating a client and server running under the same user account. I have manually tested that the new flag works, by running the following as user A: ``` `$prefix/gdbus-daemon --print-env &` gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.ListNames ``` And then running the `gdbus call` command again as user B (with the same value for `DBUS_SESSION_BUS_ADDRESS` in the environment), which produces: ``` Error connecting: Unexpected lack of content trying to read a line ``` (an authentication rejection) Commenting out the use of `G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER` from `gdbusdaemon.c`, the `gdbus call` command succeeds for both users. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
5d0ffe73b7
commit
2f91caf77e
@ -37,6 +37,7 @@ typedef enum
|
||||
INTEROP_FLAGS_TCP = (1 << 3),
|
||||
INTEROP_FLAGS_LIBDBUS = (1 << 4),
|
||||
INTEROP_FLAGS_ABSTRACT = (1 << 5),
|
||||
INTEROP_FLAGS_REQUIRE_SAME_USER = (1 << 6),
|
||||
INTEROP_FLAGS_NONE = 0
|
||||
} InteropFlags;
|
||||
|
||||
@ -325,6 +326,8 @@ do_test_server_auth (InteropFlags flags)
|
||||
|
||||
if (flags & INTEROP_FLAGS_ANONYMOUS)
|
||||
server_flags |= G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS;
|
||||
if (flags & INTEROP_FLAGS_REQUIRE_SAME_USER)
|
||||
server_flags |= G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER;
|
||||
|
||||
observer = g_dbus_auth_observer_new ();
|
||||
|
||||
@ -513,6 +516,12 @@ test_server_auth_external (void)
|
||||
do_test_server_auth (INTEROP_FLAGS_EXTERNAL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_server_auth_external_require_same_user (void)
|
||||
{
|
||||
do_test_server_auth (INTEROP_FLAGS_EXTERNAL | INTEROP_FLAGS_REQUIRE_SAME_USER);
|
||||
}
|
||||
|
||||
static void
|
||||
test_server_auth_sha1 (void)
|
||||
{
|
||||
@ -537,6 +546,7 @@ main (int argc,
|
||||
g_test_add_func ("/gdbus/server-auth/anonymous", test_server_auth_anonymous);
|
||||
g_test_add_func ("/gdbus/server-auth/anonymous/tcp", test_server_auth_anonymous_tcp);
|
||||
g_test_add_func ("/gdbus/server-auth/external", test_server_auth_external);
|
||||
g_test_add_func ("/gdbus/server-auth/external/require-same-user", test_server_auth_external_require_same_user);
|
||||
g_test_add_func ("/gdbus/server-auth/sha1", test_server_auth_sha1);
|
||||
g_test_add_func ("/gdbus/server-auth/sha1/tcp", test_server_auth_sha1_tcp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user