test(gnupg): add tests for gnupg agent configuration

Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
This commit is contained in:
Angel J 2025-12-26 07:44:43 -08:00
parent 0b53d57d3a
commit d70b24c2a8
No known key found for this signature in database
GPG key ID: B4A70CCBA08D9762
2 changed files with 32 additions and 0 deletions

View file

@ -90,6 +90,7 @@ in {
tests.networking-networkservices = makeTest ./tests/networking-networkservices.nix;
tests.nix-enable = makeTest ./tests/nix-enable.nix;
tests.nixpkgs-overlays = makeTest ./tests/nixpkgs-overlays.nix;
tests.programs-gnupg = makeTest ./tests/programs-gnupg.nix;
tests.programs-ssh = makeTest ./tests/programs-ssh.nix;
tests.programs-tmux = makeTest ./tests/programs-tmux.nix;
tests.programs-zsh = makeTest ./tests/programs-zsh.nix;

31
tests/programs-gnupg.nix Normal file
View file

@ -0,0 +1,31 @@
{
config,
lib,
pkgs,
...
}:
let
gnupg = pkgs.runCommand "gnupg-0.0.0" { } "mkdir -p $out/bin";
in
{
system.primaryUser = "test-gnupg-user";
programs.gnupg.package = gnupg;
programs.gnupg.agent.enable = true;
programs.gnupg.agent.enableSSHSupport = true;
test = ''
echo >&2 "checking gnupg-agent service in ~/Library/LaunchAgents"
grep "org.nixos.gnupg-agent" ${config.out}/user/Library/LaunchAgents/org.nixos.gnupg-agent.plist
grep "${gnupg}/bin/gpg-connect-agent" ${config.out}/user/Library/LaunchAgents/org.nixos.gnupg-agent.plist
echo >&2 "checking GPG_TTY in set-environment"
grep 'export GPG_TTY=\$(tty)' ${config.system.build.setEnvironment}
echo >&2 "checking SSH support in set-environment"
grep "${gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye" ${config.system.build.setEnvironment}
grep "${gnupg}/bin/gpgconf --list-dirs agent-ssh-socket" ${config.system.build.setEnvironment}
'';
}