nixosTests.xandikos: migrate to runTest

Part Of #386873
This commit is contained in:
Martin Weinelt 2025-03-14 23:38:25 +01:00
parent ae0871bca2
commit ca409e5a02
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
2 changed files with 62 additions and 64 deletions

View file

@ -1285,7 +1285,7 @@ in {
wrappers = handleTest ./wrappers.nix {}; wrappers = handleTest ./wrappers.nix {};
writefreely = handleTest ./web-apps/writefreely.nix {}; writefreely = handleTest ./web-apps/writefreely.nix {};
wstunnel = runTest ./wstunnel.nix; wstunnel = runTest ./wstunnel.nix;
xandikos = handleTest ./xandikos.nix {}; xandikos = runTest ./xandikos.nix;
xautolock = runTest ./xautolock.nix; xautolock = runTest ./xautolock.nix;
xfce = runTest ./xfce.nix; xfce = runTest ./xfce.nix;
xfce-wayland = runTest ./xfce-wayland.nix; xfce-wayland = runTest ./xfce-wayland.nix;

View file

@ -1,73 +1,71 @@
import ./make-test-python.nix ( { lib, ... }:
{ pkgs, lib, ... }:
{ {
name = "xandikos"; name = "xandikos";
meta.maintainers = with lib.maintainers; [ _0x4A6F ]; meta.maintainers = with lib.maintainers; [ _0x4A6F ];
nodes = { nodes = {
xandikos_client = { }; xandikos_client = { };
xandikos_default = { xandikos_default = {
networking.firewall.allowedTCPPorts = [ 8080 ]; networking.firewall.allowedTCPPorts = [ 8080 ];
services.xandikos.enable = true; services.xandikos.enable = true;
}; };
xandikos_proxy = { xandikos_proxy = {
networking.firewall.allowedTCPPorts = [ networking.firewall.allowedTCPPorts = [
80 80
8080 8080
]; ];
services.xandikos.enable = true; services.xandikos.enable = true;
services.xandikos.address = "localhost"; services.xandikos.address = "localhost";
services.xandikos.port = 8080; services.xandikos.port = 8080;
services.xandikos.routePrefix = "/xandikos-prefix/"; services.xandikos.routePrefix = "/xandikos-prefix/";
services.xandikos.extraOptions = [ services.xandikos.extraOptions = [
"--defaults" "--defaults"
]; ];
services.nginx = { services.nginx = {
enable = true; enable = true;
recommendedProxySettings = true; recommendedProxySettings = true;
virtualHosts."xandikos" = { virtualHosts."xandikos" = {
serverName = "xandikos.local"; serverName = "xandikos.local";
basicAuth.xandikos = "snakeOilPassword"; basicAuth.xandikos = "snakeOilPassword";
locations."/xandikos/" = { locations."/xandikos/" = {
proxyPass = "http://localhost:8080/xandikos-prefix/"; proxyPass = "http://localhost:8080/xandikos-prefix/";
};
}; };
}; };
}; };
}; };
};
testScript = '' testScript = ''
start_all() start_all()
with subtest("Xandikos default"): with subtest("Xandikos default"):
xandikos_default.wait_for_unit("multi-user.target") xandikos_default.wait_for_unit("multi-user.target")
xandikos_default.wait_for_unit("xandikos.service") xandikos_default.wait_for_unit("xandikos.service")
xandikos_default.wait_for_open_port(8080) xandikos_default.wait_for_open_port(8080)
xandikos_default.succeed("curl --fail http://localhost:8080/") xandikos_default.succeed("curl --fail http://localhost:8080/")
xandikos_default.succeed( xandikos_default.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
) )
xandikos_client.wait_for_unit("network.target") xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_default:8080/") xandikos_client.fail("curl --fail http://xandikos_default:8080/")
with subtest("Xandikos proxy"): with subtest("Xandikos proxy"):
xandikos_proxy.wait_for_unit("multi-user.target") xandikos_proxy.wait_for_unit("multi-user.target")
xandikos_proxy.wait_for_unit("xandikos.service") xandikos_proxy.wait_for_unit("xandikos.service")
xandikos_proxy.wait_for_open_port(8080) xandikos_proxy.wait_for_open_port(8080)
xandikos_proxy.succeed("curl --fail http://localhost:8080/") xandikos_proxy.succeed("curl --fail http://localhost:8080/")
xandikos_proxy.succeed( xandikos_proxy.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
) )
xandikos_client.wait_for_unit("network.target") xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_proxy:8080/") xandikos_client.fail("curl --fail http://xandikos_proxy:8080/")
xandikos_client.succeed( xandikos_client.succeed(
"curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos" "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos"
) )
xandikos_client.succeed( xandikos_client.succeed(
"curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos" "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos"
) )
''; '';
} }
)