1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/tests/testdata/run/resolve_dns.ts
Matt Mastracci f5e46c9bf2
chore: move cli/tests/ -> tests/ (#22369)
This looks like a massive PR, but it's only a move from cli/tests ->
tests, and updates of relative paths for files.

This is the first step towards aggregate all of the integration test
files under tests/, which will lead to a set of integration tests that
can run without the CLI binary being built.

While we could leave these tests under `cli`, it would require us to
keep a more complex directory structure for the various test runners. In
addition, we have a lot of complexity to ignore various test files in
the `cli` project itself (cargo publish exclusion rules, autotests =
false, etc).

And finally, the `tests/` folder will eventually house the `test_ffi`,
`test_napi` and other testing code, reducing the size of the root repo
directory.

For easier review, the extremely large and noisy "move" is in the first
commit (with no changes -- just a move), while the remainder of the
changes to actual files is in the second commit.
2024-02-10 20:22:13 +00:00

93 lines
2.3 KiB
TypeScript

const nameServer = { nameServer: { ipAddr: "127.0.0.1", port: 4553 } };
const [a, aaaa, aname, caa, cname, mx, naptr, ns, ptr, soa, srv, txt] =
await Promise
.all([
Deno.resolveDns("www.example.com", "A", nameServer),
Deno.resolveDns("www.example.com", "AAAA", nameServer),
Deno.resolveDns("www.example.com", "ANAME", nameServer),
Deno.resolveDns("example.com", "CAA", nameServer),
Deno.resolveDns("alias.example.com", "CNAME", nameServer),
Deno.resolveDns("example.com", "MX", nameServer),
Deno.resolveDns("example.com", "NAPTR", nameServer),
Deno.resolveDns("example.com", "NS", nameServer),
Deno.resolveDns("1.2.3.4.IN-ADDR.ARPA.", "PTR", nameServer),
Deno.resolveDns("example.com", "SOA", nameServer),
Deno.resolveDns("_service._tcp.example.com", "SRV", nameServer),
Deno.resolveDns("example.com", "TXT", nameServer),
]);
console.log("A");
console.log(JSON.stringify(a));
console.log("AAAA");
console.log(JSON.stringify(aaaa));
console.log("ANAME");
console.log(JSON.stringify(aname));
console.log("CAA");
console.log(JSON.stringify(caa));
console.log("CNAME");
console.log(JSON.stringify(cname));
console.log("MX");
console.log(JSON.stringify(mx));
console.log("NAPTR");
console.log(JSON.stringify(naptr));
console.log("NS");
console.log(JSON.stringify(ns));
console.log("PTR");
console.log(JSON.stringify(ptr));
console.log("SOA");
console.log(JSON.stringify(soa));
console.log("SRV");
console.log(JSON.stringify(srv));
console.log("TXT");
console.log(JSON.stringify(txt));
try {
await Deno.resolveDns("not-found-example.com", "A", nameServer);
} catch (e) {
console.log(
`Error ${
e instanceof Error ? e.name : "[non-error]"
} thrown for not-found-example.com`,
);
}
try {
// @ts-ignore testing invalid overloads
await Deno.resolveDns("example.com", "SSHFP", nameServer);
} catch (e) {
console.log(e.message);
}
try {
const ac = new AbortController();
queueMicrotask(() => ac.abort());
await Deno.resolveDns("www.example.com", "A", {
...nameServer,
signal: ac.signal,
});
} catch (e) {
console.log(e.name);
}
try {
const ac = new AbortController();
ac.abort();
await Deno.resolveDns("www.example.com", "A", {
...nameServer,
signal: ac.signal,
});
} catch (e) {
console.log(e.name);
}