-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: autofirma nixos module firefox integration
- Loading branch information
1 parent
eac3e7a
commit 5dd1c2a
Showing
5 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions
58
nix/tests/nixos/autofirma/firefoxIntegration/sign-document.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
''; | ||
} |
File renamed without changes.