at 25.11-pre 1.5 kB view raw
1import ./make-test-python.nix ( 2 { lib, pkgs, ... }: 3 { 4 name = "doh-proxy-rust"; 5 meta.maintainers = with lib.maintainers; [ stephank ]; 6 7 nodes = { 8 machine = 9 { pkgs, lib, ... }: 10 { 11 services.bind = { 12 enable = true; 13 extraOptions = "empty-zones-enable no;"; 14 zones = lib.singleton { 15 name = "."; 16 master = true; 17 file = pkgs.writeText "root.zone" '' 18 $TTL 3600 19 . IN SOA ns.example.org. admin.example.org. ( 1 3h 1h 1w 1d ) 20 . IN NS ns.example.org. 21 ns.example.org. IN A 192.168.0.1 22 ''; 23 }; 24 }; 25 services.doh-proxy-rust = { 26 enable = true; 27 flags = [ 28 "--server-address=127.0.0.1:53" 29 ]; 30 }; 31 }; 32 }; 33 34 testScript = 35 { nodes, ... }: 36 '' 37 url = "http://localhost:3000/dns-query" 38 query = "AAABAAABAAAAAAAAAm5zB2V4YW1wbGUDb3JnAAABAAE=" # IN A ns.example.org. 39 bin_ip = r"$'\xC0\xA8\x00\x01'" # 192.168.0.1, as shell binary string 40 41 machine.wait_for_unit("bind.service") 42 machine.wait_for_unit("doh-proxy-rust.service") 43 machine.wait_for_open_port(53) 44 machine.wait_for_open_port(3000) 45 machine.succeed(f"curl --fail -H 'Accept: application/dns-message' '{url}?dns={query}' | grep -F {bin_ip}") 46 ''; 47 } 48)