base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / nixos / tests / keepassxc.nix
blobd487d87fbacbd00ec42fa5aeb8a872bb0e0c56c8
1 import ./make-test-python.nix ({ pkgs, ...} :
4   name = "keepassxc";
5   meta = with pkgs.lib.maintainers; {
6     maintainers = [ turion ];
7     timeout = 1800;
8   };
10   nodes.machine = { ... }:
12   {
13     imports = [
14       ./common/user-account.nix
15       ./common/x11.nix
16     ];
18     services.xserver.enable = true;
20     # for better OCR
21     environment.etc."icewm/prefoverride".text = ''
22       ColorActiveTitleBar = "rgb:FF/FF/FF"
23     '';
25     # Regression test for https://github.com/NixOS/nixpkgs/issues/163482
26     qt = {
27       enable = true;
28       platformTheme = "gnome";
29       style = "adwaita-dark";
30     };
32     test-support.displayManager.auto.user = "alice";
33     environment.systemPackages = with pkgs; [
34       keepassxc
35       xdotool
36     ];
37   };
39   enableOCR = true;
41   testScript = { nodes, ... }: let
42     aliceDo = cmd: ''machine.succeed("su - alice -c '${cmd}' >&2 &");'';
43     in ''
44     with subtest("Ensure X starts"):
45         start_all()
46         machine.wait_for_x()
48     with subtest("Can create database and entry with CLI"):
49         ${aliceDo "keepassxc-cli db-create --set-key-file foo.keyfile foo.kdbx"}
50         ${aliceDo "keepassxc-cli add --no-password -k foo.keyfile foo.kdbx bar"}
52     with subtest("Ensure KeePassXC starts"):
53         # start KeePassXC window
54         ${aliceDo "keepassxc >&2 &"}
56         machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}")
57         machine.screenshot("KeePassXC")
59     with subtest("Can open existing database"):
60         machine.send_key("ctrl-o")
61         machine.sleep(5)
62         # Regression #163482: keepassxc did not crash
63         machine.succeed("ps -e | grep keepassxc")
64         machine.wait_for_text("Open database")
65         machine.send_key("ret")
67         # Wait for the enter password screen to appear.
68         machine.wait_for_text("/home/alice/foo.kdbx")
70         # Click on "I have key file" button to open keyfile dialog
71         machine.send_key("tab")
72         machine.send_key("tab")
73         machine.send_key("tab")
74         machine.send_key("ret")
76         # Select keyfile
77         machine.wait_for_text("Select key file")
78         machine.send_chars("/home/alice/foo.keyfile")
79         machine.send_key("ret")
81         # Open database
82         machine.wait_for_text("foo.kdbx \\[Locked] - KeePassXC")
83         machine.send_key("ret")
85         # Database is unlocked (doesn't have "[Locked]" in the title anymore)
86         machine.wait_for_text("foo.kdbx - KeePassXC")
87   '';