diff --git a/flake.nix b/flake.nix index e51151b..aedaf68 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; }; }; }; diff --git a/nix/tests/hm/nixos-module-installation/autofirma-sign.nix b/nix/tests/hm-as-nixos-module/autofirma/cli/sign-document.nix similarity index 100% rename from nix/tests/hm/nixos-module-installation/autofirma-sign.nix rename to nix/tests/hm-as-nixos-module/autofirma/cli/sign-document.nix diff --git a/nix/tests/nixos/autofirma-sign.nix b/nix/tests/nixos/autofirma/cli/sign-document.nix similarity index 100% rename from nix/tests/nixos/autofirma-sign.nix rename to nix/tests/nixos/autofirma/cli/sign-document.nix diff --git a/nix/tests/nixos/autofirma/firefoxIntegration/sign-document.nix b/nix/tests/nixos/autofirma/firefoxIntegration/sign-document.nix new file mode 100644 index 0000000..645a197 --- /dev/null +++ b/nix/tests/nixos/autofirma/firefoxIntegration/sign-document.nix @@ -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 + +
+ + + +Redirecting to autofirma...
+ + + 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") + ''; +} diff --git a/nix/tests/nixos/configuradorfnmt-request.nix b/nix/tests/nixos/configuradorfnmt/firefoxIntegration/request-certificate.nix similarity index 100% rename from nix/tests/nixos/configuradorfnmt-request.nix rename to nix/tests/nixos/configuradorfnmt/firefoxIntegration/request-certificate.nix