@nictool/dns-resource-record 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -2
- package/package.json +11 -6
- package/rr/a.js +1 -3
- package/rr/aaaa.js +1 -3
- package/rr/cname.js +1 -3
- package/rr/dname.js +1 -3
- package/rr/ipseckey.js +2 -4
- package/rr/mx.js +1 -3
- package/rr/srv.js +1 -3
- package/rr.js +12 -3
- package/.codeclimate.yml +0 -25
- package/.github/FUNDING.yml +0 -3
- package/.github/workflows/ci.yml +0 -43
- package/.github/workflows/codeql.yml +0 -14
- package/.github/workflows/publish.yml +0 -16
- package/.gitmodules +0 -3
- package/.prettierrc.yml +0 -3
- package/DEVELOP.md +0 -9
- package/eslint.config.mjs +0 -41
- package/test/a.js +0 -75
- package/test/aaaa.js +0 -86
- package/test/base.js +0 -148
- package/test/caa.js +0 -111
- package/test/cert.js +0 -48
- package/test/cname.js +0 -40
- package/test/dname.js +0 -57
- package/test/dnskey.js +0 -45
- package/test/ds.js +0 -45
- package/test/fake.js +0 -34
- package/test/hinfo.js +0 -80
- package/test/https.js +0 -56
- package/test/ipseckey.js +0 -141
- package/test/key.js +0 -36
- package/test/loc.js +0 -75
- package/test/mx.js +0 -78
- package/test/naptr.js +0 -47
- package/test/ns.js +0 -56
- package/test/nsec.js +0 -37
- package/test/nsec3.js +0 -47
- package/test/nsec3param.js +0 -23
- package/test/nxt.js +0 -37
- package/test/openpgpkey.js +0 -85
- package/test/ptr.js +0 -56
- package/test/rr.js +0 -212
- package/test/smimea.js +0 -51
- package/test/soa.js +0 -99
- package/test/spf.js +0 -51
- package/test/srv.js +0 -101
- package/test/sshfp.js +0 -69
- package/test/svcb.js +0 -56
- package/test/tinydns.js +0 -163
- package/test/tlsa.js +0 -63
- package/test/txt.js +0 -82
- package/test/uri.js +0 -65
package/test/ptr.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
|
|
3
|
-
import * as base from './base.js'
|
|
4
|
-
|
|
5
|
-
import PTR from '../rr/ptr.js'
|
|
6
|
-
|
|
7
|
-
const defaults = { class: 'IN', ttl: 86400, type: 'PTR' }
|
|
8
|
-
|
|
9
|
-
const validRecords = [
|
|
10
|
-
{
|
|
11
|
-
...defaults,
|
|
12
|
-
owner: '2.2.0.192.in-addr.arpa.',
|
|
13
|
-
dname: 'dhcp.example.com.',
|
|
14
|
-
testB: '2.2.0.192.in-addr.arpa.\t86400\tIN\tPTR\tdhcp.example.com.\n',
|
|
15
|
-
testT: '^2.2.0.192.in-addr.arpa:dhcp.example.com:86400::\n',
|
|
16
|
-
},
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
const invalidRecords = [
|
|
20
|
-
{
|
|
21
|
-
...defaults,
|
|
22
|
-
owner: 'example.com.',
|
|
23
|
-
dname: '192.0.2.4', // FQDN required
|
|
24
|
-
msg: /dname must be fully qualified/,
|
|
25
|
-
},
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
describe('PTR record', function () {
|
|
29
|
-
base.valid(PTR, validRecords)
|
|
30
|
-
base.invalid(PTR, invalidRecords)
|
|
31
|
-
|
|
32
|
-
base.getDescription(PTR)
|
|
33
|
-
base.getRFCs(PTR, validRecords[0])
|
|
34
|
-
base.getFields(PTR, ['dname'])
|
|
35
|
-
base.getTypeId(PTR, 12)
|
|
36
|
-
|
|
37
|
-
base.toBind(PTR, validRecords)
|
|
38
|
-
base.toTinydns(PTR, validRecords)
|
|
39
|
-
|
|
40
|
-
base.fromBind(PTR, validRecords)
|
|
41
|
-
base.fromTinydns(PTR, validRecords)
|
|
42
|
-
|
|
43
|
-
for (const val of validRecords) {
|
|
44
|
-
it.skip(`imports tinydns PTR (^) record (${val.owner})`, async function () {
|
|
45
|
-
const r = new PTR({ tinyline: val.testT })
|
|
46
|
-
if (process.env.DEBUG) console.dir(r)
|
|
47
|
-
for (const f of ['owner', 'dname', 'ttl']) {
|
|
48
|
-
assert.deepStrictEqual(
|
|
49
|
-
r.get(f),
|
|
50
|
-
val[f],
|
|
51
|
-
`${f}: ${r.get(f)} !== ${val[f]}`,
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
})
|
package/test/rr.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
|
|
3
|
-
import RR from '../rr.js'
|
|
4
|
-
import A from '../rr/a.js'
|
|
5
|
-
|
|
6
|
-
const cases = [
|
|
7
|
-
// { name: 'RR class', obj: RR, expect: [ 'owner', 'ttl', 'class', 'type' ] },
|
|
8
|
-
{
|
|
9
|
-
name: 'RR instance',
|
|
10
|
-
obj: new RR(null),
|
|
11
|
-
expect: ['owner', 'ttl', 'class', 'type'],
|
|
12
|
-
},
|
|
13
|
-
// { name: 'A class', obj: A, expect: [ 'owner', 'ttl', 'class', 'type', 'address' ] },
|
|
14
|
-
{
|
|
15
|
-
name: 'A instance',
|
|
16
|
-
obj: new A(null),
|
|
17
|
-
expect: ['owner', 'ttl', 'class', 'type', 'address'],
|
|
18
|
-
},
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
for (const c of cases) {
|
|
22
|
-
describe(`${c.name}`, function () {
|
|
23
|
-
describe('getFields', function () {
|
|
24
|
-
it('gets expected fields', async function () {
|
|
25
|
-
assert.deepStrictEqual(c.obj.getFields(), c.expect)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('RR', function () {
|
|
32
|
-
const r = new RR(null)
|
|
33
|
-
|
|
34
|
-
describe('setTtl', function () {
|
|
35
|
-
const invalid = [-1, -4, -299, 2147483648, undefined]
|
|
36
|
-
for (const i of invalid) {
|
|
37
|
-
it(`throws on invalid TTL: ${i}`, async function () {
|
|
38
|
-
try {
|
|
39
|
-
assert.deepStrictEqual(r.setTtl(i), false)
|
|
40
|
-
} catch (e) {
|
|
41
|
-
assert.ok(e.message)
|
|
42
|
-
console.error(e.message)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
describe('setClass', function () {
|
|
49
|
-
for (const i of ['IN', 'CH', 'ANY', 'NONE']) {
|
|
50
|
-
it(`accepts valid class: ${i}`, async function () {
|
|
51
|
-
r.setClass(i)
|
|
52
|
-
assert.deepEqual(r.get('class'), i)
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
for (const i of ['matt', 'in', 0]) {
|
|
57
|
-
it(`throws on invalid class: ${i}`, async function () {
|
|
58
|
-
try {
|
|
59
|
-
assert.strictEqual(r.setClass(i), false)
|
|
60
|
-
} catch (e) {
|
|
61
|
-
assert.ok(e.message)
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
describe('fullyQualify', function () {
|
|
68
|
-
it('does nothing to empty hostname', async () => {
|
|
69
|
-
assert.equal(r.fullyQualify(''), '')
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('fully qualifies a valid hostname', async () => {
|
|
73
|
-
assert.equal(r.fullyQualify('example.com'), 'example.com.')
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
describe('getFQDN', function () {
|
|
78
|
-
it('adds a period to hostnames', async () => {
|
|
79
|
-
const rr = new RR(null)
|
|
80
|
-
rr.set('owner', 'www.example.com') // bypass FQ check
|
|
81
|
-
assert.equal(rr.getFQDN('owner'), 'www.example.com.')
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('reduces origin on request', async () => {
|
|
85
|
-
const rr = new RR(null)
|
|
86
|
-
const zone_opts = { origin: 'example.com.', hide: { origin: true } }
|
|
87
|
-
rr.setOwner('www.example.com.')
|
|
88
|
-
assert.equal(rr.getFQDN('owner', zone_opts), 'www')
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
describe('isFullyQualified', function () {
|
|
93
|
-
it('should detect FQDNs', async function () {
|
|
94
|
-
assert.deepEqual(
|
|
95
|
-
r.isFullyQualified('$type', '$field', 'host.example.com.'),
|
|
96
|
-
true,
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
assert.deepEqual(
|
|
101
|
-
r.isFullyQualified('$type', '$field', 'host.example.com'),
|
|
102
|
-
false,
|
|
103
|
-
)
|
|
104
|
-
} catch (e) {
|
|
105
|
-
assert.ok(/must be fully qualified/.test(e.message))
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
describe('is8bitInt', function () {
|
|
111
|
-
const valid = [1, 2, 255]
|
|
112
|
-
const invalid = [-1, 'a', new Date(), undefined, 256]
|
|
113
|
-
|
|
114
|
-
for (const i of valid) {
|
|
115
|
-
it(`returns true for valid int: ${i}`, async function () {
|
|
116
|
-
assert.strictEqual(r.is8bitInt('test', 'field', i), true)
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
for (const i of invalid) {
|
|
121
|
-
it(`throws on invalid int: ${i}`, async function () {
|
|
122
|
-
try {
|
|
123
|
-
assert.strictEqual(r.is8bitInt('test', 'field', i), false)
|
|
124
|
-
} catch (e) {
|
|
125
|
-
assert.strictEqual(
|
|
126
|
-
e.message,
|
|
127
|
-
'test field must be a 8-bit integer (in the range 0-255)',
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
describe('is16bitInt', function () {
|
|
135
|
-
const valid = [0, 1, 2, 55555, 65535]
|
|
136
|
-
const invalid = ['a', new Date(), undefined, 65536]
|
|
137
|
-
|
|
138
|
-
for (const i of valid) {
|
|
139
|
-
it(`returns true for valid int: ${i}`, async function () {
|
|
140
|
-
assert.strictEqual(r.is16bitInt('test', 'field', i), true)
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
for (const i of invalid) {
|
|
145
|
-
it(`throws on invalid int: ${i}`, async function () {
|
|
146
|
-
try {
|
|
147
|
-
assert.strictEqual(r.is16bitInt('test', 'field', i), false)
|
|
148
|
-
} catch (e) {
|
|
149
|
-
assert.strictEqual(
|
|
150
|
-
e.message,
|
|
151
|
-
'test field must be a 16-bit integer (in the range 0-65535)',
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
describe('is32bitInt', function () {
|
|
159
|
-
const valid = [1, 2, 55555, 2147483647]
|
|
160
|
-
const invalid = ['a', new Date(), undefined, 2147483648]
|
|
161
|
-
|
|
162
|
-
for (const i of valid) {
|
|
163
|
-
it(`returns true for valid int: ${i}`, async function () {
|
|
164
|
-
assert.strictEqual(r.is32bitInt('test', 'field', i), true)
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
for (const i of invalid) {
|
|
169
|
-
it(`throws on invalid int: ${i}`, async function () {
|
|
170
|
-
try {
|
|
171
|
-
assert.strictEqual(r.is32bitInt('test', 'field', i), false)
|
|
172
|
-
} catch (e) {
|
|
173
|
-
assert.strictEqual(
|
|
174
|
-
e.message,
|
|
175
|
-
'test field must be a 32-bit integer (in the range 0-2147483647)',
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
describe('getQuoted', function () {
|
|
183
|
-
it('returns a quoted string', async () => {
|
|
184
|
-
r.set('cpu', '"already quoted"')
|
|
185
|
-
assert.equal(r.get('cpu'), '"already quoted"')
|
|
186
|
-
assert.equal(r.getQuoted('cpu'), '"already quoted"') // doesn't double quote
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
it("doesn't double quote a quoted string", async () => {
|
|
190
|
-
r.set('cpu', '"already quoted"')
|
|
191
|
-
assert.equal(r.getQuoted('cpu'), '"already quoted"')
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
describe('isQuoted', function () {
|
|
196
|
-
it('detects a quoted strings', async function () {
|
|
197
|
-
assert.deepEqual(r.isQuoted('"yes, this is"'), true)
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
it('detects non-quoted strings', async function () {
|
|
201
|
-
assert.deepEqual(r.isQuoted('nope, not quoted'), false)
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
describe('isValidHostname', function () {
|
|
206
|
-
for (const n of ['x', '2x', '*', '*.something']) {
|
|
207
|
-
it(`passes name: ${n}`, async function () {
|
|
208
|
-
assert.deepEqual(r.isValidHostname(n), true)
|
|
209
|
-
})
|
|
210
|
-
}
|
|
211
|
-
})
|
|
212
|
-
})
|
package/test/smimea.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as base from './base.js'
|
|
2
|
-
|
|
3
|
-
import SMIMEA from '../rr/smimea.js'
|
|
4
|
-
|
|
5
|
-
const defaults = { class: 'IN', ttl: 3600, type: 'SMIMEA' }
|
|
6
|
-
|
|
7
|
-
const validRecords = [
|
|
8
|
-
{
|
|
9
|
-
...defaults,
|
|
10
|
-
owner: '_443._tcp.www.example.com.',
|
|
11
|
-
ttl: 3600,
|
|
12
|
-
'certificate usage': 0,
|
|
13
|
-
selector: 0,
|
|
14
|
-
'matching type': 1,
|
|
15
|
-
'certificate association data':
|
|
16
|
-
'( d2abde240d7cd3ee6b4b28c54df034b9 7983a1d16e8a410e4561cb106618e971 )',
|
|
17
|
-
testB:
|
|
18
|
-
'_443._tcp.www.example.com.\t3600\tIN\tSMIMEA\t0\t0\t1\t( d2abde240d7cd3ee6b4b28c54df034b9 7983a1d16e8a410e4561cb106618e971 )\n',
|
|
19
|
-
// testT : '',
|
|
20
|
-
},
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
const invalidRecords = [
|
|
24
|
-
{
|
|
25
|
-
...defaults,
|
|
26
|
-
owner: 'test.example.com.',
|
|
27
|
-
selector: 6, // invalid
|
|
28
|
-
msg: /certificate usage invalid/,
|
|
29
|
-
},
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
describe('SMIMEA record', function () {
|
|
33
|
-
base.valid(SMIMEA, validRecords)
|
|
34
|
-
base.invalid(SMIMEA, invalidRecords)
|
|
35
|
-
|
|
36
|
-
base.getDescription(SMIMEA)
|
|
37
|
-
base.getRFCs(SMIMEA, validRecords[0])
|
|
38
|
-
base.getFields(SMIMEA, [
|
|
39
|
-
'certificate usage',
|
|
40
|
-
'selector',
|
|
41
|
-
'matching type',
|
|
42
|
-
'certificate association data',
|
|
43
|
-
])
|
|
44
|
-
base.getTypeId(SMIMEA, 53)
|
|
45
|
-
|
|
46
|
-
base.toBind(SMIMEA, validRecords)
|
|
47
|
-
// base.toTinydns(SMIMEA, validRecords)
|
|
48
|
-
|
|
49
|
-
base.fromBind(SMIMEA, validRecords)
|
|
50
|
-
// base.fromTinydns(SMIMEA, validRecords)
|
|
51
|
-
})
|
package/test/soa.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
|
|
3
|
-
import * as base from './base.js'
|
|
4
|
-
|
|
5
|
-
import SOA from '../rr/soa.js'
|
|
6
|
-
|
|
7
|
-
const defaults = { class: 'IN', ttl: 3600, type: 'SOA' }
|
|
8
|
-
|
|
9
|
-
const validRecords = [
|
|
10
|
-
{
|
|
11
|
-
...defaults,
|
|
12
|
-
owner: 'example.com.',
|
|
13
|
-
mname: 'ns1.example.com.',
|
|
14
|
-
rname: 'matt.example.com.',
|
|
15
|
-
serial: 1,
|
|
16
|
-
refresh: 7200,
|
|
17
|
-
retry: 3600,
|
|
18
|
-
expire: 1209600,
|
|
19
|
-
minimum: 3600,
|
|
20
|
-
testB: `example.com.\t3600\tIN\tSOA\tns1.example.com.\tmatt.example.com.\t1\t7200\t3600\t1209600\t3600\n`,
|
|
21
|
-
testT:
|
|
22
|
-
'Zexample.com:ns1.example.com:matt.example.com:1:7200:3600:1209600:3600:3600::\n',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
...defaults,
|
|
26
|
-
owner: '2.example.com.',
|
|
27
|
-
mname: 'ns2.example.com.',
|
|
28
|
-
rname: 'matt.example.com.',
|
|
29
|
-
serial: 1,
|
|
30
|
-
refresh: 7200,
|
|
31
|
-
retry: 3600,
|
|
32
|
-
expire: 1209600,
|
|
33
|
-
minimum: 3600,
|
|
34
|
-
testB: `2.example.com.\t3600\tIN\tSOA\tns2.example.com.\tmatt.example.com.\t1\t7200\t3600\t1209600\t3600\n`,
|
|
35
|
-
testT:
|
|
36
|
-
'Z2.example.com:ns2.example.com:matt.example.com:1:7200:3600:1209600:3600:3600::\n',
|
|
37
|
-
},
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
const invalidRecords = [
|
|
41
|
-
{
|
|
42
|
-
...defaults,
|
|
43
|
-
owner: 'example.com.',
|
|
44
|
-
mname: 'ns1.example.com.',
|
|
45
|
-
rname: 'matt.example.com.',
|
|
46
|
-
serial: 4294967296,
|
|
47
|
-
refresh: 7200,
|
|
48
|
-
retry: 3600,
|
|
49
|
-
expire: 1209600,
|
|
50
|
-
msg: /serial must be a 32-bit integer/,
|
|
51
|
-
},
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
describe('SOA record', function () {
|
|
55
|
-
base.valid(SOA, validRecords)
|
|
56
|
-
base.invalid(SOA, invalidRecords)
|
|
57
|
-
|
|
58
|
-
base.getDescription(SOA)
|
|
59
|
-
base.getRFCs(SOA, validRecords[0])
|
|
60
|
-
base.getFields(SOA, [
|
|
61
|
-
'mname',
|
|
62
|
-
'rname',
|
|
63
|
-
'serial',
|
|
64
|
-
'refresh',
|
|
65
|
-
'retry',
|
|
66
|
-
'expire',
|
|
67
|
-
'minimum',
|
|
68
|
-
])
|
|
69
|
-
base.getTypeId(SOA, 6)
|
|
70
|
-
|
|
71
|
-
base.toBind(SOA, validRecords)
|
|
72
|
-
base.toTinydns(SOA, validRecords)
|
|
73
|
-
|
|
74
|
-
base.fromBind(SOA, validRecords)
|
|
75
|
-
base.fromTinydns(SOA, validRecords)
|
|
76
|
-
|
|
77
|
-
for (const val of validRecords) {
|
|
78
|
-
it.skip(`imports tinydns SOA (Z) record (${val.owner})`, async function () {
|
|
79
|
-
const r = new SOA({ tinyline: val.testT })
|
|
80
|
-
if (process.env.DEBUG) console.dir(r)
|
|
81
|
-
for (const f of [
|
|
82
|
-
'owner',
|
|
83
|
-
'mname',
|
|
84
|
-
'rname',
|
|
85
|
-
'serial',
|
|
86
|
-
'refresh',
|
|
87
|
-
'retry',
|
|
88
|
-
'expire',
|
|
89
|
-
'ttl',
|
|
90
|
-
]) {
|
|
91
|
-
assert.deepStrictEqual(
|
|
92
|
-
r.get(f),
|
|
93
|
-
val[f],
|
|
94
|
-
`${f}: ${r.get(f)} !== ${val[f]}`,
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
})
|
package/test/spf.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
|
|
3
|
-
import * as base from './base.js'
|
|
4
|
-
|
|
5
|
-
import SPF from '../rr/spf.js'
|
|
6
|
-
|
|
7
|
-
const defaults = { class: 'IN', ttl: 86400, type: 'SPF' }
|
|
8
|
-
|
|
9
|
-
const validRecords = [
|
|
10
|
-
{
|
|
11
|
-
...defaults,
|
|
12
|
-
owner: 'example.com.',
|
|
13
|
-
data: 'v=spf1 mx a include:mx.example.com -all',
|
|
14
|
-
testB:
|
|
15
|
-
'example.com.\t86400\tIN\tSPF\t"v=spf1 mx a include:mx.example.com -all"\n',
|
|
16
|
-
testT:
|
|
17
|
-
':example.com:99:v=spf1 mx a include\\072mx.example.com -all:86400::\n',
|
|
18
|
-
},
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
const invalidRecords = []
|
|
22
|
-
|
|
23
|
-
describe('SPF record', function () {
|
|
24
|
-
base.valid(SPF, validRecords)
|
|
25
|
-
base.invalid(SPF, invalidRecords)
|
|
26
|
-
|
|
27
|
-
base.getDescription(SPF)
|
|
28
|
-
base.getRFCs(SPF, validRecords[0])
|
|
29
|
-
base.getFields(SPF, ['data'])
|
|
30
|
-
base.getTypeId(SPF, 99)
|
|
31
|
-
|
|
32
|
-
base.toBind(SPF, validRecords)
|
|
33
|
-
base.toTinydns(SPF, validRecords)
|
|
34
|
-
|
|
35
|
-
base.fromBind(SPF, validRecords)
|
|
36
|
-
base.fromTinydns(SPF, validRecords)
|
|
37
|
-
|
|
38
|
-
for (const val of validRecords) {
|
|
39
|
-
it.skip(`imports tinydns SPF (generic) record`, async function () {
|
|
40
|
-
const r = new SPF({ tinyline: val.testT })
|
|
41
|
-
if (process.env.DEBUG) console.dir(r)
|
|
42
|
-
for (const f of ['owner', 'data', 'ttl']) {
|
|
43
|
-
assert.deepStrictEqual(
|
|
44
|
-
r.get(f),
|
|
45
|
-
val[f],
|
|
46
|
-
`${f}: ${r.get(f)} !== ${val[f]}`,
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
})
|
package/test/srv.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
|
|
3
|
-
import * as base from './base.js'
|
|
4
|
-
|
|
5
|
-
import SRV from '../rr/srv.js'
|
|
6
|
-
|
|
7
|
-
const defaults = { class: 'IN', ttl: 3600, type: 'SRV' }
|
|
8
|
-
|
|
9
|
-
const validRecords = [
|
|
10
|
-
{
|
|
11
|
-
...defaults,
|
|
12
|
-
owner: '_imaps._tcp.example.com.',
|
|
13
|
-
priority: 1,
|
|
14
|
-
weight: 0,
|
|
15
|
-
port: 993,
|
|
16
|
-
target: 'mail.example.com.',
|
|
17
|
-
testB:
|
|
18
|
-
'_imaps._tcp.example.com.\t3600\tIN\tSRV\t1\t0\t993\tmail.example.com.\n',
|
|
19
|
-
testT:
|
|
20
|
-
':_imaps._tcp.example.com:33:\\000\\001\\000\\000\\003\\341\\004mail\\007example\\003com\\000:3600::\n',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
...defaults,
|
|
24
|
-
owner: '_sip._tls.example.com.',
|
|
25
|
-
priority: 100,
|
|
26
|
-
weight: 1,
|
|
27
|
-
port: 443,
|
|
28
|
-
target: 'sipdir.online.lync.com.',
|
|
29
|
-
testB:
|
|
30
|
-
'_sip._tls.example.com.\t3600\tIN\tSRV\t100\t1\t443\tsipdir.online.lync.com.\n',
|
|
31
|
-
testT:
|
|
32
|
-
':_sip._tls.example.com:33:\\000\\144\\000\\001\\001\\273\\006sipdir\\006online\\004lync\\003com\\000:3600::\n',
|
|
33
|
-
},
|
|
34
|
-
]
|
|
35
|
-
|
|
36
|
-
const invalidRecords = [
|
|
37
|
-
{
|
|
38
|
-
...defaults,
|
|
39
|
-
owner: 'test.example.com.',
|
|
40
|
-
target: 'not-full-qualified.example.com',
|
|
41
|
-
msg: /must be a 16-bit integer/,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
...defaults,
|
|
45
|
-
owner: 'test.example.com.',
|
|
46
|
-
target: '192.168.0.1',
|
|
47
|
-
msg: /must be a 16-bit integer/,
|
|
48
|
-
},
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
describe('SRV record', function () {
|
|
52
|
-
base.valid(SRV, validRecords)
|
|
53
|
-
base.invalid(SRV, invalidRecords)
|
|
54
|
-
|
|
55
|
-
base.getDescription(SRV)
|
|
56
|
-
base.getRFCs(SRV, validRecords[0])
|
|
57
|
-
base.getFields(SRV, ['priority', 'weight', 'port', 'target'])
|
|
58
|
-
base.getTypeId(SRV, 33)
|
|
59
|
-
|
|
60
|
-
base.toBind(SRV, validRecords)
|
|
61
|
-
base.toTinydns(SRV, validRecords)
|
|
62
|
-
|
|
63
|
-
base.fromBind(SRV, validRecords)
|
|
64
|
-
base.fromTinydns(SRV, validRecords)
|
|
65
|
-
|
|
66
|
-
for (const val of validRecords) {
|
|
67
|
-
it(`imports tinydns SRV (generic) record (${val.owner})`, async function () {
|
|
68
|
-
const r = new SRV({ tinyline: val.testT })
|
|
69
|
-
if (process.env.DEBUG) console.dir(r)
|
|
70
|
-
for (const f of [
|
|
71
|
-
'owner',
|
|
72
|
-
'target',
|
|
73
|
-
'priority',
|
|
74
|
-
'weight',
|
|
75
|
-
'port',
|
|
76
|
-
'ttl',
|
|
77
|
-
]) {
|
|
78
|
-
assert.deepStrictEqual(
|
|
79
|
-
r.get(f),
|
|
80
|
-
val[f],
|
|
81
|
-
`${f}: ${r.get(f)} !== ${val[f]}`,
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
it(`imports tinydns SRV (S) record`, async function () {
|
|
88
|
-
const val = validRecords[0]
|
|
89
|
-
const r = new SRV({
|
|
90
|
-
tinyline: 'S_imaps._tcp.example.com:mail.example.com:993:1:0:3600::',
|
|
91
|
-
})
|
|
92
|
-
if (process.env.DEBUG) console.dir(r)
|
|
93
|
-
for (const f of ['owner', 'target', 'priority', 'weight', 'port', 'ttl']) {
|
|
94
|
-
assert.deepStrictEqual(
|
|
95
|
-
r.get(f),
|
|
96
|
-
val[f],
|
|
97
|
-
`${f}: ${r.get(f)} !== ${val[f]}`,
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
})
|
package/test/sshfp.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as base from './base.js'
|
|
2
|
-
|
|
3
|
-
import SSHFP from '../rr/sshfp.js'
|
|
4
|
-
|
|
5
|
-
const common = { type: 'SSHFP', ttl: 86400, class: 'IN' }
|
|
6
|
-
|
|
7
|
-
const validRecords = [
|
|
8
|
-
{
|
|
9
|
-
...common,
|
|
10
|
-
owner: 'mail.example.com.',
|
|
11
|
-
algorithm: 1,
|
|
12
|
-
fptype: 1,
|
|
13
|
-
fingerprint:
|
|
14
|
-
'ed8c6e16fdae4f633eee6a7b8f64fdd356bbb32841d535565d777014c9ea4c26',
|
|
15
|
-
testB:
|
|
16
|
-
'mail.example.com.\t86400\tIN\tSSHFP\t1\t1\ted8c6e16fdae4f633eee6a7b8f64fdd356bbb32841d535565d777014c9ea4c26\n',
|
|
17
|
-
testT:
|
|
18
|
-
':mail.example.com:44:\\001\\001\\355\\214\\156\\026\\375\\256\\117\\143\\076\\356\\152\\173\\217\\144\\375\\323\\126\\273\\263\\050\\101\\325\\065\\126\\135\\167\\160\\024\\311\\352\\114\\046:86400::\n',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
...common,
|
|
22
|
-
owner: 'jails.example.com.',
|
|
23
|
-
algorithm: 1,
|
|
24
|
-
fptype: 1,
|
|
25
|
-
fingerprint: '684981f1b57cc6b05bb2a5a7fd51a9114fef064d',
|
|
26
|
-
testB:
|
|
27
|
-
'jails.example.com.\t86400\tIN\tSSHFP\t1\t1\t684981f1b57cc6b05bb2a5a7fd51a9114fef064d\n',
|
|
28
|
-
testT:
|
|
29
|
-
':jails.example.com:44:\\001\\001\\150\\111\\201\\361\\265\\174\\306\\260\\133\\262\\245\\247\\375\\121\\251\\021\\117\\357\\006\\115:86400::\n',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
...common,
|
|
33
|
-
owner: 'jails.example.com.',
|
|
34
|
-
algorithm: 3,
|
|
35
|
-
fptype: 2,
|
|
36
|
-
fingerprint:
|
|
37
|
-
'81f9dbc4c009a1297336d69fcc2264f2a28417b781dafdd9c1ef7ff256066a35',
|
|
38
|
-
testB:
|
|
39
|
-
'jails.example.com.\t86400\tIN\tSSHFP\t3\t2\t81f9dbc4c009a1297336d69fcc2264f2a28417b781dafdd9c1ef7ff256066a35\n',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
...common,
|
|
43
|
-
owner: 'jails.example.com.',
|
|
44
|
-
algorithm: 1,
|
|
45
|
-
fptype: 2,
|
|
46
|
-
fingerprint:
|
|
47
|
-
'ed8c6e16fdae4f633eee6a7b8f64fdd356bbb32841d535565d777014c9ea4c26',
|
|
48
|
-
testB:
|
|
49
|
-
'jails.example.com.\t86400\tIN\tSSHFP\t1\t2\ted8c6e16fdae4f633eee6a7b8f64fdd356bbb32841d535565d777014c9ea4c26\n',
|
|
50
|
-
},
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
const invalidRecords = []
|
|
54
|
-
|
|
55
|
-
describe('SSHFP record', function () {
|
|
56
|
-
base.valid(SSHFP, validRecords)
|
|
57
|
-
base.invalid(SSHFP, invalidRecords)
|
|
58
|
-
|
|
59
|
-
base.getDescription(SSHFP)
|
|
60
|
-
base.getRFCs(SSHFP, validRecords[0])
|
|
61
|
-
base.getFields(SSHFP, ['algorithm', 'fptype', 'fingerprint'])
|
|
62
|
-
base.getTypeId(SSHFP, 44)
|
|
63
|
-
|
|
64
|
-
base.toBind(SSHFP, validRecords)
|
|
65
|
-
base.toTinydns(SSHFP, validRecords)
|
|
66
|
-
|
|
67
|
-
base.fromBind(SSHFP, validRecords)
|
|
68
|
-
base.fromTinydns(SSHFP, validRecords)
|
|
69
|
-
})
|
package/test/svcb.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as base from './base.js'
|
|
2
|
-
|
|
3
|
-
import SVCB from '../rr/svcb.js'
|
|
4
|
-
|
|
5
|
-
const defaults = { class: 'IN', ttl: 3600, type: 'SVCB' }
|
|
6
|
-
|
|
7
|
-
const validRecords = [
|
|
8
|
-
{
|
|
9
|
-
...defaults,
|
|
10
|
-
owner: '_8443._foo.api.example.com.',
|
|
11
|
-
ttl: 7200,
|
|
12
|
-
priority: 0,
|
|
13
|
-
'target name': 'svc4.example.net.',
|
|
14
|
-
params: 'alpn="bar" port="8004" ech="..."',
|
|
15
|
-
testB:
|
|
16
|
-
'_8443._foo.api.example.com.\t7200\tIN\tSVCB\t0\tsvc4.example.net.\talpn="bar" port="8004" ech="..."\n',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
...defaults,
|
|
20
|
-
owner: '_8080._foo.example.com.',
|
|
21
|
-
priority: 0,
|
|
22
|
-
'target name': 'foosvc.example.net.',
|
|
23
|
-
params: '',
|
|
24
|
-
testB:
|
|
25
|
-
'_8080._foo.example.com.\t3600\tIN\tSVCB\t0\tfoosvc.example.net.\t\n',
|
|
26
|
-
},
|
|
27
|
-
/*
|
|
28
|
-
_1234._bar.example.com. 300 IN SVCB 1 svc1.example.net. ( ech="111..." ipv6hint=2001:db8::1 port=1234 )
|
|
29
|
-
SVCB 2 svc2.example.net. ( ech="222..." ipv6hint=2001:db8::2 port=1234 )
|
|
30
|
-
*/
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
const invalidRecords = [
|
|
34
|
-
// {
|
|
35
|
-
// ...defaults,
|
|
36
|
-
// owner : 'test.example.com.',
|
|
37
|
-
// 'target name': 'not-full-qualified.example.com',
|
|
38
|
-
// params : /must be a 16-bit integer/,
|
|
39
|
-
// },
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
describe('SVCB record', function () {
|
|
43
|
-
base.valid(SVCB, validRecords)
|
|
44
|
-
base.invalid(SVCB, invalidRecords)
|
|
45
|
-
|
|
46
|
-
base.getDescription(SVCB)
|
|
47
|
-
base.getRFCs(SVCB, validRecords[0])
|
|
48
|
-
base.getFields(SVCB, ['priority', 'target name', 'params'])
|
|
49
|
-
base.getTypeId(SVCB, 64)
|
|
50
|
-
|
|
51
|
-
base.toBind(SVCB, validRecords)
|
|
52
|
-
// base.toTinydns(SVCB, validRecords)
|
|
53
|
-
|
|
54
|
-
base.fromBind(SVCB, validRecords)
|
|
55
|
-
// base.fromTinydns(SVCB, validRecords)
|
|
56
|
-
})
|