2020-09-24 06:32:34 +00:00
|
|
|
import ./make-test-python.nix ({ lib, pkgs, ... }:
|
2020-06-07 21:59:12 +00:00
|
|
|
let
|
|
|
|
fakeReply = pkgs.writeText "namecoin-reply.json" ''
|
|
|
|
{ "error": null,
|
|
|
|
"id": 1,
|
|
|
|
"result": {
|
|
|
|
"address": "T31q8ucJ4dI1xzhxQ5QispfECld5c7Xw",
|
|
|
|
"expired": false,
|
|
|
|
"expires_in": 2248,
|
|
|
|
"height": 438155,
|
|
|
|
"name": "d/test",
|
|
|
|
"txid": "db61c0b2540ba0c1a2c8cc92af703a37002e7566ecea4dbf8727c7191421edfb",
|
|
|
|
"value": "{\"ip\": \"1.2.3.4\", \"email\": \"root@test.bit\",\"info\": \"Fake record\"}",
|
|
|
|
"vout": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
2020-09-24 06:32:34 +00:00
|
|
|
|
|
|
|
# Disabled because DNSSEC does not currently validate,
|
|
|
|
# see https://github.com/namecoin/ncdns/issues/127
|
|
|
|
dnssec = false;
|
|
|
|
|
2020-06-07 21:59:12 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "ncdns";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2020-09-24 06:32:34 +00:00
|
|
|
maintainers = [ rnhmjoj ];
|
|
|
|
};
|
2020-06-07 21:59:12 +00:00
|
|
|
|
|
|
|
nodes.server = { ... }: {
|
2022-04-13 19:52:31 +00:00
|
|
|
networking.nameservers = [ "::1" ];
|
2020-06-07 21:59:12 +00:00
|
|
|
|
|
|
|
services.namecoind.rpc = {
|
2022-04-13 19:52:31 +00:00
|
|
|
address = "::1";
|
2020-06-07 21:59:12 +00:00
|
|
|
user = "namecoin";
|
|
|
|
password = "secret";
|
|
|
|
port = 8332;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Fake namecoin RPC server because we can't
|
|
|
|
# run a full node in a test.
|
|
|
|
systemd.services.namecoind = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
script = ''
|
|
|
|
while true; do
|
|
|
|
echo -e "HTTP/1.1 200 OK\n\n $(<${fakeReply})\n" \
|
2022-04-13 19:52:31 +00:00
|
|
|
| ${pkgs.netcat}/bin/nc -N -l ::1 8332
|
2020-06-07 21:59:12 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
services.ncdns = {
|
|
|
|
enable = true;
|
2020-09-24 06:32:34 +00:00
|
|
|
dnssec.enable = dnssec;
|
|
|
|
identity.hostname = "example.com";
|
|
|
|
identity.hostmaster = "root@example.com";
|
|
|
|
identity.address = "1.0.0.1";
|
2020-06-07 21:59:12 +00:00
|
|
|
};
|
|
|
|
|
2022-04-13 19:52:31 +00:00
|
|
|
services.pdns-recursor.enable = true;
|
|
|
|
services.pdns-recursor.resolveNamecoin = true;
|
2020-06-07 21:59:12 +00:00
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.dnsutils ];
|
|
|
|
};
|
|
|
|
|
2020-09-24 06:32:34 +00:00
|
|
|
testScript =
|
|
|
|
(lib.optionalString dnssec ''
|
|
|
|
with subtest("DNSSEC keys have been generated"):
|
|
|
|
server.wait_for_unit("ncdns")
|
|
|
|
server.wait_for_file("/var/lib/ncdns/bit.key")
|
|
|
|
server.wait_for_file("/var/lib/ncdns/bit-zone.key")
|
2020-06-07 21:59:12 +00:00
|
|
|
|
2020-09-24 06:32:34 +00:00
|
|
|
with subtest("DNSKEY bit record is present"):
|
|
|
|
server.wait_for_unit("pdns-recursor")
|
2022-06-11 12:22:53 +00:00
|
|
|
server.wait_for_open_port(53)
|
2020-09-24 06:32:34 +00:00
|
|
|
server.succeed("host -t DNSKEY bit")
|
|
|
|
'') +
|
|
|
|
''
|
|
|
|
with subtest("can resolve a .bit name"):
|
|
|
|
server.wait_for_unit("namecoind")
|
|
|
|
server.wait_for_unit("ncdns")
|
2022-06-11 12:22:53 +00:00
|
|
|
server.wait_for_open_port(8332)
|
2020-09-24 06:32:34 +00:00
|
|
|
assert "1.2.3.4" in server.succeed("dig @localhost -p 5333 test.bit")
|
2020-06-07 21:59:12 +00:00
|
|
|
|
2020-09-24 06:32:34 +00:00
|
|
|
with subtest("SOA record has identity information"):
|
|
|
|
assert "example.com" in server.succeed("dig SOA @localhost -p 5333 bit")
|
|
|
|
|
|
|
|
with subtest("bit. zone forwarding works"):
|
2022-04-13 19:52:31 +00:00
|
|
|
server.wait_for_unit("pdns-recursor")
|
2020-09-24 06:32:34 +00:00
|
|
|
assert "1.2.3.4" in server.succeed("host test.bit")
|
|
|
|
'';
|
2020-06-07 21:59:12 +00:00
|
|
|
})
|