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