summary refs log tree commit diff
path: root/nixos/tests/keepassxc.nix
blob: d0f353c71e0ba1d19e699dcdee9a11e4ff530b68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import ./make-test-python.nix ({ pkgs, ...} :

{
  name = "keepassxc";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ turion ];
  };

  nodes.machine = { ... }:

  {
    imports = [
      ./common/user-account.nix
      ./common/x11.nix
    ];

    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 = with pkgs; [
      keepassxc
      xdotool
    ];
  };

  enableOCR = true;

  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 &"}

        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")
  '';
})