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