at 25.11-pre 1.5 kB view raw
1import ./make-test-python.nix ( 2 { pkgs, ... }: 3 { 4 name = "mihomo"; 5 meta.maintainers = with pkgs.lib.maintainers; [ Guanran928 ]; 6 7 nodes.machine = { 8 environment.systemPackages = [ pkgs.curl ]; 9 10 services.nginx = { 11 enable = true; 12 statusPage = true; 13 }; 14 15 services.mihomo = { 16 enable = true; 17 configFile = pkgs.writeTextFile { 18 name = "config.yaml"; 19 text = '' 20 mixed-port: 7890 21 external-controller: 127.0.0.1:9090 22 authentication: 23 - "user:supersecret" 24 ''; 25 }; 26 }; 27 }; 28 29 testScript = '' 30 # Wait until it starts 31 machine.wait_for_unit("nginx.service") 32 machine.wait_for_unit("mihomo.service") 33 machine.wait_for_open_port(80) 34 machine.wait_for_open_port(7890) 35 machine.wait_for_open_port(9090) 36 37 # Proxy 38 machine.succeed("curl --fail --max-time 10 --proxy http://user:supersecret@localhost:7890 http://localhost") 39 machine.succeed("curl --fail --max-time 10 --proxy socks5://user:supersecret@localhost:7890 http://localhost") 40 machine.fail("curl --fail --max-time 10 --proxy http://user:supervillain@localhost:7890 http://localhost") 41 machine.fail("curl --fail --max-time 10 --proxy socks5://user:supervillain@localhost:7890 http://localhost") 42 43 # Web UI 44 result = machine.succeed("curl --fail http://localhost:9090") 45 target = '{"hello":"mihomo"}\n' 46 assert result == target, f"{result!r} != {target!r}" 47 ''; 48 } 49)