1import ./make-test-python.nix ({ pkgs, ...} :
2
3{
4 name = "keepassxc";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ turion ];
7 };
8
9 nodes.machine = { ... }:
10
11 {
12 imports = [
13 ./common/user-account.nix
14 ./common/x11.nix
15 ];
16
17 services.xserver.enable = true;
18
19 # Regression test for https://github.com/NixOS/nixpkgs/issues/163482
20 qt5 = {
21 enable = true;
22 platformTheme = "gnome";
23 style = "adwaita-dark";
24 };
25
26 test-support.displayManager.auto.user = "alice";
27 environment.systemPackages = with pkgs; [
28 keepassxc
29 xdotool
30 ];
31 };
32
33 enableOCR = true;
34
35 testScript = { nodes, ... }: let
36 aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");'';
37 in ''
38 with subtest("Ensure X starts"):
39 start_all()
40 machine.wait_for_x()
41
42 with subtest("Can create database and entry with CLI"):
43 ${aliceDo "keepassxc-cli db-create -k foo.keyfile foo.kdbx"}
44 ${aliceDo "keepassxc-cli add --no-password -k foo.keyfile foo.kdbx bar"}
45
46 with subtest("Ensure KeePassXC starts"):
47 # start KeePassXC window
48 ${aliceDo "keepassxc >&2 &"}
49
50 machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}")
51 machine.screenshot("KeePassXC")
52
53 with subtest("Can open existing database"):
54 machine.send_key("ctrl-o")
55 machine.sleep(5)
56 # Regression #163482: keepassxc did not crash
57 machine.succeed("ps -e | grep keepassxc")
58 machine.wait_for_text("foo.kdbx")
59 machine.send_key("ret")
60 machine.sleep(1)
61 # Click on "Browse" button to select keyfile
62 machine.send_key("tab")
63 machine.send_chars("/home/alice/foo.keyfile")
64 machine.send_key("ret")
65 # Database is unlocked (doesn't have "[Locked]" in the title anymore)
66 machine.wait_for_text("foo.kdbx - KeePassXC")
67 '';
68})