From f8b6ba005e8dc259a6ae065b1322bb879380aa57 Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sun, 18 Jul 2021 09:51:49 +0200 Subject: [PATCH] nixos/tests: Init hockeypuck tests --- nixos/tests/all-tests.nix | 1 + nixos/tests/hockeypuck.nix | 63 ++++++++++++++++++++++++++++++ pkgs/servers/hockeypuck/server.nix | 4 +- pkgs/servers/hockeypuck/web.nix | 4 +- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 nixos/tests/hockeypuck.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index fd502a473b1..746139c4816 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -174,6 +174,7 @@ in hitch = handleTest ./hitch {}; hledger-web = handleTest ./hledger-web.nix {}; hocker-fetchdocker = handleTest ./hocker-fetchdocker {}; + hockeypuck = handleTest ./hockeypuck.nix { }; home-assistant = handleTest ./home-assistant.nix {}; hostname = handleTest ./hostname.nix {}; hound = handleTest ./hound.nix {}; diff --git a/nixos/tests/hockeypuck.nix b/nixos/tests/hockeypuck.nix new file mode 100644 index 00000000000..79313f314fd --- /dev/null +++ b/nixos/tests/hockeypuck.nix @@ -0,0 +1,63 @@ +import ./make-test-python.nix ({ lib, pkgs, ... }: +let + gpgKeyring = (pkgs.runCommandNoCC "gpg-keyring" { buildInputs = [ pkgs.gnupg ]; } '' + mkdir -p $out + export GNUPGHOME=$out + cat > foo <OpenPGP Keyserver" in response, "HTML title not found" + + # Copy the keyring + machine.succeed("cp -R ${gpgKeyring} /tmp/GNUPGHOME") + + # Extract our GPG key id + keyId = machine.succeed("GNUPGHOME=/tmp/GNUPGHOME gpg --list-keys | grep dsa1024 --after-context=1 | grep -v dsa1024").strip() + + # Send the key to our local keyserver + machine.succeed("GNUPGHOME=/tmp/GNUPGHOME gpg --keyserver hkp://127.0.0.1:11371 --send-keys " + keyId) + + # Recieve the key from our local keyserver to a separate directory + machine.succeed("GNUPGHOME=$(mktemp -d) gpg --keyserver hkp://127.0.0.1:11371 --recv-keys " + keyId) + ''; +}) diff --git a/pkgs/servers/hockeypuck/server.nix b/pkgs/servers/hockeypuck/server.nix index 5a95f227832..cf48fd5716c 100644 --- a/pkgs/servers/hockeypuck/server.nix +++ b/pkgs/servers/hockeypuck/server.nix @@ -1,4 +1,4 @@ -{ lib, buildGoModule, fetchFromGitHub }: +{ lib, buildGoModule, fetchFromGitHub, nixosTests }: let sources = (import ./sources.nix) { inherit fetchFromGitHub; }; @@ -10,6 +10,8 @@ buildGoModule { vendorSha256 = null; doCheck = false; # Uses networking for tests + passthru.tests = nixosTests.hockeypuck; + meta = with lib; { description = "OpenPGP Key Server"; homepage = "https://github.com/hockeypuck/hockeypuck"; diff --git a/pkgs/servers/hockeypuck/web.nix b/pkgs/servers/hockeypuck/web.nix index eda5317e8c4..32f2b1acd22 100644 --- a/pkgs/servers/hockeypuck/web.nix +++ b/pkgs/servers/hockeypuck/web.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchFromGitHub }: +{ stdenv, lib, fetchFromGitHub, nixosTests }: let sources = (import ./sources.nix) { inherit fetchFromGitHub; }; @@ -17,6 +17,8 @@ stdenv.mkDerivation { cp -vr contrib/templates $out/share/ ''; + passthru.tests = nixosTests.hockeypuck; + meta = with lib; { description = "OpenPGP Key Server web resources"; homepage = "https://github.com/hockeypuck/hockeypuck";