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