Skip to content

Commit

Permalink
test: configuradorfnmt 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 2d27625 commit eac3e7a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
};
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; };
};
};
Expand Down
58 changes: 58 additions & 0 deletions nix/tests/nixos/configuradorfnmt-request.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-configuradorfnmt-request";
nodes.machine = { config, pkgs, modulesPath, ... }: {
imports = [
self.nixosModules.configuradorfnmt
(modulesPath + "./../tests/common/x11.nix")
];

programs.configuradorfnmt.enable = true;
programs.configuradorfnmt.firefoxIntegration.enable = true;

programs.firefox.enable = true;

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

environment.systemPackages = [
(pkgs.writeScriptBin "open-configuradorfnmt-via-firefox" ''
cat <<'EOF' > /tmp/configuradorfnmt.html
<html>
<head>
<meta http-equiv="refresh" content="0;url=fnmtcr://request?fileid=0">
</head>
<body>
<p>Redirecting to configuradorfnmt...</p>
</body>
</html>
EOF
${lib.getExe config.programs.firefox.package} /tmp/configuradorfnmt.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 fnmtcr:// URL in Firefox
machine.execute("open-configuradorfnmt-via-firefox")
# Configurador FNMT-RCM should open automatically
machine.wait_for_window('Introduzca la contraseña', 30)
machine.screenshot("screen")
'';
}

0 comments on commit eac3e7a

Please sign in to comment.