From c69206e657af7ebc23fa4aa0f671b4c90618b836 Mon Sep 17 00:00:00 2001 From: PopeRigby Date: Sun, 3 May 2026 02:29:36 +0200 Subject: [PATCH] nixos/tests/rustical: init Co-Authored-By: Martin Weinelt --- nixos/tests/all-tests.nix | 1 + nixos/tests/web-apps/rustical.nix | 72 ++++++++++++++++++++++++++++ pkgs/by-name/ru/rustical/package.nix | 6 +++ 3 files changed, 79 insertions(+) create mode 100644 nixos/tests/web-apps/rustical.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index b276d07786bc..2e264857fde7 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1451,6 +1451,7 @@ in rtkit = runTest ./rtkit.nix; rtorrent = runTest ./rtorrent.nix; rush = runTest ./rush.nix; + rustical = runTest ./web-apps/rustical.nix; rustls-libssl = runTest ./rustls-libssl.nix; rxe = runTest ./rxe.nix; sabnzbd = runTest ./sabnzbd.nix; diff --git a/nixos/tests/web-apps/rustical.nix b/nixos/tests/web-apps/rustical.nix new file mode 100644 index 000000000000..86b0e95afa20 --- /dev/null +++ b/nixos/tests/web-apps/rustical.nix @@ -0,0 +1,72 @@ +{ + pkgs, + lib, + ... +}: +{ + name = "rustical"; + + meta.maintainers = pkgs.rustical.meta.maintainers; + + nodes.machine = + { + pkgs, + ... + }: + { + services.rustical.enable = true; + environment.systemPackages = with pkgs; [ calendar-cli ]; + }; + + testScript = + { + nodes, + ... + }: + let + port = toString nodes.machine.services.rustical.settings.http.port; + url = "http://localhost:${toString port}"; + + createPrincipalScript = pkgs.writeScript "rustical-create-principal" '' + #!${lib.getExe pkgs.expect} + spawn rustical principals create alice --password + expect "Enter your password:\r" + send "foobar\r" + expect eof + ''; + + calendarCliConfig = (pkgs.formats.json { }).generate "rustical-test-calendar-cli.json" { + default = { + caldav_user = "alice"; + caldav_url = "${url}/caldav/"; + calendar_url = "${url}/caldav/principal/alice"; + }; + testcal = { + inherits = "default"; + calendar_url = "${url}/caldav/principal/alice/testcal"; + }; + }; + in + # python + '' + machine.wait_for_unit("rustical.service") + machine.wait_for_open_port(${port}) + + with subtest("Smoketest"): + machine.succeed("curl --fail ${url}") + + with subtest("Create principal"): + machine.succeed("${createPrincipalScript}") + machine.succeed("rustical principals list | grep alice") + + with subtest("Generate token for principal"): + machine.succeed("curl -f -c cookies.txt -d 'username=alice&password=foobar' ${url}/frontend/login") + machine.succeed("curl -f -b cookies.txt -d 'name=mytoken' ${url}/frontend/user/alice/app_token > token.txt") + + with subtest("Interact with caldav"): + machine.succeed('calendar-cli --config-file ${calendarCliConfig} --caldav-pass "$(cat token.txt)" calendar create testcal') + machine.succeed('calendar-cli --config-file ${calendarCliConfig} --config-section testcal --caldav-pass "$(cat token.txt)" calendar add 2013-10-01 testevent') + + machine.log(machine.execute("systemd-analyze security rustical.service | grep -v ✓")[1]) + ''; +} diff --git a/pkgs/by-name/ru/rustical/package.nix b/pkgs/by-name/ru/rustical/package.nix index f478c6f6c06f..055006a3ca85 100644 --- a/pkgs/by-name/ru/rustical/package.nix +++ b/pkgs/by-name/ru/rustical/package.nix @@ -4,6 +4,7 @@ fetchFromGitHub, pkg-config, openssl, + nixosTests, }: rustPlatform.buildRustPackage (finalAttrs: { @@ -20,10 +21,15 @@ rustPlatform.buildRustPackage (finalAttrs: { cargoHash = "sha256-uP1lZarcwQhBKyASQIiNUs053EuxJy112P2e3hy2uZY="; nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl ]; env.OPENSSL_NO_VENDOR = true; + passthru.tests = { + inherit (nixosTests) rustical; + }; + meta = { description = "Yet another calendar server aiming to be simple, fast and passwordless"; homepage = "https://github.com/lennart-k/rustical";