Skip to content

Commit

Permalink
fix: autofirma sign test. Closes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
nilp0inter committed Jan 4, 2025
1 parent 146bce2 commit 98eb8f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
10 changes: 1 addition & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,7 @@
default = self'.packages.autofirma;
};
checks = {
# autofirma-sign = pkgs.runCommand "autofirma-sign" {} ''
# mkdir -p $out
# echo "NixOS AutoFirma Sign Test" > document.txt
#
# ${inputs.nixpkgs.lib.getExe pkgs.openssl} req -x509 -newkey rsa:2048 -keyout private.key -out certificate.crt -days 365 -nodes -subj "/C=ES/O=TEST AUTOFIRMA NIX/OU=DNIE/CN=AC DNIE 004" -passout pass:1234
# ${inputs.nixpkgs.lib.getExe pkgs.openssl} pkcs12 -export -out certificate.p12 -inkey private.key -in certificate.crt -name "testcert" -password pass:1234
#
# ${inputs.nixpkgs.lib.getExe self'.packages.autofirma} sign -store pkcs12:certificate.p12 -i document.txt -o document.txt.sign -filter alias.contains=testcert -password 1234 -xml
# '';
nixos-module-sign = pkgs.callPackage ./nix/tests/test-sign.nix { inherit self; };
};
};
};
Expand Down
28 changes: 28 additions & 0 deletions nix/tests/test-sign.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ self, pkgs, lib }:
let
openssl = lib.getExe pkgs.openssl;
in

pkgs.nixosTest {
name = "test-nixos-module-sign";
nodes.machine = { config, pkgs, modulesPath, ... }: {
imports = [
self.nixosModules.autofirma
(modulesPath + "./../tests/common/x11.nix")
];

programs.autofirma.enable = true;

system.stateVersion = "${lib.versions.major lib.version}.${lib.versions.minor lib.version}";
};

testScript = ''
machine.succeed('echo "NixOS AutoFirma Sign Test" > document.txt')
machine.succeed('${openssl} req -x509 -newkey rsa:2048 -keyout private.key -out certificate.crt -days 365 -nodes -subj "/C=ES/O=TEST AUTOFIRMA NIX/OU=DNIE/CN=AC DNIE 004" -passout pass:1234')
machine.succeed('${openssl} pkcs12 -export -out certificate.p12 -inkey private.key -in certificate.crt -name "testcert" -password pass:1234')
machine.wait_for_x()
machine.succeed('autofirma sign -store pkcs12:certificate.p12 -i document.txt -o document.txt.sign -filter alias.contains=testcert -password 1234 -xml')
'';
}

0 comments on commit 98eb8f8

Please sign in to comment.