Ϫf\dZddlZddlZddlZddlmZmZddlmZddl m Z ddl m Z m Z mZddlmZddlmZmZmZdd lmZmZmZmZmZdd lmZdd lmZmZm Z m!Z!m"Z"m#Z#dd l$m%Z%dd l&m'Z'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.dZ/Gddej`Z1ejDddddddddZ2ejDddddd d!d"d#Z3ejDd$d%d&d'dd(d)Z4e1de2fe2ejBd*ejjd+ejld,ejld-d.ejnd/d0ejpd1d23ejrd4ejtd5ejvd6ejxd7d8ejzdd9d:ejzd;dd?d@ejxdAej|dBej~dCdDEejddFGejdHdIJejdKejdLejdd/dMdNdOejdPgejdQdRdSdTgejBdUejBdVgejBdWejBdXgejrdgejBdYgdZ[ZGe1de3fd\ejd]e3gi[ZIe1d^e4fd^e4ejBdYd_`ejjdadb`ejjdcdd`ejdQdRdSdTde`gi[ZJGdfdge.jZLGdhdie.jZMGdjdke.jZNGdldme.jZOGdndoe.jZPGdpdqe.jZQGdrdse.jZRGdtdue.jZSGdvdwe.jZTdxZUGdydze.jZVd{ZWGd|d}e.jZXy)~z Test cases for twisted.names. N)partialreduce)BytesIO)pack)defererrorreactor)succeed)MemoryReactorClockStringTransportwaitUntilAllDisconnected) authorityclientcommondnsserver)Resolver)SOAMessageQueryRecord_A Record_SOARRHeader) DomainError)SecondaryAuthoritySecondaryAuthorityService) nativeString)FilePath)unittestcF|dDcgc]}|jc}Scc}wNrpayload)resultsrs ?/usr/lib/python3/dist-packages/twisted/names/test/test_names.py justPayloadr'!s&qz *!AII ** *sceZdZdZy)NoFileAuthorityc`tjj|||c|_|_yN)r ResolverBase__init__soarecords)selfr.r/s r&r-zNoFileAuthority.__init__&s&$$T*!$g$,N)__name__ __module__ __qualname__r-r1r&r)r)%s.r1r)test-domain.comzroot.test-domain.comdiH?&mnamernameserialrefreshminimumexpireretryttls93.84.28.in-addr.arpaxi1i~Ϊ my-domain.comspostmaster.test-domain.comi90i?B)r=r>r?r@rArBrCs 127.0.0.1s 39.28.189.39#v=spf1 mx/30 mx:example.org/30 -allv=spf1 +mx a:colo.example.com/28 -all not valid host.test-domain.comLinuxA Fast One, Dontcha know)oscpuscanonical.name.comsmailbox.test-domain.comsmail.group.someplaceA First piece of Texta SecoNd pieces ABCD::4321r1 s 0:0069::0ssome.network.tlds$0:5634:1294:AFCB:56AC:48EF:34C3:01FFs tra.la.la.net+Some more text, haha! Yes. Still here?smail.redirect.or.whatevers r mail boxs e mail box)rmailbxemailbxsafsdb.test-domain.com)subtypehostnameswhatever.i.dunnossome.more.text)mboxtxts 12.54.78.12usip+E2U!!^.*$!sip:information@domain.tld!s'AF43:5634:1294:AFCB:56AC:48EF:34C3:01FF?骪ssome.other.place.fool 123.242.1.5 0.255.0.255s255.255.255.254s0.0.0.0s1.2.3.4)r6shttp.tcp.test-domain.comhost.test-domain.comshost-two.test-domain.comscname.test-domain.comsanothertest-domain.comr.r/s123.93.84.28.in-addr.arpastest.host-reverse.lookup.coms my-domain.com1SrDs ns1.domains2Ms ns2.domain3H4DceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ y) ServerDNSTestsz/ Test cases for DNS server and client. c>tjtttgd|_t j|j } tjd|j d}|j|j|jj} tj||d}|j|j ||_||_t'j(d|fg|_y#tj $rYnwxYw)N)verboser 127.0.0.1) interfaceservers)rDNSServerFactorytest_domain_comreverse_domain my_domain_comfactoryrDNSDatagramProtocolr listenTCP addCleanup stopListeninggetHostport listenUDPrCannotListenError listenerTCP listenerUDPrrresolver)r0prrrs r&setUpzServerDNSTests.setUps.. nm .checkResultss')(3O   S133G Hr1) addCallback)r0queryingrrs` ` r& namesTestzServerDNSTests.namesTests  I \*r1c|j|jjdtjddgS)z"Test simple DNS 'A' record queriestest-domain.comrsr9rkrr lookupAddressrrr0s r&test_addressRecord1z"ServerDNSTests.test_addressRecord1s7~~ MM ' '(9 : \\+8 4 5  r1c|j|jjdtjddtjddgS)z1Test DNS 'A' record queries with multiple answersrOz 123.242.1.5r9rkz 0.255.0.255rrs r&test_addressRecord2z"ServerDNSTests.test_addressRecord2sG~~ MM ' '(> ? ]9 ]9   r1c|j|jjdtjddtjddgS)z+Test DNS 'A' record queries with edge caseszhost-two.test-domain.comz255.255.255.254r9rk0.0.0.0rrs r&test_addressRecord3z"ServerDNSTests.test_addressRecord3sH~~ MM ' '(B C .H= YH5   r1cb|j|jjdtgS)zTest DNS 'SOA' record queriesr)rrlookupAuthority soa_recordrs r&test_authorityzServerDNSTests.test_authoritys*~~ MM ) )*; ]]>x 8 9  r1c|j|jjdtjdddgS)zTest DNS 'HINFO' record queriesrrPrQr9)rRrSrD)rrlookupHostInfor Record_HINFOrs r& test_HINFOzServerDNSTests.test_HINFOsA~~ MM ( (): ;  %@h   r1c|j|jjdtjddgS)zTest DNS 'PTR' record queriesz123.93.84.28.in-addr.arpaztest.host-reverse.lookup.comrFrk)rr lookupPointerr Record_PTRrs r&test_PTRzServerDNSTests.test_PTR s8~~ MM ' '(C D ^^: I J  r1c|j|jjdtjddgS)zTest DNS 'CNAME' record queriesrzcanonical.name.comr9rk)rrlookupCanonicalNamer Record_CNAMErs r& test_CNAMEzServerDNSTests.test_CNAME's:~~ MM - -.? @   2 A B  r1c|j|jjdtjddgS)zTest DNS 'MB' record queriesrzmailbox.test-domain.comr9rk)rr lookupMailBoxr Record_MBrs r&test_MBzServerDNSTests.test_MB.s8~~ MM ' '(9 : ]]4( C D  r1c|j|jjdtjddgS)zTest DNS 'MG' record queriesrzmail.group.someplacer9rk)rrlookupMailGroupr Record_MGrs r&test_MGzServerDNSTests.test_MG5s8~~ MM ) )*; < ]]1x @ A  r1c|j|jjdtjddgS)zTest DNS 'MR' record queriesrzmail.redirect.or.whateverr9rk)rrlookupMailRenamer Record_MRrs r&test_MRzServerDNSTests.test_MR<s8~~ MM * *+< = ]]6H E F  r1c|j|jjdtjdddgS)zTest DNS 'MINFO' record queriesrz r mail boxz e mail boxr9)rYrZrD)rrlookupMailboxInfor Record_MINFOrs r& test_MINFOzServerDNSTests.test_MINFOCs@~~ MM + +,= >  (,H   r1c |j|jjdtjdddddgS)zTest DNS 'SRV' record querieszhttp.tcp.test-domain.comrcrdresome.other.place.foolr9rk)rr lookupServicer Record_SRVrs r&test_SRVzServerDNSTests.test_SRVNs>~~ MM ' '(B C ^^C/FH U V  r1c|j|jjdtjdddgS)zTest DNS 'AFSDB' record queriesrr;zafsdb.test-domain.comr9)r[r\rD)rrlookupAFSDatabaser Record_AFSDBrs r& test_AFSDBzServerDNSTests.test_AFSDBUsA~~ MM + +,= >  (?X   r1c|j|jjdtjdddgS)zTest DNS 'RP' record queriesrzwhatever.i.dunnozsome.more.textr9)r]r^rD)rrlookupResponsibilityr Record_RPrs r&test_RPzServerDNSTests.test_RP`s?~~ MM . ./@ A +1Ax   r1c|j|jjdtjdddtjddgS)zTest DNS 'TXT' record queriesrrTrUr9rkrX)rr lookupTextr Record_TXTrs r&test_TXTzServerDNSTests.test_TXTksR~~ MM $ $%6 7,.?XC    r1c |j|jjdtjddtjdddgS)zH L{DNSServerFactory} can serve I{SPF} resource records. rrKr9rkrLrM)rrlookupSenderPolicyr Record_SPFrs r&test_spfzServerDNSTests.test_spfysQ~~ MM , ,-> ?E8T*5    r1c |j|jjdtjdt j ddgS)zTest DNS 'WKS' record queriesrz 12.54.78.12r_r9rk)rrlookupWellKnownServicesr Record_WKSsocket IPPROTO_TCPrs r&test_WKSzServerDNSTests.test_WKSsI~~ MM 1 12C D!&&3    r1cltjt}tj|_|j |j j d|tjddtjddtjddtjd d d d d gS)NrI1.2.3.4rjrkz ns1.domain2Mz ns2.domainrlrcrdrerrm) copymy_soarBrDrrlookupAllRecordsrrrr)r0 result_soas r&test_someRecordsWithTTLsz'ServerDNSTests.test_someRecordsWithTTLssYYv&  ~~ MM * *? ; YD1 l5 l5sE52ItT    r1c|j|jjdtjddgS)z%Test DNS 'AAAA' record queries (IPv6)rz'AF43:5634:1294:AFCB:56AC:48EF:34C3:01FFr9rk)rrlookupIPV6Addressr Record_AAAArs r& test_AAAAzServerDNSTests.test_AAAAs8~~ MM + +,= > __FH U V  r1c |j|jjdtjddddtjddd dtjd d d dgS) z#Test DNS 'A6' record queries (IPv6)rrz ABCD::4321r9rkrVz 0:0069::0zsome.network.tldrWz$0:5634:1294:AFCB:56AC:48EF:34C3:01FFz tra.la.la.net)rrlookupAddress6r Record_A6rs r&test_A6zServerDNSTests.test_A6sh~~ MM ( (): ; arx@ b+/AxP :#    r1ctj}ttjt j jDcgc]}tj|}}|D]}|j||_ |j|jjdjd|Scc}w)z9 Test DNS 'AXFR' queries (Zone transfer) rc|dddfS)Nrr5)r%s r&z2ServerDNSTests.test_zoneTransfer..s1Q49,r1)rrBroperatoraddrxr/valuesrrDrr lookupZoner)r0 default_ttlr%r$s r&test_zoneTransferz ServerDNSTests.test_zoneTransfers!'' "(7N7N7U7U7W"X DIIaL   $Auu}# $~~ MM $ $%6 7 C C&      s B=cztdg}|j|jdtjS)zu A failed AXFR TCP connection errbacks the L{Deferred} returned from L{Resolver.lookupZone}. )znameserver.invalid5ruzimpossible.invalid)r assertFailurerrDNSLookupError)r0rs r& test_zoneTransferConnectionFailsz/ServerDNSTests.test_zoneTransferConnectionFailss< %?$@A!!    4 5u7K7K  r1c|j|jjdtjddgS)z6Tests that unrelated zones don't mess with each other.zanothertest-domain.comrr9rkrrs r&test_similarZonesDontInterferez-ServerDNSTests.test_similarZonesDontInterferes7~~ MM ' '(@ A \\) 2 3  r1c |j|jjdtjddddddgS) z2 Test DNS 'NAPTR' record queries. rr7rNr`rarbr9rk)rrlookupNamingAuthorityPointerr Record_NAPTRrs r& test_NAPTRzServerDNSTests.test_NAPTRsM~~ MM 6 67H I  8    r1N)!r2r3r4__doc__rrrrrrrrrrrrrrrrrrrrrrrrrrrr r r5r1r&rorosG< N.                             $   r1roceZdZdZy) HelperTestsc|j}tj|}tdD]-}tj|}|j ||k|}/y)N)mktempr getSerialrange assertTrue)r0faibs r&test_serialGeneratorz HelperTests.test_serialGeneratorsU KKM    "r A##A&A OOAE "A r1N)r2r3r4rr5r1r&rrsr1rc*eZdZdZdZdZdZdZy) AXFRTestscd|_tj|_|jj |j t jd|j|_tjdtjtjddtjddddddd d  |_|jtjdtjtjd dtj dd  tjdtj"tjd dtj$ddd  tjdtj&tjd dtj(dd  |jg|_y)N fooby.comiQFzhooj.fooby.comr7i,iiiX)r=r>r?r@rCrBrArDnametypeclsrDauthr#ns.twistedmatrix.comr"rDrNz mail.mv3d.com) preferenceexchangerDz 64.123.27.105)addressrD)r$rDeferreddr _gotResultsrAXFRController controllerrrrINrr.NSrMXrArr/rs r&rzAXFRTests.setUpsH ! 4++, // TVVD<<NN!&   & HH LL VVFF +AsK   LL VVFF oSVW   LL UUFF _#F   HH5  r1c >tjddddddddd S)Nr;r idansweropCoderecDesrecAvr%rCodetruncmaxSize)rrrs r& _makeMessagezAXFRTests._makeMessage2s.{{  r1c<|j}tjdtjtjg|_|j |_|jj|d|j|j|j y)Nr) r@rrAXFRr1queriesr/answersr0messageReceivedrr$)r0ms r&test_bindAndTNamesStylez!AXFRTests.test_bindAndTNamesStyle@sf    YY{CHHcff=> LL  ''40 t||4r1c||_yr+)r$)r0results r&r.zAXFRTests._gotResultsHs  r1c |jdd}|rM|j}g|_|jdg|_|j j |d|rM|j|j|jyr!) r/r@rCpoprDr0rErr$)r0r/rFs r& test_DJBStylezAXFRTests.test_DJBStyleKsl,,q/!!#AAI Q(AI OO + +At 4  t||4r1N)r2r3r4rr@rGr.rLr5r1r&rrs3 j  55r1rceZdZdZdZy)ResolvConfHandlingTestsc|j}tj|}|j|jdg|j j y)Nresolvrsr)rrrr dynServers _parseCallcancelr0 resolvConfr%s r& test_missingz$ResolvConfHandlingTests.test_missingWsC[[] OO: . (9':; r1c|j}t|djtj|}|j |j dg|jjy)NwrPrR) ropencloserrrrSrTrUrVs r& test_emptyz"ResolvConfHandlingTests.test_empty]sV[[]  Z##% OO: . (9':; r1N)r2r3r4rXr]r5r1r&rNrNVs  r1rNc:eZdZdZdZdZdZdZdZdZ dZ y ) AuthorityTestszs Tests for the basic response record selection code in L{FileAuthority} (independent of its fileness). ct}d|jdz}|j|j|}|j |j t y)aJ L{FileAuthority} lookup methods errback with L{DomainError} if the requested C{name} shares a common suffix with its zone but is not actually a descendant of its zone, in terms of its sequence of DNS name labels. eg www.the-example.com has nothing to do with the zone example.com. nonexistent.prefix-rN)rxr.failureResultOfrassertIsInstancevaluer)r0 testDomaintestDomainNamers r&'test_domainErrorForNameWithCommonSuffixz6AuthorityTests.test_domainErrorForNameWithCommonSuffixksK% /*..2CC  !9!9.!I J agg{3r1c Httjjtftjjtt j dgi}|j |jtjj\}}}|j|g|j|t jtjjtjtjtdg|j|gy)a! If a L{FileAuthority} has a zone which includes an I{NS} record for a particular name and that authority is asked for another record for the same name which does not exist, the I{NS} record is not included in the authority section of the response. rriTrDr#r%N) r)rr=r"rrsuccessResultOfrrrTYPErB)r0rr9 additionals r&test_recordMissingz!AuthorityTests.test_recordMissingxs$!!&& 3  %%MM),( )-(<(< #I # #J$4$4$9$9 :) % : $   $$))OO"))&    R(r1ct}d|jdz}ttjdz}|j |j t||}|j|jty)z Requesting a record of unknown type where no records exist for the name in question results in L{DomainError}. rarr;r"r#N) rxr.maxr typeToMethodrbqueryrrcrdr)r0rerf unknownTypers r&test_unknownTypeNXDOMAINz'AuthorityTests.test_unknownTypeNXDOMAINsl % /*..2CC&--.2    U[I J  agg{3r1cttjdz}|jtj t d|\}}}|j|gy)z Requesting a record of unknown type where other records exist for the name in question results in an empty answer set. r;rIroN)rprrqrjrzrrrr)r0rsr9rrls r&test_unknownTypeMissingz&AuthorityTests.test_unknownTypeMissingsW &--.2 (,(<(<   ? M N) % : $r1c dtjjz}tjd}t tjjtf||gi}t |||}|j|\}}}|j|g|j|tj|tjtj|dg|j|gy)z Create an authority and make a request against it. Then verify that the result is a referral, including no records in the answers or additional sections, but with an I{NS} record in the authority section. sexample.rriFriN) rr=r"rrr)getattrrjrrr2rB)r0method subdomain nameserverrr-r9rls r& _referralTestzAuthorityTests._referralTests  *"2"2"7"77 ]]9- #!!&& 3  'GIv &y 1(,(<(AdditionalProcessingTests.assertRecordsMatch..$s r1)keyN)rsorted)r0expectedcomputedrs r&assertRecordsMatchz,AdditionalProcessingTests.assertRecordsMatchs'$! c2F84MNr1c Ddtjjz}|j|t|||}|j |\}}}|j |D cgc]4} t j|| jtj| d6c} |ycc} w)aT Verify that certain address records are included in the I{additional} section of a response generated by L{FileAuthority}. @param method: See L{_lookupSomeRecords} @param makeRecord: See L{_lookupSomeRecords} @param addresses: A L{list} of L{IRecord} providers which the I{additional} section of the response is required to match (ignoring order). @raise self.failureException: If the I{additional} section of the response consists of different records than those given by C{addresses}. smail.TriN) rr=r"rrjrrrrkrB) r0ryrrrr-r9rrlr+s r&_additionalTestz)AdditionalProcessingTests._additionalTest's"J,,111  # #FJ FI V(,(<(.querys8<<?+ +r1cRtjtjdS)NzCouldn't connect)rfailrgaierror)r0rkwargss r& queryProtocolz;NoInitialResponseTests.test_noAnswer..queryProtocols::foo.@AB Br1)rrrurrz fooba.comr&Fr'r(r!r6r;rr7r)r_querypatchrr|rr2r1rrrDappendr getHostByNamerr)r0rrrrr/rFrs @r& test_noAnswerz$NoInitialResponseTests.test_noAnswers  ,  C^$45 3**G]C LL VVFF +AsK     KK  !!("8"8"EvWWr1N)r2r3r4rr5r1r&rrs,Xr1rc"eZdZdZdZdZdZy)SecondaryAuthorityServiceTestsz Tests for L{SecondaryAuthorityService}, a service which keeps one or more authorities up to date by doing zone transfers from a master. cd}t|ddg}|j|j||j|jd|j|jdj||j|jdjd|j|jdj d|j|jdj||j|jdjd|j|jdj dy) a L{SecondaryAuthorityService} can be constructed with a C{str} giving a master server address and several domains, causing the creation of a secondary authority for each domain and that master server address and the default DNS port. 192.168.1.2 example.comz example.orgrrr;s example.orgN)rrprimary_portdomainsdomainr0rservices r&test_constructAuthorityFromHostz>SecondaryAuthorityServiceTests.test_constructAuthorityFromHosts +Gnm5TU '2 + +33W= +1126 +22NC +33W= +1126 +22NCr1cd}d}tj||fddg}|j|j||j|jd|j|j dj||j|j dj||j|j dj d|j|j dj||j|j dj||j|j dj dy) a\ L{SecondaryAuthorityService.fromServerAddressAndDomains} constructs a new L{SecondaryAuthorityService} from a C{str} giving a master server address and DNS port and several domains, causing the creation of a secondary authority for each domain and that master server address and the given DNS port. 192.168.1.3iz example.net example.edur example.netr;N)rfromServerAddressAndDomainsrrrrr)r0rrrs r&&test_constructAuthorityFromHostAndPortzESecondaryAuthorityServiceTests.test_constructAuthorityFromHostAndPort s +GG dOm^<  '2 - +33W= +1148 +22NC +33W= +1148 +22NCr1cd}t|jddg}|j|j||j|jdj||j|jdj d|j|jdj||j|jdj dy)aQ L{SecondaryAuthorityService.fromServerAddressAndDomains} constructs a new L{SecondaryAuthorityService} from a C{bytes} giving a master server address and several domains, causing the creation of a secondary authority for each domain and that master server address and the given DNS port. rrz example.edurr;rN)rencoderrrrrs r& test_constructAuthorityFromBytesz?SecondaryAuthorityServiceTests.test_constructAuthorityFromBytes#s + NN  ] +  '2 +33W= +22NC +33W= +22NCr1N)r2r3r4rrrrr5r1r&rrs D(D0Dr1rc(eZdZdZdZdZdZdZy)SecondaryAuthorityTestsz L{twisted.names.secondary.SecondaryAuthority} correctly constructs objects with a specified IP address and optionally specified DNS port. ctdd}|j|jd|j|jd|j|jdy)zp When constructed using L{SecondaryAuthority.__init__}, the default port of 53 is used. 192.168.1.1 inside.comr inside.comN)rrrrrr0 secondarys r&test_defaultPortz(SecondaryAuthorityTests.test_defaultPort?sP '}lC  **M: "- ))=9r1ctjdd}|j|jd|j|jd|j|j dy)z~ When constructed using L{SecondaryAuthority.fromServerAddressAndDomain}, the specified port is used. )rrrrrN)rfromServerAddressAndDomainrrrrrs r&test_explicitPortz)SecondaryAuthorityTests.test_explicitPortIs[ 'AA !<  **M: $/ ))=9r1c^tjdd}tx|_}|j |j j d\}}}}}|j|d|j|d|j||f}t} |j| t} | jt| jdd|jtj dtj"tj$g| j&y)z An attempt is made to transfer the zone for the domain the L{SecondaryAuthority} was constructed with from the server address it was constructed with when L{SecondaryAuthority.transfer} is called. rr8 example.comrrr8rqN)rrr _reactortransfer tcpClientsrKr buildProtocolr makeConnectionrdecoderrdrrrBr1rC) r0rr hostrr{timeout bindAddressprotormsgs r& test_transferz%SecondaryAuthorityTests.test_transferUs 'AA != (:';; W5<4F4F4J4J14M1dGWk }- t$%%tTl3#%  Y'i 79??,QR012 #))M388SVVDEs{{Sr1c ttjdd}tx|_}|j |j j d\}}}}}|j||f}t} |j| tdd} | jt| jddtdd d d d d dd} tdd} t| j dd} | j"j%t'dt(| t'd| t'dt(| g| j+}|j-t/dt1||z|j3|j5d}|j7t'd| dgggf|y)z L{SecondaryAuthority.lookupAddress} returns a L{Deferred} that fires with the I{A} records the authority has cached from the primary. rrrr;)r9r%rqNsns1.example.comzadmin.example.comi@iii i%i.r<s 192.168.1.2rk)r8r9r%)r#r#r"z!HrT)r#r%)rrr rrrrKrr rrrrrdrrr8rDextendrrtoStr dataReceivedrlenrjrr)r0rr rrr{rrrrrrr.rr9datarIs r&test_lookupAddressz*SecondaryAuthorityTests.test_lookupAddressss 'AA !> (:';; W4;4F4F4J4J14M1dGWk%%tTl3#%  Y'qq) WY__.qr234$%   ^ +EHHQQ7c3?3c3?  ||~ 4c$i0478%%i&=&=m&LM ~qt< =r2 F r1N)r2r3r4rrrrrr5r1r&rr9s : :T<0 r1rsY$ORIGIN example.com. $TTL 1w example.com. IN SOA dns.example.com ( 2013120201 ; serial number of this zone file 1d ; slave refresh 2h ; slave retry time in case of a problem 4w ; slave expiration time 1h ; maximum caching time in case of failed lookups ) ; A comment. @ IN AAAA 2001:db8:10::1 example.com. IN A 10.0.0.1 no-in.example.com. A 10.0.0.2 ; technically wrong but used to work not-fqdn IN MX 10 mx.example.com www IN CNAME example.comcLeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z y ) BindAuthorityTestsz= Tests for L{twisted.names.authority.BindAuthority}. ct|jjd}|j|t j |j S)z Create a new L{twisted.names.authority.BindAuthority} from C{s}. @param s: A string with BIND zone data. @type s: bytes @return: a new bind authority @rtype: L{twisted.names.authority.BindAuthority} ascii)rrr setContentr BindAuthoritypath)r0sfps r&loadBindStringz!BindAuthorityTests.loadBindStrings@dkkm**73 4 a&&rww//r1c8|jt|_yr+)rsampleBindZoner%rs r&rzBindAuthorityTests.setUps''7 r1c|jjjD]>}|jj|D] }|jd|jk("@y)zG Loads the default $TTL and applies it to all records. : N)r%r/keysrrD)r0domrecs r&test_ttlzBindAuthorityTests.test_ttlsY99$$))+ 3Cyy((- 3#'' 12 3 3r1c|jd|jj|jd|jjy)z, Loads the default $ORIGIN. s example.com.not-fqdn.example.comN)rr%originassertInr/rs r&test_originFromFilez&BindAuthorityTests.test_originFromFiles@   II    # II   r1cdD]g\}}|j|jj|\\}\\|jt j |d|j iy)' A records are loaded. )rz10.0.0.1)no-in.example.comz10.0.0.2rNrjr%rrrrr#r0r iprs r& test_aRecordsz BindAuthorityTests.test_aRecordssi GC"11$))2I2I#2NONTb2r       r1c|j|jjd\\}\\|jt j dd|j y)* AAAA records are loaded. r2001:db8:10::1rNrjr%rrrrr#r0rs r&test_aaaaRecordsz#BindAuthorityTests.test_aaaaRecordssY-- II ' ' 7 "r2  OO   JJ  r1c|j|jjd\\}\\|jt j ddd|j y)( MX records are loaded. rrNzmx.example.comr)r)r"rDNrjr%rrrrr#rs r&test_mxRecordsz!BindAuthorityTests.test_mxRecordss]-- II ( ()@ A "r2  MM%  JJ  r1c|j|jjd\}\\|d}|jt j dd|j y)+ CNAME records are loaded. www.example.comrrrr(Nrjr%rrrrr#r0rDrs r&test_cnameRecordsz$BindAuthorityTests.test_cnameRecordssd!00 II ' '(: ; "bQZ    "  JJ  r1c|jt5}|jdddd|jdjj dy#1swY3xYw)zO loadBindString raises NotImplementedError on invalid records. sexample.com. IN LOL 192.168.0.1NzRecord type 'LOL' not supportedr) assertRaisesNotImplementedErrorrr exceptionr)r0es r&test_invalidRecordClassz*BindAuthorityTests.test_invalidRecordClass%s]  2 3 Dq    B C D :AKKrVs   %22* A@)QQ+Q.,"+.i--.S^^         cnn " "           '     " Z(  CLL & CMM/ * CNNA B CNN13T U CMM"4 5 C  .I J C  2 3 CMM4 5 CMM1 2 CNN35F G CMM!]C 0 CMM"l,? @ CMM!DFV W CNNJ K CMM6 7 C  ]M J C  Q1I J CMM28I J CNN 2 24S  C  Rz+O  COOF G5 : CNN3u.F G&  CLL ( CLL ("  CLL+ , CLL $ & $43#3#34F#G"H$0CLL$<#=[. 1f! !;/$ CNN: ; '   6"  CLL . CMM-U 3 CMM-T 2 CNN3u.FD Q     W X&&W t (##W5!!W5t h// {/X&&{/|[5 1 1[5|-XX..-X`EDX%6%6EDPj h//j Z+&~**~B(VdLX..dLr1