From f341151cfa872ff8d80d3c00e090380920cda8c5 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 25 Mar 2023 17:02:52 +0100 Subject: [PATCH] nixos/tests/pixelfed: init test --- nixos/tests/all-tests.nix | 1 + nixos/tests/web-apps/pixelfed/default.nix | 8 +++++ nixos/tests/web-apps/pixelfed/standard.nix | 38 ++++++++++++++++++++++ pkgs/servers/web-apps/pixelfed/default.nix | 3 ++ 4 files changed, 50 insertions(+) create mode 100644 nixos/tests/web-apps/pixelfed/default.nix create mode 100644 nixos/tests/web-apps/pixelfed/standard.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 8386219f73d8..38ff9f8cca4c 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -392,6 +392,7 @@ in { man = handleTest ./man.nix {}; mariadb-galera = handleTest ./mysql/mariadb-galera.nix {}; mastodon = discoverTests (import ./web-apps/mastodon { inherit handleTestOn; }); + pixelfed = discoverTests (import ./web-apps/pixelfed { inherit handleTestOn; }); mate = handleTest ./mate.nix {}; matomo = handleTest ./matomo.nix {}; matrix-appservice-irc = handleTest ./matrix/appservice-irc.nix {}; diff --git a/nixos/tests/web-apps/pixelfed/default.nix b/nixos/tests/web-apps/pixelfed/default.nix new file mode 100644 index 000000000000..4464ebe43486 --- /dev/null +++ b/nixos/tests/web-apps/pixelfed/default.nix @@ -0,0 +1,8 @@ +{ system ? builtins.currentSystem, handleTestOn }: +let + supportedSystems = [ "x86_64-linux" "i686-linux" ]; + +in +{ + standard = handleTestOn supportedSystems ./standard.nix { inherit system; }; +} diff --git a/nixos/tests/web-apps/pixelfed/standard.nix b/nixos/tests/web-apps/pixelfed/standard.nix new file mode 100644 index 000000000000..9260e27af960 --- /dev/null +++ b/nixos/tests/web-apps/pixelfed/standard.nix @@ -0,0 +1,38 @@ +import ../../make-test-python.nix ({pkgs, ...}: +{ + name = "pixelfed-standard"; + meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ]; + + nodes = { + server = { pkgs, ... }: { + services.pixelfed = { + enable = true; + domain = "pixelfed.local"; + # Configure NGINX. + nginx = {}; + secretFile = (pkgs.writeText "secrets.env" '' + # Snakeoil secret, can be any random 32-chars secret via CSPRNG. + APP_KEY=adKK9EcY8Hcj3PLU7rzG9rJ6KKTOtYfA + ''); + settings."FORCE_HTTPS_URLS" = false; + }; + }; + }; + + testScript = '' + # Wait for Pixelfed PHP pool + server.wait_for_unit("phpfpm-pixelfed.service") + # Wait for NGINX + server.wait_for_unit("nginx.service") + # Wait for HTTP port + server.wait_for_open_port(80) + # Access the homepage. + server.succeed("curl -H 'Host: pixelfed.local' http://localhost") + # Create an account + server.succeed("pixelfed-manage user:create --name=test --username=test --email=test@test.com --password=test") + # Create a OAuth token. + # TODO: figure out how to use it to send a image/toot + # server.succeed("pixelfed-manage passport:client --personal") + # server.succeed("curl -H 'Host: pixefed.local' -H 'Accept: application/json' -H 'Authorization: Bearer secret' -F'status'='test' http://localhost/api/v1/statuses") + ''; +}) diff --git a/pkgs/servers/web-apps/pixelfed/default.nix b/pkgs/servers/web-apps/pixelfed/default.nix index fb9b68f4af51..5a8dfbabd395 100644 --- a/pkgs/servers/web-apps/pixelfed/default.nix +++ b/pkgs/servers/web-apps/pixelfed/default.nix @@ -3,6 +3,7 @@ , fetchFromGitHub , php , pkgs +, nixosTests , dataDir ? "/var/lib/pixelfed" , runtimeDir ? "/run/pixelfed" }: @@ -37,6 +38,8 @@ in package.override rec { hash = "sha256-ZrvYKMSx5WymWR46/UKr5jCsclXXzBeY21ju22zeqN0="; }; + passthru.tests = { inherit (nixosTests) pixelfed; }; + meta = with lib; { description = "A federated image sharing platform"; license = licenses.agpl3Only;