at 23.11-pre 2.7 kB view raw
1import ./make-test-python.nix ( 2 { pkgs, lib, ... }: 3 4 { 5 name = "xandikos"; 6 7 meta.maintainers = with lib.maintainers; [ _0x4A6F ]; 8 9 nodes = { 10 xandikos_client = {}; 11 xandikos_default = { 12 networking.firewall.allowedTCPPorts = [ 8080 ]; 13 services.xandikos.enable = true; 14 }; 15 xandikos_proxy = { 16 networking.firewall.allowedTCPPorts = [ 80 8080 ]; 17 services.xandikos.enable = true; 18 services.xandikos.address = "localhost"; 19 services.xandikos.port = 8080; 20 services.xandikos.routePrefix = "/xandikos-prefix/"; 21 services.xandikos.extraOptions = [ 22 "--defaults" 23 ]; 24 services.nginx = { 25 enable = true; 26 recommendedProxySettings = true; 27 virtualHosts."xandikos" = { 28 serverName = "xandikos.local"; 29 basicAuth.xandikos = "snakeOilPassword"; 30 locations."/xandikos/" = { 31 proxyPass = "http://localhost:8080/xandikos-prefix/"; 32 }; 33 }; 34 }; 35 }; 36 }; 37 38 testScript = '' 39 start_all() 40 41 with subtest("Xandikos default"): 42 xandikos_default.wait_for_unit("multi-user.target") 43 xandikos_default.wait_for_unit("xandikos.service") 44 xandikos_default.wait_for_open_port(8080) 45 xandikos_default.succeed("curl --fail http://localhost:8080/") 46 xandikos_default.succeed( 47 "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" 48 ) 49 xandikos_client.wait_for_unit("network.target") 50 xandikos_client.fail("curl --fail http://xandikos_default:8080/") 51 52 with subtest("Xandikos proxy"): 53 xandikos_proxy.wait_for_unit("multi-user.target") 54 xandikos_proxy.wait_for_unit("xandikos.service") 55 xandikos_proxy.wait_for_open_port(8080) 56 xandikos_proxy.succeed("curl --fail http://localhost:8080/") 57 xandikos_proxy.succeed( 58 "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" 59 ) 60 xandikos_client.wait_for_unit("network.target") 61 xandikos_client.fail("curl --fail http://xandikos_proxy:8080/") 62 xandikos_client.succeed( 63 "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos" 64 ) 65 xandikos_client.succeed( 66 "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos" 67 ) 68 ''; 69 } 70)