-
Notifications
You must be signed in to change notification settings - Fork 12
/
gozone_test.go
611 lines (531 loc) · 18.9 KB
/
gozone_test.go
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
package gozone
import (
"io"
"reflect"
"strings"
"testing"
)
func TestClassMap(t *testing.T) {
check := map[string]RecordClass{
"IN": RecordClass_IN,
"CS": RecordClass_CS,
"CH": RecordClass_CH,
"HS": RecordClass_HS,
"*": RecordClass_any,
}
for label, rc := range check {
parsed, err := parseClass(label)
if err != nil {
t.Fatalf("Failed to parse RecordClass '%s'", label)
}
if parsed != rc {
t.Fatalf("Parsing of '%s' did not return expected class", label)
}
if parsed.String() != label {
t.Fatalf("String output of RecordClass for '%s' did not match the original input", label)
}
}
}
func TestTypeMap(t *testing.T) {
check := map[string]RecordType{
"A": RecordType_A,
"NS": RecordType_NS,
"MD": RecordType_MD,
"MF": RecordType_MF,
"CNAME": RecordType_CNAME,
"SOA": RecordType_SOA,
"MB": RecordType_MB,
"MG": RecordType_MG,
"MR": RecordType_MR,
"NULL": RecordType_NULL,
"WKS": RecordType_WKS,
"PTR": RecordType_PTR,
"HINFO": RecordType_HINFO,
"MINFO": RecordType_MINFO,
"MX": RecordType_MX,
"TXT": RecordType_TXT,
"RP": RecordType_RP,
"AFSDB": RecordType_AFSDB,
"X25": RecordType_X25,
"ISDN": RecordType_ISDN,
"RT": RecordType_RT,
"NSAP": RecordType_NSAP,
"NSAP-PTR": RecordType_NSAP_PTR,
"SIG": RecordType_SIG,
"KEY": RecordType_KEY,
"PX": RecordType_PX,
"GPOS": RecordType_GPOS,
"AAAA": RecordType_AAAA,
"LOC": RecordType_LOC,
"NXT": RecordType_NXT,
"EID": RecordType_EID,
"NIMLOC": RecordType_NIMLOC,
"SRV": RecordType_SRV,
"ATMA": RecordType_ATMA,
"NAPTR": RecordType_NAPTR,
"KX": RecordType_KX,
"CERT": RecordType_CERT,
"A6": RecordType_A6,
"DNAME": RecordType_DNAME,
"SINK": RecordType_SINK,
"OPT": RecordType_OPT,
"APL": RecordType_APL,
"DS": RecordType_DS,
"SSHFP": RecordType_SSHFP,
"IPSECKEY": RecordType_IPSECKEY,
"RRSIG": RecordType_RRSIG,
"NSEC": RecordType_NSEC,
"DNSKEY": RecordType_DNSKEY,
"DHCID": RecordType_DHCID,
"NSEC3": RecordType_NSEC3,
"NSEC3PARAM": RecordType_NSEC3PARAM,
"TLSA": RecordType_TLSA,
"SMIMEA": RecordType_SMIMEA,
"HIP": RecordType_HIP,
"NINFO": RecordType_NINFO,
"RKEY": RecordType_RKEY,
"TALINK": RecordType_TALINK,
"CDS": RecordType_CDS,
"CDNSKEY": RecordType_CDNSKEY,
"OPENPGPKEY": RecordType_OPENPGPKEY,
"CSYNC": RecordType_CSYNC,
"ZONEMD": RecordType_ZONEMD,
"SPF": RecordType_SPF,
"UINFO": RecordType_UINFO,
"UID": RecordType_UID,
"GID": RecordType_GID,
"UNSPEC": RecordType_UNSPEC,
"NID": RecordType_NID,
"L32": RecordType_L32,
"L64": RecordType_L64,
"LP": RecordType_LP,
"EUI48": RecordType_EUI48,
"EUI64": RecordType_EUI64,
"TKEY": RecordType_TKEY,
"TSIG": RecordType_TSIG,
"IXFR": RecordType_IXFR,
"AXFR": RecordType_AXFR,
"MAILB": RecordType_MAILB,
"MAILA": RecordType_MAILA,
"*": RecordType_all,
"URI": RecordType_URI,
"CAA": RecordType_CAA,
"AVC": RecordType_AVC,
"DOA": RecordType_DOA,
"AMTRELAY": RecordType_AMTRELAY,
"TA": RecordType_TA,
"DLV": RecordType_DLV,
}
for label, rt := range check {
parsed, err := parseType(label)
if err != nil {
t.Fatalf("Failed to parse RecordType '%s'", label)
}
if parsed != rt {
t.Fatalf("Parsing of '%s' did not return expected type", label)
}
if parsed.String() != label {
t.Fatalf("String output of RecordType for '%s' did not match the original input", label)
}
}
}
func TestRecordTypes(t *testing.T) {
records := map[string]Record{
"adomain.com. 300 IN SOA ns.ahostdomain.com. hostmaster.ahostdomain.com. ( 1271271271 10800 3600 604800 300 )": Record{
"adomain.com.", 300, RecordClass_IN, RecordType_SOA,
[]string{"ns.ahostdomain.com.", "hostmaster.ahostdomain.com.", "(", "1271271271", "10800", "3600", "604800", "300", ")"}, "",
},
"adomain.com. 300 IN SOA ns.ahostdomain.com. hostmaster.ahostdomain.com.(1271271271 10800 3600 604800 300)": Record{
"adomain.com.", 300, RecordClass_IN, RecordType_SOA,
[]string{"ns.ahostdomain.com.", "hostmaster.ahostdomain.com.", "(", "1271271271", "10800", "3600", "604800", "300", ")"}, "",
},
"adomain.com. 300 IN A 192.168.0.1;aComment": Record{"adomain.com.", 300, RecordClass_IN, RecordType_A, []string{"192.168.0.1"}, ";aComment"},
"adomain.com. IN A 192.168.0.1": Record{"adomain.com.", -1, RecordClass_IN, RecordType_A, []string{"192.168.0.1"}, ""},
"adomain.com. 300 IN A 192.168.0.1\n\nadomain.com. 300 IN A 192.168.0.2\n": Record{"adomain.com.", 300, RecordClass_IN, RecordType_A, []string{"192.168.0.1"}, ""},
"adomain.com. 300 IN NS ns.ahostdomain.com.": Record{"adomain.com.", 300, RecordClass_IN, RecordType_NS, []string{"ns.ahostdomain.com."}, ""},
"adomain.com. 300 IN MX 10 smtp.ahostdomain.com.": Record{"adomain.com.", 300, RecordClass_IN, RecordType_MX, []string{"10", "smtp.ahostdomain.com."}, ""},
`adomain.com. 300 IN TXT "a \"b\" c"`: Record{"adomain.com.", 300, RecordClass_IN, RecordType_TXT, []string{`"a \"b\" c"`}, ""},
`adomain.com. 300 IN TXT"a \"b\" c"`: Record{"adomain.com.", 300, RecordClass_IN, RecordType_TXT, []string{`"a \"b\" c"`}, ""},
"www.adomain.com. 300 IN CNAME adomain.com.": Record{"www.adomain.com.", 300, RecordClass_IN, RecordType_CNAME, []string{"adomain.com."}, ""},
}
for spec, record := range records {
var r Record
s := NewScanner(strings.NewReader(spec))
err := s.Next(&r)
if err != nil {
t.Fatalf("Failed to parse [%s]: %s", spec, err)
}
if !reflect.DeepEqual(r, record) {
t.Fatalf("Generated Output [%#v] not equal to Input [%#v]", r, record)
}
}
}
func TestRecordTypesOuput(t *testing.T) {
records := map[string]string{
"adomain.com. 300 IN SOA ns.ahostdomain.com. hostmaster.ahostdomain.com. ( 1271271271 10800 3600 604800 300 )": "adomain.com. 300 IN SOA ns.ahostdomain.com. hostmaster.ahostdomain.com. ( 1271271271 10800 3600 604800 300 )",
"adomain.com. 300 IN A 192.168.0.1;aComment\n": "adomain.com. 300 IN A 192.168.0.1 ;aComment",
"adomain.com. IN A 192.168.0.1": "adomain.com. IN A 192.168.0.1",
"adomain.com. 300 IN NS ns.ahostdomain.com.": "adomain.com. 300 IN NS ns.ahostdomain.com.",
"adomain.com. 300 IN MX 10 smtp.ahostdomain.com.": "adomain.com. 300 IN MX 10 smtp.ahostdomain.com.",
`adomain.com. 300 IN TXT "a \"b\" c"`: `adomain.com. 300 IN TXT "a \"b\" c"`,
"www.adomain.com. 300 IN CNAME adomain.com.": "www.adomain.com. 300 IN CNAME adomain.com.",
}
for spec, expected := range records {
var r Record
s := NewScanner(strings.NewReader(spec))
err := s.Next(&r)
if err != nil {
t.Fatalf("Failed to parse [%s]: %s", spec, err)
}
if r.String() != expected {
t.Fatalf("Generated Output [%s] not equal to expected output [%s]", r.String(), expected)
}
}
}
func TestIncompleteTXTRecordFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 IN TXT \""))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of unclosed TXT record did not return an error")
}
}
func TestIncompleteSOARecordFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 IN SOA ( 1271271271"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of unclosed SOA record did not return an error")
}
}
func TestIncompleteTypelessRecordFailsEOF(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 IN "))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of typeless record did not return an error")
}
}
func TestIncompleteTypelessRecordFailsEOL(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 IN \n"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of typeless record did not return an error")
}
}
func TestIncompleteDatalessRecordFailsEOF(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 IN A "))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of dataless record did not return an error")
}
}
func TestIncompleteDatalessRecordFailsEOL(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 IN A \n"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of dataless record did not return an error")
}
}
func TestBadClassRecordFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 FAKE A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of bad-class record did not return an error")
}
}
func TestBadTypeRecordFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. 300 IN FAKE 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of bad-type record did not return an error")
}
}
func TestOriginDefinesDefault(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("@ 300 IN A 192.168.1.1"))
err := s.SetOrigin("adomain.com.")
if err != nil {
t.Fatalf("Unexpected error when setting Origin: %s", err)
}
err = s.Next(&r)
if err != nil {
t.Fatalf("Parsing of default-domain record returned an error: %s", err)
}
if r.DomainName != "adomain.com." {
t.Fatalf("Parsing of default-domain record did not result in a Record with the default domain")
}
}
func TestOriginControlEntrySetsOrigin(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN adomain.com.\n@ 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err != nil {
t.Fatalf("Unexpected error when setting Origin via $ORIGIN Control Entry: %s", err)
}
if s.origin != "adomain.com." {
t.Fatalf("Parsing of $ORIGIN control entry did not set the default origin")
}
}
func TestOriginControlEntryCanHaveComment(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN adomain.com. ; should be ignored\n@ 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err != nil {
t.Fatalf("Parsing of default-domain record returned an error: %s", err)
}
if r.DomainName != "adomain.com." {
t.Fatalf("Parsing of default-domain record did not result in a Record with the default domain")
}
}
func TestOriginDefinesRelative(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("www 300 IN A 192.168.1.1"))
err := s.SetOrigin("adomain.com.")
if err != nil {
t.Fatalf("Unexpected error when setting Origin: %s", err)
}
err = s.Next(&r)
if err != nil {
t.Fatalf("Parsing of relative record returned an error: %s", err)
}
if r.DomainName != "www.adomain.com." {
t.Fatalf("Parsing of relative record did not result in a Record within the default domain")
}
}
func TestOriginDoesNotImpactFullyQualified(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("www.example.com. 300 IN A 192.168.1.1"))
err := s.SetOrigin("adomain.com.")
if err != nil {
t.Fatalf("Unexpected error when setting Origin: %s", err)
}
err = s.Next(&r)
if err != nil {
t.Fatalf("Parsing of fully-qualified record returned an error: %s", err)
}
if r.DomainName != "www.example.com." {
t.Fatalf("Parsing of fully-qualified record with an $ORIGIN defined did not result in the entry's domain as-specified")
}
}
func TestOriginControlEntryRelativeFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN adomain.com\nwww 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of relative $ORIGIN control entry did not return an error")
}
}
func TestDefaultDomainWithoutOriginFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("@ 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of default domain entry when no $ORIGIN defined did not result in an error")
}
}
func TestRelativeDomainWithoutOriginFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("www 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of relative domain when no $ORIGIN defined did not result in an error")
}
}
func TestIncompleteOriginControlEntry(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN\nwww 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of incomplete $ORIGIN control entry did not result in an error")
}
}
func TestIncompleteOriginControlEntryComment(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN ;this should be ignored\nwww 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of incomplete $ORIGIN control entry (with comment) did not result in an error")
}
}
func TestIncompleteOriginControlEntryEOF(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of incomplete $ORIGIN control entry (at end of file) did not result in an error")
}
}
// This one may require some explanation. It is asserting two things:
// 1) an $ORIGIN at the end of the file is not an error on its own
// 2) the presence of an $ORIGIN control entry should not cause a record to be
// returned, ie: there should still be an error returned, but that error is
// merely the normal "EOF" error.
func TestCompleteOriginControlEntryEOF(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN adomain.com."))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of a zone containing nothing but an $ORIGIN control entry did not result in an error")
}
if err != io.EOF {
t.Fatalf("Parsing of a zone containing nothing but an $ORIGIN control entry did not result in EOF error")
}
}
func TestMalformedOriginControlEntryMultipleDomains(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$ORIGIN adomain.com. andanother.com."))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of malformed $ORIGIN control entry (multiple domains) did not result in an error")
}
}
func TestUnknownControlEntryFails(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$UNKNOWN"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of unknown control entry did not result in an error")
}
}
func TestTimeToLiveDefinesDefault(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("adomain.com. IN A 192.168.1.1"))
err := s.SetTimeToLive(600)
if err != nil {
t.Fatalf("Unexpected error when setting TimeToLive: %s", err)
}
err = s.Next(&r)
if err != nil {
t.Fatalf("Parsing of TTL-less record returned an error: %s", err)
}
if r.TimeToLive != 600 {
t.Fatalf("Parsing of TTL-less record did not result in a Record with the default TTL")
}
}
func TestTimeToLiveControlEntrySetsTimeToLive(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL 600\nadomain.com. IN A 192.168.1.1"))
err := s.Next(&r)
if err != nil {
t.Fatalf("Unexpected error when setting TimeToLive via $TTL Control Entry: %s", err)
}
if s.timeToLive != 600 {
t.Fatalf("Parsing of $TTL control entry did not set the default TTL")
}
}
func TestTimeToLiveControlEntryCanHaveComment(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL 600 ; should be ignored\nadomain.com. IN A 192.168.1.1"))
err := s.Next(&r)
if err != nil {
t.Fatalf("Parsing of TTL-less record returned an error: %s", err)
}
if r.TimeToLive != 600 {
t.Fatalf("Parsing of TTL-less record did not result in a Record with the default TTL")
}
}
func TestTimeToLiveDoesNotImpactSpecified(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("www.example.com. 300 IN A 192.168.1.1"))
err := s.SetTimeToLive(600)
if err != nil {
t.Fatalf("Unexpected error when setting TimeToLive: %s", err)
}
err = s.Next(&r)
if err != nil {
t.Fatalf("Parsing of TTL-specified record returned an error: %s", err)
}
if r.TimeToLive != 300 {
t.Fatalf("Parsing of TTL-specified record a $TTL defined did not result in the entry's TTL as-specified")
}
}
func TestIncompleteTimeToLiveControlEntry(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL\nwww 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of incomplete $TTL control entry did not result in an error")
}
}
func TestIncompleteTimeToLiveControlEntryComment(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL ;this should be ignored\nwww 300 IN A 192.168.1.1"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of incomplete $TTL control entry (with comment) did not result in an error")
}
}
func TestIncompleteTimeToLiveControlEntryEOF(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of incomplete $TTL control entry (at end of file) did not result in an error")
}
}
func TestCompleteTimeToLiveControlEntryEOF(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL 600"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of a zone containing nothing but an $TTL control entry did not result in an error")
}
if err != io.EOF {
t.Fatalf("Parsing of a zone containing nothing but an $TTL control entry did not result in EOF error")
}
}
func TestMalformedTimeToLiveControlEntryMultipleTimeToLive(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL 600 300"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of malformed $TTL control entry (multiple time-to-live) did not result in an error")
}
}
func TestMalformedTimeToLiveControlEntryNonNumeric(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL aaa"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of malformed $TTL control entry (non-numeric) did not result in an error")
}
}
func TestMalformedTimeToLiveControlEntryNegative(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL -600"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of malformed $TTL control entry (negative) did not result in an error")
}
}
func TestMalformedTimeToLiveControlEntryTooLarge(t *testing.T) {
var r Record
s := NewScanner(strings.NewReader("$TTL 4294967296"))
err := s.Next(&r)
if err == nil {
t.Fatalf("Parsing of malformed $TTL control entry (number larger than MaxUint32) did not result in an error")
}
}
func TestSetTimeToLiveTooLargeFail(t *testing.T) {
s := NewScanner(strings.NewReader("adomain.com. IN A 192.168.1.1"))
err := s.SetTimeToLive(4294967296)
if err == nil {
t.Fatalf("Setting TimeToLive to a number larger than MaxUint32 did not result in an error")
}
}
func TestSetTimeToLiveTooSmallFolds(t *testing.T) {
s := NewScanner(strings.NewReader("adomain.com. IN A 192.168.1.1"))
err := s.SetTimeToLive(-2)
if err != nil {
t.Fatalf("Setting TimeToLive to a number smaller than -1 (ie, to indicate unspecified) resulted in an error")
}
if s.timeToLive != -1 {
t.Fatalf("Setting TimeToLive to a number smaller than -1 (ie, to indicate unspecified) did not fold the value to -1")
}
}