summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2014-07-31 16:59:55 +1200
committerRobert Ancell <robert.ancell@canonical.com>2014-07-31 16:59:55 +1200
commit2edcdf149b9093d1ca4e8ebc3bee6c63c4306f22 (patch)
tree00910e0051e752238b0e38ae187e81fbdc6b07a8 /tests
parent865b37bf30201efa0d2cb43e2afdcdeced0542f0 (diff)
downloadlightdm-2edcdf149b9093d1ca4e8ebc3bee6c63c4306f22.tar.gz
Add a seat option 'allow-user-switching' that can disable all user switching for that seat
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/scripts/switch-to-greeter-disabled.conf39
-rw-r--r--tests/scripts/switch-to-greeter.conf4
-rw-r--r--tests/scripts/switch-to-guest-disabled.conf44
-rw-r--r--tests/scripts/switch-to-guest.conf8
-rw-r--r--tests/scripts/switch-to-user-disabled.conf40
-rw-r--r--tests/scripts/switch-to-user.conf4
-rw-r--r--tests/src/test-runner.c159
-rwxr-xr-xtests/test-switch-to-greeter-disabled2
-rwxr-xr-xtests/test-switch-to-guest-disabled2
-rwxr-xr-xtests/test-switch-to-user-disabled2
11 files changed, 269 insertions, 41 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ad2d22ad..172d31f3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -138,14 +138,17 @@ TESTS = \
test-lock-seat-console-kit \
test-lock-seat-return-session-console-kit \
test-switch-to-greeter \
+ test-switch-to-greeter-disabled \
test-switch-to-greeter-new-session \
test-switch-to-greeter-resettable \
test-switch-to-greeter-return-session \
test-switch-to-greeter-return-session-pam \
test-switch-to-greeter-return-session-logout \
test-switch-to-guest \
+ test-switch-to-guest-disabled \
test-switch-to-guest-fail-resettable \
test-switch-to-user \
+ test-switch-to-user-disabled \
test-switch-to-user-no-password \
test-switch-to-user-active \
test-switch-to-user-existing \
@@ -473,16 +476,19 @@ EXTRA_DIST = \
scripts/session-stderr-backup.conf \
scripts/surfaceflinger-autologin.conf \
scripts/switch-to-greeter.conf \
+ scripts/switch-to-greeter-disabled.conf \
scripts/switch-to-greeter-new-session.conf \
scripts/switch-to-greeter-resettable.conf \
scripts/switch-to-greeter-return-session.conf \
scripts/switch-to-greeter-return-session-logout.conf \
scripts/switch-to-greeter-return-session-pam.conf \
scripts/switch-to-guest.conf \
+ scripts/switch-to-guest-disabled.conf \
scripts/switch-to-guest-fail-resettable.conf \
scripts/switch-to-user.conf \
scripts/switch-to-users.conf \
scripts/switch-to-user-active.conf \
+ scripts/switch-to-user-disabled.conf \
scripts/switch-to-user-existing.conf \
scripts/switch-to-user-existing-no-password.conf \
scripts/switch-to-user-existing-resettable.conf \
diff --git a/tests/scripts/switch-to-greeter-disabled.conf b/tests/scripts/switch-to-greeter-disabled.conf
new file mode 100644
index 00000000..23634f1b
--- /dev/null
+++ b/tests/scripts/switch-to-greeter-disabled.conf
@@ -0,0 +1,39 @@
+#
+# Check can't switch to greeter when disabled
+#
+
+[SeatDefaults]
+autologin-user=have-password1
+user-session=default
+allow-user-switching=false
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Check daemon says we can't switch
+#?*SEAT-CAN-SWITCH
+#?RUNNER SEAT-CAN-SWITCH CAN-SWITCH=FALSE
+
+# Attempt to show the greeter
+#?*SWITCH-TO-GREETER
+#?RUNNER SWITCH-TO-GREETER FAILED
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/switch-to-greeter.conf b/tests/scripts/switch-to-greeter.conf
index d91bae5a..e3f6f752 100644
--- a/tests/scripts/switch-to-greeter.conf
+++ b/tests/scripts/switch-to-greeter.conf
@@ -23,6 +23,10 @@ user-session=default
#?XSERVER-0 ACCEPT-CONNECT
#?SESSION-X-0 CONNECT-XSERVER
+# Check daemon says we can switch
+#?*SEAT-CAN-SWITCH
+#?RUNNER SEAT-CAN-SWITCH CAN-SWITCH=TRUE
+
# Show the greeter
#?*SWITCH-TO-GREETER
#?RUNNER SWITCH-TO-GREETER
diff --git a/tests/scripts/switch-to-guest-disabled.conf b/tests/scripts/switch-to-guest-disabled.conf
new file mode 100644
index 00000000..ceca7096
--- /dev/null
+++ b/tests/scripts/switch-to-guest-disabled.conf
@@ -0,0 +1,44 @@
+#
+# Check can't switch to guest when disabled
+#
+
+[SeatDefaults]
+autologin-user=have-password1
+user-session=default
+allow-user-switching=false
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+#?*WAIT
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Default session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Check daemon says we can't switch
+#?*SEAT-CAN-SWITCH
+#?RUNNER SEAT-CAN-SWITCH CAN-SWITCH=FALSE
+
+# Check daemon says we have a guest account
+#?*SEAT-HAS-GUEST-ACCOUNT
+#?RUNNER SEAT-HAS-GUEST-ACCOUNT HAS-GUEST-ACCOUNT=TRUE
+
+# Attempt to switch to guest
+#?*SWITCH-TO-GUEST
+#?RUNNER SWITCH-TO-GUEST FAILED
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/switch-to-guest.conf b/tests/scripts/switch-to-guest.conf
index b993af77..cc59cca1 100644
--- a/tests/scripts/switch-to-guest.conf
+++ b/tests/scripts/switch-to-guest.conf
@@ -24,6 +24,14 @@ user-session=default
#?XSERVER-0 ACCEPT-CONNECT
#?SESSION-X-0 CONNECT-XSERVER
+# Check daemon says we can switch
+#?*SEAT-CAN-SWITCH
+#?RUNNER SEAT-CAN-SWITCH CAN-SWITCH=TRUE
+
+# Check daemon says we have a guest account
+#?*SEAT-HAS-GUEST-ACCOUNT
+#?RUNNER SEAT-HAS-GUEST-ACCOUNT HAS-GUEST-ACCOUNT=TRUE
+
# Switch to guest
#?*SWITCH-TO-GUEST
#?RUNNER SWITCH-TO-GUEST
diff --git a/tests/scripts/switch-to-user-disabled.conf b/tests/scripts/switch-to-user-disabled.conf
new file mode 100644
index 00000000..c3fbc6b5
--- /dev/null
+++ b/tests/scripts/switch-to-user-disabled.conf
@@ -0,0 +1,40 @@
+#
+# Check that can't switch to a user when switching disabled
+#
+
+[SeatDefaults]
+autologin-user=no-password1
+user-session=default
+allow-user-switching=false
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+#?*WAIT
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=no-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Check daemon says we can't switch
+#?*SEAT-CAN-SWITCH
+#?RUNNER SEAT-CAN-SWITCH CAN-SWITCH=FALSE
+
+# Attempt to switch to an account
+#?*SWITCH-TO-USER USERNAME=have-password1
+#?RUNNER SWITCH-TO-USER USERNAME=have-password1 FAILED
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/switch-to-user.conf b/tests/scripts/switch-to-user.conf
index c6ea69ac..5789af4c 100644
--- a/tests/scripts/switch-to-user.conf
+++ b/tests/scripts/switch-to-user.conf
@@ -24,6 +24,10 @@ user-session=default
#?XSERVER-0 ACCEPT-CONNECT
#?SESSION-X-0 CONNECT-XSERVER
+# Check daemon says we can switch
+#?*SEAT-CAN-SWITCH
+#?RUNNER SEAT-CAN-SWITCH CAN-SWITCH=TRUE
+
# Switch to an account with a password
#?*SWITCH-TO-USER USERNAME=have-password1
#?RUNNER SWITCH-TO-USER USERNAME=have-password1
diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c
index dc1a384d..f1792fc2 100644
--- a/tests/src/test-runner.c
+++ b/tests/src/test-runner.c
@@ -463,7 +463,7 @@ handle_command (const gchar *command)
g_variant_new ("(ss)", "org.freedesktop.DisplayManager", "Seats"),
G_VARIANT_TYPE ("(v)"),
G_DBUS_CALL_FLAGS_NONE,
- 1000,
+ G_MAXINT,
NULL,
NULL);
@@ -499,7 +499,7 @@ handle_command (const gchar *command)
g_variant_new ("(ss)", "org.freedesktop.DisplayManager", "Sessions"),
G_VARIANT_TYPE ("(v)"),
G_DBUS_CALL_FLAGS_NONE,
- 1000,
+ G_MAXINT,
NULL,
NULL);
@@ -519,55 +519,132 @@ handle_command (const gchar *command)
check_status (status->str);
g_string_free (status, TRUE);
}
+ else if (strcmp (name, "SEAT-CAN-SWITCH") == 0)
+ {
+ GVariant *result, *value;
+ gchar *status;
+
+ result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
+ "org.freedesktop.DisplayManager",
+ "/org/freedesktop/DisplayManager/Seat0",
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ g_variant_new ("(ss)", "org.freedesktop.DisplayManager.Seat", "CanSwitch"),
+ G_VARIANT_TYPE ("(v)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ NULL);
+
+ g_variant_get (result, "(v)", &value);
+ status = g_strdup_printf ("RUNNER SEAT-CAN-SWITCH CAN-SWITCH=%s", g_variant_get_boolean (value) ? "TRUE" : "FALSE");
+ g_variant_unref (value);
+ g_variant_unref (result);
+ check_status (status);
+ g_free (status);
+ }
+ else if (strcmp (name, "SEAT-HAS-GUEST-ACCOUNT") == 0)
+ {
+ GVariant *result, *value;
+ gchar *status;
+
+ result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
+ "org.freedesktop.DisplayManager",
+ "/org/freedesktop/DisplayManager/Seat0",
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ g_variant_new ("(ss)", "org.freedesktop.DisplayManager.Seat", "HasGuestAccount"),
+ G_VARIANT_TYPE ("(v)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ NULL);
+
+ g_variant_get (result, "(v)", &value);
+ status = g_strdup_printf ("RUNNER SEAT-HAS-GUEST-ACCOUNT HAS-GUEST-ACCOUNT=%s", g_variant_get_boolean (value) ? "TRUE" : "FALSE");
+ g_variant_unref (value);
+ g_variant_unref (result);
+ check_status (status);
+ g_free (status);
+ }
else if (strcmp (name, "SWITCH-TO-GREETER") == 0)
{
- g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
- "org.freedesktop.DisplayManager",
- "/org/freedesktop/DisplayManager/Seat0",
- "org.freedesktop.DisplayManager.Seat",
- "SwitchToGreeter",
- g_variant_new ("()"),
- G_VARIANT_TYPE ("()"),
- G_DBUS_CALL_FLAGS_NONE,
- 1000,
- NULL,
- NULL);
- check_status ("RUNNER SWITCH-TO-GREETER");
+ GVariant *result;
+
+ result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
+ "org.freedesktop.DisplayManager",
+ "/org/freedesktop/DisplayManager/Seat0",
+ "org.freedesktop.DisplayManager.Seat",
+ "SwitchToGreeter",
+ g_variant_new ("()"),
+ G_VARIANT_TYPE ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ NULL);
+ if (result)
+ {
+ check_status ("RUNNER SWITCH-TO-GREETER");
+ g_variant_unref (result);
+ }
+ else
+ check_status ("RUNNER SWITCH-TO-GREETER FAILED");
}
else if (strcmp (name, "SWITCH-TO-USER") == 0)
{
- gchar *status_text, *username;
+ GVariant *result;
+ const gchar *username;
username = g_hash_table_lookup (params, "USERNAME");
- g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
- "org.freedesktop.DisplayManager",
- "/org/freedesktop/DisplayManager/Seat0",
- "org.freedesktop.DisplayManager.Seat",
- "SwitchToUser",
- g_variant_new ("(ss)", username, ""),
- G_VARIANT_TYPE ("()"),
- G_DBUS_CALL_FLAGS_NONE,
- 1000,
- NULL,
- NULL);
- status_text = g_strdup_printf ("RUNNER SWITCH-TO-USER USERNAME=%s", username);
- check_status (status_text);
- g_free (status_text);
+ result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
+ "org.freedesktop.DisplayManager",
+ "/org/freedesktop/DisplayManager/Seat0",
+ "org.freedesktop.DisplayManager.Seat",
+ "SwitchToUser",
+ g_variant_new ("(ss)", username, ""),
+ G_VARIANT_TYPE ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ NULL);
+ if (result)
+ {
+ gchar *status_text;
+ status_text = g_strdup_printf ("RUNNER SWITCH-TO-USER USERNAME=%s", username);
+ check_status (status_text);
+ g_free (status_text);
+ g_variant_unref (result);
+ }
+ else
+ {
+ gchar *status_text;
+ status_text = g_strdup_printf ("RUNNER SWITCH-TO-USER USERNAME=%s FAILED", username);
+ check_status (status_text);
+ g_free (status_text);
+ }
}
else if (strcmp (name, "SWITCH-TO-GUEST") == 0)
{
- g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
- "org.freedesktop.DisplayManager",
- "/org/freedesktop/DisplayManager/Seat0",
- "org.freedesktop.DisplayManager.Seat",
- "SwitchToGuest",
- g_variant_new ("(s)", ""),
- G_VARIANT_TYPE ("()"),
- G_DBUS_CALL_FLAGS_NONE,
- 1000,
- NULL,
- NULL);
- check_status ("RUNNER SWITCH-TO-GUEST");
+ GVariant *result;
+
+ result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
+ "org.freedesktop.DisplayManager",
+ "/org/freedesktop/DisplayManager/Seat0",
+ "org.freedesktop.DisplayManager.Seat",
+ "SwitchToGuest",
+ g_variant_new ("(s)", ""),
+ G_VARIANT_TYPE ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ NULL);
+ if (result)
+ {
+ check_status ("RUNNER SWITCH-TO-GUEST");
+ g_variant_unref (result);
+ }
+ else
+ check_status ("RUNNER SWITCH-TO-GUEST FAILED");
}
else if (strcmp (name, "STOP-DAEMON") == 0)
stop_process (lightdm_process);
diff --git a/tests/test-switch-to-greeter-disabled b/tests/test-switch-to-greeter-disabled
new file mode 100755
index 00000000..8f64682b
--- /dev/null
+++ b/tests/test-switch-to-greeter-disabled
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner switch-to-greeter-disabled test-gobject-greeter
diff --git a/tests/test-switch-to-guest-disabled b/tests/test-switch-to-guest-disabled
new file mode 100755
index 00000000..11e41c76
--- /dev/null
+++ b/tests/test-switch-to-guest-disabled
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner switch-to-guest-disabled test-gobject-greeter
diff --git a/tests/test-switch-to-user-disabled b/tests/test-switch-to-user-disabled
new file mode 100755
index 00000000..c2cd7494
--- /dev/null
+++ b/tests/test-switch-to-user-disabled
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner switch-to-user-disabled test-gobject-greeter