summary refs log tree commit diff
path: root/nixos/tests/common
diff options
context:
space:
mode:
authornikstur <nikstur@outlook.com>2023-07-17 17:19:44 +0200
committernikstur <nikstur@outlook.com>2023-07-26 20:32:51 +0200
commit7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe (patch)
treee645d13a6742dc4dc4c2a438fdfde4ff469c4e25 /nixos/tests/common
parent78df3591ec67310b8cc4b753e1496999da2678cf (diff)
downloadnixpkgs-7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe.tar
nixpkgs-7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe.tar.gz
nixpkgs-7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe.tar.bz2
nixpkgs-7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe.tar.lz
nixpkgs-7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe.tar.xz
nixpkgs-7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe.tar.zst
nixpkgs-7e522a81ef99a2e7ce0b86bd2c5fd33233e464fe.zip
nixos/tests: refactor gpg-keyring test utility
Diffstat (limited to 'nixos/tests/common')
-rw-r--r--nixos/tests/common/gpg-keyring.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/nixos/tests/common/gpg-keyring.nix b/nixos/tests/common/gpg-keyring.nix
new file mode 100644
index 00000000000..50b5846b096
--- /dev/null
+++ b/nixos/tests/common/gpg-keyring.nix
@@ -0,0 +1,23 @@
+{ pkgs, ... }:
+
+pkgs.runCommand "gpg-keyring" { nativeBuildInputs = [ pkgs.gnupg ]; } ''
+  mkdir -p $out
+  export GNUPGHOME=$out
+  cat > foo <<EOF
+    %echo Generating a basic OpenPGP key
+    %no-protection
+    Key-Type: DSA
+    Key-Length: 1024
+    Subkey-Type: ELG-E
+    Subkey-Length: 1024
+    Name-Real: Bob Foobar
+    Name-Email: bob@foo.bar
+    Expire-Date: 0
+    # Do a commit here, so that we can later print "done"
+    %commit
+    %echo done
+  EOF
+  gpg --batch --generate-key foo
+  rm $out/S.gpg-agent $out/S.gpg-agent.*
+  gpg --export bob@foo.bar -a > $out/pubkey.gpg
+''