diff options
| author | Bob Halley <halley@dnspython.org> | 2020-08-22 19:11:19 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2020-08-22 19:11:19 -0700 |
| commit | ae2b35b0145ae3b75c9494a984b14ff3851e9532 (patch) | |
| tree | 6c61cf27a8e0a5ccf888de381e3c9062b66e03ae /tests | |
| parent | 030a9f8f87e862c738c858facabf2d0c4d44e440 (diff) | |
| download | dnspython-ae2b35b0145ae3b75c9494a984b14ff3851e9532.tar.gz | |
is_udp is better as Inbound attribute not parameter to process_message(). Increase coverage.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_xfr.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/tests/test_xfr.py b/tests/test_xfr.py index fbda5fa..c1a011c 100644 --- a/tests/test_xfr.py +++ b/tests/test_xfr.py @@ -211,6 +211,20 @@ ns3 3600 IN A 10.0.0.3 @ 3600 IN SOA foo bar 4 2 3 4 5 ''' +unexpected_end_ixfr_2 = '''id 1 +opcode QUERY +rcode NOERROR +flags AA +;QUESTION +example. IN IXFR +;ANSWER +@ 3600 IN SOA foo bar 4 2 3 4 5 +@ 3600 IN SOA foo bar 1 2 3 4 5 +bar.foo 300 IN MX 0 blaz.foo +ns2 3600 IN A 10.0.0.2 +@ 3600 IN NS ns2 +''' + bad_serial_ixfr = '''id 1 opcode QUERY rcode NOERROR @@ -329,9 +343,9 @@ def test_retry_tcp_ixfr(): zone_factory=dns.versioned.Zone) m = dns.message.from_text(retry_tcp_ixfr, origin=z.origin, one_rr_per_rrset=True) - with dns.xfr.Inbound(z, dns.rdatatype.IXFR, serial=1) as xfr: + with dns.xfr.Inbound(z, dns.rdatatype.IXFR, serial=1, is_udp=True) as xfr: with pytest.raises(dns.xfr.UseTCP): - xfr.process_message(m, True) + xfr.process_message(m) def test_bad_empty_ixfr(): z = dns.zone.from_text(ixfr_expected, 'example.', @@ -368,7 +382,9 @@ def test_ixfr_requires_serial(): with pytest.raises(ValueError): dns.xfr.Inbound(z, dns.rdatatype.IXFR) -def test_ixfr_unexpected_end(): +def test_ixfr_unexpected_end_bad_diff_sequence(): + # This is where we get the end serial, but haven't seen all of + # the expected diffs z = dns.zone.from_text(base, 'example.', zone_factory=dns.versioned.Zone) m = dns.message.from_text(unexpected_end_ixfr, origin=z.origin, @@ -377,6 +393,17 @@ def test_ixfr_unexpected_end(): with pytest.raises(dns.exception.FormError): xfr.process_message(m) +def test_udp_ixfr_unexpected_end_just_stops(): + # This is where everything looks good, but the IXFR just stops + # in the middle. + z = dns.zone.from_text(base, 'example.', + zone_factory=dns.versioned.Zone) + m = dns.message.from_text(unexpected_end_ixfr_2, origin=z.origin, + one_rr_per_rrset=True) + with dns.xfr.Inbound(z, dns.rdatatype.IXFR, serial=1, is_udp=True) as xfr: + with pytest.raises(dns.exception.FormError): + xfr.process_message(m) + def test_ixfr_bad_serial(): z = dns.zone.from_text(base, 'example.', zone_factory=dns.versioned.Zone) @@ -386,6 +413,12 @@ def test_ixfr_bad_serial(): with pytest.raises(dns.exception.FormError): xfr.process_message(m) +def test_no_udp_with_axfr(): + z = dns.versioned.Zone('example.') + with pytest.raises(ValueError): + with dns.xfr.Inbound(z, dns.rdatatype.AXFR, is_udp=True) as xfr: + pass + refused = '''id 1 opcode QUERY rcode REFUSED |
