diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile | 23 | ||||
| -rw-r--r-- | tests/example | 243 | ||||
| -rw-r--r-- | tests/example1.good | 126 | ||||
| -rw-r--r-- | tests/example2.good | 126 | ||||
| -rw-r--r-- | tests/example3.good | 126 | ||||
| -rw-r--r-- | tests/test_bugs.py | 76 | ||||
| -rw-r--r-- | tests/test_dnssec.py | 233 | ||||
| -rw-r--r-- | tests/test_exceptions.py | 62 | ||||
| -rw-r--r-- | tests/test_flags.py | 59 | ||||
| -rw-r--r-- | tests/test_generate.py | 498 | ||||
| -rw-r--r-- | tests/test_grange.py | 86 | ||||
| -rw-r--r-- | tests/test_message.py | 178 | ||||
| -rw-r--r-- | tests/test_name.py | 710 | ||||
| -rw-r--r-- | tests/test_namedict.py | 102 | ||||
| -rw-r--r-- | tests/test_ntoaaton.py | 195 | ||||
| -rw-r--r-- | tests/test_rdata.py | 33 | ||||
| -rw-r--r-- | tests/test_rdtypeandclass.py | 123 | ||||
| -rw-r--r-- | tests/test_rdtypeanydnskey.py | 68 | ||||
| -rw-r--r-- | tests/test_rdtypeanyeui.py | 223 | ||||
| -rw-r--r-- | tests/test_rdtypeanyloc.py | 68 | ||||
| -rw-r--r-- | tests/test_resolver.py | 184 | ||||
| -rw-r--r-- | tests/test_rrset.py | 54 | ||||
| -rw-r--r-- | tests/test_set.py | 208 | ||||
| -rw-r--r-- | tests/test_tokenizer.py | 190 | ||||
| -rw-r--r-- | tests/test_update.py | 114 | ||||
| -rw-r--r-- | tests/test_zone.py | 420 | ||||
| -rw-r--r-- | tests/utest.py | 10 |
27 files changed, 0 insertions, 4538 deletions
diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 8c465df..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile,v 1.5 2004/03/19 00:17:27 halley Exp $ - -PYTHON=python3 - -check: test - -test: - ${PYTHON} ./utest.py diff --git a/tests/example b/tests/example deleted file mode 100644 index b4ad606..0000000 --- a/tests/example +++ /dev/null @@ -1,243 +0,0 @@ -; Copyright (C) 2000, 2001 Internet Software Consortium. -; -; Permission to use, copy, modify, and distribute this software for any -; purpose with or without fee is hereby granted, provided that the above -; copyright notice and this permission notice appear in all copies. -; -; THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM -; DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL -; INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, -; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING -; FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -; WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -; $Id: example,v 1.13 2004/03/19 00:06:37 halley Exp $ - -$ORIGIN . -$TTL 300 ; 5 minutes -example IN SOA ns1.example. hostmaster.example. ( - 1 ; serial - 2000 ; refresh (2000 seconds) - 2000 ; retry (2000 seconds) - 1814400 ; expire (3 weeks) - 3600 ; minimum (1 hour) - ) -example. NS ns1.example. -ns1.example. A 10.53.0.1 -example. NS ns2.example. -ns2.example. A 10.53.0.2 - -$ORIGIN example. -* MX 10 mail -a TXT "foo foo foo" - PTR foo.net. -;; The next line not starting with ';;' is leading whitespace followed by -;; EOL. We want to treat that as if EOL had appeared alone. - -;; The next line not starting with ';;' is leading whitespace followed by -;; a comment followed by EOL. We want to treat that as if EOL had appeared -;; alone. - ; foo -$TTL 3600 ; 1 hour -a01 A 0.0.0.0 -a02 A 255.255.255.255 -;; -;; XXXRTH dnspython doesn't currently implement A6, and since -;; A6 records are effectively dead, it may never do so. -;; -;;a601 A6 0 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff -;; A6 64 ::ffff:ffff:ffff:ffff foo. -;; A6 127 ::1 foo. -;; A6 128 . -aaaa01 AAAA ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff -aaaa02 AAAA ::1 -afsdb01 AFSDB 0 hostname -afsdb02 AFSDB 65535 . -$TTL 300 ; 5 minutes -b CNAME foo.net. -c A 73.80.65.49 -$TTL 3600 ; 1 hour -cert01 CERT 65534 65535 PRIVATEOID ( - MxFcby9k/yvedMfQgKzhH5er0Mu/vILz45IkskceFGgi - WCn/GxHhai6VAuHAoNUz4YoU1tVfSCSqQYn6//11U6Nl - d80jEeC8aTrO+KKmCaY= ) -cname01 CNAME cname-target. -cname02 CNAME cname-target -cname03 CNAME . -$TTL 300 ; 5 minutes -d A 73.80.65.49 -$TTL 3600 ; 1 hour -dhcid01 DHCID ( AAIBY2/AuCccgoJbsaxcQc9TUapptP69l - OjxfNuVAA2kjEA= ) -dhcid02 DHCID ( AAEBOSD+XR3Os/0LozeXVqcNc7FwCfQdW - L3b/NaiUDlW2No= ) -dhcid03 DHCID ( AAABxLmlskllE0MVjd57zHcWmEH3pCQ6V - ytcKD//7es/deY= ) -dname01 DNAME dname-target. -dname02 DNAME dname-target -dname03 DNAME . -$TTL 300 ; 5 minutes -e MX 10 mail - TXT "one" - TXT "three" - TXT "two" - A 73.80.65.49 - A 73.80.65.50 - A 73.80.65.52 - A 73.80.65.51 -f A 73.80.65.52 -$TTL 3600 ; 1 hour -gpos01 GPOS "-22.6882" "116.8652" "250.0" -;; -;; XXXRTH I have commented out the following line because I don't think -;; it is a valid GPOS record. -;; -;;gpos02 GPOS "" "" "" -hinfo01 HINFO "Generic PC clone" "NetBSD-1.4" -hinfo02 HINFO "PC" "NetBSD" -isdn01 ISDN "isdn-address" -isdn02 ISDN "isdn-address" "subaddress" -isdn03 ISDN "isdn-address" -isdn04 ISDN "isdn-address" "subaddress" -;; dnspython no longer supports old DNSSEC -;;key01 KEY 512 255 1 ( -;; AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR -;; yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3 -;; GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o -;; jqf0BaqHT+8= ) -;;key02 KEY HOST|FLAG4 DNSSEC RSAMD5 ( -;; AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR -;; yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3 -;; GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o -;; jqf0BaqHT+8= ) -kx01 KX 10 kdc -kx02 KX 10 . -loc01 LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20m 2000m 20m -loc02 LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20m 2000m 20m -loc03 LOC 60 9 0.000 N 24 39 0.000 E 10.00m 90000000.00m 2000m 20m -loc04 LOC 60 9 1.5 N 24 39 0.000 E 10.00m 20m 2000m 20m -loc05 LOC 60 9 1.51 N 24 39 0.000 E 10.00m 20m 2000m 20m -;; -;; XXXRTH These are all obsolete and unused. dnspython doesn't implement -;; them -;;mb01 MG madname -;;mb02 MG . -;;mg01 MG mgmname -;;mg02 MG . -;;minfo01 MINFO rmailbx emailbx -;;minfo02 MINFO . . -;;mr01 MR mrname -;;mr02 MR . -mx01 MX 10 mail -mx02 MX 10 . -naptr01 NAPTR 0 0 "" "" "" . -naptr02 NAPTR 65535 65535 "blurgh" "blorf" "blegh" foo. -nsap-ptr01 NSAP-PTR foo. - NSAP-PTR . -nsap01 NSAP 0x47000580005a0000000001e133ffffff00016100 -nsap02 NSAP 0x47.000580005a0000000001e133ffffff000161.00 -;;nxt01 NXT a.secure ( NS SOA MX SIG KEY LOC NXT ) -;;nxt02 NXT . ( NSAP-PTR NXT ) -;;nxt03 NXT . ( A ) -;;nxt04 NXT . ( 127 ) -ptr01 PTR example. -px01 PX 65535 foo. bar. -px02 PX 65535 . . -rp01 RP mbox-dname txt-dname -rp02 RP . . -rt01 RT 0 intermediate-host -rt02 RT 65535 . -$TTL 300 ; 5 minutes -s NS ns.s -$ORIGIN s.example. -ns A 73.80.65.49 -$ORIGIN example. -$TTL 3600 ; 1 hour -;;sig01 SIG NXT 1 3 3600 ( -;; 20200101000000 20030101000000 2143 foo -;; MxFcby9k/yvedMfQgKzhH5er0Mu/vILz45IkskceFGgi -;; WCn/GxHhai6VAuHAoNUz4YoU1tVfSCSqQYn6//11U6Nl -;; d80jEeC8aTrO+KKmCaY= ) -srv01 SRV 0 0 0 . -srv02 SRV 65535 65535 65535 old-slow-box.example.com. -$TTL 301 ; 5 minutes 1 second -t A 73.80.65.49 -$TTL 3600 ; 1 hour -tlsa1 TLSA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 -tlsa2 TLSA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 -tlsa3 TLSA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 -txt01 TXT "foo" -txt02 TXT "foo" "bar" -txt03 TXT "foo" -txt04 TXT "foo" "bar" -txt05 TXT "foo bar" -txt06 TXT "foo bar" -txt07 TXT "foo bar" -txt08 TXT "foo\010bar" -txt09 TXT "foo\010bar" -txt10 TXT "foo bar" -txt11 TXT "\"foo\"" -txt12 TXT "\"foo\"" -txt13 TXT foo -$TTL 300 ; 5 minutes -u TXT "txt-not-in-nxt" -$ORIGIN u.example. -a A 73.80.65.49 -b A 73.80.65.49 -$ORIGIN example. -$TTL 3600 ; 1 hour -wks01 WKS 10.0.0.1 6 ( 0 1 2 21 23 ) -wks02 WKS 10.0.0.1 17 ( 0 1 2 53 ) -wks03 WKS 10.0.0.2 6 ( 65535 ) -x2501 X25 "123456789" -dlv01 DLV 12345 3 1 123456789abcdef67890123456789abcdef67890 -ds01 DS 12345 3 1 123456789abcdef67890123456789abcdef67890 -cds01 CDS 12345 3 1 123456789abcdef67890123456789abcdef67890 -apl01 APL 1:192.168.32.0/21 !1:192.168.38.0/28 -apl02 APL 1:224.0.0.0/4 2:FF00:0:0:0:0:0:0:0/8 -unknown2 TYPE999 \# 8 0a0000010a000001 -rrsig01 RRSIG NSEC 1 3 3600 20200101000000 20030101000000 2143 foo MxFcby9k/yvedMfQgKzhH5er0Mu/ vILz45IkskceFGgiWCn/GxHhai6V AuHAoNUz4YoU1tVfSCSqQYn6//11 U6Nld80jEeC8aTrO+KKmCaY= -nsec01 NSEC a.secure. A MX RRSIG NSEC TYPE1234 -nsec02 NSEC . NSAP-PTR NSEC -nsec03 NSEC . NSEC TYPE65535 -dnskey01 DNSKEY 512 255 1 ( - AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR - yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3 - GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o - jqf0BaqHT+8= ) -dnskey02 DNSKEY 257 3 RSAMD5 ( - AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR - yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3 - GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o - jqf0BaqHT+8= ) -cdnskey01 CDNSKEY 256 3 8 ( - AwEAAbmiLgh411Pz3v3XCSBrvYf52A/Gv55ItN1NbOLH - Cqt3Ec3p+VB/kQ87VjjMrycanZFnZT4l9uCFuYh21Ccy - xVpcxExbM0UuhX5rJoDyeFSXoQlkHrB01osPl5Vri5Ym - KtcmqGxZ9An0VSunohkyiX1SrNRZSdQnk9/pIHDe/c8D - ) -; -; test known type using unknown RR syntax -; -unknown3 A \# 4 7f000002 -sshfp1 SSHFP 1 1 aa549bfe898489c02d1715d97d79c57ba2fa76ab -spf SPF "v=spf1 mx -all" -ipseckey01 IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey02 IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey03 IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey04 IPSECKEY 10 2 2 2001:0DB8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey05 IPSECKEY 10 3 2 mygateway2 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -nsec301 NSEC3 1 1 12 aabbccdd 2t7b4g4vsa5smi47k61mv5bv1a22bojr MX DNSKEY NS SOA NSEC3PARAM RRSIG -nsec302 NSEC3 1 1 12 - 2t7b4g4vsa5smi47k61mv5bv1a22bojr MX DNSKEY NS SOA NSEC3PARAM RRSIG -nsec3param01 NSEC3PARAM 1 1 12 aabbccdd -nsec3param02 NSEC3PARAM 1 1 12 - -hip01 HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs1.example.com. rvs2 -caa01 CAA 0 issue "ca.example.net" -caa02 CAA 0 iodef "mailto:security@example.com" -caa03 CAA 0 iodef "http://iodef.example.com/" -caa04 CAA 0 issue "ca.example.net; account=230123" -caa05 CAA 0 issue "ca.example.net; policy=ev" -caa06 CAA 128 tbs "Unknown" -uri0q URI 10 1 "http://www.example.com/" diff --git a/tests/example1.good b/tests/example1.good deleted file mode 100644 index 1eef90b..0000000 --- a/tests/example1.good +++ /dev/null @@ -1,126 +0,0 @@ -@ 300 IN SOA ns1 hostmaster 1 2000 2000 1814400 3600 -@ 300 IN NS ns1 -@ 300 IN NS ns2 -* 300 IN MX 10 mail -a 300 IN TXT "foo foo foo" -a 300 IN PTR foo.net. -a01 3600 IN A 0.0.0.0 -a02 3600 IN A 255.255.255.255 -aaaa01 3600 IN AAAA ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff -aaaa02 3600 IN AAAA ::1 -afsdb01 3600 IN AFSDB 0 hostname -afsdb02 3600 IN AFSDB 65535 . -apl01 3600 IN APL 1:192.168.32.0/21 !1:192.168.38.0/28 -apl02 3600 IN APL 1:224.0.0.0/4 2:FF00:0:0:0:0:0:0:0/8 -b 300 IN CNAME foo.net. -c 300 IN A 73.80.65.49 -caa01 3600 IN CAA 0 issue "ca.example.net" -caa02 3600 IN CAA 0 iodef "mailto:security@example.com" -caa03 3600 IN CAA 0 iodef "http://iodef.example.com/" -caa04 3600 IN CAA 0 issue "ca.example.net; account=230123" -caa05 3600 IN CAA 0 issue "ca.example.net; policy=ev" -caa06 3600 IN CAA 128 tbs "Unknown" -cdnskey01 3600 IN CDNSKEY 256 3 8 AwEAAbmiLgh411Pz3v3XCSBrvYf52A/G v55ItN1NbOLHCqt3Ec3p+VB/kQ87VjjM rycanZFnZT4l9uCFuYh21CcyxVpcxExb M0UuhX5rJoDyeFSXoQlkHrB01osPl5Vr i5YmKtcmqGxZ9An0VSunohkyiX1SrNRZ SdQnk9/pIHDe/c8D -cds01 3600 IN CDS 12345 3 1 123456789abcdef67890123456789abcdef67890 -cert01 3600 IN CERT 65534 65535 PRIVATEOID MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY= -cname01 3600 IN CNAME cname-target. -cname02 3600 IN CNAME cname-target -cname03 3600 IN CNAME . -d 300 IN A 73.80.65.49 -dhcid01 3600 IN DHCID AAIBY2/AuCccgoJbsaxcQc9TUapptP69 lOjxfNuVAA2kjEA= -dhcid02 3600 IN DHCID AAEBOSD+XR3Os/0LozeXVqcNc7FwCfQd WL3b/NaiUDlW2No= -dhcid03 3600 IN DHCID AAABxLmlskllE0MVjd57zHcWmEH3pCQ6 VytcKD//7es/deY= -dlv01 3600 IN DLV 12345 3 1 123456789abcdef67890123456789abcdef67890 -dname01 3600 IN DNAME dname-target. -dname02 3600 IN DNAME dname-target -dname03 3600 IN DNAME . -dnskey01 3600 IN DNSKEY 512 255 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8= -dnskey02 3600 IN DNSKEY 257 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8= -ds01 3600 IN DS 12345 3 1 123456789abcdef67890123456789abcdef67890 -e 300 IN MX 10 mail -e 300 IN TXT "one" -e 300 IN TXT "three" -e 300 IN TXT "two" -e 300 IN A 73.80.65.49 -e 300 IN A 73.80.65.50 -e 300 IN A 73.80.65.52 -e 300 IN A 73.80.65.51 -f 300 IN A 73.80.65.52 -gpos01 3600 IN GPOS -22.6882 116.8652 250.0 -hinfo01 3600 IN HINFO "Generic PC clone" "NetBSD-1.4" -hinfo02 3600 IN HINFO "PC" "NetBSD" -hip01 3600 IN HIP 2 200100107b1a74df365639cc39f1d578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs1.example.com. rvs2 -ipseckey01 3600 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey02 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey03 3600 IN IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey04 3600 IN IPSECKEY 10 2 2 2001:0DB8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey05 3600 IN IPSECKEY 10 3 2 mygateway2 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -isdn01 3600 IN ISDN "isdn-address" -isdn02 3600 IN ISDN "isdn-address" "subaddress" -isdn03 3600 IN ISDN "isdn-address" -isdn04 3600 IN ISDN "isdn-address" "subaddress" -kx01 3600 IN KX 10 kdc -kx02 3600 IN KX 10 . -loc01 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc02 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc03 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 90000000.00m 2000.00m 20.00m -loc04 3600 IN LOC 60 9 1.500 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc05 3600 IN LOC 60 9 1.510 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -mx01 3600 IN MX 10 mail -mx02 3600 IN MX 10 . -naptr01 3600 IN NAPTR 0 0 "" "" "" . -naptr02 3600 IN NAPTR 65535 65535 "blurgh" "blorf" "blegh" foo. -ns1 300 IN A 10.53.0.1 -ns2 300 IN A 10.53.0.2 -nsap-ptr01 3600 IN NSAP-PTR foo. -nsap-ptr01 3600 IN NSAP-PTR . -nsap01 3600 IN NSAP 0x47000580005a0000000001e133ffffff00016100 -nsap02 3600 IN NSAP 0x47000580005a0000000001e133ffffff00016100 -nsec01 3600 IN NSEC a.secure. A MX RRSIG NSEC TYPE1234 -nsec02 3600 IN NSEC . NSAP-PTR NSEC -nsec03 3600 IN NSEC . NSEC TYPE65535 -nsec301 3600 IN NSEC3 1 1 12 aabbccdd 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM -nsec302 3600 IN NSEC3 1 1 12 - 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM -nsec3param01 3600 IN NSEC3PARAM 1 1 12 aabbccdd -nsec3param02 3600 IN NSEC3PARAM 1 1 12 - -ptr01 3600 IN PTR @ -px01 3600 IN PX 65535 foo. bar. -px02 3600 IN PX 65535 . . -rp01 3600 IN RP mbox-dname txt-dname -rp02 3600 IN RP . . -rrsig01 3600 IN RRSIG NSEC 1 3 3600 20200101000000 20030101000000 2143 foo MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY= -rt01 3600 IN RT 0 intermediate-host -rt02 3600 IN RT 65535 . -s 300 IN NS ns.s -ns.s 300 IN A 73.80.65.49 -spf 3600 IN SPF "v=spf1 mx -all" -srv01 3600 IN SRV 0 0 0 . -srv02 3600 IN SRV 65535 65535 65535 old-slow-box.example.com. -sshfp1 3600 IN SSHFP 1 1 aa549bfe898489c02d1715d97d79c57ba2fa76ab -t 301 IN A 73.80.65.49 -tlsa1 3600 IN TLSA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 -tlsa2 3600 IN TLSA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 -tlsa3 3600 IN TLSA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 -txt01 3600 IN TXT "foo" -txt02 3600 IN TXT "foo" "bar" -txt03 3600 IN TXT "foo" -txt04 3600 IN TXT "foo" "bar" -txt05 3600 IN TXT "foo bar" -txt06 3600 IN TXT "foo bar" -txt07 3600 IN TXT "foo bar" -txt08 3600 IN TXT "foo\010bar" -txt09 3600 IN TXT "foo\010bar" -txt10 3600 IN TXT "foo bar" -txt11 3600 IN TXT "\"foo\"" -txt12 3600 IN TXT "\"foo\"" -txt13 3600 IN TXT "foo" -u 300 IN TXT "txt-not-in-nxt" -a.u 300 IN A 73.80.65.49 -b.u 300 IN A 73.80.65.49 -unknown2 3600 IN TYPE999 \# 8 0a0000010a000001 -unknown3 3600 IN A 127.0.0.2 -uri0q 3600 IN URI 10 1 "http://www.example.com/" -wks01 3600 IN WKS 10.0.0.1 6 0 1 2 21 23 -wks02 3600 IN WKS 10.0.0.1 17 0 1 2 53 -wks03 3600 IN WKS 10.0.0.2 6 65535 -x2501 3600 IN X25 "123456789" diff --git a/tests/example2.good b/tests/example2.good deleted file mode 100644 index 2a10506..0000000 --- a/tests/example2.good +++ /dev/null @@ -1,126 +0,0 @@ -example. 300 IN SOA ns1.example. hostmaster.example. 1 2000 2000 1814400 3600 -example. 300 IN NS ns1.example. -example. 300 IN NS ns2.example. -*.example. 300 IN MX 10 mail.example. -a.example. 300 IN TXT "foo foo foo" -a.example. 300 IN PTR foo.net. -a01.example. 3600 IN A 0.0.0.0 -a02.example. 3600 IN A 255.255.255.255 -aaaa01.example. 3600 IN AAAA ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff -aaaa02.example. 3600 IN AAAA ::1 -afsdb01.example. 3600 IN AFSDB 0 hostname.example. -afsdb02.example. 3600 IN AFSDB 65535 . -apl01.example. 3600 IN APL 1:192.168.32.0/21 !1:192.168.38.0/28 -apl02.example. 3600 IN APL 1:224.0.0.0/4 2:FF00:0:0:0:0:0:0:0/8 -b.example. 300 IN CNAME foo.net. -c.example. 300 IN A 73.80.65.49 -caa01.example. 3600 IN CAA 0 issue "ca.example.net" -caa02.example. 3600 IN CAA 0 iodef "mailto:security@example.com" -caa03.example. 3600 IN CAA 0 iodef "http://iodef.example.com/" -caa04.example. 3600 IN CAA 0 issue "ca.example.net; account=230123" -caa05.example. 3600 IN CAA 0 issue "ca.example.net; policy=ev" -caa06.example. 3600 IN CAA 128 tbs "Unknown" -cdnskey01.example. 3600 IN CDNSKEY 256 3 8 AwEAAbmiLgh411Pz3v3XCSBrvYf52A/G v55ItN1NbOLHCqt3Ec3p+VB/kQ87VjjM rycanZFnZT4l9uCFuYh21CcyxVpcxExb M0UuhX5rJoDyeFSXoQlkHrB01osPl5Vr i5YmKtcmqGxZ9An0VSunohkyiX1SrNRZ SdQnk9/pIHDe/c8D -cds01.example. 3600 IN CDS 12345 3 1 123456789abcdef67890123456789abcdef67890 -cert01.example. 3600 IN CERT 65534 65535 PRIVATEOID MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY= -cname01.example. 3600 IN CNAME cname-target. -cname02.example. 3600 IN CNAME cname-target.example. -cname03.example. 3600 IN CNAME . -d.example. 300 IN A 73.80.65.49 -dhcid01.example. 3600 IN DHCID AAIBY2/AuCccgoJbsaxcQc9TUapptP69 lOjxfNuVAA2kjEA= -dhcid02.example. 3600 IN DHCID AAEBOSD+XR3Os/0LozeXVqcNc7FwCfQd WL3b/NaiUDlW2No= -dhcid03.example. 3600 IN DHCID AAABxLmlskllE0MVjd57zHcWmEH3pCQ6 VytcKD//7es/deY= -dlv01.example. 3600 IN DLV 12345 3 1 123456789abcdef67890123456789abcdef67890 -dname01.example. 3600 IN DNAME dname-target. -dname02.example. 3600 IN DNAME dname-target.example. -dname03.example. 3600 IN DNAME . -dnskey01.example. 3600 IN DNSKEY 512 255 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8= -dnskey02.example. 3600 IN DNSKEY 257 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8= -ds01.example. 3600 IN DS 12345 3 1 123456789abcdef67890123456789abcdef67890 -e.example. 300 IN MX 10 mail.example. -e.example. 300 IN TXT "one" -e.example. 300 IN TXT "three" -e.example. 300 IN TXT "two" -e.example. 300 IN A 73.80.65.49 -e.example. 300 IN A 73.80.65.50 -e.example. 300 IN A 73.80.65.52 -e.example. 300 IN A 73.80.65.51 -f.example. 300 IN A 73.80.65.52 -gpos01.example. 3600 IN GPOS -22.6882 116.8652 250.0 -hinfo01.example. 3600 IN HINFO "Generic PC clone" "NetBSD-1.4" -hinfo02.example. 3600 IN HINFO "PC" "NetBSD" -hip01.example. 3600 IN HIP 2 200100107b1a74df365639cc39f1d578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs1.example.com. rvs2.example. -ipseckey01.example. 3600 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey02.example. 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey03.example. 3600 IN IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey04.example. 3600 IN IPSECKEY 10 2 2 2001:0DB8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey05.example. 3600 IN IPSECKEY 10 3 2 mygateway2.example. AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -isdn01.example. 3600 IN ISDN "isdn-address" -isdn02.example. 3600 IN ISDN "isdn-address" "subaddress" -isdn03.example. 3600 IN ISDN "isdn-address" -isdn04.example. 3600 IN ISDN "isdn-address" "subaddress" -kx01.example. 3600 IN KX 10 kdc.example. -kx02.example. 3600 IN KX 10 . -loc01.example. 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc02.example. 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc03.example. 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 90000000.00m 2000.00m 20.00m -loc04.example. 3600 IN LOC 60 9 1.500 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc05.example. 3600 IN LOC 60 9 1.510 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -mx01.example. 3600 IN MX 10 mail.example. -mx02.example. 3600 IN MX 10 . -naptr01.example. 3600 IN NAPTR 0 0 "" "" "" . -naptr02.example. 3600 IN NAPTR 65535 65535 "blurgh" "blorf" "blegh" foo. -ns1.example. 300 IN A 10.53.0.1 -ns2.example. 300 IN A 10.53.0.2 -nsap-ptr01.example. 3600 IN NSAP-PTR foo. -nsap-ptr01.example. 3600 IN NSAP-PTR . -nsap01.example. 3600 IN NSAP 0x47000580005a0000000001e133ffffff00016100 -nsap02.example. 3600 IN NSAP 0x47000580005a0000000001e133ffffff00016100 -nsec01.example. 3600 IN NSEC a.secure. A MX RRSIG NSEC TYPE1234 -nsec02.example. 3600 IN NSEC . NSAP-PTR NSEC -nsec03.example. 3600 IN NSEC . NSEC TYPE65535 -nsec301.example. 3600 IN NSEC3 1 1 12 aabbccdd 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM -nsec302.example. 3600 IN NSEC3 1 1 12 - 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM -nsec3param01.example. 3600 IN NSEC3PARAM 1 1 12 aabbccdd -nsec3param02.example. 3600 IN NSEC3PARAM 1 1 12 - -ptr01.example. 3600 IN PTR example. -px01.example. 3600 IN PX 65535 foo. bar. -px02.example. 3600 IN PX 65535 . . -rp01.example. 3600 IN RP mbox-dname.example. txt-dname.example. -rp02.example. 3600 IN RP . . -rrsig01.example. 3600 IN RRSIG NSEC 1 3 3600 20200101000000 20030101000000 2143 foo.example. MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY= -rt01.example. 3600 IN RT 0 intermediate-host.example. -rt02.example. 3600 IN RT 65535 . -s.example. 300 IN NS ns.s.example. -ns.s.example. 300 IN A 73.80.65.49 -spf.example. 3600 IN SPF "v=spf1 mx -all" -srv01.example. 3600 IN SRV 0 0 0 . -srv02.example. 3600 IN SRV 65535 65535 65535 old-slow-box.example.com. -sshfp1.example. 3600 IN SSHFP 1 1 aa549bfe898489c02d1715d97d79c57ba2fa76ab -t.example. 301 IN A 73.80.65.49 -tlsa1.example. 3600 IN TLSA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 -tlsa2.example. 3600 IN TLSA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 -tlsa3.example. 3600 IN TLSA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 -txt01.example. 3600 IN TXT "foo" -txt02.example. 3600 IN TXT "foo" "bar" -txt03.example. 3600 IN TXT "foo" -txt04.example. 3600 IN TXT "foo" "bar" -txt05.example. 3600 IN TXT "foo bar" -txt06.example. 3600 IN TXT "foo bar" -txt07.example. 3600 IN TXT "foo bar" -txt08.example. 3600 IN TXT "foo\010bar" -txt09.example. 3600 IN TXT "foo\010bar" -txt10.example. 3600 IN TXT "foo bar" -txt11.example. 3600 IN TXT "\"foo\"" -txt12.example. 3600 IN TXT "\"foo\"" -txt13.example. 3600 IN TXT "foo" -u.example. 300 IN TXT "txt-not-in-nxt" -a.u.example. 300 IN A 73.80.65.49 -b.u.example. 300 IN A 73.80.65.49 -unknown2.example. 3600 IN TYPE999 \# 8 0a0000010a000001 -unknown3.example. 3600 IN A 127.0.0.2 -uri0q.example. 3600 IN URI 10 1 "http://www.example.com/" -wks01.example. 3600 IN WKS 10.0.0.1 6 0 1 2 21 23 -wks02.example. 3600 IN WKS 10.0.0.1 17 0 1 2 53 -wks03.example. 3600 IN WKS 10.0.0.2 6 65535 -x2501.example. 3600 IN X25 "123456789" diff --git a/tests/example3.good b/tests/example3.good deleted file mode 100644 index 1eef90b..0000000 --- a/tests/example3.good +++ /dev/null @@ -1,126 +0,0 @@ -@ 300 IN SOA ns1 hostmaster 1 2000 2000 1814400 3600 -@ 300 IN NS ns1 -@ 300 IN NS ns2 -* 300 IN MX 10 mail -a 300 IN TXT "foo foo foo" -a 300 IN PTR foo.net. -a01 3600 IN A 0.0.0.0 -a02 3600 IN A 255.255.255.255 -aaaa01 3600 IN AAAA ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff -aaaa02 3600 IN AAAA ::1 -afsdb01 3600 IN AFSDB 0 hostname -afsdb02 3600 IN AFSDB 65535 . -apl01 3600 IN APL 1:192.168.32.0/21 !1:192.168.38.0/28 -apl02 3600 IN APL 1:224.0.0.0/4 2:FF00:0:0:0:0:0:0:0/8 -b 300 IN CNAME foo.net. -c 300 IN A 73.80.65.49 -caa01 3600 IN CAA 0 issue "ca.example.net" -caa02 3600 IN CAA 0 iodef "mailto:security@example.com" -caa03 3600 IN CAA 0 iodef "http://iodef.example.com/" -caa04 3600 IN CAA 0 issue "ca.example.net; account=230123" -caa05 3600 IN CAA 0 issue "ca.example.net; policy=ev" -caa06 3600 IN CAA 128 tbs "Unknown" -cdnskey01 3600 IN CDNSKEY 256 3 8 AwEAAbmiLgh411Pz3v3XCSBrvYf52A/G v55ItN1NbOLHCqt3Ec3p+VB/kQ87VjjM rycanZFnZT4l9uCFuYh21CcyxVpcxExb M0UuhX5rJoDyeFSXoQlkHrB01osPl5Vr i5YmKtcmqGxZ9An0VSunohkyiX1SrNRZ SdQnk9/pIHDe/c8D -cds01 3600 IN CDS 12345 3 1 123456789abcdef67890123456789abcdef67890 -cert01 3600 IN CERT 65534 65535 PRIVATEOID MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY= -cname01 3600 IN CNAME cname-target. -cname02 3600 IN CNAME cname-target -cname03 3600 IN CNAME . -d 300 IN A 73.80.65.49 -dhcid01 3600 IN DHCID AAIBY2/AuCccgoJbsaxcQc9TUapptP69 lOjxfNuVAA2kjEA= -dhcid02 3600 IN DHCID AAEBOSD+XR3Os/0LozeXVqcNc7FwCfQd WL3b/NaiUDlW2No= -dhcid03 3600 IN DHCID AAABxLmlskllE0MVjd57zHcWmEH3pCQ6 VytcKD//7es/deY= -dlv01 3600 IN DLV 12345 3 1 123456789abcdef67890123456789abcdef67890 -dname01 3600 IN DNAME dname-target. -dname02 3600 IN DNAME dname-target -dname03 3600 IN DNAME . -dnskey01 3600 IN DNSKEY 512 255 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8= -dnskey02 3600 IN DNSKEY 257 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8= -ds01 3600 IN DS 12345 3 1 123456789abcdef67890123456789abcdef67890 -e 300 IN MX 10 mail -e 300 IN TXT "one" -e 300 IN TXT "three" -e 300 IN TXT "two" -e 300 IN A 73.80.65.49 -e 300 IN A 73.80.65.50 -e 300 IN A 73.80.65.52 -e 300 IN A 73.80.65.51 -f 300 IN A 73.80.65.52 -gpos01 3600 IN GPOS -22.6882 116.8652 250.0 -hinfo01 3600 IN HINFO "Generic PC clone" "NetBSD-1.4" -hinfo02 3600 IN HINFO "PC" "NetBSD" -hip01 3600 IN HIP 2 200100107b1a74df365639cc39f1d578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs1.example.com. rvs2 -ipseckey01 3600 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey02 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey03 3600 IN IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey04 3600 IN IPSECKEY 10 2 2 2001:0DB8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -ipseckey05 3600 IN IPSECKEY 10 3 2 mygateway2 AQNRU3mG7TVTO2BkR47usntb102uFJtu gbo6BSGvgqt4AQ== -isdn01 3600 IN ISDN "isdn-address" -isdn02 3600 IN ISDN "isdn-address" "subaddress" -isdn03 3600 IN ISDN "isdn-address" -isdn04 3600 IN ISDN "isdn-address" "subaddress" -kx01 3600 IN KX 10 kdc -kx02 3600 IN KX 10 . -loc01 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc02 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc03 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 90000000.00m 2000.00m 20.00m -loc04 3600 IN LOC 60 9 1.500 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -loc05 3600 IN LOC 60 9 1.510 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m -mx01 3600 IN MX 10 mail -mx02 3600 IN MX 10 . -naptr01 3600 IN NAPTR 0 0 "" "" "" . -naptr02 3600 IN NAPTR 65535 65535 "blurgh" "blorf" "blegh" foo. -ns1 300 IN A 10.53.0.1 -ns2 300 IN A 10.53.0.2 -nsap-ptr01 3600 IN NSAP-PTR foo. -nsap-ptr01 3600 IN NSAP-PTR . -nsap01 3600 IN NSAP 0x47000580005a0000000001e133ffffff00016100 -nsap02 3600 IN NSAP 0x47000580005a0000000001e133ffffff00016100 -nsec01 3600 IN NSEC a.secure. A MX RRSIG NSEC TYPE1234 -nsec02 3600 IN NSEC . NSAP-PTR NSEC -nsec03 3600 IN NSEC . NSEC TYPE65535 -nsec301 3600 IN NSEC3 1 1 12 aabbccdd 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM -nsec302 3600 IN NSEC3 1 1 12 - 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM -nsec3param01 3600 IN NSEC3PARAM 1 1 12 aabbccdd -nsec3param02 3600 IN NSEC3PARAM 1 1 12 - -ptr01 3600 IN PTR @ -px01 3600 IN PX 65535 foo. bar. -px02 3600 IN PX 65535 . . -rp01 3600 IN RP mbox-dname txt-dname -rp02 3600 IN RP . . -rrsig01 3600 IN RRSIG NSEC 1 3 3600 20200101000000 20030101000000 2143 foo MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY= -rt01 3600 IN RT 0 intermediate-host -rt02 3600 IN RT 65535 . -s 300 IN NS ns.s -ns.s 300 IN A 73.80.65.49 -spf 3600 IN SPF "v=spf1 mx -all" -srv01 3600 IN SRV 0 0 0 . -srv02 3600 IN SRV 65535 65535 65535 old-slow-box.example.com. -sshfp1 3600 IN SSHFP 1 1 aa549bfe898489c02d1715d97d79c57ba2fa76ab -t 301 IN A 73.80.65.49 -tlsa1 3600 IN TLSA 3 1 1 a9cdf989b504fe5dca90c0d2167b6550570734f7c763e09fdf88904e06157065 -tlsa2 3600 IN TLSA 1 0 1 efddf0d915c7bdc5782c0881e1b2a95ad099fbdd06d7b1f77982d9364338d955 -tlsa3 3600 IN TLSA 1 0 2 81ee7f6c0ecc6b09b7785a9418f54432de630dd54dc6ee9e3c49de547708d236d4c413c3e97e44f969e635958aa410495844127c04883503e5b024cf7a8f6a94 -txt01 3600 IN TXT "foo" -txt02 3600 IN TXT "foo" "bar" -txt03 3600 IN TXT "foo" -txt04 3600 IN TXT "foo" "bar" -txt05 3600 IN TXT "foo bar" -txt06 3600 IN TXT "foo bar" -txt07 3600 IN TXT "foo bar" -txt08 3600 IN TXT "foo\010bar" -txt09 3600 IN TXT "foo\010bar" -txt10 3600 IN TXT "foo bar" -txt11 3600 IN TXT "\"foo\"" -txt12 3600 IN TXT "\"foo\"" -txt13 3600 IN TXT "foo" -u 300 IN TXT "txt-not-in-nxt" -a.u 300 IN A 73.80.65.49 -b.u 300 IN A 73.80.65.49 -unknown2 3600 IN TYPE999 \# 8 0a0000010a000001 -unknown3 3600 IN A 127.0.0.2 -uri0q 3600 IN URI 10 1 "http://www.example.com/" -wks01 3600 IN WKS 10.0.0.1 6 0 1 2 21 23 -wks02 3600 IN WKS 10.0.0.1 17 0 1 2 53 -wks03 3600 IN WKS 10.0.0.2 6 65535 -x2501 3600 IN X25 "123456789" diff --git a/tests/test_bugs.py b/tests/test_bugs.py deleted file mode 100644 index 5aae6a4..0000000 --- a/tests/test_bugs.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import binascii -import io -import unittest - -import dns.rdata -import dns.rdataclass -import dns.rdatatype -import dns.ttl - -class BugsTestCase(unittest.TestCase): - - def test_float_LOC(self): - rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.LOC, - "30 30 0.000 N 100 30 0.000 W 10.00m 20m 2000m 20m") - self.assertTrue(rdata.float_latitude == 30.5) - self.assertTrue(rdata.float_longitude == -100.5) - - def test_SOA_BIND8_TTL(self): - rdata1 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - "a b 100 1s 1m 1h 1d") - rdata2 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - "a b 100 1 60 3600 86400") - self.assertTrue(rdata1 == rdata2) - - def test_TTL_bounds_check(self): - def bad(): - ttl = dns.ttl.from_text("2147483648") - self.assertRaises(dns.ttl.BadTTL, bad) - - def test_empty_NSEC3_window(self): - rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NSEC3, - "1 0 100 ABCD SCBCQHKU35969L2A68P3AD59LHF30715") - self.assertTrue(rdata.windows == []) - - def test_APL_trailing_zero(self): - rd4 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.APL, - '!1:127.0.0.0/1') - out4 = rd4.to_digestable(dns.name.from_text("test")) - self.assertTrue(binascii.hexlify(out4).decode('ascii') == '000101817f') - - def test_zero_size_APL(self): - rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.APL, - "") - rdata2 = dns.rdata.from_wire(dns.rdataclass.IN, dns.rdatatype.APL, - b"", 0, 0) - self.assertTrue(rdata == rdata2) - - def test_CAA_from_wire(self): - rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CAA, - '0 issue "ca.example.net"'); - f = io.BytesIO() - rdata.to_wire(f) - wire = f.getvalue() - rdlen = len(wire) - wire += b"trailing garbage" - rdata2 = dns.rdata.from_wire(dns.rdataclass.IN, dns.rdatatype.CAA, - wire, 0, rdlen) - self.failUnless(rdata == rdata2) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_dnssec.py b/tests/test_dnssec.py deleted file mode 100644 index 23b1736..0000000 --- a/tests/test_dnssec.py +++ /dev/null @@ -1,233 +0,0 @@ -# Copyright (C) 2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.dnssec -import dns.name -import dns.rdata -import dns.rdataclass -import dns.rdatatype -import dns.rrset - -abs_dnspython_org = dns.name.from_text('dnspython.org') - -abs_keys = { abs_dnspython_org : - dns.rrset.from_text('dnspython.org.', 3600, 'IN', 'DNSKEY', - '257 3 5 AwEAAenVTr9L1OMlL1/N2ta0Qj9LLLnnmFWIr1dJoAsWM9BQfsbV7kFZ XbAkER/FY9Ji2o7cELxBwAsVBuWn6IUUAJXLH74YbC1anY0lifjgt29z SwDzuB7zmC7yVYZzUunBulVW4zT0tg1aePbpVL2EtTL8VzREqbJbE25R KuQYHZtFwG8S4iBxJUmT2Bbd0921LLxSQgVoFXlQx/gFV2+UERXcJ5ce iX6A6wc02M/pdg/YbJd2rBa0MYL3/Fz/Xltre0tqsImZGxzi6YtYDs45 NC8gH+44egz82e2DATCVM1ICPmRDjXYTLldQiWA2ZXIWnK0iitl5ue24 7EsWJefrIhE=', - '256 3 5 AwEAAdSSghOGjU33IQZgwZM2Hh771VGXX05olJK49FxpSyuEAjDBXY58 LGU9R2Zgeecnk/b9EAhFu/vCV9oECtiTCvwuVAkt9YEweqYDluQInmgP NGMJCKdSLlnX93DkjDw8rMYv5dqXCuSGPlKChfTJOLQxIAxGloS7lL+c 0CTZydAF') - } - -abs_keys_duplicate_keytag = { abs_dnspython_org : - dns.rrset.from_text('dnspython.org.', 3600, 'IN', 'DNSKEY', - '257 3 5 AwEAAenVTr9L1OMlL1/N2ta0Qj9LLLnnmFWIr1dJoAsWM9BQfsbV7kFZ XbAkER/FY9Ji2o7cELxBwAsVBuWn6IUUAJXLH74YbC1anY0lifjgt29z SwDzuB7zmC7yVYZzUunBulVW4zT0tg1aePbpVL2EtTL8VzREqbJbE25R KuQYHZtFwG8S4iBxJUmT2Bbd0921LLxSQgVoFXlQx/gFV2+UERXcJ5ce iX6A6wc02M/pdg/YbJd2rBa0MYL3/Fz/Xltre0tqsImZGxzi6YtYDs45 NC8gH+44egz82e2DATCVM1ICPmRDjXYTLldQiWA2ZXIWnK0iitl5ue24 7EsWJefrIhE=', - '256 3 5 AwEAAdSSg++++THIS/IS/NOT/THE/CORRECT/KEY++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AaOSydAF', - '256 3 5 AwEAAdSSghOGjU33IQZgwZM2Hh771VGXX05olJK49FxpSyuEAjDBXY58 LGU9R2Zgeecnk/b9EAhFu/vCV9oECtiTCvwuVAkt9YEweqYDluQInmgP NGMJCKdSLlnX93DkjDw8rMYv5dqXCuSGPlKChfTJOLQxIAxGloS7lL+c 0CTZydAF') - } - -rel_keys = { dns.name.empty : - dns.rrset.from_text('@', 3600, 'IN', 'DNSKEY', - '257 3 5 AwEAAenVTr9L1OMlL1/N2ta0Qj9LLLnnmFWIr1dJoAsWM9BQfsbV7kFZ XbAkER/FY9Ji2o7cELxBwAsVBuWn6IUUAJXLH74YbC1anY0lifjgt29z SwDzuB7zmC7yVYZzUunBulVW4zT0tg1aePbpVL2EtTL8VzREqbJbE25R KuQYHZtFwG8S4iBxJUmT2Bbd0921LLxSQgVoFXlQx/gFV2+UERXcJ5ce iX6A6wc02M/pdg/YbJd2rBa0MYL3/Fz/Xltre0tqsImZGxzi6YtYDs45 NC8gH+44egz82e2DATCVM1ICPmRDjXYTLldQiWA2ZXIWnK0iitl5ue24 7EsWJefrIhE=', - '256 3 5 AwEAAdSSghOGjU33IQZgwZM2Hh771VGXX05olJK49FxpSyuEAjDBXY58 LGU9R2Zgeecnk/b9EAhFu/vCV9oECtiTCvwuVAkt9YEweqYDluQInmgP NGMJCKdSLlnX93DkjDw8rMYv5dqXCuSGPlKChfTJOLQxIAxGloS7lL+c 0CTZydAF') - } - -when = 1290250287 - -abs_soa = dns.rrset.from_text('dnspython.org.', 3600, 'IN', 'SOA', - 'howl.dnspython.org. hostmaster.dnspython.org. 2010020047 3600 1800 604800 3600') - -abs_other_soa = dns.rrset.from_text('dnspython.org.', 3600, 'IN', 'SOA', - 'foo.dnspython.org. hostmaster.dnspython.org. 2010020047 3600 1800 604800 3600') - -abs_soa_rrsig = dns.rrset.from_text('dnspython.org.', 3600, 'IN', 'RRSIG', - 'SOA 5 2 3600 20101127004331 20101119213831 61695 dnspython.org. sDUlltRlFTQw5ITFxOXW3TgmrHeMeNpdqcZ4EXxM9FHhIlte6V9YCnDw t6dvM9jAXdIEi03l9H/RAd9xNNW6gvGMHsBGzpvvqFQxIBR2PoiZA1mX /SWHZFdbt4xjYTtXqpyYvrMK0Dt7bUYPadyhPFCJ1B+I8Zi7B5WJEOd0 8vs=') - -rel_soa = dns.rrset.from_text('@', 3600, 'IN', 'SOA', - 'howl hostmaster 2010020047 3600 1800 604800 3600') - -rel_other_soa = dns.rrset.from_text('@', 3600, 'IN', 'SOA', - 'foo hostmaster 2010020047 3600 1800 604800 3600') - -rel_soa_rrsig = dns.rrset.from_text('@', 3600, 'IN', 'RRSIG', - 'SOA 5 2 3600 20101127004331 20101119213831 61695 @ sDUlltRlFTQw5ITFxOXW3TgmrHeMeNpdqcZ4EXxM9FHhIlte6V9YCnDw t6dvM9jAXdIEi03l9H/RAd9xNNW6gvGMHsBGzpvvqFQxIBR2PoiZA1mX /SWHZFdbt4xjYTtXqpyYvrMK0Dt7bUYPadyhPFCJ1B+I8Zi7B5WJEOd0 8vs=') - -sep_key = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DNSKEY, - '257 3 5 AwEAAenVTr9L1OMlL1/N2ta0Qj9LLLnnmFWIr1dJoAsWM9BQfsbV7kFZ XbAkER/FY9Ji2o7cELxBwAsVBuWn6IUUAJXLH74YbC1anY0lifjgt29z SwDzuB7zmC7yVYZzUunBulVW4zT0tg1aePbpVL2EtTL8VzREqbJbE25R KuQYHZtFwG8S4iBxJUmT2Bbd0921LLxSQgVoFXlQx/gFV2+UERXcJ5ce iX6A6wc02M/pdg/YbJd2rBa0MYL3/Fz/Xltre0tqsImZGxzi6YtYDs45 NC8gH+44egz82e2DATCVM1ICPmRDjXYTLldQiWA2ZXIWnK0iitl5ue24 7EsWJefrIhE=') - -good_ds = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DS, - '57349 5 2 53A79A3E7488AB44FFC56B2D1109F0699D1796DD977E72108B841F96 E47D7013') - -when2 = 1290425644 - -abs_example = dns.name.from_text('example') - -abs_dsa_keys = { abs_example : - dns.rrset.from_text('example.', 86400, 'IN', 'DNSKEY', - '257 3 3 CI3nCqyJsiCJHTjrNsJOT4RaszetzcJPYuoH3F9ZTVt3KJXncCVR3bwn 1w0iavKljb9hDlAYSfHbFCp4ic/rvg4p1L8vh5s8ToMjqDNl40A0hUGQ Ybx5hsECyK+qHoajilUX1phYSAD8d9WAGO3fDWzUPBuzR7o85NiZCDxz yXuNVfni0uhj9n1KYhEO5yAbbruDGN89wIZcxMKuQsdUY2GYD93ssnBv a55W6XRABYWayKZ90WkRVODLVYLSn53Pj/wwxGH+XdhIAZJXimrZL4yl My7rtBsLMqq8Ihs4Tows7LqYwY7cp6y/50tw6pj8tFqMYcPUjKZV36l1 M/2t5BVg3i7IK61Aidt6aoC3TDJtzAxg3ZxfjZWJfhHjMJqzQIfbW5b9 q1mjFsW5EUv39RaNnX+3JWPRLyDqD4pIwDyqfutMsdk/Py3paHn82FGp CaOg+nicqZ9TiMZURN/XXy5JoXUNQ3RNvbHCUiPUe18KUkY6mTfnyHld 1l9YCWmzXQVClkx/hOYxjJ4j8Ife58+Obu5X', - '256 3 3 CJE1yb9YRQiw5d2xZrMUMR+cGCTt1bp1KDCefmYKmS+Z1+q9f42ETVhx JRiQwXclYwmxborzIkSZegTNYIV6mrYwbNB27Q44c3UGcspb3PiOw5TC jNPRYEcdwGvDZ2wWy+vkSV/S9tHXY8O6ODiE6abZJDDg/RnITyi+eoDL R3KZ5n/V1f1T1b90rrV6EewhBGQJpQGDogaXb2oHww9Tm6NfXyo7SoMM pbwbzOckXv+GxRPJIQNSF4D4A9E8XCksuzVVdE/0lr37+uoiAiPia38U 5W2QWe/FJAEPLjIp2eTzf0TrADc1pKP1wrA2ASpdzpm/aX3IB5RPp8Ew S9U72eBFZJAUwg635HxJVxH1maG6atzorR566E+e0OZSaxXS9o1o6QqN 3oPlYLGPORDiExilKfez3C/x/yioOupW9K5eKF0gmtaqrHX0oq9s67f/ RIM2xVaKHgG9Vf2cgJIZkhv7sntujr+E4htnRmy9P9BxyFxsItYxPI6Z bzygHAZpGhlI/7ltEGlIwKxyTK3ZKBm67q7B') - } - -abs_dsa_soa = dns.rrset.from_text('example.', 86400, 'IN', 'SOA', - 'ns1.example. hostmaster.example. 2 10800 3600 604800 86400') - -abs_other_dsa_soa = dns.rrset.from_text('example.', 86400, 'IN', 'SOA', - 'ns1.example. hostmaster.example. 2 10800 3600 604800 86401') - -abs_dsa_soa_rrsig = dns.rrset.from_text('example.', 86400, 'IN', 'RRSIG', - 'SOA 3 1 86400 20101129143231 20101122112731 42088 example. CGul9SuBofsktunV8cJs4eRs6u+3NCS3yaPKvBbD+pB2C76OUXDZq9U=') - -example_sep_key = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DNSKEY, - '257 3 3 CI3nCqyJsiCJHTjrNsJOT4RaszetzcJPYuoH3F9ZTVt3KJXncCVR3bwn 1w0iavKljb9hDlAYSfHbFCp4ic/rvg4p1L8vh5s8ToMjqDNl40A0hUGQ Ybx5hsECyK+qHoajilUX1phYSAD8d9WAGO3fDWzUPBuzR7o85NiZCDxz yXuNVfni0uhj9n1KYhEO5yAbbruDGN89wIZcxMKuQsdUY2GYD93ssnBv a55W6XRABYWayKZ90WkRVODLVYLSn53Pj/wwxGH+XdhIAZJXimrZL4yl My7rtBsLMqq8Ihs4Tows7LqYwY7cp6y/50tw6pj8tFqMYcPUjKZV36l1 M/2t5BVg3i7IK61Aidt6aoC3TDJtzAxg3ZxfjZWJfhHjMJqzQIfbW5b9 q1mjFsW5EUv39RaNnX+3JWPRLyDqD4pIwDyqfutMsdk/Py3paHn82FGp CaOg+nicqZ9TiMZURN/XXy5JoXUNQ3RNvbHCUiPUe18KUkY6mTfnyHld 1l9YCWmzXQVClkx/hOYxjJ4j8Ife58+Obu5X') - -example_ds_sha1 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DS, - '18673 3 1 71b71d4f3e11bbd71b4eff12cde69f7f9215bbe7') - -example_ds_sha256 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DS, - '18673 3 2 eb8344cbbf07c9d3d3d6c81d10c76653e28d8611a65e639ef8f716e4e4e5d913') - -when3 = 1379801800 - -abs_ecdsa256_keys = { abs_example : - dns.rrset.from_text('example.', 86400, 'IN', 'DNSKEY', - "256 3 13 +3ss1sCpdARVA61DJigEsL/8quo2a8MszKtn2gkkfxgzFs8S2UHtpb4N fY+XFmNW+JK6MsCkI3jHYN8eEQUgMw==", - "257 3 13 eJCEVH7AS3wnoaQpaNlAXH0W8wxymtT9P6P3qjN2ZCV641ED8pF7wZ5V yWfOpgTs6oaZevbJgehl/GaRPUgVyQ==") - } - -abs_ecdsa256_soa = dns.rrset.from_text('example.', 86400, 'IN', 'SOA', - 'ns1.example. hostmaster.example. 4 10800 3600 604800 86400') - -abs_other_ecdsa256_soa = dns.rrset.from_text('example.', 86400, 'IN', 'SOA', - 'ns1.example. hostmaster.example. 2 10800 3600 604800 86401') - -abs_ecdsa256_soa_rrsig = dns.rrset.from_text('example.', 86400, 'IN', 'RRSIG', - "SOA 13 1 86400 20130921221753 20130921221638 7460 example. Sm09SOGz1ULB5D/duwdE2Zpn8bWbVBM77H6N1wPkc42LevvVO+kZEjpq 2nq4GOMJcih52667GIAbMrwmU5P2MQ==") - -when4 = 1379804850 - -abs_ecdsa384_keys = { abs_example : - dns.rrset.from_text('example.', 86400, 'IN', 'DNSKEY', - "256 3 14 1bG8qWviKNXQX3BIuG6/T5jrP1FISiLW/8qGF6BsM9DQtWYhhZUA3Owr OAEiyHAhQwjkN2kTvWiAYoPN80Ii+5ff9/atzY4F9W50P4l75Dj9PYrL HN/hLUgWMNVc9pvA", - "257 3 14 mSub2n0KRt6u2FaD5XJ3oQu0R4XvB/9vUJcyW6+oo0y+KzfQeTdkf1ro ZMVKoyWXW9zUKBYGJpMUIdbAxzrYi7f5HyZ3yDpBFz1hw9+o3CX+gtgb +RyhHfJDwwFXBid9") - } - -abs_ecdsa384_soa = dns.rrset.from_text('example.', 86400, 'IN', 'SOA', - 'ns1.example. hostmaster.example. 2 10800 3600 604800 86400') - -abs_other_ecdsa384_soa = dns.rrset.from_text('example.', 86400, 'IN', 'SOA', - 'ns1.example. hostmaster.example. 2 10800 3600 604800 86401') - -abs_ecdsa384_soa_rrsig = dns.rrset.from_text('example.', 86400, 'IN', 'RRSIG', - "SOA 14 1 86400 20130929021229 20130921230729 63571 example. CrnCu34EeeRz0fEhL9PLlwjpBKGYW8QjBjFQTwd+ViVLRAS8tNkcDwQE NhSV89NEjj7ze1a/JcCfcJ+/mZgnvH4NHLNg3Tf6KuLZsgs2I4kKQXEk 37oIHravPEOlGYNI") - -class DNSSECValidatorTestCase(unittest.TestCase): - - @unittest.skipIf(not dns.dnssec._have_pycrypto, - "PyCrypto cannot be imported") - def testAbsoluteRSAGood(self): - dns.dnssec.validate(abs_soa, abs_soa_rrsig, abs_keys, None, when) - - @unittest.skipIf(not dns.dnssec._have_pycrypto, - "PyCrypto cannot be imported") - def testDuplicateKeytag(self): - dns.dnssec.validate(abs_soa, abs_soa_rrsig, abs_keys_duplicate_keytag, None, when) - - @unittest.skipIf(not dns.dnssec._have_pycrypto, - "PyCrypto cannot be imported") - def testAbsoluteRSABad(self): - def bad(): - dns.dnssec.validate(abs_other_soa, abs_soa_rrsig, abs_keys, None, - when) - self.assertRaises(dns.dnssec.ValidationFailure, bad) - - @unittest.skipIf(not dns.dnssec._have_pycrypto, - "PyCrypto cannot be imported") - def testRelativeRSAGood(self): - dns.dnssec.validate(rel_soa, rel_soa_rrsig, rel_keys, - abs_dnspython_org, when) - - @unittest.skipIf(not dns.dnssec._have_pycrypto, - "PyCrypto cannot be imported") - def testRelativeRSABad(self): - def bad(): - dns.dnssec.validate(rel_other_soa, rel_soa_rrsig, rel_keys, - abs_dnspython_org, when) - self.assertRaises(dns.dnssec.ValidationFailure, bad) - - def testMakeSHA256DS(self): - ds = dns.dnssec.make_ds(abs_dnspython_org, sep_key, 'SHA256') - self.assertTrue(ds == good_ds) - - @unittest.skipIf(not dns.dnssec._have_pycrypto, - "PyCrypto cannot be imported") - def testAbsoluteDSAGood(self): - dns.dnssec.validate(abs_dsa_soa, abs_dsa_soa_rrsig, abs_dsa_keys, None, - when2) - - @unittest.skipIf(not dns.dnssec._have_pycrypto, - "PyCrypto cannot be imported") - def testAbsoluteDSABad(self): - def bad(): - dns.dnssec.validate(abs_other_dsa_soa, abs_dsa_soa_rrsig, - abs_dsa_keys, None, when2) - self.assertRaises(dns.dnssec.ValidationFailure, bad) - - def testMakeExampleSHA1DS(self): - ds = dns.dnssec.make_ds(abs_example, example_sep_key, 'SHA1') - self.assertTrue(ds == example_ds_sha1) - - def testMakeExampleSHA256DS(self): - ds = dns.dnssec.make_ds(abs_example, example_sep_key, 'SHA256') - self.assertTrue(ds == example_ds_sha256) - - @unittest.skipIf(not dns.dnssec._have_ecdsa, - "python ECDSA can not be imported") - def testAbsoluteECDSA256Good(self): - dns.dnssec.validate(abs_ecdsa256_soa, abs_ecdsa256_soa_rrsig, - abs_ecdsa256_keys, None, when3) - - @unittest.skipIf(not dns.dnssec._have_ecdsa, - "python ECDSA can not be imported") - def testAbsoluteECDSA256Bad(self): - def bad(): - dns.dnssec.validate(abs_other_ecdsa256_soa, abs_ecdsa256_soa_rrsig, - abs_ecdsa256_keys, None, when3) - self.failUnlessRaises(dns.dnssec.ValidationFailure, bad) - - @unittest.skipIf(not dns.dnssec._have_ecdsa, - "python ECDSA can not be imported") - def testAbsoluteECDSA384Good(self): - dns.dnssec.validate(abs_ecdsa384_soa, abs_ecdsa384_soa_rrsig, - abs_ecdsa384_keys, None, when4) - - @unittest.skipIf(not dns.dnssec._have_ecdsa, - "python ECDSA can not be imported") - def testAbsoluteECDSA384Bad(self): - def bad(): - dns.dnssec.validate(abs_other_ecdsa384_soa, abs_ecdsa384_soa_rrsig, - abs_ecdsa384_keys, None, when4) - self.failUnlessRaises(dns.dnssec.ValidationFailure, bad) - - -if __name__ == '__main__': - import_ok = False - try: - import Crypto.Util.number - import_ok = True - except: - pass - if import_ok: - unittest.main() - else: - print('skipping DNSSEC tests because pycrypto is not installed') diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py deleted file mode 100644 index 90a6af4..0000000 --- a/tests/test_exceptions.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import binascii -import unittest - -from dns.exception import DNSException - - -class FormatedError(DNSException): - fmt = "Custom format: {parameter}" - supp_kwargs = set(['parameter']) - - -class ExceptionTestCase(unittest.TestCase): - - def test_custom_message(self): - msg = "this is a custom message" - try: - raise DNSException(msg) - except DNSException as ex: - self.assertEqual(str(ex), msg) - - def test_implicit_message(self): - try: - raise DNSException() - except DNSException as ex: - self.assertEqual(ex.__class__.__doc__, str(ex)) - - def test_formatted_error(self): - """Exceptions with explicit format has to respect it.""" - params = {'parameter': 'value'} - try: - raise FormatedError(**params) - except FormatedError as ex: - msg = FormatedError.fmt.format(**params) - self.assertEqual(msg, str(ex)) - - def test_kwargs_only(self): - """Kwargs cannot be combined with args.""" - with self.assertRaises(AssertionError): - raise FormatedError(1, a=2) - - def test_kwargs_unsupported(self): - """Only supported kwargs are accepted.""" - with self.assertRaises(AssertionError): - raise FormatedError(unsupported=2) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_flags.py b/tests/test_flags.py deleted file mode 100644 index 95fd455..0000000 --- a/tests/test_flags.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.flags -import dns.rcode -import dns.opcode - -class FlagsTestCase(unittest.TestCase): - - def test_rcode1(self): - self.assertTrue(dns.rcode.from_text('FORMERR') == dns.rcode.FORMERR) - - def test_rcode2(self): - self.assertTrue(dns.rcode.to_text(dns.rcode.FORMERR) == "FORMERR") - - def test_rcode3(self): - self.assertTrue(dns.rcode.to_flags(dns.rcode.FORMERR) == (1, 0)) - - def test_rcode4(self): - self.assertTrue(dns.rcode.to_flags(dns.rcode.BADVERS) == \ - (0, 0x01000000)) - - def test_rcode6(self): - self.assertTrue(dns.rcode.from_flags(0, 0x01000000) == \ - dns.rcode.BADVERS) - - def test_rcode6a(self): - self.assertTrue(dns.rcode.from_flags(5, 0) == dns.rcode.REFUSED) - - def test_rcode7(self): - def bad(): - dns.rcode.to_flags(4096) - self.assertRaises(ValueError, bad) - - def test_flags1(self): - self.assertTrue(dns.flags.from_text("RA RD AA QR") == \ - dns.flags.QR|dns.flags.AA|dns.flags.RD|dns.flags.RA) - - def test_flags2(self): - flags = dns.flags.QR|dns.flags.AA|dns.flags.RD|dns.flags.RA - self.assertTrue(dns.flags.to_text(flags) == "QR AA RD RA") - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_generate.py b/tests/test_generate.py deleted file mode 100644 index fd78925..0000000 --- a/tests/test_generate.py +++ /dev/null @@ -1,498 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2013 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import sys -sys.path.insert(0, '../') # Force the local project to be *the* dns - -import filecmp -import os -import unittest - -import dns.exception -import dns.rdata -import dns.rdataclass -import dns.rdatatype -import dns.rrset -import dns.zone - -import pprint - -pp = pprint.PrettyPrinter(indent=2) - -import pdb -example_text = """$TTL 1h -$ORIGIN 0.0.192.IN-ADDR.ARPA. -$GENERATE 1-2 0 CNAME SERVER$.EXAMPLE. -""" - -example_text1 = """$TTL 1h -$ORIGIN 0.0.192.IN-ADDR.ARPA. -$GENERATE 1-10 fooo$ CNAME $.0 -""" - -example_text2 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 3-5 foo$ A 10.0.0.$ -""" - -example_text3 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 4-8/2 foo$ A 10.0.0.$ -""" - -example_text4 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 11-13 wp-db${-10,2,d}.services.mozilla.com 0 CNAME SERVER.FOOBAR. -""" - -example_text5 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 11-13 wp-db${10,2,d}.services.mozilla.com 0 CNAME SERVER.FOOBAR. -""" - -example_text6 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 11-13 wp-db${+10,2,d}.services.mozilla.com 0 CNAME SERVER.FOOBAR. -""" - -example_text7 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 11-13 sync${-10}.db IN A 10.10.16.0 -""" - -example_text8 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 11-12 wp-db${-10,2,d} IN A 10.10.16.0 -""" - -example_text9 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 11-12 wp-db${-10,2,d} IN A 10.10.16.0 -$GENERATE 11-13 sync${-10}.db IN A 10.10.16.0 -""" -example_text10 = """$TTL 1h -@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -$GENERATE 27-28 $.2 PTR zlb${-26}.oob -""" - - -class GenerateTestCase(unittest.TestCase): - - def testFromText(self): - def bad(): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - self.assertRaises(dns.zone.NoSOA, bad) - - def testFromText1(self): - def bad(): - z = dns.zone.from_text(example_text1, 'example.', relativize=True) - self.assertRaises(dns.zone.NoSOA, bad) - - def testIterateAllRdatas2(self): - z = dns.zone.from_text(example_text2, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - (dns.name.from_text('foo3', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.3')), - (dns.name.from_text('foo4', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.4')), - (dns.name.from_text('foo5', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.5'))] - - exl.sort() - self.assertTrue(l == exl) - - def testIterateAllRdatas3(self): - z = dns.zone.from_text(example_text3, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - (dns.name.from_text('foo4', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.4')), - (dns.name.from_text('foo6', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.6')), - (dns.name.from_text('foo8', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.8'))] - exl.sort() - self.assertTrue(l == exl) - def testGenerate1(self): - z = dns.zone.from_text(example_text4, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - - (dns.name.from_text('wp-db01.services.mozilla.com', None), - 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.')), - - (dns.name.from_text('wp-db02.services.mozilla.com', None), - 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.')), - - (dns.name.from_text('wp-db03.services.mozilla.com', None), - 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.'))] - exl.sort() - self.assertTrue(l == exl) - - def testGenerate2(self): - z = dns.zone.from_text(example_text5, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - - (dns.name.from_text('wp-db21.services.mozilla.com', None), 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.')), - - (dns.name.from_text('wp-db22.services.mozilla.com', None), 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.')), - - (dns.name.from_text('wp-db23.services.mozilla.com', None), 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.'))] - exl.sort() - self.assertTrue(l == exl) - - def testGenerate3(self): - z = dns.zone.from_text(example_text6, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - (dns.name.from_text('wp-db21.services.mozilla.com', None), 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.')), - - (dns.name.from_text('wp-db22.services.mozilla.com', None), 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.')), - - (dns.name.from_text('wp-db23.services.mozilla.com', None), 0, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CNAME, - 'SERVER.FOOBAR.'))] - exl.sort() - self.assertTrue(l == exl) - - def testGenerate4(self): - z = dns.zone.from_text(example_text7, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - - (dns.name.from_text('sync1.db', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0')), - - (dns.name.from_text('sync2.db', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0')), - - (dns.name.from_text('sync3.db', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0'))] - exl.sort() - self.assertTrue(l == exl) - - def testGenerate6(self): - z = dns.zone.from_text(example_text9, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - - (dns.name.from_text('wp-db01', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0')), - (dns.name.from_text('wp-db02', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0')), - - (dns.name.from_text('sync1.db', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0')), - - (dns.name.from_text('sync2.db', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0')), - - (dns.name.from_text('sync3.db', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.10.16.0'))] - exl.sort() - self.assertTrue(l == exl) - - def testGenerate7(self): - z = dns.zone.from_text(example_text10, 'example.', relativize=True) - l = list(z.iterate_rdatas()) - l.sort() - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2')), - - (dns.name.from_text('27.2', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.PTR, - 'zlb1.oob')), - - (dns.name.from_text('28.2', None), 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.PTR, - 'zlb2.oob'))] - - exl.sort() - self.assertTrue(l == exl) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_grange.py b/tests/test_grange.py deleted file mode 100644 index aee9653..0000000 --- a/tests/test_grange.py +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns -import dns.exception -import dns.grange - - -class GRangeTestCase(unittest.TestCase): - - def testFromText1(self): - start, stop, step = dns.grange.from_text('1-1') - self.assertEqual(start, 1) - self.assertEqual(stop, 1) - self.assertEqual(step, 1) - - def testFromText2(self): - start, stop, step = dns.grange.from_text('1-4') - self.assertEqual(start, 1) - self.assertEqual(stop, 4) - self.assertEqual(step, 1) - - def testFromText3(self): - start, stop, step = dns.grange.from_text('4-255') - self.assertEqual(start, 4) - self.assertEqual(stop, 255) - self.assertEqual(step, 1) - - def testFromText4(self): - start, stop, step = dns.grange.from_text('1-1/1') - self.assertEqual(start, 1) - self.assertEqual(stop, 1) - self.assertEqual(step, 1) - - def testFromText5(self): - start, stop, step = dns.grange.from_text('1-4/2') - self.assertEqual(start, 1) - self.assertEqual(stop, 4) - self.assertEqual(step, 2) - - def testFromText6(self): - start, stop, step = dns.grange.from_text('4-255/77') - self.assertEqual(start, 4) - self.assertEqual(stop, 255) - self.assertEqual(step, 77) - - def testFailFromText1(self): - def bad(): - start = 2 - stop = 1 - step = 1 - dns.grange.from_text('%d-%d/%d' % (start, stop, step)) - self.assertRaises(AssertionError, bad) - - def testFailFromText2(self): - def bad(): - start = '-1' - stop = 3 - step = 1 - dns.grange.from_text('%s-%d/%d' % (start, stop, step)) - self.assertRaises(dns.exception.SyntaxError, bad) - - def testFailFromText2(self): - def bad(): - start = 1 - stop = 4 - step = '-2' - dns.grange.from_text('%d-%d/%s' % (start, stop, step)) - self.assertRaises(dns.exception.SyntaxError, bad) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_message.py b/tests/test_message.py deleted file mode 100644 index 603b4ac..0000000 --- a/tests/test_message.py +++ /dev/null @@ -1,178 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import os -import unittest - -import dns.exception -import dns.message - -query_text = """id 1234 -opcode QUERY -rcode NOERROR -flags RD -edns 0 -eflags DO -payload 4096 -;QUESTION -wwww.dnspython.org. IN A -;ANSWER -;AUTHORITY -;ADDITIONAL""" - -goodhex = '04d201000001000000000001047777777709646e73707974686f6e' \ - '036f726700000100010000291000000080000000' - -goodwire = bytes.fromhex(goodhex) - -answer_text = """id 1234 -opcode QUERY -rcode NOERROR -flags QR AA RD -;QUESTION -dnspython.org. IN SOA -;ANSWER -dnspython.org. 3600 IN SOA woof.dnspython.org. hostmaster.dnspython.org. 2003052700 3600 1800 604800 3600 -;AUTHORITY -dnspython.org. 3600 IN NS ns1.staff.nominum.org. -dnspython.org. 3600 IN NS ns2.staff.nominum.org. -dnspython.org. 3600 IN NS woof.play-bow.org. -;ADDITIONAL -woof.play-bow.org. 3600 IN A 204.152.186.150 -""" - -goodhex2 = '04d2 8500 0001 0001 0003 0001' \ - '09646e73707974686f6e036f726700 0006 0001' \ - 'c00c 0006 0001 00000e10 0028 ' \ - '04776f6f66c00c 0a686f73746d6173746572c00c' \ - '7764289c 00000e10 00000708 00093a80 00000e10' \ - 'c00c 0002 0001 00000e10 0014' \ - '036e7331057374616666076e6f6d696e756dc016' \ - 'c00c 0002 0001 00000e10 0006 036e7332c063' \ - 'c00c 0002 0001 00000e10 0010 04776f6f6608706c61792d626f77c016' \ - 'c091 0001 0001 00000e10 0004 cc98ba96' - - -goodwire2 = bytes.fromhex(goodhex2.replace(' ', '')) - -query_text_2 = """id 1234 -opcode QUERY -rcode 4095 -flags RD -edns 0 -eflags DO -payload 4096 -;QUESTION -wwww.dnspython.org. IN A -;ANSWER -;AUTHORITY -;ADDITIONAL""" - -goodhex3 = '04d2010f0001000000000001047777777709646e73707974686f6e' \ - '036f726700000100010000291000ff0080000000' - -goodwire3 = bytes.fromhex(goodhex3) - -class MessageTestCase(unittest.TestCase): - - def test_comparison_eq1(self): - q1 = dns.message.from_text(query_text) - q2 = dns.message.from_text(query_text) - self.assertTrue(q1 == q2) - - def test_comparison_ne1(self): - q1 = dns.message.from_text(query_text) - q2 = dns.message.from_text(query_text) - q2.id = 10 - self.assertTrue(q1 != q2) - - def test_comparison_ne2(self): - q1 = dns.message.from_text(query_text) - q2 = dns.message.from_text(query_text) - q2.question = [] - self.assertTrue(q1 != q2) - - def test_comparison_ne3(self): - q1 = dns.message.from_text(query_text) - self.assertTrue(q1 != 1) - - def test_EDNS_to_wire1(self): - q = dns.message.from_text(query_text) - w = q.to_wire() - self.assertTrue(w == goodwire) - - def test_EDNS_from_wire1(self): - m = dns.message.from_wire(goodwire) - self.assertTrue(str(m) == query_text) - - def test_EDNS_to_wire2(self): - q = dns.message.from_text(query_text_2) - w = q.to_wire() - self.assertTrue(w == goodwire3) - - def test_EDNS_from_wire2(self): - m = dns.message.from_wire(goodwire3) - self.assertTrue(str(m) == query_text_2) - - def test_TooBig(self): - def bad(): - q = dns.message.from_text(query_text) - for i in range(0, 25): - rrset = dns.rrset.from_text('foo%d.' % i, 3600, - dns.rdataclass.IN, - dns.rdatatype.A, - '10.0.0.%d' % i) - q.additional.append(rrset) - w = q.to_wire(max_size=512) - self.assertRaises(dns.exception.TooBig, bad) - - def test_answer1(self): - a = dns.message.from_text(answer_text) - wire = a.to_wire(want_shuffle=False) - self.assertTrue(wire == goodwire2) - - def test_TrailingJunk(self): - def bad(): - badwire = goodwire + b'\x00' - m = dns.message.from_wire(badwire) - self.assertRaises(dns.message.TrailingJunk, bad) - - def test_ShortHeader(self): - def bad(): - badwire = b'\x00' * 11 - m = dns.message.from_wire(badwire) - self.assertRaises(dns.message.ShortHeader, bad) - - def test_RespondingToResponse(self): - def bad(): - q = dns.message.make_query('foo', 'A') - r1 = dns.message.make_response(q) - r2 = dns.message.make_response(r1) - self.assertRaises(dns.exception.FormError, bad) - - def test_ExtendedRcodeSetting(self): - m = dns.message.make_query('foo', 'A') - m.set_rcode(4095) - self.assertTrue(m.rcode() == 4095) - m.set_rcode(2) - self.assertTrue(m.rcode() == 2) - - def test_EDNSVersionCoherence(self): - m = dns.message.make_query('foo', 'A') - m.use_edns(1) - self.assertTrue((m.ednsflags >> 16) & 0xFF == 1) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_name.py b/tests/test_name.py deleted file mode 100644 index e62b558..0000000 --- a/tests/test_name.py +++ /dev/null @@ -1,710 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import io -import socket -import sys -import pickle - -import dns.name -import dns.reversename -import dns.e164 - -class NameTestCase(unittest.TestCase): - def setUp(self): - self.origin = dns.name.from_text('example.') - - def testFromTextRel1(self): - n = dns.name.from_text('foo.bar') - self.assertTrue(n.labels == (b'foo', b'bar', b'')) - - def testFromTextRel2(self): - n = dns.name.from_text('foo.bar', origin=self.origin) - self.assertTrue(n.labels == (b'foo', b'bar', b'example', b'')) - - def testFromTextRel3(self): - n = dns.name.from_text('foo.bar', origin=None) - self.assertTrue(n.labels == (b'foo', b'bar')) - - def testFromTextRel4(self): - n = dns.name.from_text('@', origin=None) - self.assertTrue(n == dns.name.empty) - - def testFromTextRel5(self): - n = dns.name.from_text('@', origin=self.origin) - self.assertTrue(n == self.origin) - - def testFromTextAbs1(self): - n = dns.name.from_text('foo.bar.') - self.assertTrue(n.labels == (b'foo', b'bar', b'')) - - def testTortureFromText(self): - good = [ - r'.', - r'a', - r'a.', - r'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - r'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - r'\000.\008.\010.\032.\046.\092.\099.\255', - r'\\', - r'\..\.', - r'\\.\\', - r'!"#%&/()=+-', - r'\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255.\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255.\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255.\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255', - ] - bad = [ - r'..', - r'.a', - r'\\..', - '\\', # yes, we don't want the 'r' prefix! - r'\0', - r'\00', - r'\00Z', - r'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - r'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - r'\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255.\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255.\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255.\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255', - ] - for t in good: - try: - n = dns.name.from_text(t) - except: - info = sys.exc_info() - print(info[0]) - print(info[2]) - self.fail("good test '%s' raised an exception" % t) - for t in bad: - caught = False - try: - n = dns.name.from_text(t) - except: - caught = True - if not caught: - self.fail("bad test '%s' did not raise an exception" % t) - - def testImmutable1(self): - def bad(): - self.origin.labels = () - self.assertRaises(TypeError, bad) - - def testImmutable2(self): - def bad(): - self.origin.labels[0] = b'foo' - self.assertRaises(TypeError, bad) - - def testAbs1(self): - self.assertTrue(dns.name.root.is_absolute()) - - def testAbs2(self): - self.assertTrue(not dns.name.empty.is_absolute()) - - def testAbs3(self): - self.assertTrue(self.origin.is_absolute()) - - def testAbs4(self): - n = dns.name.from_text('foo', origin=None) - self.assertTrue(not n.is_absolute()) - - def testWild1(self): - n = dns.name.from_text('*.foo', origin=None) - self.assertTrue(n.is_wild()) - - def testWild2(self): - n = dns.name.from_text('*a.foo', origin=None) - self.assertTrue(not n.is_wild()) - - def testWild3(self): - n = dns.name.from_text('a.*.foo', origin=None) - self.assertTrue(not n.is_wild()) - - def testWild4(self): - self.assertTrue(not dns.name.root.is_wild()) - - def testWild5(self): - self.assertTrue(not dns.name.empty.is_wild()) - - def testHash1(self): - n1 = dns.name.from_text('fOo.COM') - n2 = dns.name.from_text('foo.com') - self.assertTrue(hash(n1) == hash(n2)) - - def testCompare1(self): - n1 = dns.name.from_text('a') - n2 = dns.name.from_text('b') - self.assertTrue(n1 < n2) - self.assertTrue(n2 > n1) - - def testCompare2(self): - n1 = dns.name.from_text('') - n2 = dns.name.from_text('b') - self.assertTrue(n1 < n2) - self.assertTrue(n2 > n1) - - def testCompare3(self): - self.assertTrue(dns.name.empty < dns.name.root) - self.assertTrue(dns.name.root > dns.name.empty) - - def testCompare4(self): - self.assertTrue(dns.name.root != 1) - - def testSubdomain1(self): - self.assertTrue(not dns.name.empty.is_subdomain(dns.name.root)) - - def testSubdomain2(self): - self.assertTrue(not dns.name.root.is_subdomain(dns.name.empty)) - - def testSubdomain3(self): - n = dns.name.from_text('foo', origin=self.origin) - self.assertTrue(n.is_subdomain(self.origin)) - - def testSubdomain4(self): - n = dns.name.from_text('foo', origin=self.origin) - self.assertTrue(n.is_subdomain(dns.name.root)) - - def testSubdomain5(self): - n = dns.name.from_text('foo', origin=self.origin) - self.assertTrue(n.is_subdomain(n)) - - def testSuperdomain1(self): - self.assertTrue(not dns.name.empty.is_superdomain(dns.name.root)) - - def testSuperdomain2(self): - self.assertTrue(not dns.name.root.is_superdomain(dns.name.empty)) - - def testSuperdomain3(self): - n = dns.name.from_text('foo', origin=self.origin) - self.assertTrue(self.origin.is_superdomain(n)) - - def testSuperdomain4(self): - n = dns.name.from_text('foo', origin=self.origin) - self.assertTrue(dns.name.root.is_superdomain(n)) - - def testSuperdomain5(self): - n = dns.name.from_text('foo', origin=self.origin) - self.assertTrue(n.is_superdomain(n)) - - def testCanonicalize1(self): - n = dns.name.from_text('FOO.bar', origin=self.origin) - c = n.canonicalize() - self.assertTrue(c.labels == (b'foo', b'bar', b'example', b'')) - - def testToText1(self): - n = dns.name.from_text('FOO.bar', origin=self.origin) - t = n.to_text() - self.assertTrue(t == 'FOO.bar.example.') - - def testToText2(self): - n = dns.name.from_text('FOO.bar', origin=self.origin) - t = n.to_text(True) - self.assertTrue(t == 'FOO.bar.example') - - def testToText3(self): - n = dns.name.from_text('FOO.bar', origin=None) - t = n.to_text() - self.assertTrue(t == 'FOO.bar') - - def testToText4(self): - t = dns.name.empty.to_text() - self.assertTrue(t == '@') - - def testToText5(self): - t = dns.name.root.to_text() - self.assertTrue(t == '.') - - def testToText6(self): - n = dns.name.from_text('FOO bar', origin=None) - t = n.to_text() - self.assertTrue(t == r'FOO\032bar') - - def testToText7(self): - n = dns.name.from_text(r'FOO\.bar', origin=None) - t = n.to_text() - self.assertTrue(t == r'FOO\.bar') - - def testToText8(self): - n = dns.name.from_text(r'\070OO\.bar', origin=None) - t = n.to_text() - self.assertTrue(t == r'FOO\.bar') - - def testSlice1(self): - n = dns.name.from_text(r'a.b.c.', origin=None) - s = n[:] - self.assertTrue(s == (b'a', b'b', b'c', b'')) - - def testSlice2(self): - n = dns.name.from_text(r'a.b.c.', origin=None) - s = n[:2] - self.assertTrue(s == (b'a', b'b')) - - def testSlice3(self): - n = dns.name.from_text(r'a.b.c.', origin=None) - s = n[2:] - self.assertTrue(s == (b'c', b'')) - - def testEmptyLabel1(self): - def bad(): - n = dns.name.Name(['a', '', 'b']) - self.assertRaises(dns.name.EmptyLabel, bad) - - def testEmptyLabel2(self): - def bad(): - n = dns.name.Name(['', 'b']) - self.assertRaises(dns.name.EmptyLabel, bad) - - def testEmptyLabel3(self): - n = dns.name.Name(['b', '']) - self.assertTrue(n) - - def testLongLabel(self): - n = dns.name.Name(['a' * 63]) - self.assertTrue(n) - - def testLabelTooLong(self): - def bad(): - n = dns.name.Name(['a' * 64, 'b']) - self.assertRaises(dns.name.LabelTooLong, bad) - - def testLongName(self): - n = dns.name.Name(['a' * 63, 'a' * 63, 'a' * 63, 'a' * 62]) - self.assertTrue(n) - - def testNameTooLong(self): - def bad(): - n = dns.name.Name(['a' * 63, 'a' * 63, 'a' * 63, 'a' * 63]) - self.assertRaises(dns.name.NameTooLong, bad) - - def testConcat1(self): - n1 = dns.name.Name(['a', 'b']) - n2 = dns.name.Name(['c', 'd']) - e = dns.name.Name(['a', 'b', 'c', 'd']) - r = n1 + n2 - self.assertTrue(r == e) - - def testConcat2(self): - n1 = dns.name.Name(['a', 'b']) - n2 = dns.name.Name([]) - e = dns.name.Name(['a', 'b']) - r = n1 + n2 - self.assertTrue(r == e) - - def testConcat2a(self): - n1 = dns.name.Name([]) - n2 = dns.name.Name(['a', 'b']) - e = dns.name.Name(['a', 'b']) - r = n1 + n2 - self.assertTrue(r == e) - - def testConcat3(self): - n1 = dns.name.Name(['a', 'b', '']) - n2 = dns.name.Name([]) - e = dns.name.Name(['a', 'b', '']) - r = n1 + n2 - self.assertTrue(r == e) - - def testConcat4(self): - n1 = dns.name.Name(['a', 'b']) - n2 = dns.name.Name(['c', '']) - e = dns.name.Name(['a', 'b', 'c', '']) - r = n1 + n2 - self.assertTrue(r == e) - - def testConcat5(self): - def bad(): - n1 = dns.name.Name(['a', 'b', '']) - n2 = dns.name.Name(['c']) - r = n1 + n2 - self.assertRaises(dns.name.AbsoluteConcatenation, bad) - - def testBadEscape(self): - def bad(): - n = dns.name.from_text(r'a.b\0q1.c.') - print(n) - self.assertRaises(dns.name.BadEscape, bad) - - def testDigestable1(self): - n = dns.name.from_text('FOO.bar') - d = n.to_digestable() - self.assertTrue(d == b'\x03foo\x03bar\x00') - - def testDigestable2(self): - n1 = dns.name.from_text('FOO.bar') - n2 = dns.name.from_text('foo.BAR.') - d1 = n1.to_digestable() - d2 = n2.to_digestable() - self.assertTrue(d1 == d2) - - def testDigestable3(self): - d = dns.name.root.to_digestable() - self.assertTrue(d == b'\x00') - - def testDigestable4(self): - n = dns.name.from_text('FOO.bar', None) - d = n.to_digestable(dns.name.root) - self.assertTrue(d == b'\x03foo\x03bar\x00') - - def testBadDigestable(self): - def bad(): - n = dns.name.from_text('FOO.bar', None) - d = n.to_digestable() - self.assertRaises(dns.name.NeedAbsoluteNameOrOrigin, bad) - - def testToWire1(self): - n = dns.name.from_text('FOO.bar') - f = io.BytesIO() - compress = {} - n.to_wire(f, compress) - self.assertTrue(f.getvalue() == b'\x03FOO\x03bar\x00') - - def testToWire2(self): - n = dns.name.from_text('FOO.bar') - f = io.BytesIO() - compress = {} - n.to_wire(f, compress) - n.to_wire(f, compress) - self.assertTrue(f.getvalue() == b'\x03FOO\x03bar\x00\xc0\x00') - - def testToWire3(self): - n1 = dns.name.from_text('FOO.bar') - n2 = dns.name.from_text('foo.bar') - f = io.BytesIO() - compress = {} - n1.to_wire(f, compress) - n2.to_wire(f, compress) - self.assertTrue(f.getvalue() == b'\x03FOO\x03bar\x00\xc0\x00') - - def testToWire4(self): - n1 = dns.name.from_text('FOO.bar') - n2 = dns.name.from_text('a.foo.bar') - f = io.BytesIO() - compress = {} - n1.to_wire(f, compress) - n2.to_wire(f, compress) - self.assertTrue(f.getvalue() == b'\x03FOO\x03bar\x00\x01\x61\xc0\x00') - - def testToWire5(self): - n1 = dns.name.from_text('FOO.bar') - n2 = dns.name.from_text('a.foo.bar') - f = io.BytesIO() - compress = {} - n1.to_wire(f, compress) - n2.to_wire(f, None) - self.assertTrue(f.getvalue() == \ - b'\x03FOO\x03bar\x00\x01\x61\x03foo\x03bar\x00') - - def testToWire6(self): - n = dns.name.from_text('FOO.bar') - v = n.to_wire() - self.assertTrue(v == b'\x03FOO\x03bar\x00') - - def testBadToWire(self): - def bad(): - n = dns.name.from_text('FOO.bar', None) - f = io.BytesIO() - compress = {} - n.to_wire(f, compress) - self.assertRaises(dns.name.NeedAbsoluteNameOrOrigin, bad) - - def testSplit1(self): - n = dns.name.from_text('foo.bar.') - (prefix, suffix) = n.split(2) - ep = dns.name.from_text('foo', None) - es = dns.name.from_text('bar.', None) - self.assertTrue(prefix == ep and suffix == es) - - def testSplit2(self): - n = dns.name.from_text('foo.bar.') - (prefix, suffix) = n.split(1) - ep = dns.name.from_text('foo.bar', None) - es = dns.name.from_text('.', None) - self.assertTrue(prefix == ep and suffix == es) - - def testSplit3(self): - n = dns.name.from_text('foo.bar.') - (prefix, suffix) = n.split(0) - ep = dns.name.from_text('foo.bar.', None) - es = dns.name.from_text('', None) - self.assertTrue(prefix == ep and suffix == es) - - def testSplit4(self): - n = dns.name.from_text('foo.bar.') - (prefix, suffix) = n.split(3) - ep = dns.name.from_text('', None) - es = dns.name.from_text('foo.bar.', None) - self.assertTrue(prefix == ep and suffix == es) - - def testBadSplit1(self): - def bad(): - n = dns.name.from_text('foo.bar.') - (prefix, suffix) = n.split(-1) - self.assertRaises(ValueError, bad) - - def testBadSplit2(self): - def bad(): - n = dns.name.from_text('foo.bar.') - (prefix, suffix) = n.split(4) - self.assertRaises(ValueError, bad) - - def testRelativize1(self): - n = dns.name.from_text('a.foo.bar.', None) - o = dns.name.from_text('bar.', None) - e = dns.name.from_text('a.foo', None) - self.assertTrue(n.relativize(o) == e) - - def testRelativize2(self): - n = dns.name.from_text('a.foo.bar.', None) - o = n - e = dns.name.empty - self.assertTrue(n.relativize(o) == e) - - def testRelativize3(self): - n = dns.name.from_text('a.foo.bar.', None) - o = dns.name.from_text('blaz.', None) - e = n - self.assertTrue(n.relativize(o) == e) - - def testRelativize4(self): - n = dns.name.from_text('a.foo', None) - o = dns.name.root - e = n - self.assertTrue(n.relativize(o) == e) - - def testDerelativize1(self): - n = dns.name.from_text('a.foo', None) - o = dns.name.from_text('bar.', None) - e = dns.name.from_text('a.foo.bar.', None) - self.assertTrue(n.derelativize(o) == e) - - def testDerelativize2(self): - n = dns.name.empty - o = dns.name.from_text('a.foo.bar.', None) - e = o - self.assertTrue(n.derelativize(o) == e) - - def testDerelativize3(self): - n = dns.name.from_text('a.foo.bar.', None) - o = dns.name.from_text('blaz.', None) - e = n - self.assertTrue(n.derelativize(o) == e) - - def testChooseRelativity1(self): - n = dns.name.from_text('a.foo.bar.', None) - o = dns.name.from_text('bar.', None) - e = dns.name.from_text('a.foo', None) - self.assertTrue(n.choose_relativity(o, True) == e) - - def testChooseRelativity2(self): - n = dns.name.from_text('a.foo.bar.', None) - o = dns.name.from_text('bar.', None) - e = n - self.assertTrue(n.choose_relativity(o, False) == e) - - def testChooseRelativity3(self): - n = dns.name.from_text('a.foo', None) - o = dns.name.from_text('bar.', None) - e = dns.name.from_text('a.foo.bar.', None) - self.assertTrue(n.choose_relativity(o, False) == e) - - def testChooseRelativity4(self): - n = dns.name.from_text('a.foo', None) - o = None - e = n - self.assertTrue(n.choose_relativity(o, True) == e) - - def testChooseRelativity5(self): - n = dns.name.from_text('a.foo', None) - o = None - e = n - self.assertTrue(n.choose_relativity(o, False) == e) - - def testChooseRelativity6(self): - n = dns.name.from_text('a.foo.', None) - o = None - e = n - self.assertTrue(n.choose_relativity(o, True) == e) - - def testChooseRelativity7(self): - n = dns.name.from_text('a.foo.', None) - o = None - e = n - self.assertTrue(n.choose_relativity(o, False) == e) - - def testFromWire1(self): - w = b'\x03foo\x00\xc0\x00' - (n1, cused1) = dns.name.from_wire(w, 0) - (n2, cused2) = dns.name.from_wire(w, cused1) - en1 = dns.name.from_text('foo.') - en2 = en1 - ecused1 = 5 - ecused2 = 2 - self.assertTrue(n1 == en1 and cused1 == ecused1 and \ - n2 == en2 and cused2 == ecused2) - - def testFromWire2(self): - w = b'\x03foo\x00\x01a\xc0\x00\x01b\xc0\x05' - current = 0 - (n1, cused1) = dns.name.from_wire(w, current) - current += cused1 - (n2, cused2) = dns.name.from_wire(w, current) - current += cused2 - (n3, cused3) = dns.name.from_wire(w, current) - en1 = dns.name.from_text('foo.') - en2 = dns.name.from_text('a.foo.') - en3 = dns.name.from_text('b.a.foo.') - ecused1 = 5 - ecused2 = 4 - ecused3 = 4 - self.assertTrue(n1 == en1 and cused1 == ecused1 and \ - n2 == en2 and cused2 == ecused2 and \ - n3 == en3 and cused3 == ecused3) - - def testBadFromWire1(self): - def bad(): - w = b'\x03foo\xc0\x04' - (n, cused) = dns.name.from_wire(w, 0) - self.assertRaises(dns.name.BadPointer, bad) - - def testBadFromWire2(self): - def bad(): - w = b'\x03foo\xc0\x05' - (n, cused) = dns.name.from_wire(w, 0) - self.assertRaises(dns.name.BadPointer, bad) - - def testBadFromWire3(self): - def bad(): - w = b'\xbffoo' - (n, cused) = dns.name.from_wire(w, 0) - self.assertRaises(dns.name.BadLabelType, bad) - - def testBadFromWire4(self): - def bad(): - w = b'\x41foo' - (n, cused) = dns.name.from_wire(w, 0) - self.assertRaises(dns.name.BadLabelType, bad) - - def testParent1(self): - n = dns.name.from_text('foo.bar.') - self.assertTrue(n.parent() == dns.name.from_text('bar.')) - self.assertTrue(n.parent().parent() == dns.name.root) - - def testParent2(self): - n = dns.name.from_text('foo.bar', None) - self.assertTrue(n.parent() == dns.name.from_text('bar', None)) - self.assertTrue(n.parent().parent() == dns.name.empty) - - def testParent3(self): - def bad(): - n = dns.name.root - n.parent() - self.assertRaises(dns.name.NoParent, bad) - - def testParent4(self): - def bad(): - n = dns.name.empty - n.parent() - self.assertRaises(dns.name.NoParent, bad) - - def testFromUnicode1(self): - n = dns.name.from_text('foo.bar') - self.assertTrue(n.labels == (b'foo', b'bar', b'')) - - def testFromUnicode2(self): - n = dns.name.from_text('foo\u1234bar.bar') - self.assertTrue(n.labels == (b'xn--foobar-r5z', b'bar', b'')) - - def testFromUnicodeAlternateDot1(self): - n = dns.name.from_text('foo\u3002bar') - self.assertTrue(n.labels == (b'foo', b'bar', b'')) - - def testFromUnicodeAlternateDot2(self): - n = dns.name.from_text('foo\uff0ebar') - self.assertTrue(n.labels == (b'foo', b'bar', b'')) - - def testFromUnicodeAlternateDot3(self): - n = dns.name.from_text('foo\uff61bar') - self.assertTrue(n.labels == (b'foo', b'bar', b'')) - - def testToUnicode1(self): - n = dns.name.from_text('foo.bar') - s = n.to_unicode() - self.assertTrue(s == 'foo.bar.') - - def testToUnicode2(self): - n = dns.name.from_text('foo\u1234bar.bar') - s = n.to_unicode() - self.assertTrue(s == 'foo\u1234bar.bar.') - - def testToUnicode3(self): - n = dns.name.from_text('foo.bar') - s = n.to_unicode() - self.assertTrue(s == 'foo.bar.') - - def testReverseIPv4(self): - e = dns.name.from_text('1.0.0.127.in-addr.arpa.') - n = dns.reversename.from_address('127.0.0.1') - self.assertTrue(e == n) - - def testReverseIPv6(self): - e = dns.name.from_text('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.') - n = dns.reversename.from_address('::1') - self.assertTrue(e == n) - - def testReverseIPv6MappedIpv4(self): - e = dns.name.from_text('1.0.0.127.in-addr.arpa.') - n = dns.reversename.from_address('::ffff:127.0.0.1') - self.assertTrue(e == n) - - def testBadReverseIPv4(self): - def bad(): - n = dns.reversename.from_address('127.0.foo.1') - self.assertRaises(dns.exception.SyntaxError, bad) - - def testBadReverseIPv6(self): - def bad(): - n = dns.reversename.from_address('::1::1') - self.assertRaises(dns.exception.SyntaxError, bad) - - def testForwardIPv4(self): - n = dns.name.from_text('1.0.0.127.in-addr.arpa.') - e = '127.0.0.1' - text = dns.reversename.to_address(n) - self.assertTrue(text == e) - - def testForwardIPv6(self): - n = dns.name.from_text('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.') - e = '::1' - text = dns.reversename.to_address(n) - self.assertTrue(text == e) - - def testE164ToEnum(self): - text = '+1 650 555 1212' - e = dns.name.from_text('2.1.2.1.5.5.5.0.5.6.1.e164.arpa.') - n = dns.e164.from_e164(text) - self.assertTrue(n == e) - - def testEnumToE164(self): - n = dns.name.from_text('2.1.2.1.5.5.5.0.5.6.1.e164.arpa.') - e = '+16505551212' - text = dns.e164.to_e164(n) - self.assertTrue(text == e) - - def testPickling(self): - n = dns.name.from_text('foo.bar') - pickled = pickle.dumps(n) - unpickled = pickle.loads(pickled) - self.assertEqual(n, unpickled) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_namedict.py b/tests/test_namedict.py deleted file mode 100644 index 91fd397..0000000 --- a/tests/test_namedict.py +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.name -import dns.namedict - -class NameTestCase(unittest.TestCase): - - def setUp(self): - self.ndict = dns.namedict.NameDict() - n1 = dns.name.from_text('foo.bar.') - n2 = dns.name.from_text('bar.') - self.ndict[n1] = 1 - self.ndict[n2] = 2 - self.rndict = dns.namedict.NameDict() - n1 = dns.name.from_text('foo.bar', None) - n2 = dns.name.from_text('bar', None) - self.rndict[n1] = 1 - self.rndict[n2] = 2 - - def testDepth(self): - self.assertTrue(self.ndict.max_depth == 3) - - def testLookup1(self): - k = dns.name.from_text('foo.bar.') - self.assertTrue(self.ndict[k] == 1) - - def testLookup2(self): - k = dns.name.from_text('foo.bar.') - self.assertTrue(self.ndict.get_deepest_match(k)[1] == 1) - - def testLookup3(self): - k = dns.name.from_text('a.b.c.foo.bar.') - self.assertTrue(self.ndict.get_deepest_match(k)[1] == 1) - - def testLookup4(self): - k = dns.name.from_text('a.b.c.bar.') - self.assertTrue(self.ndict.get_deepest_match(k)[1] == 2) - - def testLookup5(self): - def bad(): - n = dns.name.from_text('a.b.c.') - (k, v) = self.ndict.get_deepest_match(n) - self.assertRaises(KeyError, bad) - - def testLookup6(self): - def bad(): - (k, v) = self.ndict.get_deepest_match(dns.name.empty) - self.assertRaises(KeyError, bad) - - def testLookup7(self): - self.ndict[dns.name.empty] = 100 - n = dns.name.from_text('a.b.c.') - (k, v) = self.ndict.get_deepest_match(n) - self.assertTrue(v == 100) - - def testLookup8(self): - def bad(): - self.ndict['foo'] = 100 - self.assertRaises(ValueError, bad) - - def testRelDepth(self): - self.assertTrue(self.rndict.max_depth == 2) - - def testRelLookup1(self): - k = dns.name.from_text('foo.bar', None) - self.assertTrue(self.rndict[k] == 1) - - def testRelLookup2(self): - k = dns.name.from_text('foo.bar', None) - self.assertTrue(self.rndict.get_deepest_match(k)[1] == 1) - - def testRelLookup3(self): - k = dns.name.from_text('a.b.c.foo.bar', None) - self.assertTrue(self.rndict.get_deepest_match(k)[1] == 1) - - def testRelLookup4(self): - k = dns.name.from_text('a.b.c.bar', None) - self.assertTrue(self.rndict.get_deepest_match(k)[1] == 2) - - def testRelLookup7(self): - self.rndict[dns.name.empty] = 100 - n = dns.name.from_text('a.b.c', None) - (k, v) = self.rndict.get_deepest_match(n) - self.assertTrue(v == 100) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_ntoaaton.py b/tests/test_ntoaaton.py deleted file mode 100644 index 56c671b..0000000 --- a/tests/test_ntoaaton.py +++ /dev/null @@ -1,195 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.exception -import dns.ipv4 -import dns.ipv6 - -# for convenience -aton4 = dns.ipv4.inet_aton -ntoa4 = dns.ipv4.inet_ntoa -aton6 = dns.ipv6.inet_aton -ntoa6 = dns.ipv6.inet_ntoa - -v4_bad_addrs = ['256.1.1.1', '1.1.1', '1.1.1.1.1', '01.1.1.1', - '+1.1.1.1', '1.1.1.1+', '1..2.3.4', '.1.2.3.4', - '1.2.3.4.'] - -class NtoAAtoNTestCase(unittest.TestCase): - - def test_aton1(self): - a = aton6('::') - self.assertTrue(a == b'\x00' * 16) - - def test_aton2(self): - a = aton6('::1') - self.assertTrue(a == b'\x00' * 15 + b'\x01') - - def test_aton3(self): - a = aton6('::10.0.0.1') - self.assertTrue(a == b'\x00' * 12 + b'\x0a\x00\x00\x01') - - def test_aton4(self): - a = aton6('abcd::dcba') - self.assertTrue(a == b'\xab\xcd' + b'\x00' * 12 + b'\xdc\xba') - - def test_aton5(self): - a = aton6('1:2:3:4:5:6:7:8') - self.assertTrue(a == \ - bytes.fromhex('00010002000300040005000600070008')) - - def test_bad_aton1(self): - def bad(): - a = aton6('abcd:dcba') - self.assertRaises(dns.exception.SyntaxError, bad) - - def test_bad_aton2(self): - def bad(): - a = aton6('abcd::dcba::1') - self.assertRaises(dns.exception.SyntaxError, bad) - - def test_bad_aton3(self): - def bad(): - a = aton6('1:2:3:4:5:6:7:8:9') - self.assertRaises(dns.exception.SyntaxError, bad) - - def test_ntoa1(self): - b = bytes.fromhex('00010002000300040005000600070008') - t = ntoa6(b) - self.assertTrue(t == '1:2:3:4:5:6:7:8') - - def test_ntoa2(self): - b = b'\x00' * 16 - t = ntoa6(b) - self.assertTrue(t == '::') - - def test_ntoa3(self): - b = b'\x00' * 15 + b'\x01' - t = ntoa6(b) - self.assertTrue(t == '::1') - - def test_ntoa4(self): - b = b'\x80' + b'\x00' * 15 - t = ntoa6(b) - self.assertTrue(t == '8000::') - - def test_ntoa5(self): - b = b'\x01\xcd' + b'\x00' * 12 + b'\x03\xef' - t = ntoa6(b) - self.assertTrue(t == '1cd::3ef') - - def test_ntoa6(self): - b = bytes.fromhex('ffff00000000ffff000000000000ffff') - t = ntoa6(b) - self.assertTrue(t == 'ffff:0:0:ffff::ffff') - - def test_ntoa7(self): - b = bytes.fromhex('00000000ffff000000000000ffffffff') - t = ntoa6(b) - self.assertTrue(t == '0:0:ffff::ffff:ffff') - - def test_ntoa8(self): - b = bytes.fromhex('ffff0000ffff00000000ffff00000000') - t = ntoa6(b) - self.assertTrue(t == 'ffff:0:ffff::ffff:0:0') - - def test_ntoa9(self): - b = bytes.fromhex('0000000000000000000000000a000001') - t = ntoa6(b) - self.assertTrue(t == '::10.0.0.1') - - def test_ntoa10(self): - b = bytes.fromhex('0000000000000000000000010a000001') - t = ntoa6(b) - self.assertTrue(t == '::1:a00:1') - - def test_ntoa11(self): - b = bytes.fromhex('00000000000000000000ffff0a000001') - t = ntoa6(b) - self.assertTrue(t == '::ffff:10.0.0.1') - - def test_ntoa12(self): - b = bytes.fromhex('000000000000000000000000ffffffff') - t = ntoa6(b) - self.assertTrue(t == '::255.255.255.255') - - def test_ntoa13(self): - b = bytes.fromhex('00000000000000000000ffffffffffff') - t = ntoa6(b) - self.assertTrue(t == '::ffff:255.255.255.255') - - def test_ntoa14(self): - b = bytes.fromhex('0000000000000000000000000001ffff') - t = ntoa6(b) - self.assertTrue(t == '::0.1.255.255') - - def test_bad_ntoa1(self): - def bad(): - a = ntoa6('') - self.assertRaises(ValueError, bad) - - def test_bad_ntoa2(self): - def bad(): - a = ntoa6(b'\x00' * 17) - self.assertRaises(ValueError, bad) - - def test_good_v4_aton(self): - pairs = [('1.2.3.4', b'\x01\x02\x03\x04'), - ('255.255.255.255', b'\xff\xff\xff\xff'), - ('0.0.0.0', b'\x00\x00\x00\x00')] - for (t, b) in pairs: - b1 = aton4(t) - t1 = ntoa4(b1) - self.assertTrue(b1 == b) - self.assertTrue(t1 == t) - - def test_bad_v4_aton(self): - def make_bad(a): - def bad(): - return aton4(a) - return bad - for addr in v4_bad_addrs: - self.assertRaises(dns.exception.SyntaxError, make_bad(addr)) - - def test_bad_v6_aton(self): - addrs = ['+::0', '0::0::', '::0::', '1:2:3:4:5:6:7:8:9', - ':::::::'] - embedded = ['::' + x for x in v4_bad_addrs] - addrs.extend(embedded) - def make_bad(a): - def bad(): - x = aton6(a) - return bad - for addr in addrs: - self.assertRaises(dns.exception.SyntaxError, make_bad(addr)) - - def test_rfc5952_section_4_2_2(self): - addr = '2001:db8:0:1:1:1:1:1' - b1 = aton6(addr) - t1 = ntoa6(b1) - self.assertTrue(t1 == addr) - - def test_is_mapped(self): - t1 = '2001:db8:0:1:1:1:1:1' - t2 = '::ffff:127.0.0.1' - t3 = '1::ffff:127.0.0.1' - self.assertFalse(dns.ipv6.is_mapped(aton6(t1))) - self.assertTrue(dns.ipv6.is_mapped(aton6(t2))) - self.assertFalse(dns.ipv6.is_mapped(aton6(t3))) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_rdata.py b/tests/test_rdata.py deleted file mode 100644 index 69e64e1..0000000 --- a/tests/test_rdata.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.rdata -import dns.rdataclass -import dns.rdatatype - -class RdataTestCase(unittest.TestCase): - - def test_str(self): - rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, "1.2.3.4") - self.failUnless(rdata.address == "1.2.3.4") - - def test_unicode(self): - rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, u"1.2.3.4") - self.failUnless(rdata.address == "1.2.3.4") - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_rdtypeandclass.py b/tests/test_rdtypeandclass.py deleted file mode 100644 index d2849d3..0000000 --- a/tests/test_rdtypeandclass.py +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.rdataclass -import dns.rdatatype - -class RdTypeAndClassTestCase(unittest.TestCase): - - # Classes - - def test_class_meta1(self): - self.assertTrue(dns.rdataclass.is_metaclass(dns.rdataclass.ANY)) - - def test_class_meta2(self): - self.assertTrue(not dns.rdataclass.is_metaclass(dns.rdataclass.IN)) - - def test_class_bytext1(self): - self.assertTrue(dns.rdataclass.from_text('IN') == dns.rdataclass.IN) - - def test_class_bytext2(self): - self.assertTrue(dns.rdataclass.from_text('CLASS1') == - dns.rdataclass.IN) - - def test_class_bytext_bounds1(self): - self.assertTrue(dns.rdataclass.from_text('CLASS0') == 0) - self.assertTrue(dns.rdataclass.from_text('CLASS65535') == 65535) - - def test_class_bytext_bounds2(self): - def bad(): - junk = dns.rdataclass.from_text('CLASS65536') - self.assertRaises(ValueError, bad) - - def test_class_bytext_unknown(self): - def bad(): - junk = dns.rdataclass.from_text('XXX') - self.assertRaises(dns.rdataclass.UnknownRdataclass, bad) - - def test_class_totext1(self): - self.assertTrue(dns.rdataclass.to_text(dns.rdataclass.IN) == 'IN') - - def test_class_totext2(self): - self.assertTrue(dns.rdataclass.to_text(999) == 'CLASS999') - - def test_class_totext_bounds1(self): - def bad(): - junk = dns.rdataclass.to_text(-1) - self.assertRaises(ValueError, bad) - - def test_class_totext_bounds2(self): - def bad(): - junk = dns.rdataclass.to_text(65536) - self.assertRaises(ValueError, bad) - - # Types - - def test_type_meta1(self): - self.assertTrue(dns.rdatatype.is_metatype(dns.rdatatype.ANY)) - - def test_type_meta2(self): - self.assertTrue(dns.rdatatype.is_metatype(dns.rdatatype.OPT)) - - def test_type_meta3(self): - self.assertTrue(not dns.rdatatype.is_metatype(dns.rdatatype.A)) - - def test_type_singleton1(self): - self.assertTrue(dns.rdatatype.is_singleton(dns.rdatatype.SOA)) - - def test_type_singleton2(self): - self.assertTrue(not dns.rdatatype.is_singleton(dns.rdatatype.A)) - - def test_type_bytext1(self): - self.assertTrue(dns.rdatatype.from_text('A') == dns.rdatatype.A) - - def test_type_bytext2(self): - self.assertTrue(dns.rdatatype.from_text('TYPE1') == - dns.rdatatype.A) - - def test_type_bytext_bounds1(self): - self.assertTrue(dns.rdatatype.from_text('TYPE0') == 0) - self.assertTrue(dns.rdatatype.from_text('TYPE65535') == 65535) - - def test_type_bytext_bounds2(self): - def bad(): - junk = dns.rdatatype.from_text('TYPE65536') - self.assertRaises(ValueError, bad) - - def test_type_bytext_unknown(self): - def bad(): - junk = dns.rdatatype.from_text('XXX') - self.assertRaises(dns.rdatatype.UnknownRdatatype, bad) - - def test_type_totext1(self): - self.assertTrue(dns.rdatatype.to_text(dns.rdatatype.A) == 'A') - - def test_type_totext2(self): - self.assertTrue(dns.rdatatype.to_text(999) == 'TYPE999') - - def test_type_totext_bounds1(self): - def bad(): - junk = dns.rdatatype.to_text(-1) - self.assertRaises(ValueError, bad) - - def test_type_totext_bounds2(self): - def bad(): - junk = dns.rdatatype.to_text(65536) - self.assertRaises(ValueError, bad) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_rdtypeanydnskey.py b/tests/test_rdtypeanydnskey.py deleted file mode 100644 index 7c59e36..0000000 --- a/tests/test_rdtypeanydnskey.py +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (C) 2014 Red Hat, Inc. -# Author: Petr Spacek <pspacek@redhat.com> -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED 'AS IS' AND RED HAT DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.rrset -import dns.rdtypes.ANY.DNSKEY - - -class RdtypeAnyDnskeyTestCase(unittest.TestCase): - - def testFlagsEmpty(self): - '''Test DNSKEY flag to/from text conversion for zero flag/empty set.''' - good_s = set() - good_f = 0 - from_flags = dns.rdtypes.ANY.DNSKEY.flags_to_text_set(good_f) - self.assertTrue(from_flags == good_s, - '"%s" != "%s"' % (from_flags, good_s)) - from_set = dns.rdtypes.ANY.DNSKEY.flags_from_text_set(good_s) - self.assertTrue(from_set == good_f, - '"0x%x" != "0x%x"' % (from_set, good_f)) - - def testFlagsAll(self): - '''Test that all defined flags are recognized.''' - good_s = set(['SEP', 'REVOKE', 'ZONE']) - good_f = 0x181 - from_flags = dns.rdtypes.ANY.DNSKEY.flags_to_text_set(good_f) - self.assertTrue(from_flags == good_s, - '"%s" != "%s"' % (from_flags, good_s)) - from_text = dns.rdtypes.ANY.DNSKEY.flags_from_text_set(good_s) - self.assertTrue(from_text == good_f, - '"0x%x" != "0x%x"' % (from_text, good_f)) - - def testFlagsUnknownToText(self): - '''Test that undefined flags are returned in hexadecimal notation.''' - unk_s = set(['0x8000']) - flags_s = dns.rdtypes.ANY.DNSKEY.flags_to_text_set(0x8000) - self.assertTrue(flags_s == unk_s, '"%s" != "%s"' % (flags_s, unk_s)) - - def testFlagsUnknownToFlags(self): - '''Test that conversion from undefined mnemonic raises error.''' - self.assertRaises(NotImplementedError, - dns.rdtypes.ANY.DNSKEY.flags_from_text_set, - (['0x8000'])) - - def testFlagsRRToText(self): - '''Test that RR method returns correct flags.''' - rr = dns.rrset.from_text('foo', 300, 'IN', 'DNSKEY', '257 3 8 KEY=')[0] - rr_s = set(['ZONE', 'SEP']) - flags_s = rr.flags_to_text_set() - self.assertTrue(flags_s == rr_s, '"%s" != "%s"' % (flags_s, rr_s)) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_rdtypeanyeui.py b/tests/test_rdtypeanyeui.py deleted file mode 100644 index 800d103..0000000 --- a/tests/test_rdtypeanyeui.py +++ /dev/null @@ -1,223 +0,0 @@ -# Copyright (C) 2015 Red Hat, Inc. -# Author: Petr Spacek <pspacek@redhat.com> -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED 'AS IS' AND RED HAT DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest -try: - from StringIO import StringIO -except ImportError: - from io import BytesIO as StringIO - -import dns.rrset -import dns.rdtypes.ANY.EUI48 -import dns.exception - - -class RdtypeAnyEUI48TestCase(unittest.TestCase): - def testInstOk(self): - '''Valid binary input.''' - eui = b'\x01\x23\x45\x67\x89\xab' - inst = dns.rdtypes.ANY.EUI48.EUI48(dns.rdataclass.IN, - dns.rdatatype.EUI48, - eui) - self.assertEqual(inst.eui, eui) - - def testInstLength(self): - '''Incorrect input length.''' - eui = b'\x01\x23\x45\x67\x89\xab\xcd' - with self.assertRaises(dns.exception.FormError): - dns.rdtypes.ANY.EUI48.EUI48(dns.rdataclass.IN, - dns.rdatatype.EUI48, - eui) - - def testFromTextOk(self): - '''Valid text input.''' - r1 = dns.rrset.from_text('foo', 300, 'IN', 'EUI48', - '01-23-45-67-89-ab') - eui = b'\x01\x23\x45\x67\x89\xab' - self.assertEqual(r1[0].eui, eui) - - def testFromTextLength(self): - '''Invalid input length.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI48', - '00-01-23-45-67-89-ab') - - def testFromTextDelim(self): - '''Invalid delimiter.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI48', '01_23-45-67-89-ab') - - def testFromTextExtraDash(self): - '''Extra dash instead of hex digit.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI48', '0--23-45-67-89-ab') - - def testFromTextMultipleTokens(self): - '''Invalid input divided to multiple tokens.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI48', '01 23-45-67-89-ab') - - def testFromTextInvalidHex(self): - '''Invalid hexadecimal input.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI48', 'g0-23-45-67-89-ab') - - def testToTextOk(self): - '''Valid text output.''' - eui = b'\x01\x23\x45\x67\x89\xab' - exp_text = '01-23-45-67-89-ab' - inst = dns.rdtypes.ANY.EUI48.EUI48(dns.rdataclass.IN, - dns.rdatatype.EUI48, - eui) - text = inst.to_text() - self.assertEqual(exp_text, text) - - def testToWire(self): - '''Valid wire format.''' - eui = b'\x01\x23\x45\x67\x89\xab' - inst = dns.rdtypes.ANY.EUI48.EUI48(dns.rdataclass.IN, - dns.rdatatype.EUI48, - eui) - buff = StringIO() - inst.to_wire(buff) - self.assertEqual(buff.getvalue(), eui) - - def testFromWireOk(self): - '''Valid wire format.''' - eui = b'\x01\x23\x45\x67\x89\xab' - pad_len = 100 - wire = dns.wiredata.WireData(b'x' * pad_len + eui + b'y' * pad_len * 2) - inst = dns.rdtypes.ANY.EUI48.EUI48.from_wire(dns.rdataclass.IN, - dns.rdatatype.EUI48, - wire, - pad_len, - len(eui)) - self.assertEqual(inst.eui, eui) - - def testFromWireLength(self): - '''Valid wire format.''' - eui = b'\x01\x23\x45\x67\x89' - pad_len = 100 - wire = dns.wiredata.WireData(b'x' * pad_len + eui + b'y' * pad_len * 2) - with self.assertRaises(dns.exception.FormError): - dns.rdtypes.ANY.EUI48.EUI48.from_wire(dns.rdataclass.IN, - dns.rdatatype.EUI48, - wire, - pad_len, - len(eui)) - - -class RdtypeAnyEUI64TestCase(unittest.TestCase): - def testInstOk(self): - '''Valid binary input.''' - eui = b'\x01\x23\x45\x67\x89\xab\xcd\xef' - inst = dns.rdtypes.ANY.EUI64.EUI64(dns.rdataclass.IN, - dns.rdatatype.EUI64, - eui) - self.assertEqual(inst.eui, eui) - - def testInstLength(self): - '''Incorrect input length.''' - eui = b'\x01\x23\x45\x67\x89\xab' - with self.assertRaises(dns.exception.FormError): - dns.rdtypes.ANY.EUI64.EUI64(dns.rdataclass.IN, - dns.rdatatype.EUI64, - eui) - - def testFromTextOk(self): - '''Valid text input.''' - r1 = dns.rrset.from_text('foo', 300, 'IN', 'EUI64', - '01-23-45-67-89-ab-cd-ef') - eui = b'\x01\x23\x45\x67\x89\xab\xcd\xef' - self.assertEqual(r1[0].eui, eui) - - def testFromTextLength(self): - '''Invalid input length.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI64', - '01-23-45-67-89-ab') - - def testFromTextDelim(self): - '''Invalid delimiter.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI64', - '01_23-45-67-89-ab-cd-ef') - - def testFromTextExtraDash(self): - '''Extra dash instead of hex digit.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI64', - '0--23-45-67-89-ab-cd-ef') - - def testFromTextMultipleTokens(self): - '''Invalid input divided to multiple tokens.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI64', - '01 23-45-67-89-ab-cd-ef') - - def testFromTextInvalidHex(self): - '''Invalid hexadecimal input.''' - with self.assertRaises(dns.exception.SyntaxError): - dns.rrset.from_text('foo', 300, 'IN', 'EUI64', - 'g0-23-45-67-89-ab-cd-ef') - - def testToTextOk(self): - '''Valid text output.''' - eui = b'\x01\x23\x45\x67\x89\xab\xcd\xef' - exp_text = '01-23-45-67-89-ab-cd-ef' - inst = dns.rdtypes.ANY.EUI64.EUI64(dns.rdataclass.IN, - dns.rdatatype.EUI64, - eui) - text = inst.to_text() - self.assertEqual(exp_text, text) - - def testToWire(self): - '''Valid wire format.''' - eui = b'\x01\x23\x45\x67\x89\xab\xcd\xef' - inst = dns.rdtypes.ANY.EUI64.EUI64(dns.rdataclass.IN, - dns.rdatatype.EUI64, - eui) - buff = StringIO() - inst.to_wire(buff) - self.assertEqual(buff.getvalue(), eui) - - def testFromWireOk(self): - '''Valid wire format.''' - eui = b'\x01\x23\x45\x67\x89\xab\xcd\xef' - pad_len = 100 - wire = dns.wiredata.WireData(b'x' * pad_len + eui + b'y' * pad_len * 2) - inst = dns.rdtypes.ANY.EUI64.EUI64.from_wire(dns.rdataclass.IN, - dns.rdatatype.EUI64, - wire, - pad_len, - len(eui)) - self.assertEqual(inst.eui, eui) - - def testFromWireLength(self): - '''Valid wire format.''' - eui = b'\x01\x23\x45\x67\x89' - pad_len = 100 - wire = dns.wiredata.WireData(b'x' * pad_len + eui + b'y' * pad_len * 2) - with self.assertRaises(dns.exception.FormError): - dns.rdtypes.ANY.EUI64.EUI64.from_wire(dns.rdataclass.IN, - dns.rdatatype.EUI64, - wire, - pad_len, - len(eui)) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_rdtypeanyloc.py b/tests/test_rdtypeanyloc.py deleted file mode 100644 index 7595b9f..0000000 --- a/tests/test_rdtypeanyloc.py +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (C) 2014 Red Hat, Inc. -# Author: Petr Spacek <pspacek@redhat.com> -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED 'AS IS' AND RED HAT DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.rrset -import dns.rdtypes.ANY.LOC - -class RdtypeAnyLocTestCase(unittest.TestCase): - - def testEqual1(self): - '''Test default values for size, horizontal and vertical precision.''' - r1 = dns.rrset.from_text('foo', 300, 'IN', 'LOC', - '49 11 42.400 N 16 36 29.600 E 227.64m') - r2 = dns.rrset.from_text('FOO', 600, 'in', 'loc', - '49 11 42.400 N 16 36 29.600 E 227.64m ' - '1.00m 10000.00m 10.00m') - self.assertTrue(r1 == r2, '"%s" != "%s"' % (r1, r2)) - - def testEqual2(self): - '''Test default values for size, horizontal and vertical precision.''' - r1 = dns.rdtypes.ANY.LOC.LOC(1, 29, (49, 11, 42, 400), - (16, 36, 29, 600), 22764.0) # centimeters - r2 = dns.rdtypes.ANY.LOC.LOC(1, 29, (49, 11, 42, 400), - (16, 36, 29, 600), 22764.0, # centimeters - 100.0, 1000000.00, 1000.0) # centimeters - self.assertTrue(r1 == r2, '"%s" != "%s"' % (r1, r2)) - - def testEqual3(self): - '''Test size, horizontal and vertical precision parsers: 100 cm == 1 m. - - Parsers in from_text() and __init__() have to produce equal results.''' - r1 = dns.rdtypes.ANY.LOC.LOC(1, 29, (49, 11, 42, 400), - (16, 36, 29, 600), 22764.0, - 200.0, 1000.00, 200.0) # centimeters - r2 = dns.rrset.from_text('FOO', 600, 'in', 'loc', - '49 11 42.400 N 16 36 29.600 E 227.64m ' - '2.00m 10.00m 2.00m')[0] - self.assertTrue(r1 == r2, '"%s" != "%s"' % (r1, r2)) - - def testEqual4(self): - '''Test size, horizontal and vertical precision parsers without unit. - - Parsers in from_text() and __init__() have produce equal result - for values with and without trailing "m".''' - r1 = dns.rdtypes.ANY.LOC.LOC(1, 29, (49, 11, 42, 400), - (16, 36, 29, 600), 22764.0, - 200.0, 1000.00, 200.0) # centimeters - r2 = dns.rrset.from_text('FOO', 600, 'in', 'loc', - '49 11 42.400 N 16 36 29.600 E 227.64 ' - '2 10 2')[0] # meters without explicit unit - self.assertTrue(r1 == r2, '"%s" != "%s"' % (r1, r2)) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_resolver.py b/tests/test_resolver.py deleted file mode 100644 index f3c0d35..0000000 --- a/tests/test_resolver.py +++ /dev/null @@ -1,184 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import io -import select -import sys -import time -import unittest - -import dns.name -import dns.message -import dns.name -import dns.rdataclass -import dns.rdatatype -import dns.resolver - -resolv_conf = """ - /t/t -# comment 1 -; comment 2 -domain foo -nameserver 10.0.0.1 -nameserver 10.0.0.2 -""" - -message_text = """id 1234 -opcode QUERY -rcode NOERROR -flags QR AA RD -;QUESTION -example. IN A -;ANSWER -example. 1 IN A 10.0.0.1 -;AUTHORITY -;ADDITIONAL -""" - -class FakeAnswer(object): - def __init__(self, expiration): - self.expiration = expiration - -class BaseResolverTests(object): - - if sys.platform != 'win32': - def testRead(self): - f = io.StringIO(resolv_conf) - r = dns.resolver.Resolver(f) - self.assertTrue(r.nameservers == ['10.0.0.1', '10.0.0.2'] and - r.domain == dns.name.from_text('foo')) - - def testCacheExpiration(self): - message = dns.message.from_text(message_text) - name = dns.name.from_text('example.') - answer = dns.resolver.Answer(name, dns.rdatatype.A, dns.rdataclass.IN, - message) - cache = dns.resolver.Cache() - cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) - time.sleep(2) - self.assertTrue(cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) - is None) - - def testCacheCleaning(self): - message = dns.message.from_text(message_text) - name = dns.name.from_text('example.') - answer = dns.resolver.Answer(name, dns.rdatatype.A, dns.rdataclass.IN, - message) - cache = dns.resolver.Cache(cleaning_interval=1.0) - cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) - time.sleep(2) - self.assertTrue(cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) - is None) - - def testZoneForName1(self): - name = dns.name.from_text('www.dnspython.org.') - ezname = dns.name.from_text('dnspython.org.') - zname = dns.resolver.zone_for_name(name) - self.assertTrue(zname == ezname) - - def testZoneForName2(self): - name = dns.name.from_text('a.b.www.dnspython.org.') - ezname = dns.name.from_text('dnspython.org.') - zname = dns.resolver.zone_for_name(name) - self.assertTrue(zname == ezname) - - def testZoneForName3(self): - name = dns.name.from_text('dnspython.org.') - ezname = dns.name.from_text('dnspython.org.') - zname = dns.resolver.zone_for_name(name) - self.assertTrue(zname == ezname) - - def testZoneForName4(self): - def bad(): - name = dns.name.from_text('dnspython.org', None) - zname = dns.resolver.zone_for_name(name) - self.assertRaises(dns.resolver.NotAbsolute, bad) - - def testLRUReplace(self): - cache = dns.resolver.LRUCache(4) - for i in range(0, 5): - name = dns.name.from_text('example%d.' % i) - answer = FakeAnswer(time.time() + 1) - cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) - for i in range(0, 5): - name = dns.name.from_text('example%d.' % i) - if i == 0: - self.assertTrue(cache.get((name, dns.rdatatype.A, - dns.rdataclass.IN)) - is None) - else: - self.assertTrue(not cache.get((name, dns.rdatatype.A, - dns.rdataclass.IN)) - is None) - - def testLRUDoesLRU(self): - cache = dns.resolver.LRUCache(4) - for i in range(0, 4): - name = dns.name.from_text('example%d.' % i) - answer = FakeAnswer(time.time() + 1) - cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) - name = dns.name.from_text('example0.') - cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) - # The LRU is now example1. - name = dns.name.from_text('example4.') - answer = FakeAnswer(time.time() + 1) - cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) - for i in range(0, 5): - name = dns.name.from_text('example%d.' % i) - if i == 1: - self.assertTrue(cache.get((name, dns.rdatatype.A, - dns.rdataclass.IN)) - is None) - else: - self.assertTrue(not cache.get((name, dns.rdatatype.A, - dns.rdataclass.IN)) - is None) - - def testLRUExpiration(self): - cache = dns.resolver.LRUCache(4) - for i in range(0, 4): - name = dns.name.from_text('example%d.' % i) - answer = FakeAnswer(time.time() + 1) - cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) - time.sleep(2) - for i in range(0, 4): - name = dns.name.from_text('example%d.' % i) - self.assertTrue(cache.get((name, dns.rdatatype.A, - dns.rdataclass.IN)) - is None) - -class PollingMonkeyPatchMixin(object): - def setUp(self): - self.__native_polling_backend = dns.query._polling_backend - dns.query._set_polling_backend(self.polling_backend()) - - unittest.TestCase.setUp(self) - - def tearDown(self): - dns.query._set_polling_backend(self.__native_polling_backend) - - unittest.TestCase.tearDown(self) - -class SelectResolverTestCase(PollingMonkeyPatchMixin, BaseResolverTests, unittest.TestCase): - def polling_backend(self): - return dns.query._select_for - -if hasattr(select, 'poll'): - class PollResolverTestCase(PollingMonkeyPatchMixin, BaseResolverTests, unittest.TestCase): - def polling_backend(self): - return dns.query._poll_for - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_rrset.py b/tests/test_rrset.py deleted file mode 100644 index f4b2b2e..0000000 --- a/tests/test_rrset.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.rrset - -class RRsetTestCase(unittest.TestCase): - - def testEqual1(self): - r1 = dns.rrset.from_text('foo', 300, 'in', 'a', '10.0.0.1', '10.0.0.2') - r2 = dns.rrset.from_text('FOO', 300, 'in', 'a', '10.0.0.2', '10.0.0.1') - self.assertTrue(r1 == r2) - - def testEqual2(self): - r1 = dns.rrset.from_text('foo', 300, 'in', 'a', '10.0.0.1', '10.0.0.2') - r2 = dns.rrset.from_text('FOO', 600, 'in', 'a', '10.0.0.2', '10.0.0.1') - self.assertTrue(r1 == r2) - - def testNotEqual1(self): - r1 = dns.rrset.from_text('fooa', 30, 'in', 'a', '10.0.0.1', '10.0.0.2') - r2 = dns.rrset.from_text('FOO', 30, 'in', 'a', '10.0.0.2', '10.0.0.1') - self.assertTrue(r1 != r2) - - def testNotEqual2(self): - r1 = dns.rrset.from_text('foo', 30, 'in', 'a', '10.0.0.1', '10.0.0.3') - r2 = dns.rrset.from_text('FOO', 30, 'in', 'a', '10.0.0.2', '10.0.0.1') - self.assertTrue(r1 != r2) - - def testNotEqual3(self): - r1 = dns.rrset.from_text('foo', 30, 'in', 'a', '10.0.0.1', '10.0.0.2', - '10.0.0.3') - r2 = dns.rrset.from_text('FOO', 30, 'in', 'a', '10.0.0.2', '10.0.0.1') - self.assertTrue(r1 != r2) - - def testNotEqual4(self): - r1 = dns.rrset.from_text('foo', 30, 'in', 'a', '10.0.0.1') - r2 = dns.rrset.from_text('FOO', 30, 'in', 'a', '10.0.0.2', '10.0.0.1') - self.assertTrue(r1 != r2) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_set.py b/tests/test_set.py deleted file mode 100644 index a6607b8..0000000 --- a/tests/test_set.py +++ /dev/null @@ -1,208 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.set - -# for convenience -S = dns.set.Set - -class SimpleSetTestCase(unittest.TestCase): - - def testLen1(self): - s1 = S() - self.assertTrue(len(s1) == 0) - - def testLen2(self): - s1 = S([1, 2, 3]) - self.assertTrue(len(s1) == 3) - - def testLen3(self): - s1 = S([1, 2, 3, 3, 3]) - self.assertTrue(len(s1) == 3) - - def testUnion1(self): - s1 = S([1, 2, 3]) - s2 = S([1, 2, 3]) - e = S([1, 2, 3]) - self.assertTrue(s1 | s2 == e) - - def testUnion2(self): - s1 = S([1, 2, 3]) - s2 = S([]) - e = S([1, 2, 3]) - self.assertTrue(s1 | s2 == e) - - def testUnion3(self): - s1 = S([1, 2, 3]) - s2 = S([3, 4]) - e = S([1, 2, 3, 4]) - self.assertTrue(s1 | s2 == e) - - def testIntersection1(self): - s1 = S([1, 2, 3]) - s2 = S([1, 2, 3]) - e = S([1, 2, 3]) - self.assertTrue(s1 & s2 == e) - - def testIntersection2(self): - s1 = S([0, 1, 2, 3]) - s2 = S([1, 2, 3, 4]) - e = S([1, 2, 3]) - self.assertTrue(s1 & s2 == e) - - def testIntersection3(self): - s1 = S([1, 2, 3]) - s2 = S([]) - e = S([]) - self.assertTrue(s1 & s2 == e) - - def testIntersection4(self): - s1 = S([1, 2, 3]) - s2 = S([5, 4]) - e = S([]) - self.assertTrue(s1 & s2 == e) - - def testDifference1(self): - s1 = S([1, 2, 3]) - s2 = S([5, 4]) - e = S([1, 2, 3]) - self.assertTrue(s1 - s2 == e) - - def testDifference2(self): - s1 = S([1, 2, 3]) - s2 = S([]) - e = S([1, 2, 3]) - self.assertTrue(s1 - s2 == e) - - def testDifference3(self): - s1 = S([1, 2, 3]) - s2 = S([3, 2]) - e = S([1]) - self.assertTrue(s1 - s2 == e) - - def testDifference4(self): - s1 = S([1, 2, 3]) - s2 = S([3, 2, 1]) - e = S([]) - self.assertTrue(s1 - s2 == e) - - def testSubset1(self): - s1 = S([1, 2, 3]) - s2 = S([3, 2, 1]) - self.assertTrue(s1.issubset(s2)) - - def testSubset2(self): - s1 = S([1, 2, 3]) - self.assertTrue(s1.issubset(s1)) - - def testSubset3(self): - s1 = S([]) - s2 = S([1, 2, 3]) - self.assertTrue(s1.issubset(s2)) - - def testSubset4(self): - s1 = S([1]) - s2 = S([1, 2, 3]) - self.assertTrue(s1.issubset(s2)) - - def testSubset5(self): - s1 = S([]) - s2 = S([]) - self.assertTrue(s1.issubset(s2)) - - def testSubset6(self): - s1 = S([1, 4]) - s2 = S([1, 2, 3]) - self.assertTrue(not s1.issubset(s2)) - - def testSuperset1(self): - s1 = S([1, 2, 3]) - s2 = S([3, 2, 1]) - self.assertTrue(s1.issuperset(s2)) - - def testSuperset2(self): - s1 = S([1, 2, 3]) - self.assertTrue(s1.issuperset(s1)) - - def testSuperset3(self): - s1 = S([1, 2, 3]) - s2 = S([]) - self.assertTrue(s1.issuperset(s2)) - - def testSuperset4(self): - s1 = S([1, 2, 3]) - s2 = S([1]) - self.assertTrue(s1.issuperset(s2)) - - def testSuperset5(self): - s1 = S([]) - s2 = S([]) - self.assertTrue(s1.issuperset(s2)) - - def testSuperset6(self): - s1 = S([1, 2, 3]) - s2 = S([1, 4]) - self.assertTrue(not s1.issuperset(s2)) - - def testUpdate1(self): - s1 = S([1, 2, 3]) - u = (4, 5, 6) - e = S([1, 2, 3, 4, 5, 6]) - s1.update(u) - self.assertTrue(s1 == e) - - def testUpdate2(self): - s1 = S([1, 2, 3]) - u = [] - e = S([1, 2, 3]) - s1.update(u) - self.assertTrue(s1 == e) - - def testGetitem(self): - s1 = S([1, 2, 3]) - i0 = s1[0] - i1 = s1[1] - i2 = s1[2] - s2 = S([i0, i1, i2]) - self.assertTrue(s1 == s2) - - def testGetslice(self): - s1 = S([1, 2, 3]) - slice = s1[0:2] - self.assertTrue(len(slice) == 2) - item = s1[2] - slice.append(item) - s2 = S(slice) - self.assertTrue(s1 == s2) - - def testDelitem(self): - s1 = S([1, 2, 3]) - del s1[0] - i1 = s1[0] - i2 = s1[1] - self.assertTrue(i1 != i2) - self.assertTrue(i1 == 1 or i1 == 2 or i1 == 3) - self.assertTrue(i2 == 1 or i2 == 2 or i2 == 3) - - def testDelslice(self): - s1 = S([1, 2, 3]) - del s1[0:2] - i1 = s1[0] - self.assertTrue(i1 == 1 or i1 == 2 or i1 == 3) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py deleted file mode 100644 index 8bc33c0..0000000 --- a/tests/test_tokenizer.py +++ /dev/null @@ -1,190 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.exception -import dns.tokenizer - -Token = dns.tokenizer.Token - -class TokenizerTestCase(unittest.TestCase): - - def testQuotedString1(self): - tok = dns.tokenizer.Tokenizer(r'"foo"') - token = tok.get() - self.assertTrue(token == Token(dns.tokenizer.QUOTED_STRING, 'foo')) - - def testQuotedString2(self): - tok = dns.tokenizer.Tokenizer(r'""') - token = tok.get() - self.assertTrue(token == Token(dns.tokenizer.QUOTED_STRING, '')) - - def testQuotedString3(self): - tok = dns.tokenizer.Tokenizer(r'"\"foo\""') - token = tok.get() - self.assertTrue(token == Token(dns.tokenizer.QUOTED_STRING, '"foo"')) - - def testQuotedString4(self): - tok = dns.tokenizer.Tokenizer(r'"foo\010bar"') - token = tok.get() - self.assertTrue(token == Token(dns.tokenizer.QUOTED_STRING, 'foo\x0abar')) - - def testQuotedString5(self): - def bad(): - tok = dns.tokenizer.Tokenizer(r'"foo') - token = tok.get() - self.assertRaises(dns.exception.UnexpectedEnd, bad) - - def testQuotedString6(self): - def bad(): - tok = dns.tokenizer.Tokenizer(r'"foo\01') - token = tok.get() - self.assertRaises(dns.exception.SyntaxError, bad) - - def testQuotedString7(self): - def bad(): - tok = dns.tokenizer.Tokenizer('"foo\nbar"') - token = tok.get() - self.assertRaises(dns.exception.SyntaxError, bad) - - def testEmpty1(self): - tok = dns.tokenizer.Tokenizer('') - token = tok.get() - self.assertTrue(token.is_eof()) - - def testEmpty2(self): - tok = dns.tokenizer.Tokenizer('') - token1 = tok.get() - token2 = tok.get() - self.assertTrue(token1.is_eof() and token2.is_eof()) - - def testEOL(self): - tok = dns.tokenizer.Tokenizer('\n') - token1 = tok.get() - token2 = tok.get() - self.assertTrue(token1.is_eol() and token2.is_eof()) - - def testWS1(self): - tok = dns.tokenizer.Tokenizer(' \n') - token1 = tok.get() - self.assertTrue(token1.is_eol()) - - def testWS2(self): - tok = dns.tokenizer.Tokenizer(' \n') - token1 = tok.get(want_leading=True) - self.assertTrue(token1.is_whitespace()) - - def testComment1(self): - tok = dns.tokenizer.Tokenizer(' ;foo\n') - token1 = tok.get() - self.assertTrue(token1.is_eol()) - - def testComment2(self): - tok = dns.tokenizer.Tokenizer(' ;foo\n') - token1 = tok.get(want_comment = True) - token2 = tok.get() - self.assertTrue(token1 == Token(dns.tokenizer.COMMENT, 'foo') and - token2.is_eol()) - - def testComment3(self): - tok = dns.tokenizer.Tokenizer(' ;foo bar\n') - token1 = tok.get(want_comment = True) - token2 = tok.get() - self.assertTrue(token1 == Token(dns.tokenizer.COMMENT, 'foo bar') and - token2.is_eol()) - - def testMultiline1(self): - tok = dns.tokenizer.Tokenizer('( foo\n\n bar\n)') - tokens = list(iter(tok)) - self.assertTrue(tokens == [Token(dns.tokenizer.IDENTIFIER, 'foo'), - Token(dns.tokenizer.IDENTIFIER, 'bar')]) - - def testMultiline2(self): - tok = dns.tokenizer.Tokenizer('( foo\n\n bar\n)\n') - tokens = list(iter(tok)) - self.assertTrue(tokens == [Token(dns.tokenizer.IDENTIFIER, 'foo'), - Token(dns.tokenizer.IDENTIFIER, 'bar'), - Token(dns.tokenizer.EOL, '\n')]) - def testMultiline3(self): - def bad(): - tok = dns.tokenizer.Tokenizer('foo)') - tokens = list(iter(tok)) - self.assertRaises(dns.exception.SyntaxError, bad) - - def testMultiline4(self): - def bad(): - tok = dns.tokenizer.Tokenizer('((foo)') - tokens = list(iter(tok)) - self.assertRaises(dns.exception.SyntaxError, bad) - - def testUnget1(self): - tok = dns.tokenizer.Tokenizer('foo') - t1 = tok.get() - tok.unget(t1) - t2 = tok.get() - self.assertTrue(t1 == t2 and t1.ttype == dns.tokenizer.IDENTIFIER and \ - t1.value == 'foo') - - def testUnget2(self): - def bad(): - tok = dns.tokenizer.Tokenizer('foo') - t1 = tok.get() - tok.unget(t1) - tok.unget(t1) - self.assertRaises(dns.tokenizer.UngetBufferFull, bad) - - def testGetEOL1(self): - tok = dns.tokenizer.Tokenizer('\n') - t = tok.get_eol() - self.assertTrue(t == '\n') - - def testGetEOL2(self): - tok = dns.tokenizer.Tokenizer('') - t = tok.get_eol() - self.assertTrue(t == '') - - def testEscapedDelimiter1(self): - tok = dns.tokenizer.Tokenizer(r'ch\ ld') - t = tok.get() - self.assertTrue(t.ttype == dns.tokenizer.IDENTIFIER and t.value == r'ch\ ld') - - def testEscapedDelimiter2(self): - tok = dns.tokenizer.Tokenizer(r'ch\032ld') - t = tok.get() - self.assertTrue(t.ttype == dns.tokenizer.IDENTIFIER and t.value == r'ch\032ld') - - def testEscapedDelimiter3(self): - tok = dns.tokenizer.Tokenizer(r'ch\ild') - t = tok.get() - self.assertTrue(t.ttype == dns.tokenizer.IDENTIFIER and t.value == r'ch\ild') - - def testEscapedDelimiter1u(self): - tok = dns.tokenizer.Tokenizer(r'ch\ ld') - t = tok.get().unescape() - self.assertTrue(t.ttype == dns.tokenizer.IDENTIFIER and t.value == r'ch ld') - - def testEscapedDelimiter2u(self): - tok = dns.tokenizer.Tokenizer(r'ch\032ld') - t = tok.get().unescape() - self.assertTrue(t.ttype == dns.tokenizer.IDENTIFIER and t.value == 'ch ld') - - def testEscapedDelimiter3u(self): - tok = dns.tokenizer.Tokenizer(r'ch\ild') - t = tok.get().unescape() - self.assertTrue(t.ttype == dns.tokenizer.IDENTIFIER and t.value == r'child') - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_update.py b/tests/test_update.py deleted file mode 100644 index 471a798..0000000 --- a/tests/test_update.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest - -import dns.update -import dns.rdata -import dns.rdataset - -goodhex = '0001 2800 0001 0005 0007 0000' \ - '076578616d706c6500 0006 0001' \ - '03666f6fc00c 00ff 00ff 00000000 0000' \ - 'c019 0001 00ff 00000000 0000' \ - '03626172c00c 0001 0001 00000000 0004 0a000005' \ - '05626c617a32c00c 00ff 00fe 00000000 0000' \ - 'c049 0001 00fe 00000000 0000' \ - 'c019 0001 00ff 00000000 0000' \ - 'c019 0001 0001 0000012c 0004 0a000001' \ - 'c019 0001 0001 0000012c 0004 0a000002' \ - 'c035 0001 0001 0000012c 0004 0a000003' \ - 'c035 0001 00fe 00000000 0004 0a000004' \ - '04626c617ac00c 0001 00ff 00000000 0000' \ - 'c049 00ff 00ff 00000000 0000' - -goodwire = bytes.fromhex(goodhex.replace(' ', '')) - -update_text="""id 1 -opcode UPDATE -rcode NOERROR -;ZONE -example. IN SOA -;PREREQ -foo ANY ANY -foo ANY A -bar 0 IN A 10.0.0.5 -blaz2 NONE ANY -blaz2 NONE A -;UPDATE -foo ANY A -foo 300 IN A 10.0.0.1 -foo 300 IN A 10.0.0.2 -bar 300 IN A 10.0.0.3 -bar 0 NONE A 10.0.0.4 -blaz ANY A -blaz2 ANY ANY -""" - -class UpdateTestCase(unittest.TestCase): - - def test_to_wire1(self): - update = dns.update.Update('example') - update.id = 1 - update.present('foo') - update.present('foo', 'a') - update.present('bar', 'a', '10.0.0.5') - update.absent('blaz2') - update.absent('blaz2', 'a') - update.replace('foo', 300, 'a', '10.0.0.1', '10.0.0.2') - update.add('bar', 300, 'a', '10.0.0.3') - update.delete('bar', 'a', '10.0.0.4') - update.delete('blaz','a') - update.delete('blaz2') - self.assertTrue(update.to_wire() == goodwire) - - def test_to_wire2(self): - update = dns.update.Update('example') - update.id = 1 - update.present('foo') - update.present('foo', 'a') - update.present('bar', 'a', '10.0.0.5') - update.absent('blaz2') - update.absent('blaz2', 'a') - update.replace('foo', 300, 'a', '10.0.0.1', '10.0.0.2') - update.add('bar', 300, dns.rdata.from_text(1, 1, '10.0.0.3')) - update.delete('bar', 'a', '10.0.0.4') - update.delete('blaz','a') - update.delete('blaz2') - self.assertTrue(update.to_wire() == goodwire) - - def test_to_wire3(self): - update = dns.update.Update('example') - update.id = 1 - update.present('foo') - update.present('foo', 'a') - update.present('bar', 'a', '10.0.0.5') - update.absent('blaz2') - update.absent('blaz2', 'a') - update.replace('foo', 300, 'a', '10.0.0.1', '10.0.0.2') - update.add('bar', dns.rdataset.from_text(1, 1, 300, '10.0.0.3')) - update.delete('bar', 'a', '10.0.0.4') - update.delete('blaz','a') - update.delete('blaz2') - self.assertTrue(update.to_wire() == goodwire) - - def test_from_text1(self): - update = dns.message.from_text(update_text) - w = update.to_wire(origin=dns.name.from_text('example'), - want_shuffle=False) - self.assertTrue(w == goodwire) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_zone.py b/tests/test_zone.py deleted file mode 100644 index 08557ad..0000000 --- a/tests/test_zone.py +++ /dev/null @@ -1,420 +0,0 @@ -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import io -import filecmp -import os -import unittest - -import dns.exception -import dns.rdata -import dns.rdataclass -import dns.rdatatype -import dns.rrset -import dns.zone - -example_text = """$TTL 3600 -$ORIGIN example. -@ soa foo bar 1 2 3 4 5 -@ ns ns1 -@ ns ns2 -ns1 a 10.0.0.1 -ns2 a 10.0.0.2 -$TTL 300 -$ORIGIN foo.example. -bar mx 0 blaz -""" - -example_text_output = """@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.2 -""" - -something_quite_similar = """@ 3600 IN SOA foo bar 1 2 3 4 5 -@ 3600 IN NS ns1 -@ 3600 IN NS ns2 -bar.foo 300 IN MX 0 blaz.foo -ns1 3600 IN A 10.0.0.1 -ns2 3600 IN A 10.0.0.3 -""" - -something_different = """@ 3600 IN SOA fooa bar 1 2 3 4 5 -@ 3600 IN NS ns11 -@ 3600 IN NS ns21 -bar.fooa 300 IN MX 0 blaz.fooa -ns11 3600 IN A 10.0.0.11 -ns21 3600 IN A 10.0.0.21 -""" - -ttl_example_text = """$TTL 1h -$ORIGIN example. -@ soa foo bar 1 2 3 4 5 -@ ns ns1 -@ ns ns2 -ns1 1d1s a 10.0.0.1 -ns2 1w1D1h1m1S a 10.0.0.2 -""" - -no_soa_text = """$TTL 1h -$ORIGIN example. -@ ns ns1 -@ ns ns2 -ns1 1d1s a 10.0.0.1 -ns2 1w1D1h1m1S a 10.0.0.2 -""" - -no_ns_text = """$TTL 1h -$ORIGIN example. -@ soa foo bar 1 2 3 4 5 -""" - -include_text = """$INCLUDE "example" -""" - -bad_directive_text = """$FOO bar -$ORIGIN example. -@ soa foo bar 1 2 3 4 5 -@ ns ns1 -@ ns ns2 -ns1 1d1s a 10.0.0.1 -ns2 1w1D1h1m1S a 10.0.0.2 -""" - -_keep_output = False - -class ZoneTestCase(unittest.TestCase): - - def testFromFile1(self): - z = dns.zone.from_file('example', 'example') - ok = False - try: - z.to_file('example1.out', nl='\x0a') - ok = filecmp.cmp('example1.out', 'example1.good') - finally: - if not _keep_output: - os.unlink('example1.out') - self.assertTrue(ok) - - def testFromFile2(self): - z = dns.zone.from_file('example', 'example', relativize=False) - ok = False - try: - z.to_file('example2.out', relativize=False, nl='\x0a') - ok = filecmp.cmp('example2.out', 'example2.good') - finally: - if not _keep_output: - os.unlink('example2.out') - self.assertTrue(ok) - - def testFromFile2b(self): - """Test to_file with a binary file""" - z = dns.zone.from_file('example', 'example', relativize=False) - ok = False - try: - with open('example2b.out', 'wb') as f: - z.to_file(f, relativize=False, nl='\x0a', binary=True) - ok = filecmp.cmp('example2b.out', 'example2.good') - finally: - if not _keep_output: - os.unlink('example2b.out') - self.assertTrue(ok) - - def testToText(self): - z = dns.zone.from_file('example', 'example') - ok = False - try: - text_zone = z.to_text(nl='\x0a') - f = open('example3.out', 'w') - f.write(text_zone) - f.close() - ok = filecmp.cmp('example3.out', 'example3.good') - finally: - if not _keep_output: - os.unlink('example3.out') - self.assertTrue(ok) - - def testFromText(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - f = io.StringIO() - names = sorted(z.nodes.keys()) - for n in names: - print(z[n].to_text(n), file=f) - self.assertTrue(f.getvalue() == example_text_output) - - def testTorture1(self): - # - # Read a zone containing all our supported RR types, and - # for each RR in the zone, convert the rdata into wire format - # and then back out, and see if we get equal rdatas. - # - f = io.BytesIO() - o = dns.name.from_text('example.') - z = dns.zone.from_file('example', o) - for (name, node) in z.items(): - for rds in node: - for rd in rds: - f.seek(0) - f.truncate() - rd.to_wire(f, origin=o) - wire = f.getvalue() - rd2 = dns.rdata.from_wire(rds.rdclass, rds.rdtype, - wire, 0, len(wire), - origin = o) - self.assertTrue(rd == rd2) - - def testEqual(self): - z1 = dns.zone.from_text(example_text, 'example.', relativize=True) - z2 = dns.zone.from_text(example_text_output, 'example.', - relativize=True) - self.assertTrue(z1 == z2) - - def testNotEqual1(self): - z1 = dns.zone.from_text(example_text, 'example.', relativize=True) - z2 = dns.zone.from_text(something_quite_similar, 'example.', - relativize=True) - self.assertTrue(z1 != z2) - - def testNotEqual2(self): - z1 = dns.zone.from_text(example_text, 'example.', relativize=True) - z2 = dns.zone.from_text(something_different, 'example.', - relativize=True) - self.assertTrue(z1 != z2) - - def testNotEqual3(self): - z1 = dns.zone.from_text(example_text, 'example.', relativize=True) - z2 = dns.zone.from_text(something_different, 'example2.', - relativize=True) - self.assertTrue(z1 != z2) - - def testFindRdataset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rds = z.find_rdataset('@', 'soa') - exrds = dns.rdataset.from_text('IN', 'SOA', 300, 'foo bar 1 2 3 4 5') - self.assertTrue(rds == exrds) - - def testFindRdataset2(self): - def bad(): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rds = z.find_rdataset('@', 'loc') - self.assertRaises(KeyError, bad) - - def testFindRRset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rrs = z.find_rrset('@', 'soa') - exrrs = dns.rrset.from_text('@', 300, 'IN', 'SOA', 'foo bar 1 2 3 4 5') - self.assertTrue(rrs == exrrs) - - def testFindRRset2(self): - def bad(): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rrs = z.find_rrset('@', 'loc') - self.assertRaises(KeyError, bad) - - def testGetRdataset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rds = z.get_rdataset('@', 'soa') - exrds = dns.rdataset.from_text('IN', 'SOA', 300, 'foo bar 1 2 3 4 5') - self.assertTrue(rds == exrds) - - def testGetRdataset2(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rds = z.get_rdataset('@', 'loc') - self.assertTrue(rds == None) - - def testGetRRset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rrs = z.get_rrset('@', 'soa') - exrrs = dns.rrset.from_text('@', 300, 'IN', 'SOA', 'foo bar 1 2 3 4 5') - self.assertTrue(rrs == exrrs) - - def testGetRRset2(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rrs = z.get_rrset('@', 'loc') - self.assertTrue(rrs == None) - - def testReplaceRdataset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rdataset = dns.rdataset.from_text('in', 'ns', 300, 'ns3', 'ns4') - z.replace_rdataset('@', rdataset) - rds = z.get_rdataset('@', 'ns') - self.assertTrue(rds is rdataset) - - def testReplaceRdataset2(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - rdataset = dns.rdataset.from_text('in', 'txt', 300, '"foo"') - z.replace_rdataset('@', rdataset) - rds = z.get_rdataset('@', 'txt') - self.assertTrue(rds is rdataset) - - def testDeleteRdataset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - z.delete_rdataset('@', 'ns') - rds = z.get_rdataset('@', 'ns') - self.assertTrue(rds is None) - - def testDeleteRdataset2(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - z.delete_rdataset('ns1', 'a') - node = z.get_node('ns1') - self.assertTrue(node is None) - - def testNodeFindRdataset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - node = z['@'] - rds = node.find_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) - exrds = dns.rdataset.from_text('IN', 'SOA', 300, 'foo bar 1 2 3 4 5') - self.assertTrue(rds == exrds) - - def testNodeFindRdataset2(self): - def bad(): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - node = z['@'] - rds = node.find_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) - self.assertRaises(KeyError, bad) - - def testNodeGetRdataset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - node = z['@'] - rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) - exrds = dns.rdataset.from_text('IN', 'SOA', 300, 'foo bar 1 2 3 4 5') - self.assertTrue(rds == exrds) - - def testNodeGetRdataset2(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - node = z['@'] - rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) - self.assertTrue(rds == None) - - def testNodeDeleteRdataset1(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - node = z['@'] - rds = node.delete_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) - rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) - self.assertTrue(rds == None) - - def testNodeDeleteRdataset2(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - node = z['@'] - rds = node.delete_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) - rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) - self.assertTrue(rds == None) - - def testIterateRdatasets(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - ns = sorted([n for n, r in z.iterate_rdatasets('A')]) - self.assertTrue(ns == [dns.name.from_text('ns1', None), - dns.name.from_text('ns2', None)]) - - def testIterateAllRdatasets(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - ns = sorted([n for n, r in z.iterate_rdatasets()]) - self.assertTrue(ns == [dns.name.from_text('@', None), - dns.name.from_text('@', None), - dns.name.from_text('bar.foo', None), - dns.name.from_text('ns1', None), - dns.name.from_text('ns2', None)]) - - def testIterateRdatas(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - l = sorted(z.iterate_rdatas('A')) - exl = [(dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2'))] - self.assertTrue(l == exl) - - def testIterateAllRdatas(self): - z = dns.zone.from_text(example_text, 'example.', relativize=True) - l = sorted(z.iterate_rdatas()) - exl = [(dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns1')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, - 'ns2')), - (dns.name.from_text('@', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA, - 'foo bar 1 2 3 4 5')), - (dns.name.from_text('bar.foo', None), - 300, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX, - '0 blaz.foo')), - (dns.name.from_text('ns1', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.1')), - (dns.name.from_text('ns2', None), - 3600, - dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A, - '10.0.0.2'))] - self.assertTrue(l == exl) - - def testTTLs(self): - z = dns.zone.from_text(ttl_example_text, 'example.', relativize=True) - n = z['@'] - rds = n.get_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) - self.assertTrue(rds.ttl == 3600) - n = z['ns1'] - rds = n.get_rdataset(dns.rdataclass.IN, dns.rdatatype.A) - self.assertTrue(rds.ttl == 86401) - n = z['ns2'] - rds = n.get_rdataset(dns.rdataclass.IN, dns.rdatatype.A) - self.assertTrue(rds.ttl == 694861) - - def testNoSOA(self): - def bad(): - z = dns.zone.from_text(no_soa_text, 'example.', - relativize=True) - self.assertRaises(dns.zone.NoSOA, bad) - - def testNoNS(self): - def bad(): - z = dns.zone.from_text(no_ns_text, 'example.', - relativize=True) - self.assertRaises(dns.zone.NoNS, bad) - - def testInclude(self): - z1 = dns.zone.from_text(include_text, 'example.', relativize=True, - allow_include=True) - z2 = dns.zone.from_file('example', 'example.', relativize=True) - self.assertTrue(z1 == z2) - - def testBadDirective(self): - def bad(): - z = dns.zone.from_text(bad_directive_text, 'example.', - relativize=True) - self.assertRaises(dns.exception.SyntaxError, bad) - - def testFirstRRStartsWithWhitespace(self): - # no name is specified, so default to the intial origin - # no ttl is specified, so default to the initial TTL of 0 - z = dns.zone.from_text(' IN A 10.0.0.1', origin='example.', - check_origin=False) - n = z['@'] - rds = n.get_rdataset(dns.rdataclass.IN, dns.rdatatype.A) - self.assertTrue(rds.ttl == 0) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/utest.py b/tests/utest.py deleted file mode 100644 index f3bfaa9..0000000 --- a/tests/utest.py +++ /dev/null @@ -1,10 +0,0 @@ -import os.path -import sys -import unittest - -if __name__ == '__main__': - sys.path.insert(0, os.path.realpath('..')) - suites = unittest.defaultTestLoader.discover('.') - if (not unittest.TextTestRunner(verbosity=2).run(suites).wasSuccessful()): - sys.exit(1) - |
