nixos/tests/rustical: init
Co-Authored-By: Martin Weinelt <hexa@darmstadt.ccc.de>
This commit is contained in:
co-authored by
Martin Weinelt
parent
5dd7402a83
commit
c69206e657
@@ -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;
|
||||
|
||||
@@ -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])
|
||||
'';
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user