@nictool/dns-resource-record 1.1.6 → 1.2.0
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/.prettierrc.yml +3 -0
- package/CHANGELOG.md +17 -43
- package/README.md +56 -62
- package/index.js +77 -29
- package/lib/tinydns.js +68 -61
- package/package.json +10 -6
- package/rr/a.js +19 -20
- package/rr/aaaa.js +35 -31
- package/rr/caa.js +41 -39
- package/rr/cert.js +21 -19
- package/rr/cname.js +19 -20
- package/rr/dname.js +19 -19
- package/rr/dnskey.js +48 -41
- package/rr/ds.js +38 -36
- package/rr/hinfo.js +26 -25
- package/rr/ipseckey.js +53 -45
- package/rr/key.js +21 -21
- package/rr/loc.js +67 -54
- package/rr/mx.js +26 -24
- package/rr/naptr.js +51 -52
- package/rr/ns.js +25 -22
- package/rr/nsec.js +26 -20
- package/rr/nsec3.js +90 -30
- package/rr/nsec3param.js +29 -26
- package/rr/nxt.js +67 -0
- package/rr/openpgpkey.js +13 -14
- package/rr/ptr.js +20 -21
- package/rr/rrsig.js +27 -21
- package/rr/sig.js +24 -19
- package/rr/smimea.js +35 -28
- package/rr/soa.js +57 -42
- package/rr/spf.js +20 -17
- package/rr/srv.js +41 -41
- package/rr/sshfp.js +29 -30
- package/rr/tlsa.js +47 -40
- package/rr/tsig.js +48 -0
- package/rr/txt.js +40 -33
- package/rr/uri.js +31 -31
- package/rr/wks.js +44 -0
- package/rr.js +116 -79
- package/.codeclimate.yml +0 -25
- package/DEVELOP.md +0 -23
- package/test/a.js +0 -76
- package/test/aaaa.js +0 -79
- package/test/base.js +0 -138
- package/test/caa.js +0 -104
- package/test/cert.js +0 -48
- package/test/cname.js +0 -41
- package/test/dname.js +0 -53
- package/test/dnskey.js +0 -44
- package/test/ds.js +0 -44
- package/test/fake.js +0 -26
- package/test/hinfo.js +0 -75
- package/test/ipseckey.js +0 -115
- package/test/key.js +0 -37
- package/test/loc.js +0 -71
- package/test/mx.js +0 -75
- package/test/naptr.js +0 -40
- package/test/ns.js +0 -53
- package/test/nsec.js +0 -38
- package/test/nsec3.js +0 -26
- package/test/nsec3param.js +0 -26
- package/test/openpgpkey.js +0 -35
- package/test/ptr.js +0 -54
- package/test/rr.js +0 -196
- package/test/smimea.js +0 -45
- package/test/soa.js +0 -77
- package/test/spf.js +0 -48
- package/test/srv.js +0 -81
- package/test/sshfp.js +0 -62
- package/test/tinydns.js +0 -140
- package/test/tlsa.js +0 -54
- package/test/txt.js +0 -70
- package/test/uri.js +0 -61
package/test/base.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import assert from 'assert'
|
|
3
|
-
|
|
4
|
-
export function valid (type, validRecords, defaults) {
|
|
5
|
-
describe('valid', function () {
|
|
6
|
-
for (const val of validRecords) {
|
|
7
|
-
// console.log(val)
|
|
8
|
-
it(`parses record: ${val.owner}`, async function () {
|
|
9
|
-
if (defaults) val.default = defaults
|
|
10
|
-
const r = new type(val)
|
|
11
|
-
if (defaults) delete val.default
|
|
12
|
-
if (process.env.DEBUG) console.dir(r)
|
|
13
|
-
|
|
14
|
-
for (const k of Object.keys(val)) {
|
|
15
|
-
if (/^test/.test(k)) continue
|
|
16
|
-
assert.strictEqual(r.get(k), val[k], `${type.name} ${k} ${r.get(k)} !== ${val[k]}`)
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function invalid (type, invalidRecords, defaults) {
|
|
24
|
-
describe('invalid', function () {
|
|
25
|
-
for (const inv of invalidRecords) {
|
|
26
|
-
if (defaults) inv.default = defaults
|
|
27
|
-
it(`throws on record (${inv.owner})`, async function () {
|
|
28
|
-
assert.throws(() => {
|
|
29
|
-
new type(inv)
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
message: inv.msg,
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function toBind (type, validRecords) {
|
|
40
|
-
describe('toBind', function () {
|
|
41
|
-
for (const val of validRecords) {
|
|
42
|
-
it(`exports to BIND: ${val.owner}`, async function () {
|
|
43
|
-
const r = new type(val).toBind()
|
|
44
|
-
if (process.env.DEBUG) console.dir(r)
|
|
45
|
-
assert.strictEqual(r, val.testB)
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function toTinydns (type, validRecords) {
|
|
52
|
-
describe('toTinydns', function () {
|
|
53
|
-
for (const val of validRecords) {
|
|
54
|
-
if (val.testT === undefined) continue
|
|
55
|
-
it(`exports to tinydns: ${val.owner}`, async function () {
|
|
56
|
-
const r = new type(val).toTinydns()
|
|
57
|
-
if (process.env.DEBUG) console.dir(r)
|
|
58
|
-
assert.strictEqual(r, val.testT)
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function getDescription (type) {
|
|
65
|
-
describe('getDescription', function () {
|
|
66
|
-
const desc = new type(null).getDescription()
|
|
67
|
-
it(`gets description: ${desc}`, async function () {
|
|
68
|
-
assert.ok(desc)
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function getRFCs (type, valid) {
|
|
74
|
-
describe('getRFCs', function () {
|
|
75
|
-
const r = new type(null)
|
|
76
|
-
const rfcs = r.getRFCs()
|
|
77
|
-
it(`can retrieve RFCs: ${rfcs.join(',')}`, async function () {
|
|
78
|
-
assert.ok(rfcs.length)
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function checkFromNS (type, validRecords, nsName, nsLineName) {
|
|
84
|
-
for (const val of validRecords) {
|
|
85
|
-
const testLine = nsLineName === 'bindline' ? val.testB : val.testT
|
|
86
|
-
if (testLine == undefined) continue
|
|
87
|
-
it(`imports ${nsName} record: ${val.owner}`, async function () {
|
|
88
|
-
const r = new type({ [nsLineName]: testLine })
|
|
89
|
-
if (process.env.DEBUG) console.dir(r)
|
|
90
|
-
for (const f of r.getFields()) {
|
|
91
|
-
if (f === 'class') continue
|
|
92
|
-
let expected = val[f]
|
|
93
|
-
if (f === 'data' && Array.isArray(expected)) expected = expected.join('') // TXT
|
|
94
|
-
assert.deepStrictEqual(r.get(f), expected, `${f}: ${r.get(f)} !== ${expected}`)
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function fromTinydns (type, validRecords) {
|
|
101
|
-
describe('fromTinydns', function () {
|
|
102
|
-
checkFromNS(type, validRecords, 'tinydns', 'tinyline')
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function fromBind (type, validRecords) {
|
|
107
|
-
describe('fromBind', function () {
|
|
108
|
-
checkFromNS(type, validRecords, 'BIND', 'bindline')
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function getRdataFields (type, rdataFields) {
|
|
113
|
-
describe('getRdataFields', function () {
|
|
114
|
-
const r = new type(null)
|
|
115
|
-
it(`can retrieve rdata fields: (${r.getRdataFields('rdata')})`, async function () {
|
|
116
|
-
assert.deepEqual(r.getRdataFields('rdata'), rdataFields)
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function getFields (type, rdataFields) {
|
|
122
|
-
describe('getFields', function () {
|
|
123
|
-
const r = new type(null)
|
|
124
|
-
it(`can retrieve record fields`, async function () {
|
|
125
|
-
assert.deepEqual(r.getFields('rdata'), rdataFields)
|
|
126
|
-
assert.deepEqual(r.getFields(), r.getFields('common').concat(rdataFields))
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function getTypeId (type, val) {
|
|
132
|
-
describe('getTypeId', function () {
|
|
133
|
-
const r = new type(null)
|
|
134
|
-
it(`can retrieve record type ID (${r.getTypeId()})`, async function () {
|
|
135
|
-
assert.deepEqual(r.getTypeId(), val)
|
|
136
|
-
})
|
|
137
|
-
})
|
|
138
|
-
}
|
package/test/caa.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import assert from 'assert'
|
|
3
|
-
|
|
4
|
-
import * as base from './base.js'
|
|
5
|
-
|
|
6
|
-
import CAA from '../rr/caa.js'
|
|
7
|
-
|
|
8
|
-
const validRecords = [
|
|
9
|
-
{
|
|
10
|
-
owner: 'ns1.example.com.',
|
|
11
|
-
ttl : 3600,
|
|
12
|
-
class: 'IN',
|
|
13
|
-
type : 'CAA',
|
|
14
|
-
flags: 0,
|
|
15
|
-
tag : 'issue',
|
|
16
|
-
value: 'http://letsencrypt.org',
|
|
17
|
-
testB: `ns1.example.com.\t3600\tIN\tCAA\t0\tissue\t"http://letsencrypt.org"\n`,
|
|
18
|
-
testT: ':ns1.example.com:257:\\000\\005issue"http\\072\\057\\057letsencrypt.org":3600::\n',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
owner: 'ns2.example.com.',
|
|
22
|
-
ttl : 3600,
|
|
23
|
-
class: 'IN',
|
|
24
|
-
type : 'CAA',
|
|
25
|
-
flags: 0,
|
|
26
|
-
tag : 'issue',
|
|
27
|
-
value: 'mailto:lets-crypt.org',
|
|
28
|
-
testB: `ns2.example.com.\t3600\tIN\tCAA\t0\tissue\t"mailto:lets-crypt.org"\n`,
|
|
29
|
-
testT: ':ns2.example.com:257:\\000\\005issue"mailto\\072lets-crypt.org":3600::\n',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
owner: 'example.net.',
|
|
33
|
-
ttl : 86400,
|
|
34
|
-
type : 'CAA',
|
|
35
|
-
flags: 0,
|
|
36
|
-
tag : 'issuewild',
|
|
37
|
-
value: 'https://letsencrypt.org',
|
|
38
|
-
testB: 'example.net.\t86400\tIN\tCAA\t0\tissuewild\t"https://letsencrypt.org"\n',
|
|
39
|
-
testT: ':example.net:257:\\000\\011issuewild"https\\072\\057\\057letsencrypt.org":86400::\n',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
owner: 'certs.example.com.',
|
|
43
|
-
ttl : 86400,
|
|
44
|
-
type : 'CAA',
|
|
45
|
-
flags: 0,
|
|
46
|
-
tag : 'issue',
|
|
47
|
-
value: 'ca1.example.net',
|
|
48
|
-
testB: 'certs.example.com.\t86400\tIN\tCAA\t0\tissue\t"ca1.example.net"\n',
|
|
49
|
-
testT: ':certs.example.com:257:\\000\\005issue"ca1.example.net":86400::\n',
|
|
50
|
-
},
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
const invalidRecords = [
|
|
54
|
-
{
|
|
55
|
-
owner: 'example.com.',
|
|
56
|
-
type : 'CAA',
|
|
57
|
-
flags: 128,
|
|
58
|
-
tag : 'iodef',
|
|
59
|
-
value: 'letsencrypt.org', // missing iodef prefix
|
|
60
|
-
msg : /RFC/,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
owner: 'example.com.',
|
|
64
|
-
type : 'CAA',
|
|
65
|
-
flags: 128,
|
|
66
|
-
tag : 'invalid', // invalid
|
|
67
|
-
value: 'http://letsencrypt.org',
|
|
68
|
-
msg : /RFC/,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
owner: 'example.com.',
|
|
72
|
-
type : 'CAA',
|
|
73
|
-
flags: 15, // invalid
|
|
74
|
-
tag : 'issue',
|
|
75
|
-
value: 'http://letsencrypt.org',
|
|
76
|
-
msg : /RFC/,
|
|
77
|
-
},
|
|
78
|
-
]
|
|
79
|
-
|
|
80
|
-
describe('CAA record', function () {
|
|
81
|
-
base.valid(CAA, validRecords)
|
|
82
|
-
base.invalid(CAA, invalidRecords, { ttl: 3600 })
|
|
83
|
-
|
|
84
|
-
base.getDescription(CAA)
|
|
85
|
-
base.getRFCs(CAA, validRecords[0])
|
|
86
|
-
base.getFields(CAA, [ 'flags', 'tag', 'value' ])
|
|
87
|
-
base.getTypeId(CAA, 257)
|
|
88
|
-
|
|
89
|
-
base.toBind(CAA, validRecords)
|
|
90
|
-
base.toTinydns(CAA, validRecords)
|
|
91
|
-
|
|
92
|
-
base.fromBind(CAA, validRecords)
|
|
93
|
-
base.fromTinydns(CAA, validRecords)
|
|
94
|
-
|
|
95
|
-
for (const val of validRecords) {
|
|
96
|
-
it(`imports tinydns CAA (generic) record`, async function () {
|
|
97
|
-
const r = new CAA({ tinyline: val.testT })
|
|
98
|
-
if (process.env.DEBUG) console.dir(r)
|
|
99
|
-
for (const f of [ 'owner', 'flags', 'tag', 'value', 'ttl' ]) {
|
|
100
|
-
assert.deepStrictEqual(r.get(f), val[f], `${f}: ${r.get(f)} !== ${val[f]}`)
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
})
|
package/test/cert.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as base from './base.js'
|
|
3
|
-
|
|
4
|
-
import CERT from '../rr/cert.js'
|
|
5
|
-
|
|
6
|
-
const validRecords = [
|
|
7
|
-
{
|
|
8
|
-
owner : 'mail.example.com.',
|
|
9
|
-
ttl : 86400,
|
|
10
|
-
class : 'IN',
|
|
11
|
-
type : 'CERT',
|
|
12
|
-
'cert type' : 'PGP',
|
|
13
|
-
'key tag' : 0,
|
|
14
|
-
'algorithm' : 0,
|
|
15
|
-
'certificate': 'hexidecimalkeystring1',
|
|
16
|
-
testB : 'mail.example.com.\t86400\tIN\tCERT\tPGP\t0\t0\thexidecimalkeystring1\n',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
owner : 'smith.example.com.',
|
|
20
|
-
ttl : 86400,
|
|
21
|
-
class : 'IN',
|
|
22
|
-
type : 'CERT',
|
|
23
|
-
'cert type' : 'PGP',
|
|
24
|
-
'key tag' : 0,
|
|
25
|
-
'algorithm' : 0,
|
|
26
|
-
'certificate': 'hexidecimalkeystring2',
|
|
27
|
-
testB : 'smith.example.com.\t86400\tIN\tCERT\tPGP\t0\t0\thexidecimalkeystring2\n',
|
|
28
|
-
},
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
const invalidRecords = [
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
describe('CERT record', function () {
|
|
35
|
-
base.valid(CERT, validRecords)
|
|
36
|
-
base.invalid(CERT, invalidRecords)
|
|
37
|
-
|
|
38
|
-
base.getDescription(CERT)
|
|
39
|
-
base.getRFCs(CERT, validRecords[0])
|
|
40
|
-
base.getFields(CERT, [ 'cert type', 'key tag', 'algorithm', 'certificate' ])
|
|
41
|
-
base.getTypeId(CERT, 37)
|
|
42
|
-
|
|
43
|
-
base.toBind(CERT, validRecords)
|
|
44
|
-
// base.toTinydns(CERT, validRecords)
|
|
45
|
-
|
|
46
|
-
base.fromBind(CERT, validRecords)
|
|
47
|
-
// base.fromTinydns(CERT, validRecords)
|
|
48
|
-
})
|
package/test/cname.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as base from './base.js'
|
|
3
|
-
|
|
4
|
-
import CNAME from '../rr/cname.js'
|
|
5
|
-
|
|
6
|
-
const defaults = { class: 'IN', ttl: 3600, type: 'CNAME' }
|
|
7
|
-
|
|
8
|
-
const validRecords = [
|
|
9
|
-
{
|
|
10
|
-
...defaults,
|
|
11
|
-
owner: 'ns1.example.com.',
|
|
12
|
-
cname: 'ns2.example.com.',
|
|
13
|
-
testB: 'ns1.example.com.\t3600\tIN\tCNAME\tns2.example.com.\n',
|
|
14
|
-
testT: 'Cns1.example.com:ns2.example.com.:3600::\n',
|
|
15
|
-
},
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
const invalidRecords = [
|
|
19
|
-
{
|
|
20
|
-
...defaults,
|
|
21
|
-
owner: 'example.com.',
|
|
22
|
-
cname: '192.0.2.4', // FQDN required
|
|
23
|
-
msg : /cname must be a FQDN/,
|
|
24
|
-
},
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
describe('CNAME record', function () {
|
|
28
|
-
base.valid(CNAME, validRecords)
|
|
29
|
-
base.invalid(CNAME, invalidRecords)
|
|
30
|
-
|
|
31
|
-
base.getDescription(CNAME)
|
|
32
|
-
base.getRFCs(CNAME, validRecords[0])
|
|
33
|
-
base.getFields(CNAME, [ 'cname' ])
|
|
34
|
-
base.getTypeId(CNAME, 5)
|
|
35
|
-
|
|
36
|
-
base.toBind(CNAME, validRecords)
|
|
37
|
-
base.toTinydns(CNAME, validRecords)
|
|
38
|
-
|
|
39
|
-
base.fromTinydns(CNAME, validRecords)
|
|
40
|
-
base.fromBind(CNAME, validRecords)
|
|
41
|
-
})
|
package/test/dname.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import assert from 'assert'
|
|
3
|
-
|
|
4
|
-
import * as base from './base.js'
|
|
5
|
-
|
|
6
|
-
import DNAME from '../rr/dname.js'
|
|
7
|
-
|
|
8
|
-
const defaults = { class: 'IN', ttl: 86400, type: 'DNAME' }
|
|
9
|
-
|
|
10
|
-
const validRecords = [
|
|
11
|
-
{
|
|
12
|
-
...defaults,
|
|
13
|
-
owner : '_tcp.example.com.',
|
|
14
|
-
target: '_tcp.example.net.',
|
|
15
|
-
testB : '_tcp.example.com.\t86400\tIN\tDNAME\t_tcp.example.net.\n',
|
|
16
|
-
testT : ':_tcp.example.com:39:\\004\\137tcp\\007example\\003net\\000:86400::\n',
|
|
17
|
-
},
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
const invalidRecords = [
|
|
21
|
-
{
|
|
22
|
-
...defaults,
|
|
23
|
-
owner : 'spf.example.com.',
|
|
24
|
-
target: '1.2.3.4', // FQDN required
|
|
25
|
-
msg : /target must be a domain name/,
|
|
26
|
-
},
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
describe('DNAME record', function () {
|
|
30
|
-
base.valid(DNAME, validRecords)
|
|
31
|
-
base.invalid(DNAME, invalidRecords)
|
|
32
|
-
|
|
33
|
-
base.getDescription(DNAME)
|
|
34
|
-
base.getRFCs(DNAME, validRecords[0])
|
|
35
|
-
base.getFields(DNAME, [ 'target' ])
|
|
36
|
-
base.getTypeId(DNAME, 39)
|
|
37
|
-
|
|
38
|
-
base.toBind(DNAME, validRecords)
|
|
39
|
-
base.toTinydns(DNAME, validRecords)
|
|
40
|
-
|
|
41
|
-
base.fromBind(DNAME, validRecords)
|
|
42
|
-
base.fromTinydns(DNAME, validRecords)
|
|
43
|
-
|
|
44
|
-
for (const val of validRecords) {
|
|
45
|
-
it.skip(`imports tinydns DNAME (generic) record (${val.owner})`, async function () {
|
|
46
|
-
const r = new DNAME({ tinyline: val.testT })
|
|
47
|
-
if (process.env.DEBUG) console.dir(r)
|
|
48
|
-
for (const f of [ 'owner', 'target', 'ttl' ]) {
|
|
49
|
-
assert.deepStrictEqual(r.get(f), val[f], `${f}: ${r.get(f)} !== ${val[f]}`)
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
})
|
package/test/dnskey.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as base from './base.js'
|
|
3
|
-
|
|
4
|
-
import DNSKEY from '../rr/dnskey.js'
|
|
5
|
-
|
|
6
|
-
const defaults = { class: 'IN', ttl: 3600, type: 'DNSKEY' }
|
|
7
|
-
|
|
8
|
-
const validRecords = [
|
|
9
|
-
{
|
|
10
|
-
...defaults,
|
|
11
|
-
owner : 'example.com.',
|
|
12
|
-
flags : 256,
|
|
13
|
-
protocol : 3,
|
|
14
|
-
algorithm: 5,
|
|
15
|
-
publickey: `( AQPSKmynfzW4kyBv015MUG2DeIQ3 Cbl+BBZH4b/0PY1kxkmvHjcZc8no kfzj31GajIQKY+5CptLr3buXA10h WqTkF7H6RfoRqXQeogmMHfpftf6z Mv1LyBUgia7za6ZEzOJBOztyvhjL 742iU/TpPSEDhm2SNKLijfUppn1U aNvv4w== )`,
|
|
16
|
-
testB : 'example.com.\t3600\tIN\tDNSKEY\t256\t3\t5\t( AQPSKmynfzW4kyBv015MUG2DeIQ3 Cbl+BBZH4b/0PY1kxkmvHjcZc8no kfzj31GajIQKY+5CptLr3buXA10h WqTkF7H6RfoRqXQeogmMHfpftf6z Mv1LyBUgia7za6ZEzOJBOztyvhjL 742iU/TpPSEDhm2SNKLijfUppn1U aNvv4w== )\n',
|
|
17
|
-
testT : ':example.com:48:\\001\\000\\003\\005( AQPSKmynfzW4kyBv015MUG2DeIQ3 Cbl+BBZH4b\\0570PY1kxkmvHjcZc8no kfzj31GajIQKY+5CptLr3buXA10h WqTkF7H6RfoRqXQeogmMHfpftf6z Mv1LyBUgia7za6ZEzOJBOztyvhjL 742iU\\057TpPSEDhm2SNKLijfUppn1U aNvv4w== ):3600::\n',
|
|
18
|
-
},
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
const invalidRecords = [
|
|
22
|
-
{
|
|
23
|
-
...defaults,
|
|
24
|
-
owner : 'test.example.com.',
|
|
25
|
-
algorithm: 257, // invalid
|
|
26
|
-
msg : /flags must be a 16-bit integer/,
|
|
27
|
-
},
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
describe('DNSKEY record', function () {
|
|
31
|
-
base.valid(DNSKEY, validRecords)
|
|
32
|
-
base.invalid(DNSKEY, invalidRecords)
|
|
33
|
-
|
|
34
|
-
base.getDescription(DNSKEY)
|
|
35
|
-
base.getRFCs(DNSKEY, validRecords[0])
|
|
36
|
-
base.getFields(DNSKEY, [ 'flags', 'protocol', 'algorithm', 'publickey' ])
|
|
37
|
-
base.getTypeId(DNSKEY, 48)
|
|
38
|
-
|
|
39
|
-
base.toBind(DNSKEY, validRecords)
|
|
40
|
-
base.toTinydns(DNSKEY, validRecords)
|
|
41
|
-
|
|
42
|
-
base.fromBind(DNSKEY, validRecords)
|
|
43
|
-
base.fromTinydns(DNSKEY, validRecords)
|
|
44
|
-
})
|
package/test/ds.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as base from './base.js'
|
|
3
|
-
|
|
4
|
-
import DS from '../rr/ds.js'
|
|
5
|
-
|
|
6
|
-
const defaults = { class: 'IN', ttl: 3600, type: 'DS' }
|
|
7
|
-
|
|
8
|
-
const validRecords = [
|
|
9
|
-
{
|
|
10
|
-
...defaults,
|
|
11
|
-
owner : 'dskey.example.com.',
|
|
12
|
-
'key tag' : 60485,
|
|
13
|
-
algorithm : 5,
|
|
14
|
-
'digest type': 1,
|
|
15
|
-
digest : `( 2BB183AF5F22588179A53B0A 98631FAD1A292118 )`,
|
|
16
|
-
testB : 'dskey.example.com.\t3600\tIN\tDS\t60485\t5\t1\t( 2BB183AF5F22588179A53B0A 98631FAD1A292118 )\n',
|
|
17
|
-
testT : ':dskey.example.com:43:\\354\\105\\005\\001( 2BB183AF5F22588179A53B0A 98631FAD1A292118 ):3600::\n',
|
|
18
|
-
},
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
const invalidRecords = [
|
|
22
|
-
{
|
|
23
|
-
...defaults,
|
|
24
|
-
owner : 'test.example.com.',
|
|
25
|
-
algorithm: 6, // invalid
|
|
26
|
-
msg : /key tag is required/,
|
|
27
|
-
},
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
describe('DS record', function () {
|
|
31
|
-
base.valid(DS, validRecords)
|
|
32
|
-
base.invalid(DS, invalidRecords)
|
|
33
|
-
|
|
34
|
-
base.getDescription(DS)
|
|
35
|
-
base.getRFCs(DS, validRecords[0])
|
|
36
|
-
base.getFields(DS, [ 'key tag', 'algorithm', 'digest type', 'digest' ])
|
|
37
|
-
base.getTypeId(DS, 43)
|
|
38
|
-
|
|
39
|
-
base.toBind(DS, validRecords)
|
|
40
|
-
base.toTinydns(DS, validRecords)
|
|
41
|
-
|
|
42
|
-
base.fromBind(DS, validRecords)
|
|
43
|
-
base.fromTinydns(DS, validRecords)
|
|
44
|
-
})
|
package/test/fake.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import assert from 'assert'
|
|
3
|
-
|
|
4
|
-
import * as RR from '../index.js'
|
|
5
|
-
|
|
6
|
-
const defaults = { owner: 'fake.com.', class: 'IN', ttl: 3600, address: '192.0.2.127' }
|
|
7
|
-
|
|
8
|
-
describe('fake', function () {
|
|
9
|
-
it(`throws on invalid RR class`, async function () {
|
|
10
|
-
assert.throws(() => {
|
|
11
|
-
new RR.fake({ ...defaults, type: 'A' })
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
message: /fake is not a constructor/,
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it(`throws on invalid RR type`, async function () {
|
|
19
|
-
assert.throws(() => {
|
|
20
|
-
new RR.A({ ...defaults, type: 'NONEXIST' })
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
message: /type NONEXIST doesn't match A/,
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
})
|
package/test/hinfo.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import assert from 'assert'
|
|
3
|
-
|
|
4
|
-
import * as base from './base.js'
|
|
5
|
-
|
|
6
|
-
import HINFO from '../rr/hinfo.js'
|
|
7
|
-
|
|
8
|
-
const defaults = { class: 'IN', ttl: 86400, type: 'HINFO' }
|
|
9
|
-
|
|
10
|
-
const validRecords = [
|
|
11
|
-
{
|
|
12
|
-
...defaults,
|
|
13
|
-
owner: 'server-under-my-desk.example.com.',
|
|
14
|
-
cpu : 'PDP-11/73',
|
|
15
|
-
os : 'UNIX',
|
|
16
|
-
testB: 'server-under-my-desk.example.com.\t86400\tIN\tHINFO\t"PDP-11/73"\t"UNIX"\n',
|
|
17
|
-
testT: ':server-under-my-desk.example.com:13:\\011PDP-11/73\\004UNIX:86400::\n',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
...defaults,
|
|
21
|
-
owner: 'sri-nic.arpa.',
|
|
22
|
-
cpu : 'DEC-2060',
|
|
23
|
-
os : 'TOPS20',
|
|
24
|
-
testB: 'sri-nic.arpa.\t86400\tIN\tHINFO\t"DEC-2060"\t"TOPS20"\n',
|
|
25
|
-
testT: ':sri-nic.arpa:13:\\010DEC-2060\\006TOPS20:86400::\n',
|
|
26
|
-
},
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
const invalidRecords = [
|
|
30
|
-
{
|
|
31
|
-
...defaults,
|
|
32
|
-
owner : 'www.example.com.',
|
|
33
|
-
address: '',
|
|
34
|
-
msg : /Cannot read proper/,
|
|
35
|
-
},
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
describe('HINFO record', function () {
|
|
39
|
-
base.valid(HINFO, validRecords)
|
|
40
|
-
base.invalid(HINFO, invalidRecords)
|
|
41
|
-
|
|
42
|
-
base.getDescription(HINFO)
|
|
43
|
-
base.getRFCs(HINFO, validRecords[0])
|
|
44
|
-
base.getFields(HINFO, [ 'cpu', 'os' ])
|
|
45
|
-
base.getTypeId(HINFO, 13)
|
|
46
|
-
|
|
47
|
-
base.toBind(HINFO, validRecords)
|
|
48
|
-
base.toTinydns(HINFO, validRecords)
|
|
49
|
-
|
|
50
|
-
base.fromBind(HINFO, validRecords)
|
|
51
|
-
base.fromTinydns(HINFO, validRecords)
|
|
52
|
-
|
|
53
|
-
for (const val of validRecords) {
|
|
54
|
-
it.skip(`imports tinydns HINFO (generic) record (${val.owner})`, async function () {
|
|
55
|
-
const r = new HINFO({ tinyline: val.testT })
|
|
56
|
-
if (process.env.DEBUG) console.dir(r)
|
|
57
|
-
for (const f of [ 'owner', 'address', 'ttl' ]) {
|
|
58
|
-
assert.deepStrictEqual(r.get(f), val[f], `${f}: ${r.get(f)} !== ${val[f]}`)
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
for (const f of [ 'os', 'cpu' ]) {
|
|
64
|
-
it(`rejects ${f} value longer than 255 chars`, async () => {
|
|
65
|
-
const tooLong = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
|
|
66
|
-
const r = new HINFO(null)
|
|
67
|
-
try {
|
|
68
|
-
assert.fail(r[`set${r.ucfirst(f)}`](tooLong))
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
assert.equal(e.message, `HINFO ${f} cannot exceed 255 chars`)
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
})
|
package/test/ipseckey.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as base from './base.js'
|
|
3
|
-
|
|
4
|
-
import IPSECKEY from '../rr/ipseckey.js'
|
|
5
|
-
|
|
6
|
-
const common = { ttl: 7200, class: 'IN', type: 'IPSECKEY' }
|
|
7
|
-
|
|
8
|
-
const validRecords = [
|
|
9
|
-
{
|
|
10
|
-
...common,
|
|
11
|
-
owner : '38.2.0.192.in-addr.arpa.',
|
|
12
|
-
precedence : 10,
|
|
13
|
-
'gateway type': 1,
|
|
14
|
-
algorithm : 2,
|
|
15
|
-
gateway : '192.0.2.38',
|
|
16
|
-
publickey : 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
|
|
17
|
-
testB : '38.2.0.192.in-addr.arpa.\t7200\tIN\tIPSECKEY\t10\t1\t2\t192.0.2.38\tAQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==\n',
|
|
18
|
-
testT : ':38.2.0.192.in-addr.arpa:45:\\012\\001\\002\\300\\000\\002\\046\\001\\003QSy\\206\\3555S\\073\\140dG\\216\\356\\262\\173\\133\\327M\\256\\024\\233n\\201\\272\\072\\005\\041\\257\\202\\253x\\001:7200::\n',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
...common,
|
|
22
|
-
owner : '38.2.0.192.in-addr.arpa.',
|
|
23
|
-
precedence : 10,
|
|
24
|
-
'gateway type': 0,
|
|
25
|
-
algorithm : 2,
|
|
26
|
-
gateway : '.',
|
|
27
|
-
publickey : 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
|
|
28
|
-
testB : '38.2.0.192.in-addr.arpa.\t7200\tIN\tIPSECKEY\t10\t0\t2\t.\tAQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==\n',
|
|
29
|
-
testT : ':38.2.0.192.in-addr.arpa:45:\\012\\000\\002.\\001\\003QSy\\206\\3555S\\073\\140dG\\216\\356\\262\\173\\133\\327M\\256\\024\\233n\\201\\272\\072\\005\\041\\257\\202\\253x\\001:7200::\n',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
...common,
|
|
33
|
-
owner : '38.2.0.192.in-addr.arpa.',
|
|
34
|
-
precedence : 10,
|
|
35
|
-
'gateway type': 1,
|
|
36
|
-
algorithm : 2,
|
|
37
|
-
gateway : '192.0.2.38',
|
|
38
|
-
publickey : 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
|
|
39
|
-
testB : '38.2.0.192.in-addr.arpa.\t7200\tIN\tIPSECKEY\t10\t1\t2\t192.0.2.38\tAQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==\n',
|
|
40
|
-
testT : ':38.2.0.192.in-addr.arpa:45:\\012\\001\\002\\300\\000\\002\\046\\001\\003QSy\\206\\3555S\\073\\140dG\\216\\356\\262\\173\\133\\327M\\256\\024\\233n\\201\\272\\072\\005\\041\\257\\202\\253x\\001:7200::\n',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
...common,
|
|
44
|
-
owner : '38.1.0.192.in-addr.arpa.',
|
|
45
|
-
precedence : 10,
|
|
46
|
-
'gateway type': 3,
|
|
47
|
-
algorithm : 2,
|
|
48
|
-
gateway : 'mygateway.example.com.',
|
|
49
|
-
publickey : 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
|
|
50
|
-
testB : '38.1.0.192.in-addr.arpa.\t7200\tIN\tIPSECKEY\t10\t3\t2\tmygateway.example.com.\tAQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==\n',
|
|
51
|
-
testT : ':38.1.0.192.in-addr.arpa:45:\\012\\003\\002\\011mygateway\\007example\\003com\\000\\001\\003QSy\\206\\3555S\\073\\140dG\\216\\356\\262\\173\\133\\327M\\256\\024\\233n\\201\\272\\072\\005\\041\\257\\202\\253x\\001:7200::\n',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
...common,
|
|
55
|
-
owner : '0.d.4.0.3.0.e.f.f.f.3.f.0.1.2.0.1.0.0.0.0.0.2.8.b.d.0.1.0.0.2.ip6.arpa.',
|
|
56
|
-
precedence : 10,
|
|
57
|
-
'gateway type': 2,
|
|
58
|
-
algorithm : 2,
|
|
59
|
-
gateway : '2001:0db8:0:8002::2000:1',
|
|
60
|
-
publickey : 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
|
|
61
|
-
testB : '0.d.4.0.3.0.e.f.f.f.3.f.0.1.2.0.1.0.0.0.0.0.2.8.b.d.0.1.0.0.2.ip6.arpa.\t7200\tIN\tIPSECKEY\t10\t2\t2\t2001:0db8:0:8002::2000:1\tAQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==\n',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
...common,
|
|
65
|
-
owner : 'ipsec.simerson.com.',
|
|
66
|
-
ttl : 86400,
|
|
67
|
-
precedence : 1,
|
|
68
|
-
'gateway type': 3,
|
|
69
|
-
algorithm : 2,
|
|
70
|
-
gateway : 'matt.simerson.net.',
|
|
71
|
-
publickey : '0sAQPeOwAGDPLrDebL1q5Lg8XW9B/d9MnxqlzIYKXhvZPWEHNYGP7AwART/tmkeDNn7HPMtgM6GIwQ4p0KGLfSRoUKbjtPlRVeWYLbsnNXeFU5bchyYef0efYiKlxZdo',
|
|
72
|
-
testB : 'ipsec.simerson.com.\t86400\tIN\tIPSECKEY\t1\t3\t2\tmatt.simerson.net.\t0sAQPeOwAGDPLrDebL1q5Lg8XW9B/d9MnxqlzIYKXhvZPWEHNYGP7AwART/tmkeDNn7HPMtgM6GIwQ4p0KGLfSRoUKbjtPlRVeWYLbsnNXeFU5bchyYef0efYiKlxZdo\n',
|
|
73
|
-
testT : ':ipsec.simerson.com:45:\\001\\003\\002\\004matt\\010simerson\\003net\\000\\322\\300\\020\\075\\343\\260\\000\\140\\317.\\260\\336l\\275j\\344\\270\\074\\135oA\\375\\337L\\237\\032\\245\\314\\206\\012\\136\\033\\331\\075a\\0075\\201\\217\\354\\014\\000E\\077\\355\\232G\\2036\\176\\307\\074\\313\\1403\\241\\210\\301\\016\\051\\320\\241\\213\\175\\044hP\\246\\343\\264\\371QU\\345\\230-\\273\\0475w\\205S\\226\\334\\207\\046\\036\\177G\\237b\\042\\245\\305\\227h:86400::\n',
|
|
74
|
-
},
|
|
75
|
-
]
|
|
76
|
-
|
|
77
|
-
const invalidRecords = [
|
|
78
|
-
{
|
|
79
|
-
...common,
|
|
80
|
-
owner : '0.d.4.0.3.0.e.f.f.f.3.f.0.1.2.0.1.0.0.0.0.0.2.8.b.d.0.1.0.0.2.ip6.arpa.',
|
|
81
|
-
precedence : 10,
|
|
82
|
-
'gateway type': 4,
|
|
83
|
-
algorithm : 2,
|
|
84
|
-
gateway : '2001:0db8:0:8002::2000:1',
|
|
85
|
-
publickey : 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
|
|
86
|
-
msg : /Gateway Type is invalid/,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
...common,
|
|
90
|
-
owner : '0.d.4.0.3.0.e.f.f.f.3.f.0.1.2.0.1.0.0.0.0.0.2.8.b.d.0.1.0.0.2.ip6.arpa.',
|
|
91
|
-
precedence : 10,
|
|
92
|
-
'gateway type': 3,
|
|
93
|
-
algorithm : 3,
|
|
94
|
-
gateway : '2001:0db8:0:8002::2000:1',
|
|
95
|
-
publickey : 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
|
|
96
|
-
msg : /Algorithm invalid/,
|
|
97
|
-
},
|
|
98
|
-
]
|
|
99
|
-
|
|
100
|
-
describe('IPSECKEY record', function () {
|
|
101
|
-
base.valid(IPSECKEY, validRecords)
|
|
102
|
-
base.invalid(IPSECKEY, invalidRecords)
|
|
103
|
-
|
|
104
|
-
base.getDescription(IPSECKEY)
|
|
105
|
-
base.getRFCs(IPSECKEY, validRecords[0])
|
|
106
|
-
base.getRdataFields(IPSECKEY, [ 'precedence', 'gateway type', 'algorithm', 'gateway', 'publickey' ])
|
|
107
|
-
base.getFields(IPSECKEY, [ 'precedence', 'gateway type', 'algorithm', 'gateway', 'publickey' ])
|
|
108
|
-
base.getTypeId(IPSECKEY, 45)
|
|
109
|
-
|
|
110
|
-
base.toBind(IPSECKEY, validRecords)
|
|
111
|
-
base.toTinydns(IPSECKEY, validRecords)
|
|
112
|
-
|
|
113
|
-
base.fromBind(IPSECKEY, validRecords)
|
|
114
|
-
base.fromTinydns(IPSECKEY, validRecords)
|
|
115
|
-
})
|