1 import ./make-test-python.nix ({ pkgs, ...} :
4 sqlcipher-signal = pkgs.writeShellScriptBin "sqlcipher" ''
7 readonly CFG=~/.config/Signal/config.json
8 readonly KEY="$(${pkgs.jq}/bin/jq --raw-output '.key' $CFG)"
10 readonly SQL="SELECT * FROM sqlite_master where type='table'"
11 ${pkgs.sqlcipher}/bin/sqlcipher "$DB" "PRAGMA key = \"x'$KEY'\"; $SQL"
14 name = "signal-desktop";
15 meta = with pkgs.lib.maintainers; {
16 maintainers = [ flokli primeos ];
19 nodes.machine = { ... }:
23 ./common/user-account.nix
27 services.xserver.enable = true;
28 test-support.displayManager.auto.user = "alice";
29 environment.systemPackages = with pkgs; [
30 signal-desktop file sqlite sqlcipher-signal
36 testScript = { nodes, ... }: let
37 user = nodes.machine.config.users.users.alice;
42 # start signal desktop
43 machine.execute("su - alice -c signal-desktop >&2 &")
45 # Wait for the Signal window to appear. Since usually the tests
46 # are run sandboxed and therfore with no internet, we can not wait
47 # for the message "Link your phone ...". Nor should we wait for
48 # the "Failed to connect to server" message, because when manually
49 # running this test it will be not sandboxed.
50 machine.wait_for_text("Signal")
51 machine.wait_for_text("File Edit View Window Help")
52 machine.screenshot("signal_desktop")
54 # Test if the database is encrypted to prevent these issues:
55 # - https://github.com/NixOS/nixpkgs/issues/108772
56 # - https://github.com/NixOS/nixpkgs/pull/117555
57 print(machine.succeed("su - alice -c 'file ~/.config/Signal/sql/db.sqlite'"))
59 "su - alice -c 'file ~/.config/Signal/sql/db.sqlite' | grep -e SQLite -e database"
61 # Only SQLCipher should be able to read the encrypted DB:
63 "su - alice -c 'sqlite3 ~/.config/Signal/sql/db.sqlite .tables'"
65 print(machine.succeed(
66 "su - alice -c 'sqlcipher ~/.config/Signal/sql/db.sqlite'"