From 279057b7791a051f520ff0e78aab001333bb1626 Mon Sep 17 00:00:00 2001 From: RatCornu Date: Thu, 18 Jan 2024 22:11:16 +0100 Subject: [PATCH] nixos/suwayomi-server: add nixos tests --- nixos/tests/all-tests.nix | 1 + nixos/tests/suwayomi-server.nix | 46 +++++++++++++++++++++ pkgs/by-name/su/suwayomi-server/package.nix | 6 +++ 3 files changed, 53 insertions(+) create mode 100644 nixos/tests/suwayomi-server.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 25ee587e8f7a..936d5381bbcd 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -808,6 +808,7 @@ in { stunnel = handleTest ./stunnel.nix {}; sudo = handleTest ./sudo.nix {}; sudo-rs = handleTest ./sudo-rs.nix {}; + suwayomi-server = handleTest ./suwayomi-server.nix {}; swap-file-btrfs = handleTest ./swap-file-btrfs.nix {}; swap-partition = handleTest ./swap-partition.nix {}; swap-random-encryption = handleTest ./swap-random-encryption.nix {}; diff --git a/nixos/tests/suwayomi-server.nix b/nixos/tests/suwayomi-server.nix new file mode 100644 index 000000000000..36072028380b --- /dev/null +++ b/nixos/tests/suwayomi-server.nix @@ -0,0 +1,46 @@ +{ system ? builtins.currentSystem +, pkgs +, lib ? pkgs.lib +}: +let + inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest; + inherit (lib) recursiveUpdate; + + baseTestConfig = { + meta.maintainers = with lib.maintainers; [ ratcornu ]; + nodes.machine = { pkgs, ... }: { + services.suwayomi-server = { + enable = true; + settings.server.port = 1234; + }; + }; + testScript = '' + machine.wait_for_unit("suwayomi-server.service") + machine.wait_for_open_port(1234) + machine.succeed("curl --fail http://localhost:1234/") + ''; + }; +in + +{ + without-auth = makeTest (recursiveUpdate baseTestConfig { + name = "suwayomi-server-without-auth"; + }); + + with-auth = makeTest (recursiveUpdate baseTestConfig { + name = "suwayomi-server-with-auth"; + + nodes.machine = { pkgs, ... }: { + services.suwayomi-server = { + enable = true; + + settings.server = { + port = 1234; + basicAuthEnabled = true; + basicAuthUsername = "alice"; + basicAuthPasswordFile = pkgs.writeText "snakeoil-pass.txt" "pass"; + }; + }; + }; + }); +} diff --git a/pkgs/by-name/su/suwayomi-server/package.nix b/pkgs/by-name/su/suwayomi-server/package.nix index b49e55b4b011..01b6df8dafdf 100644 --- a/pkgs/by-name/su/suwayomi-server/package.nix +++ b/pkgs/by-name/su/suwayomi-server/package.nix @@ -3,6 +3,7 @@ , fetchurl , makeWrapper , jdk17_headless +, nixosTests }: let @@ -34,6 +35,11 @@ stdenvNoCC.mkDerivation (finalAttrs: { runHook postBuild ''; + passthru.tests = { + suwayomi-server-with-auth = nixosTests.suwayomi-server.with-auth; + suwayomi-server-without-auth = nixosTests.suwayomi-server.without-auth; + }; + meta = with lib; { description = "A free and open source manga reader server that runs extensions built for Tachiyomi."; longDescription = ''