From 2ac527530e3d3b9e335d511a6fe2736ceffe90c1 Mon Sep 17 00:00:00 2001 From: Manuel Bärenz Date: Thu, 10 Mar 2022 21:31:10 +0100 Subject: nixosTests.keepassxc: Add regression test for #163482 --- nixos/tests/keepassxc.nix | 50 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/nixos/tests/keepassxc.nix b/nixos/tests/keepassxc.nix index 685a200b318..924c137a903 100644 --- a/nixos/tests/keepassxc.nix +++ b/nixos/tests/keepassxc.nix @@ -15,20 +15,54 @@ import ./make-test-python.nix ({ pkgs, ...} : ]; services.xserver.enable = true; + + # Regression test for https://github.com/NixOS/nixpkgs/issues/163482 + qt5 = { + enable = true; + platformTheme = "gnome"; + style = "adwaita-dark"; + }; + test-support.displayManager.auto.user = "alice"; - environment.systemPackages = [ pkgs.keepassxc ]; + environment.systemPackages = with pkgs; [ + keepassxc + xdotool + ]; }; enableOCR = true; - testScript = { nodes, ... }: '' - start_all() - machine.wait_for_x() + testScript = { nodes, ... }: let + aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");''; + in '' + with subtest("Ensure X starts"): + start_all() + machine.wait_for_x() + + with subtest("Can create database and entry with CLI"): + ${aliceDo "keepassxc-cli db-create -k foo.keyfile foo.kdbx"} + ${aliceDo "keepassxc-cli add --no-password -k foo.keyfile foo.kdbx bar"} + + with subtest("Ensure KeePassXC starts"): + # start KeePassXC window + ${aliceDo "keepassxc >&2 &"} - # start KeePassXC window - machine.execute("su - alice -c keepassxc >&2 &") + machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}") + machine.screenshot("KeePassXC") - machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}") - machine.screenshot("KeePassXC") + with subtest("Can open existing database"): + machine.send_key("ctrl-o") + machine.sleep(5) + # Regression #163482: keepassxc did not crash + machine.succeed("ps -e | grep keepassxc") + machine.wait_for_text("foo.kdbx") + machine.send_key("ret") + machine.sleep(1) + # Click on "Browse" button to select keyfile + machine.send_key("tab") + machine.send_chars("/home/alice/foo.keyfile") + machine.send_key("ret") + # Passwords folder is displayed + machine.wait_for_text("Passwords") ''; }) -- cgit 1.4.1