Skip to content

Commit

Permalink
test: autofirma nixos module firefox integration
Browse files Browse the repository at this point in the history
  • Loading branch information
nilp0inter committed Jan 7, 2025
1 parent eac3e7a commit 5dd1c2a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@
default = self'.packages.autofirma;
};
checks = {
nixos-autofirma-sign = pkgs.callPackage ./nix/tests/nixos/autofirma-sign.nix { inherit self; };
nixos-configuradorfnmt-request = pkgs.callPackage ./nix/tests/nixos/configuradorfnmt-request.nix { inherit self; };
hm-nixos-module-installation-autofirma-sign = pkgs.callPackage ./nix/tests/hm/nixos-module-installation/autofirma-sign.nix { inherit self home-manager; };
nixos-autofirma-cli-sign-document = pkgs.callPackage ./nix/tests/nixos/autofirma/cli/sign-document.nix { inherit self; };
nixos-autofirma-firefoxIntegration-sign-document = pkgs.callPackage ./nix/tests/nixos/autofirma/firefoxIntegration/sign-document.nix { inherit self; };
nixos-configuradorfnmt-firefoxIntegration-request = pkgs.callPackage ./nix/tests/nixos/configuradorfnmt/firefoxIntegration/request-certificate.nix { inherit self; };
hm-as-nixos-module-autofirma-cli-sign-document = pkgs.callPackage ./nix/tests/hm-as-nixos-module/autofirma/cli/sign-document.nix { inherit self home-manager; };
};
};
};
Expand Down
File renamed without changes.
58 changes: 58 additions & 0 deletions nix/tests/nixos/autofirma/firefoxIntegration/sign-document.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{ self, pkgs, lib }:
let
stateVersion = "${lib.versions.major lib.version}.${lib.versions.minor lib.version}";
in
pkgs.nixosTest {
name = "test-nixos-autofirma-firefoxIntegration-sign-document";
nodes.machine = { config, pkgs, modulesPath, ... }: {
imports = [
self.nixosModules.autofirma
(modulesPath + "./../tests/common/x11.nix")
];

programs.autofirma.enable = true;
programs.autofirma.firefoxIntegration.enable = true;

programs.firefox.enable = true;

# Allow Firefox to open AutoConfig settings without user interaction
programs.firefox.autoConfig = ''
pref("network.protocol-handler.expose.afirma", true);
'';

environment.systemPackages = [
(pkgs.writeScriptBin "open-autofirma-via-firefox" ''
cat <<'EOF' > /tmp/autofirma.html
<html>
<head>
<meta http-equiv="refresh" content="0;url=afirma://sign?op=sign&algorithm=SHA256withRSA&format=AUTO">
</head>
<body>
<p>Redirecting to autofirma...</p>
</body>
</html>
EOF
${lib.getExe config.programs.firefox.package} /tmp/autofirma.html
'')
];
system.stateVersion = stateVersion;
};

testScript = ''
machine.wait_for_unit("default.target")
machine.wait_for_x()
# Open firefox and allow it to import AutoConfig settings
machine.execute("firefox >&2 &")
machine.wait_for_window("Mozilla Firefox")
machine.sleep(5)
# Open an afirma:// URL in Firefox
machine.execute("open-autofirma-via-firefox")
# Wait for the AutoFirma window to appear
machine.wait_for_window('Seleccione el fichero de datos a firmar', 30)
machine.screenshot("screen")
'';
}

0 comments on commit 5dd1c2a

Please sign in to comment.