deno.land / std@0.166.0 / node / _tools / test / internet / test-dns-any.js

test-dns-any.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// deno-fmt-ignore-file// deno-lint-ignore-file
// Copyright Joyent and Node contributors. All rights reserved. MIT license.// Taken from Node 16.13.0// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
// TODO(cmorten): enable remaining tests once functionality is implemented.
'use strict';
const common = require('../common');
const assert = require('assert');const dns = require('dns');const net = require('net');
let running = false;const queue = [];
const dnsPromises = dns.promises;const isIPv4 = net.isIPv4;const isIPv6 = net.isIPv6;
dns.setServers([ '8.8.8.8', '8.8.4.4' ]);
function checkWrap(req) { assert.ok(typeof req === 'object');}
const checkers = { checkA(r) { assert.ok(isIPv4(r.address)); // assert.strictEqual(typeof r.ttl, 'number'); assert.strictEqual(r.type, 'A'); }, checkAAAA(r) { assert.ok(isIPv6(r.address)); // assert.strictEqual(typeof r.ttl, 'number'); assert.strictEqual(r.type, 'AAAA'); }, checkCNAME(r) { assert.ok(r.value); assert.strictEqual(typeof r.value, 'string'); assert.strictEqual(r.type, 'CNAME'); }, checkMX(r) { assert.strictEqual(typeof r.exchange, 'string'); assert.strictEqual(typeof r.priority, 'number'); assert.strictEqual(r.type, 'MX'); }, checkNAPTR(r) { assert.strictEqual(typeof r.flags, 'string'); assert.strictEqual(typeof r.service, 'string'); assert.strictEqual(typeof r.regexp, 'string'); assert.strictEqual(typeof r.replacement, 'string'); assert.strictEqual(typeof r.order, 'number'); assert.strictEqual(typeof r.preference, 'number'); assert.strictEqual(r.type, 'NAPTR'); }, checkNS(r) { assert.strictEqual(typeof r.value, 'string'); assert.strictEqual(r.type, 'NS'); }, checkPTR(r) { assert.strictEqual(typeof r.value, 'string'); assert.strictEqual(r.type, 'PTR'); }, checkTXT(r) { assert.ok(Array.isArray(r.entries)); assert.ok(r.entries.length > 0); assert.strictEqual(r.type, 'TXT'); }, checkSOA(r) { assert.strictEqual(typeof r.nsname, 'string'); assert.strictEqual(typeof r.hostmaster, 'string'); assert.strictEqual(typeof r.serial, 'number'); assert.strictEqual(typeof r.refresh, 'number'); assert.strictEqual(typeof r.retry, 'number'); assert.strictEqual(typeof r.expire, 'number'); assert.strictEqual(typeof r.minttl, 'number'); assert.strictEqual(r.type, 'SOA'); }, checkSRV(r) { assert.strictEqual(typeof r.name, 'string'); assert.strictEqual(typeof r.port, 'number'); assert.strictEqual(typeof r.priority, 'number'); assert.strictEqual(typeof r.weight, 'number'); assert.strictEqual(r.type, 'SRV'); }};
function TEST(f) { function next() { const f = queue.shift(); if (f) { running = true; f(done); } }
function done() { running = false; process.nextTick(next); }
queue.push(f);
if (!running) { next(); }}
function processResult(res) { assert.ok(Array.isArray(res)); assert.ok(res.length > 0);
const types = {}; res.forEach((obj) => { types[obj.type] = true; checkers[`check${obj.type}`](obj); });
return types;}
TEST(async function test_sip2sip_for_naptr(done) { function validateResult(res) { const types = processResult(res); assert.ok( types.A && types.NS && types.NAPTR && types.SOA, `Missing record type, found ${Object.keys(types)}` ); }
validateResult(await dnsPromises.resolve('sip2sip.info', 'ANY'));
const req = dns.resolve( 'sip2sip.info', 'ANY', common.mustSucceed((ret) => { validateResult(ret); done(); }));
checkWrap(req);});
TEST(async function test_google_for_cname_and_srv(done) { function validateResult(res) { const types = processResult(res); assert.ok(types.SRV); }
// TODO(kt3k): Temporarily use _caldav._tcp.google.com instead of // _jabber._tcp.google.com, which currently doesn't respond // validateResult(await dnsPromises.resolve('_jabber._tcp.google.com', 'ANY')); validateResult(await dnsPromises.resolve('_caldav._tcp.google.com', 'ANY'));

// TODO(kt3k): Temporarily use _caldav._tcp.google.com instead of // _jabber._tcp.google.com, which currently doesn't respond const req = dns.resolve( // '_jabber._tcp.google.com', '_caldav._tcp.google.com', 'ANY', common.mustSucceed((ret) => { validateResult(ret); done(); }));
checkWrap(req);});
TEST(async function test_ptr(done) { function validateResult(res) { const types = processResult(res); assert.ok(types.PTR); }
validateResult(await dnsPromises.resolve('8.8.8.8.in-addr.arpa', 'ANY'));
const req = dns.resolve( '8.8.8.8.in-addr.arpa', 'ANY', common.mustSucceed((ret) => { validateResult(ret); done(); }));
checkWrap(req);});
std

Version Info

Tagged at
a year ago