-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01d242d
commit 8369399
Showing
4 changed files
with
88 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,26 @@ pkgs.nixosTest { | |
|
||
services.xserver.enable = true; | ||
services.xserver.displayManager = { | ||
lightdm.enable = true; | ||
gdm.enable = true; | ||
gdm.debug = true; | ||
autoLogin = { | ||
enable = true; | ||
user = "alice"; | ||
}; | ||
}; | ||
services.xserver.desktopManager.mate.enable = true; | ||
services.xserver.desktopManager.gnome.enable = true; | ||
services.xserver.desktopManager.gnome.debug = true; | ||
services.xserver.displayManager.defaultSession = "gnome-xorg"; | ||
systemd.user.services = { | ||
"org.gnome.Shell@x11" = { | ||
serviceConfig = { | ||
ExecStart = [ | ||
"" | ||
"${pkgs.gnome.gnome-shell}/bin/gnome-shell --unsafe-mode" | ||
]; | ||
}; | ||
}; | ||
}; | ||
|
||
# This just quiets some log spam we don't care about | ||
hardware.pulseaudio.enable = true; | ||
|
@@ -40,40 +53,76 @@ pkgs.nixosTest { | |
system.stateVersion = "23.05"; | ||
}; | ||
|
||
enableOCR = true; | ||
|
||
testScript = { nodes, ... }: | ||
let | ||
user = nodes.machine.users.users.alice; | ||
user = nodes.machine.config.users.users.alice; | ||
uid = toString user.uid; | ||
bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus"; | ||
xauthority = "/run/user/${uid}/gdm/Xauthority"; | ||
display = "DISPLAY=:0.0"; | ||
env = "${bus} XAUTHORITY=${xauthority} ${display}"; | ||
gdbus = "${env} gdbus"; | ||
su = command: "su - ${user.name} -c '${env} ${command}'"; | ||
eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval"; | ||
startingUp = su "${gdbus} ${eval} Main.layoutManager._startingUp"; | ||
launchConsole = su "${bus} gapplication launch org.gnome.Console"; | ||
wmClass = su "${gdbus} ${eval} global.display.focus_window.wm_class"; | ||
in | ||
'' | ||
machine.start() | ||
# TODO: currently launcher will shut itself down if its secret file doesn't exist, | ||
# so we don't get all the way through setup and launcher doesn't stay running. | ||
# In the future, we'll want to validate setup and that the service is running. | ||
with subtest("Login to GNOME Xorg with GDM"): | ||
machine.wait_for_x() | ||
machine.wait_for_unit("default.target", "${user.name}") | ||
machine.wait_for_file("${xauthority}") | ||
machine.succeed("xauth merge ${xauthority}") | ||
assert "alice" in machine.succeed("getfacl -p /dev/snd/timer") | ||
with subtest("kolide-launcher service starts"): | ||
machine.wait_for_unit("kolide-launcher.service") | ||
machine.sleep(10) | ||
machine.systemctl("stop kolide-launcher.service") | ||
with subtest("Wait for GNOME Shell"): | ||
machine.wait_until_succeeds( | ||
"${startingUp} | grep -q 'true,..false'" | ||
) | ||
with subtest("Open Console"): | ||
machine.send_key("esc") | ||
machine.succeed( | ||
"${launchConsole}" | ||
) | ||
machine.wait_until_succeeds( | ||
"${wmClass} | grep -q 'true,...kgx'" | ||
) | ||
machine.sleep(20) | ||
machine.screenshot("test-screen1.png") | ||
''' | ||
with subtest("enable appindicator extension"): | ||
machine.succeed("${su "gnome-extensions enable [email protected]"}") | ||
machine.screenshot("test-screen5.png") | ||
with subtest("set up secret file"): | ||
machine.copy_from_host("${./test-secret}", "/etc/kolide-k2/secret") | ||
with subtest("launcher set up correctly"): | ||
with subtest("launcher service runs and is set up correctly"): | ||
machine.systemctl("stop kolide-launcher.service") | ||
machine.systemctl("start kolide-launcher.service") | ||
machine.wait_for_unit("kolide-launcher.service", timeout=120) | ||
machine.wait_for_file("/var/kolide-k2/k2device.kolide.com/debug.json") | ||
machine.sleep(60) | ||
machine.screenshot("test-screen7.png") | ||
machine.wait_until_succeeds("pgrep osqueryd", timeout=30) | ||
with subtest("get a screenshot"): | ||
machine.wait_for_unit("display-manager.service") | ||
with subtest("launcher desktop runs"): | ||
machine.wait_for_file("/var/kolide-k2/k2device.kolide.com/kolide.png") | ||
machine.wait_for_file("/var/kolide-k2/k2device.kolide.com/menu.json") | ||
machine.screenshot("test-screen8.png") | ||
machine.wait_for_file("${user.home}/.Xauthority") | ||
machine.succeed("xauth merge ${user.home}/.Xauthority") | ||
# print(machine.get_screen_text()) | ||
machine.wait_until_succeeds("pgrep marco") | ||
machine.wait_for_window("marco") | ||
machine.wait_until_succeeds("pgrep mate-panel") | ||
machine.wait_for_window("Top Panel") | ||
machine.wait_for_window("Bottom Panel") | ||
machine.wait_until_succeeds("pgrep caja") | ||
machine.wait_for_window("Caja") | ||
machine.sleep(20) | ||
machine.screenshot("test.png") | ||
# machine.wait_until_succeeds("pgrep -U ${uid} launcher") | ||
# machine.screenshot("test-screen9.png") | ||
''' | ||
machine.shutdown() | ||
''; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test-secret |