diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 0d75a616e23a..6dce1e68f9d1 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1123,6 +1123,7 @@ in redmine = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./redmine.nix { }; renovate = handleTest ./renovate.nix { }; replace-dependencies = handleTest ./replace-dependencies { }; + reposilite = runTest ./reposilite.nix; restartByActivationScript = handleTest ./restart-by-activation-script.nix { }; restic-rest-server = handleTest ./restic-rest-server.nix { }; restic = handleTest ./restic.nix { }; diff --git a/nixos/tests/reposilite.nix b/nixos/tests/reposilite.nix new file mode 100644 index 000000000000..f66a95b47a1d --- /dev/null +++ b/nixos/tests/reposilite.nix @@ -0,0 +1,53 @@ +{ lib, ... }: +{ + name = "reposilite"; + + nodes = { + machine = + { pkgs, ... }: + { + services = { + mysql = { + enable = true; + package = pkgs.mariadb; + ensureDatabases = [ "reposilite" ]; + initialScript = pkgs.writeText "reposilite-test-db-init" '' + CREATE USER 'reposilite'@'localhost' IDENTIFIED BY 'ReposiliteDBPass'; + GRANT ALL PRIVILEGES ON reposilite.* TO 'reposilite'@'localhost'; + FLUSH PRIVILEGES; + ''; + }; + + reposilite = { + enable = true; + plugins = with pkgs.reposilitePlugins; [ + checksum + groovy + ]; + extraArgs = [ + "--token" + "test:SuperSecretTestToken" + ]; + database = { + type = "mariadb"; + passwordFile = "/run/reposiliteDbPass"; + }; + settings.port = 8080; + }; + }; + }; + }; + + testScript = '' + machine.start() + + machine.execute("echo \"ReposiliteDBPass\" > /run/reposiliteDbPass && chmod 600 /run/reposiliteDbPass && chown reposilite:reposilite /run/reposiliteDbPass") + machine.wait_for_unit("reposilite.service") + machine.wait_for_open_port(8080) + + machine.fail("curl -Sf localhost:8080/api/auth/me") + machine.succeed("curl -Sfu test:SuperSecretTestToken localhost:8080/api/auth/me") + ''; + + meta.maintainers = [ lib.maintainers.uku3lig ]; +} diff --git a/pkgs/by-name/re/reposilite/package.nix b/pkgs/by-name/re/reposilite/package.nix index 0cdb557714ca..c19c0f013ebd 100644 --- a/pkgs/by-name/re/reposilite/package.nix +++ b/pkgs/by-name/re/reposilite/package.nix @@ -5,6 +5,7 @@ jre_headless, linkFarm, makeWrapper, + nixosTests, plugins ? [ ], }: let @@ -41,7 +42,10 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; - passthru.updateScript = ./update.sh; + passthru = { + tests = nixosTests.reposilite; + updateScript = ./update.sh; + }; meta = { description = "Lightweight and easy-to-use repository management software dedicated for the Maven based artifacts in the JVM ecosystem";