
    Yf\                        d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZmZmZ ddlmZ ddlmZmZmZ dd	lmZmZmZmZmZ dd
lmZ ddlmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. d Z/ G d dej0                  Z1 ej"        dddddddd          Z2 ej"        ddddd d!d"d#          Z3 ej"        d$d%d&d'dd(d)          Z4 e1de2fe2 ej!        d*           ej5        d+           ej6        d,           ej6        d-d.           ej7        d/d0           ej8        d1d23           ej9        d4           ej:        d5           ej;        d6           ej<        d7d8           ej=        dd9d:           ej=        d;d<d=           ej=        d>d?d@           ej<        dA           ej>        dB           ej?        dCdDE           ej@        ddFG           ejA        dHdIJ           ejB        dKejC        dL           ejD        dd/dMdNdO           ejE        dP          g ejF        dQdRdSdT          g ej!        dU           ej!        dV          g ej!        dW           ej!        dX          g ej9        d          g ej!        dY          gdZ[          ZG e1de3fd\ ejH        d]          e3gi[          ZI e1d^e4fd^e4 ej!        dYd_`           ej5        dadb`           ej5        dcdd`           ejF        dQdRdSdTde`          gi[          ZJ G df dge.jK                  ZL G dh die.jK                  ZM G dj dke.jK                  ZN G dl dme.jK                  ZO G dn doe.jK                  ZP G dp dqe.jK                  ZQ G dr dse.jK                  ZR G dt due.jK                  ZS G dv dwe.jK                  ZTdxZU G dy dze.jK                  ZVd{ZW G d| d}e.jK                  ZXdS )~z
Test cases for twisted.names.
    N)partialreduce)BytesIO)pack)defererrorreactor)succeed)MemoryReactorClockStringTransportwaitUntilAllDisconnected)	authorityclientcommondnsserver)Resolver)SOAMessageQueryRecord_A
Record_SOARRHeader)DomainError)SecondaryAuthoritySecondaryAuthorityService)nativeString)FilePath)unittestc                 &    d | d         D             S )Nc                     g | ]	}|j         
S  payload.0rs     O/var/www/html/env/lib/python3.11/site-packages/twisted/names/test/test_names.py
<listcomp>zjustPayload.<locals>.<listcomp>"   s    ***!AI***    r   r"   resultss    r(   justPayloadr-   !   s    **wqz****r*   c                       e Zd Zd ZdS )NoFileAuthorityc                 b    t           j                            |            ||c| _        | _        d S N)r   ResolverBase__init__soarecords)selfr4   r5   s      r(   r3   zNoFileAuthority.__init__&   s-    $$T***!$g$,,,r*   N)__name__
__module____qualname__r3   r"   r*   r(   r/   r/   %   s#        . . . . .r*   r/      test-domain.comzroot.test-domain.comd     i  H?&      mnamernameserialrefreshminimumexpireretryttls   93.84.28.in-addr.arpax   i1  i~  Ϊ       my-domain.coms   postmaster.test-domain.com   i90  i?B )rA   rB   rC   rD   rE   rF   rG   s	   127.0.0.1s   39.28.189.39#   v=spf1 mx/30 mx:example.org/30 -all   v=spf1 +mx a: colo   .example.com/28 -all not valid
   host.test-domain.com   Linux   A Fast One, Dontcha know)oscpus   canonical.name.coms   mailbox.test-domain.coms   mail.group.someplace   A First piece of Text   a SecoNd pieces
   ABCD::4321r*      s	   0:0069::0s   some.network.tld   s$   0:5634:1294:AFCB:56AC:48EF:34C3:01FFs   tra.la.la.net+   Some more text, haha!  Yes.     Still here?s   mail.redirect.or.whatevers
   r mail boxs
   e mail box)rmailbxemailbxs   afsdb.test-domain.com)subtypehostnames   whatever.i.dunnos   some.more.text)mboxtxts   12.54.78.12       u   sip+E2U!   !^.*$!sip:information@domain.tld!s'   AF43:5634:1294:AFCB:56AC:48EF:34C3:01FF  ?  骪  s   some.other.place.fool   123.242.1.5   0.255.0.255s   255.255.255.254s   0.0.0.0s   1.2.3.4)r:   s   http.tcp.test-domain.com   host.test-domain.coms   host-two.test-domain.coms   cname.test-domain.coms   anothertest-domain.comr4   r5   s   123.93.84.28.in-addr.arpas   test.host-reverse.lookup.coms   my-domain.com1SrH   s
   ns1.domains   2Ms
   ns2.domain3H4Dc                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z dS ) ServerDNSTestsz/
    Test cases for DNS server and client.
    c                    t          j        t          t          t          gd          | _        t          j        | j                  }	 t          j	        d| j        d          }| 
                    |j                   |                                j        }	 t          j        ||d          }| 
                    |j                   n# t          j        $ r Y nw xY w|| _        || _        t'          j        d|fg          | _        d S )N   )verboser?   r   	127.0.0.1)	interfaceservers)r   DNSServerFactorytest_domain_comreverse_domainmy_domain_comfactoryr   DNSDatagramProtocolr	   	listenTCP
addCleanupstopListeninggetHostport	listenUDPr   CannotListenErrorlistenerTCPlistenerUDPr   r   resolver)r6   pr   r   r   s        r(   setUpzServerDNSTests.setUp   s   .nm<a
 
 
 #DL11	!+At|{SSSK OOK5666&&((-D%/a;OOO  9:::	 *   	& '&+t1D0EFFFs   C
 
CCc                     | j         j        dd         D ]}|j                                         t	          t
          | j         j        dd                   S )zu
        Clean up any server connections associated with the
        L{DNSServerFactory} created in L{setUp}
        N)r   connections	transportloseConnectionr   r	   )r6   conns     r(   tearDownzServerDNSTests.tearDown   sV     L,QQQ/ 	, 	,DN))++++'1I!!!1LMMMr*   c                 @      fd}|                     |           |S )aD  
        Assert that the DNS response C{querying} will eventually fire with
        contains exactly a certain collection of records.

        @param querying: A L{Deferred} returned from one of the DNS client
            I{lookup} methods.

        @param expectedRecords: A L{list} of L{IRecord} providers which must be
            in the response or the test will be failed.

        @return: A L{Deferred} that fires when the assertion has been made.  It
            fires with a success result if the assertion succeeds and with a
            L{Failure} if it fails.
        c                     t          |           }                    t                    t          |                     d S r1   )r-   assertEqualset)responsereceivedRecordsexpectedRecordsr6   s     r(   checkResultsz.ServerDNSTests.namesTest.<locals>.checkResults   s<    )(33OS1133G3GHHHHHr*   )addCallback)r6   queryingr   r   s   ` ` r(   	namesTestzServerDNSTests.namesTest   sC     	I 	I 	I 	I 	I 	I 	\***r*   c                     |                      | j                            d          t          j        dd          g          S )z"Test simple DNS 'A' record queriestest-domain.comrw   r=   ro   r   r   lookupAddressr   r   r6   s    r(   test_addressRecord1z"ServerDNSTests.test_addressRecord1   sA    ~~M''(9::\+84445
 
 	
r*   c                     |                      | j                            d          t          j        dd          t          j        dd          g          S )z1Test DNS 'A' record queries with multiple answersrS   z123.242.1.5r=   ro   z0.255.0.255r   r   s    r(   test_addressRecord2z"ServerDNSTests.test_addressRecord2   sU    ~~M''(>??]999]999
 
 	
r*   c                     |                      | j                            d          t          j        dd          t          j        dd          g          S )z+Test DNS 'A' record queries with edge caseszhost-two.test-domain.comz255.255.255.254r=   ro   0.0.0.0r   r   s    r(   test_addressRecord3z"ServerDNSTests.test_addressRecord3   sV    ~~M''(BCC.H===YH555
 
 	
r*   c                 j    |                      | j                            d          t          g          S )zTest DNS 'SOA' record queriesr   )r   r   lookupAuthority
soa_recordr   s    r(   test_authorityzServerDNSTests.test_authority   s0    ~~M))*;<<zl
 
 	
r*   c           	          |                      | j                            d          t          j        ddd          t          j        dd          t          j        dd          g          S )z
        The DNS client can issue an MX query and receive a response including
        an MX record as well as any A record hints.
        r:   rR   rl   r=   ro   rj   rk   )r   r   lookupMailExchanger   	Record_MXr   r   s    r(   test_mailExchangeRecordz&ServerDNSTests.test_mailExchangeRecord   sl    
 ~~M,,-?@@b"9xHHH^:::^:::
 
 	
r*   c                     |                      | j                            d          t          j        dd          g          S )zTest DNS 'NS' record queriesr   z39.28.189.39r=   ro   )r   r   lookupNameserversr   	Record_NSr   s    r(   test_nameserverzServerDNSTests.test_nameserver  sA    ~~M++,=>>]>x8889
 
 	
r*   c                     |                      | j                            d          t          j        ddd          g          S )zTest DNS 'HINFO' record queriesr   rT   rU   r=   )rV   rW   rH   )r   r   lookupHostInfor   Record_HINFOr   s    r(   
test_HINFOzServerDNSTests.test_HINFO  sN    ~~M(():;; %@h  
 
 	
r*   c                     |                      | j                            d          t          j        dd          g          S )zTest DNS 'PTR' record queriesz123.93.84.28.in-addr.arpaztest.host-reverse.lookup.comrJ   ro   )r   r   lookupPointerr   
Record_PTRr   s    r(   test_PTRzServerDNSTests.test_PTR   sB    ~~M''(CDD^:IIIJ
 
 	
r*   c                     |                      | j                            d          t          j        dd          g          S )zTest DNS 'CNAME' record queriesr   zcanonical.name.comr=   ro   )r   r   lookupCanonicalNamer   Record_CNAMEr   s    r(   
test_CNAMEzServerDNSTests.test_CNAME'  sC    ~~M--.?@@2AAAB
 
 	
r*   c                     |                      | j                            d          t          j        dd          g          S )zTest DNS 'MB' record queriesr   zmailbox.test-domain.comr=   ro   )r   r   lookupMailBoxr   	Record_MBr   s    r(   test_MBzServerDNSTests.test_MB.  sB    ~~M''(9::]4(CCCD
 
 	
r*   c                     |                      | j                            d          t          j        dd          g          S )zTest DNS 'MG' record queriesr   zmail.group.someplacer=   ro   )r   r   lookupMailGroupr   	Record_MGr   s    r(   test_MGzServerDNSTests.test_MG5  sB    ~~M))*;<<]1x@@@A
 
 	
r*   c                     |                      | j                            d          t          j        dd          g          S )zTest DNS 'MR' record queriesr   zmail.redirect.or.whateverr=   ro   )r   r   lookupMailRenamer   	Record_MRr   s    r(   test_MRzServerDNSTests.test_MR<  sB    ~~M**+<==]6HEEEF
 
 	
r*   c                     |                      | j                            d          t          j        ddd          g          S )zTest DNS 'MINFO' record queriesr   z
r mail boxz
e mail boxr=   )r]   r^   rH   )r   r   lookupMailboxInfor   Record_MINFOr   s    r(   
test_MINFOzServerDNSTests.test_MINFOC  sM    ~~M++,=>> (,H  
 
 	
r*   c           
          |                      | j                            d          t          j        ddddd          g          S )zTest DNS 'SRV' record querieszhttp.tcp.test-domain.comrg   rh   ri   some.other.place.foolr=   ro   )r   r   lookupServicer   
Record_SRVr   s    r(   test_SRVzServerDNSTests.test_SRVN  sH    ~~M''(BCC^C/FHUUUV
 
 	
r*   c                     |                      | j                            d          t          j        ddd          g          S )zTest DNS 'AFSDB' record queriesr   r?   zafsdb.test-domain.comr=   )r_   r`   rH   )r   r   lookupAFSDatabaser   Record_AFSDBr   s    r(   
test_AFSDBzServerDNSTests.test_AFSDBU  sN    ~~M++,=>> (?X  
 
 	
r*   c                     |                      | j                            d          t          j        ddd          g          S )zTest DNS 'RP' record queriesr   zwhatever.i.dunnozsome.more.textr=   )ra   rb   rH   )r   r   lookupResponsibilityr   	Record_RPr   s    r(   test_RPzServerDNSTests.test_RP`  sM    ~~M../@AA+1Ax  
 
 	
r*   c                     |                      | j                            d          t          j        ddd          t          j        dd          g          S )zTest DNS 'TXT' record queriesr   rX   rY   r=   ro   r\   )r   r   
lookupTextr   
Record_TXTr   s    r(   test_TXTzServerDNSTests.test_TXTk  sh    ~~M$$%677,.?X   C  	

 

 
	
r*   c           	          |                      | j                            d          t          j        dd          t          j        ddd          g          S )zH
        L{DNSServerFactory} can serve I{SPF} resource records.
        r   rO   r=   ro   rP   rQ   )r   r   lookupSenderPolicyr   
Record_SPFr   s    r(   test_spfzServerDNSTests.test_spfy  sc     ~~M,,->??E8TTT*5   

 

 
	
r*   c           	          |                      | j                            d          t          j        dt
          j        dd          g          S )zTest DNS 'WKS' record queriesr   z12.54.78.12rc   r=   ro   )r   r   lookupWellKnownServicesr   
Record_WKSsocketIPPROTO_TCPr   s    r(   test_WKSzServerDNSTests.test_WKS  sT    ~~M112CDD!&3 	  

 

 
	
r*   c                 b   t          j         t                    }t          j        |_        |                     | j                            d          |t          j        dd          t          j	        dd          t          j	        dd          t          j
        d	d
ddd          g          S )NrM   1.2.3.4rn   ro   z
ns1.domain2Mz
ns2.domainrp   rg   rh   ri   r   rq   )copymy_soarF   rH   r   r   lookupAllRecordsr   r   r   r   )r6   
result_soas     r(   test_someRecordsWithTTLsz'ServerDNSTests.test_someRecordsWithTTLs  s    Yv&&

~~M**?;;YD111l555l555sE52ItTTT	
 	
 		
r*   c                     |                      | j                            d          t          j        dd          g          S )z%Test DNS 'AAAA' record queries (IPv6)r   z'AF43:5634:1294:AFCB:56AC:48EF:34C3:01FFr=   ro   )r   r   lookupIPV6Addressr   Record_AAAAr   s    r(   	test_AAAAzServerDNSTests.test_AAAA  sB    ~~M++,=>>_FHUUUV
 
 	
r*   c                     |                      | j                            d          t          j        dddd          t          j        ddd	d          t          j        d
ddd          g          S )z#Test DNS 'A6' record queries (IPv6)r   r   z
ABCD::4321 r=   ro   rZ   z	0:0069::0zsome.network.tldr[   z$0:5634:1294:AFCB:56AC:48EF:34C3:01FFztra.la.la.net)r   r   lookupAddress6r   	Record_A6r   s    r(   test_A6zServerDNSTests.test_A6  s~    ~~M(():;;arx@@@b+/AxPPP:# 	  	
 
 	
r*   c                 D   t           j        }d t          t          j        t
          j                                                  D             }|D ]}|j        ||_        | 	                    | j
                            d                              d           |          S )z9
        Test DNS 'AXFR' queries (Zone transfer)
        c                 6    g | ]}t          j         |          S r"   )r   r%   s     r(   r)   z4ServerDNSTests.test_zoneTransfer.<locals>.<listcomp>  s-     
 
 
DIaLL
 
 
r*   Nr   c                 $    | d         d d         fS )Nr   r"   )r'   s    r(   <lambda>z2ServerDNSTests.test_zoneTransfer.<locals>.<lambda>  s    1Q49, r*   )r   rF   r   operatoraddr|   r5   valuesrH   r   r   
lookupZoner   )r6   default_ttlr,   r'   s       r(   test_zoneTransferz ServerDNSTests.test_zoneTransfer  s     !'
 
"(7N7U7U7W7W"X"X
 
 
  	$ 	$Au}#~~M$$%677CC&&  	
 
 	
r*   c                     t          dg          }|                     |                    d          t          j                  S )zu
        A failed AXFR TCP connection errbacks the L{Deferred} returned
        from L{Resolver.lookupZone}.
        )znameserver.invalid5   ry   zimpossible.invalid)r   assertFailurer  r   DNSLookupError)r6   r   s     r(    test_zoneTransferConnectionFailsz/ServerDNSTests.test_zoneTransferConnectionFails  sG    
 %?$@AAA!! 455u7K
 
 	
r*   c                     |                      | j                            d          t          j        dd          g          S )z6Tests that unrelated zones don't mess with each other.zanothertest-domain.comr   r=   ro   r   r   s    r(   test_similarZonesDontInterferez-ServerDNSTests.test_similarZonesDontInterfere  sA    ~~M''(@AA\)2223
 
 	
r*   c                     |                      | j                            d          t          j        dddddd          g          S )	z2
        Test DNS 'NAPTR' record queries.
        r   r;   rR   rd   re   rf   r=   ro   )r   r   lookupNamingAuthorityPointerr   Record_NAPTRr   s    r(   
test_NAPTRzServerDNSTests.test_NAPTR  sZ     ~~M667HII 8   	
 
 	
r*   N)!r7   r8   r9   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r"   r*   r(   rs   rs      s        G G G<N N N  .
 
 

 
 

 
 

 
 

 
 

 
 
	
 	
 	

 
 

 
 

 
 

 
 

 
 
	
 	
 	

 
 
	
 	
 	
	
 	
 	

 
 

 
 
 
 
 

 
 

 
 

 
 
 
 
 
$
 
 

 
 

 
 
 
 
r*   rs   c                       e Zd Zd ZdS )HelperTestsc                     |                                  }t          j        |          }t          d          D ]1}t          j        |          }|                     ||k                |}2d S )N   )mktempr   	getSerialrange
assertTrue)r6   faibs        r(   test_serialGeneratorz HelperTests.test_serialGenerator  sk    KKMM""r 	 	A#A&&AOOAE"""AA	 	r*   N)r7   r8   r9   r   r"   r*   r(   r  r    s#            r*   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )	AXFRTestsc                    d | _         t          j                    | _        | j                            | j                   t          j        d| j                  | _        t          j
        dt          j        t          j        ddt          j        ddddddd	d
                    | _        | j        t          j
        dt          j        t          j        ddt          j        dd                    t          j
        dt          j        t          j        ddt          j        ddd                    t          j
        dt          j        t          j        ddt          j        dd                    | j        g| _        d S )N	fooby.comiQ Fzhooj.fooby.comr;      i,  i  i  iX  )rA   rB   rC   rD   rG   rF   rE   rH   nametypeclsrH   authr$     ns.twistedmatrix.comr'  rH   rR   zmail.mv3d.com)
preferenceexchangerH   z64.123.27.105)addressrH   )r,   r   Deferreddr   _gotResultsr   AXFRController
controllerr   r   r   INr   r4   NSr   MXr   Ar   r5   r   s    r(   r   zAXFRTests.setUp  sl   !!4+,,, /TVDD<N!&	 	 	
 
 
& HL VF+AsKKK   L VFoSVWWW   L UF_#FFF   H5
r*   c                 <    t          j        ddddddddd	  	        S )N  r?   r   	idansweropCoderecDesrecAvr*  rCodetruncmaxSize)r   r   r   s    r(   _makeMessagezAXFRTests._makeMessage2  s6    {

 

 

 
	
r*   c                    |                                  }t          j        dt          j        t          j                  g|_        | j        |_        | j        	                    |d            | 
                    | j        | j                   d S )Nr$  )rE  r   r   AXFRr6  queriesr5   answersr5  messageReceivedr   r,   )r6   ms     r(   test_bindAndTNamesStylez!AXFRTests.test_bindAndTNamesStyle@  sp    Y{CHcf==>	L	''4000t|44444r*   c                     || _         d S r1   r+   )r6   results     r(   r3  zAXFRTests._gotResultsH  s    r*   c                    | j         d d          }|rS|                                 }g |_        |                    d          g|_        | j                            |d            |S|                     | j        | j                    d S Nr   )	r5   rE  rH  poprI  r5  rJ  r   r,   )r6   r5   rK  s      r(   test_DJBStylezAXFRTests.test_DJBStyleK  s    ,qqq/ 	5!!##AAI Q(AIO++At444	  	5
 	t|44444r*   N)r7   r8   r9   r   rE  rL  r3  rR  r"   r*   r(   r"  r"    s`        3
 3
 3
j
 
 
5 5 5  5 5 5 5 5r*   r"  c                       e Zd Zd Zd ZdS )ResolvConfHandlingTestsc                     |                                  }t          j        |          }|                     |j        dg           |j                                         d S )Nresolvrw   r	  )r  r   r   r   
dynServers
_parseCallcancelr6   
resolvConfr'   s      r(   test_missingz$ResolvConfHandlingTests.test_missingW  sW    [[]]
O:...(9':;;;	r*   c                    |                                  }t          |d                                           t          j        |          }|                     |j        dg           |j                                         d S )NwrV  rX  )	r  opencloser   r   r   rY  rZ  r[  r\  s      r(   
test_emptyz"ResolvConfHandlingTests.test_empty]  ss    [[]]
Z##%%%O:...(9':;;;	r*   N)r7   r8   r9   r^  rc  r"   r*   r(   rT  rT  V  s2              r*   rT  c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
AuthorityTestszs
    Tests for the basic response record selection code in L{FileAuthority}
    (independent of its fileness).
    c                     t           }d|j        d         z   }|                     |                    |                    }|                     |j        t                     dS )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-r   N)r|   r4   failureResultOfr   assertIsInstancevaluer   )r6   
testDomaintestDomainNamer  s       r(   'test_domainErrorForNameWithCommonSuffixz6AuthorityTests.test_domainErrorForNameWithCommonSuffixk  sY     %
/*.2CC  !9!9.!I!IJJag{33333r*   c           
         t          t          j        j        t          ft          j        j        t          t	          j        d          gi          }|                      |j        t          j        j                            \  }}}|                     |g            |                     |t	          j	        t          j        j        t          j
        t          j        t          d          g           |                     |g            dS )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.
        r   rm   TrH   r$   r*  N)r/   r   rA   r'  r   r   successResultOfr   r   r   TYPErF   )r6   r   r>  
additionals       r(   test_recordMissingz!AuthorityTests.test_recordMissingx  s    $!&
3 %M),,(
 
 
	 )-(<(<#I#J$4$9::)
 )
%	: 	$$$$)O")&  	
 	
 	
 	R(((((r*   c                    t           }d|j        d         z   }t          t          j                  dz   }|                     |                    t          ||                              }|                     |j	        t                     dS )z
        Requesting a record of unknown type where no records exist for the name
        in question results in L{DomainError}.
        rg  r   r?   r'  r(  N)r|   r4   maxr   typeToMethodrh  queryr   ri  rj  r   )r6   rk  rl  unknownTyper  s        r(   test_unknownTypeNXDOMAINz'AuthorityTests.test_unknownTypeNXDOMAIN  s    
 %
/*.2CC&-..2  U[IIIJJ
 
 	ag{33333r*   c                     t          t          j                  dz   }|                     t                              t          d|                              \  }}}|                     |g            dS )z
        Requesting a record of unknown type where other records exist for the
        name in question results in an empty answer set.
        r?   rM   ru  N)rv  r   rw  rp  r~   rx  r   r   )r6   ry  r>  r   rr  s        r(   test_unknownTypeMissingz&AuthorityTests.test_unknownTypeMissing  sq    
 &-..2(,(<(<? M M MNN)
 )
%	: 	$$$$$r*   c           
         dt           j        j        z   }t          j        d          }t          t           j        j        t           f||gi          } t          ||          |          }|                     |          \  }}}|                     |g            |                     |t          j	        |t          j
        t           j        |d          g           |                     |g            dS )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.
        s   example.r   rm   Fro  N)r   rA   r'  r   r   r/   getattrrp  r   r   r7  rF   )r6   method	subdomain
nameserverr   r2  r>  rr  s           r(   _referralTestzAuthorityTests._referralTest  s     *"2"77	]9--
#!&
3
 
 
	 'GIv&&y11(,(<(<Q(?(?%	:$$$F")&  	
 	
 	
 	R(((((r*   c                 0    |                      d           dS )a  
        When an I{NS} record is found for a child zone, it is included in the
        authority section of the response. It is marked as non-authoritative if
        the authority is not also authoritative for the child zone (RFC 2181,
        section 6.1).
        r   Nr  r   s    r(   test_referralzAuthorityTests.test_referral  s     	?+++++r*   c                 0    |                      d           dS )zT
        A referral is also generated for a request of type C{ALL_RECORDS}.
        r   Nr  r   s    r(   test_allRecordsReferralz&AuthorityTests.test_allRecordsReferral  s     	-.....r*   N)r7   r8   r9   r  rm  rs  rz  r|  r  r  r  r"   r*   r(   re  re  e  s         
4 4 4 )  )  )D4 4 4	% 	% 	%) ) )B, , ,/ / / / /r*   re  c                       e Zd ZdZ ej        d          Z ej        d          Zd Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd ZdS )AdditionalProcessingTestszz
    Tests for L{FileAuthority}'s additional processing for those record types
    which require it (MX, CNAME, etc).
    s   10.0.0.1s   f080::1c                     t          |j        j        |f|j        j         ||          g||i          } t          ||          t          j        j                  S )a  
        Perform a DNS lookup against a L{FileAuthority} configured with records
        as defined by C{makeRecord} and C{addresses}.

        @param method: The name of the lookup method to use; for example,
            C{"lookupNameservers"}.
        @type method: L{str}

        @param soa: A L{Record_SOA} for the zone for which the L{FileAuthority}
            is authoritative.

        @param makeRecord: A one-argument callable which accepts a name and
            returns an L{IRecord} provider.  L{FileAuthority} is constructed
            with this record.  The L{FileAuthority} is queried for a record of
            the resulting type with the given name.

        @param target: The extra name which the record returned by
            C{makeRecord} will be pointed at; this is the name which might
            require extra processing by the server so that all the available,
            useful information is returned.  For example, this is the target of
            a CNAME record or the mail exchange host pointed to by an MX record.
        @type target: L{bytes}

        @param addresses: A L{list} of records giving addresses of C{target}.

        @return: A L{Deferred} that fires with the result of the resolver
            method give by C{method}.
        rm   )r/   rA   r'  r~  r   )r6   r  r4   
makeRecordtarget	addressesr   s          r(   _lookupSomeRecordsz,AdditionalProcessingTests._lookupSomeRecords  sf    : $%	F!3!3 4	
 
 
	 *wy&))**:*?@@@r*   c                 t    d }|                      t          ||          t          ||                     dS )a  
        Assert that the L{RRHeader} instances given by C{expected} and
        C{computed} carry all the same information but without requiring the
        records appear in the same order.

        @param expected: A L{list} of L{RRHeader} instances giving the expected
            records.

        @param computed: A L{list} of L{RRHeader} instances giving the records
            computed by the scenario under test.

        @raise self.failureException: If the two collections of records
            disagree.
        c                     | j         S r1   )r(  )rrs    r(   r  z>AdditionalProcessingTests.assertRecordsMatch.<locals>.<lambda>$  s     r*   )keyN)r   sorted)r6   expectedcomputedr  s       r(   assertRecordsMatchz,AdditionalProcessingTests.assertRecordsMatch  sB    $ ! c222F84M4M4MNNNNNr*   c                     dt           j        j        z   |                     |t           ||          }|                     |          \  }}}|                     fd|D             |           dS )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}.
        s   mail.c           	      `    g | ]*}t          j        |j        t          j        |d           +S Tro  r   r   rq  r   rF   r&   r0  r  s     r(   r)   z=AdditionalProcessingTests._additionalTest.<locals>.<listcomp>=  P     	 	 	  L")#  	 	 	r*   N)r   rA   r'  r  rp  r  )	r6   r  r  r  r2  r>  r   rr  r  s	           @r(   _additionalTestz)AdditionalProcessingTests._additionalTest'  s    " J,11##FJ
FIVV(,(<(<Q(?(?%	:	 	 	 	  )	 	 	 	
 	
 	
 	
 	
r*   c                 d    |                      dt          t          j        d          |           dS )z
        Verify that a response to an MX query has certain records in the
        I{additional} section.

        @param addresses: See C{_additionalTest}
        r   rR   N)r  r   r   r   r6   r  s     r(   _additionalMXTestz+AdditionalProcessingTests._additionalMXTestJ  s9     	 '#-"<"<i	
 	
 	
 	
 	
r*   c                 <    |                      | j        g           dS )z
        If the name of the MX response has A records, they are included in the
        additional section of the response.
        N)r  _Ar   s    r(   test_mailExchangeAdditionalAz6AdditionalProcessingTests.test_mailExchangeAdditionalAU  "    
 	y)))))r*   c                 <    |                      | j        g           dS )z
        If the name of the MX response has AAAA records, they are included in
        the additional section of the response.
        N)r  _AAAAr   s    r(   test_mailExchangeAdditionalAAAAz9AdditionalProcessingTests.test_mailExchangeAdditionalAAAA\  "    
 	
|,,,,,r*   c                 H    |                      | j        | j        g           dS )z
        If the name of the MX response has both A and AAAA records, they are
        all included in the additional section of the response.
        N)r  r  r  r   s    r(   test_mailExchangeAdditionalBothz9AdditionalProcessingTests.test_mailExchangeAdditionalBothc  '    
 	455555r*   c                 H    |                      dt          j        |           dS )z
        Verify that a response to an NS query has certain records in the
        I{additional} section.

        @param addresses: See C{_additionalTest}
        r   N)r  r   r   r  s     r(   _additionalNSTestz+AdditionalProcessingTests._additionalNSTestj  s%     	0#-KKKKKr*   c                 <    |                      | j        g           dS )z
        If the name of the NS response has A records, they are included in the
        additional section of the response.
        N)r  r  r   s    r(   test_nameserverAdditionalAz4AdditionalProcessingTests.test_nameserverAdditionalAs  r  r*   c                 <    |                      | j        g           dS )z
        If the name of the NS response has AAAA records, they are included in
        the additional section of the response.
        N)r  r  r   s    r(   test_nameserverAdditionalAAAAz7AdditionalProcessingTests.test_nameserverAdditionalAAAAz  r  r*   c                 H    |                      | j        | j        g           dS )z
        If the name of the NS response has both A and AAAA records, they are
        all included in the additional section of the response.
        N)r  r  r  r   s    r(   test_nameserverAdditionalBothz7AdditionalProcessingTests.test_nameserverAdditionalBoth  r  r*   c                    dt           j        j        z   |                     dt           t          j        |          }|                     |          \  }}}t	          j        t           j        j        t          j        t           j	        t	          j                  d          }| 
                    fd|D             |gz   |           dS )z
        Verify that a response to a CNAME query has certain records in the
        I{answer} section.

        @param addresses: See C{_additionalTest}
        s   www.r   Tro  c           	      `    g | ]*}t          j        |j        t          j        |d           +S r  r  r  s     r(   r)   z>AdditionalProcessingTests._answerCNAMETest.<locals>.<listcomp>  r  r*   N)r   rA   r'  r  r   r   rp  r   CNAMErF   r  )r6   r  r2  r>  r   rr  aliasr  s          @r(   _answerCNAMETestz*AdditionalProcessingTests._answerCNAMETest  s     :+00##!:s/?
 
 )-(<(<Q(?(?%	:!I!$V,,
 
 
 		 	 	 	  )	 	 	 g
 	
 	
 	
 	
 	
r*   c                 <    |                      | j        g           dS )z
        If the name of the CNAME response has A records, they are included in
        the answer section of the response.
        N)r  r  r   s    r(   test_canonicalNameAnswerAz3AdditionalProcessingTests.test_canonicalNameAnswerA  s"    
 	twi(((((r*   c                 <    |                      | j        g           dS )z
        If the name of the CNAME response has AAAA records, they are included
        in the answer section of the response.
        N)r  r  r   s    r(   test_canonicalNameAnswerAAAAz6AdditionalProcessingTests.test_canonicalNameAnswerAAAA  s"    
 	tzl+++++r*   c                 H    |                      | j        | j        g           dS )z
        If the name of the CNAME response has both A and AAAA records, they are
        all included in the answer section of the response.
        N)r  r  r  r   s    r(   test_canonicalNameAnswerBothz6AdditionalProcessingTests.test_canonicalNameAnswerBoth  s'    
 	tw
344444r*   N)r7   r8   r9   r  r   r   r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"   r*   r(   r  r    s/        
 
k	"	"BCOJ''E$A $A $ALO O O*!
 !
 !
F	
 	
 	
* * *- - -6 6 6L L L* * *- - -6 6 6!
 !
 !
F) ) ), , ,5 5 5 5 5r*   r  c                       e Zd Zd ZdS )NoInitialResponseTestsc                    fd}d }t          dg          }||_        g |                     t          j        d|           t          j        dt          j        t          j        ddt          j        d	d
                    g}t          j	        ddddddddd	  	        }||_
                            |           |                     |                    d          t          j                  S )z
        If a request returns a L{dns.NS} response, but we can't connect to the
        given server, the request fails with the error returned at connection.
        c                 H    t                              d                    S rP  )r
   rQ  )r6   argsmessagess     r(   rx  z3NoInitialResponseTests.test_noAnswer.<locals>.query  s     8<<??+++r*   c                 N    t          j        t          j        d                    S )NzCouldn't connect)r   failr   gaierror)r6   r  kwargss      r(   queryProtocolz;NoInitialResponseTests.test_noAnswer.<locals>.queryProtocol  s    :fo.@AABBBr*   )r   r   ry   rx  z	fooba.comr+  Fr,  r-  r&  r;  r?   r   r<  r$  )r   _querypatchr   r   r   r7  r6  r   r   rI  appendr
  getHostByNamer   r  )r6   rx  r  r   r5   rK  r  s         @r(   test_noAnswerz$NoInitialResponseTests.test_noAnswer  s!   	, 	, 	, 	, 	,
	C 	C 	C ^$4555 	

3*G]CCC L VF+AsKKK  	
 K

 

 

 	!!("8"8"E"EvWWWr*   N)r7   r8   r9   r  r"   r*   r(   r  r    s(        ,X ,X ,X ,X ,Xr*   r  c                   $    e Zd ZdZd Zd Zd ZdS )SecondaryAuthorityServiceTestsz
    Tests for L{SecondaryAuthorityService}, a service which keeps one or more
    authorities up to date by doing zone transfers from a master.
    c                 b   d}t          |ddg          }|                     |j        |           |                     |j        d           |                     |j        d         j        |           |                     |j        d         j        d           |                     |j        d         j        d           |                     |j        d         j        |           |                     |j        d         j        d           |                     |j        d         j        d           dS )	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.orgr	  r   r?   s   example.orgN)r   r   primary_portdomainsdomainr6   r  services      r(   test_constructAuthorityFromHostz>SecondaryAuthorityServiceTests.test_constructAuthorityFromHost  s     +Gnm5TUU'222++++3W===+12666+2NCCC+3W===+12666+2NCCCCCr*   c                 t   d}d}t          j        ||fddg          }|                     |j        |           |                     |j        d           |                     |j        d         j        |           |                     |j        d         j        |           |                     |j        d         j        d           |                     |j        d         j        |           |                     |j        d         j        |           |                     |j        d         j        d           dS )	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.3i  zexample.net   example.edur      example.netr?   N)r   fromServerAddressAndDomainsr   r  r  r  r  )r6   r  r   r  s       r(   &test_constructAuthorityFromHostAndPortzESecondaryAuthorityServiceTests.test_constructAuthorityFromHostAndPort  s&     +GdOm^<
 
 	'222---+3W===+14888+2NCCC+3W===+14888+2NCCCCCr*   c                    d}t          |                                ddg          }|                     |j        |           |                     |j        d         j        |           |                     |j        d         j        d           |                     |j        d         j        |           |                     |j        d         j        d           dS )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.
        r  r  zexample.edur   r?   r  N)r   encoder   r  r  r  r  s      r(    test_constructAuthorityFromBytesz?SecondaryAuthorityServiceTests.test_constructAuthorityFromBytes#  s      +NN]+
 
 	'222+3W===+2NCCC+3W===+2NCCCCCr*   N)r7   r8   r9   r  r  r  r  r"   r*   r(   r  r    sV         
D D D(D D D0D D D D Dr*   r  c                   *    e Zd ZdZd Zd Zd Zd ZdS )SecondaryAuthorityTestsz
    L{twisted.names.secondary.SecondaryAuthority} correctly constructs objects
    with a specified IP address and optionally specified DNS port.
    c                     t          dd          }|                     |j        d           |                     |j        d           |                     |j        d           dS )zp
        When constructed using L{SecondaryAuthority.__init__}, the default port
        of 53 is used.
        192.168.1.1
inside.comr	  
   inside.comN)r   r   r  r  r  r6   	secondarys     r(   test_defaultPortz(SecondaryAuthorityTests.test_defaultPort?  sc    
 '}lCC	*M:::"---)=99999r*   c                     t          j        dd          }|                     |j        d           |                     |j        d           |                     |j        d           dS )z~
        When constructed using L{SecondaryAuthority.fromServerAddressAndDomain},
        the specified port is used.
        )r    r  r  r  r  N)r   fromServerAddressAndDomainr   r  r  r  r  s     r(   test_explicitPortz)SecondaryAuthorityTests.test_explicitPortI  sm    
 'A!<
 
	 	*M:::$///)=99999r*   c                    t          j        dd          }t                      x|_        }|                                 |j                            d          \  }}}}}|                     |d           |                     |d           |                    ||f          }t                      }	|
                    |	           t                      }
|
                    t          |	                                dd                              |                     t          j        dt          j        t          j                  g|
j                   dS )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.
        r  r<   example.comr   r  r<   ru   N)r   r  r   _reactortransfer
tcpClientsrQ  r   buildProtocolr   makeConnectionr   decoder   rj  r   r   rG  r6  rH  )r6   r  r	   hostr   r   timeoutbindAddressprotor   msgs              r(   test_transferz%SecondaryAuthorityTests.test_transferU  s4    'A!=
 
	 (:';';;	W 5<4F4J4J14M4M1dGWk}---t$$$ %%tTl33#%%	Y'''ii 	

79??,,QRR011222#)M38SVDDEs{SSSSSr*   c           
      ,   t          j        dd          }t                      x|_        }|                                 |j                            d          \  }}}}}|                    ||f          }t                      }	|	                    |	           t          dd          }
|
                    t          |	                                dd                              t          dd	d
ddddd          }t          dd          }t          |
j        dd          }|j                            t'          dt(          |          t'          d|          t'          dt(          |          g           |                                }|                    t/          dt1          |                    |z              |                     |                    d                    }|                     t'          d|d          gg g f|           dS )z
        L{SecondaryAuthority.lookupAddress} returns a L{Deferred} that fires
        with the I{A} records the authority has cached from the primary.
        r  r  r   r?   )r>  r*  ru   Ns   ns1.example.comzadmin.example.comi@ i  i  i   i%  i.  r@   s   192.168.1.2ro   )r=  r>  r*  )r(  r$   r#   z!Hr  T)r$   r*  )r   r  r   r  r  r  rQ  r  r   r  r   r  r   rj  r   r   r=  rI  extendr   r   toStrdataReceivedr   lenrp  r   r   )r6   r  r	   r  r   r   r  r  r  r   rx  r4   r  r>  datarN  s                   r(   test_lookupAddressz*SecondaryAuthorityTests.test_lookupAddresss  s   
 'A!>
 
	 (:';';;	W4;4F4J4J14M4M1dGWk%%tTl33#%%	Y'''qq)))WY__..qrr233444 $%	
 	
 	
 ^+++EHQQ777c3???333c3???	
 	
 	
 ||~~4c$ii0047888%%i&=&=m&L&LMM~qt<<<=r2F	
 	
 	
 	
 	
r*   N)r7   r8   r9   r  r  r  r  r  r"   r*   r(   r  r  9  s]         
: : :
: 
: 
:T T T<0
 0
 0
 0
 0
r*   r  sY  $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.comc                   N    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )BindAuthorityTestsz=
    Tests for L{twisted.names.authority.BindAuthority}.
    c                     t          |                                                     d                    }|                    |           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)r   r  r  
setContentr   BindAuthoritypath)r6   sfps      r(   loadBindStringz!BindAuthorityTests.loadBindString  sL     dkkmm**73344
a&rw///r*   c                 D    |                      t                    | _        d S r1   )r  sampleBindZoner*  r   s    r(   r   zBindAuthorityTests.setUp  s    ''77			r*   c                     | j         j                                        D ]5}| j         j        |         D ] }|                     d|j        k               !6dS )zG
        Loads the default $TTL and applies it to all records.
        :	 N)r*  r5   keysr  rH   )r6   domrecs      r(   test_ttlzBindAuthorityTests.test_ttl  sh     9$))++ 	3 	3Cy(- 3 3#' 122223	3 	3r*   c                     |                      d| j        j                   |                     d| j        j                   dS )z,
        Loads the default $ORIGIN.
        s   example.com.   not-fqdn.example.comN)r   r*  originassertInr5   r   s    r(   test_originFromFilez&BindAuthorityTests.test_originFromFile  sT     	I	
 	
 	
 	#I	
 	
 	
 	
 	
r*   c                     dD ]h\  }}|                      | j                            |                    \  \  }\   \   |                     t	          j        |d          |j                   idS )'
        A records are loaded.
        )r  z10.0.0.1)   no-in.example.comz10.0.0.2r  Nrp  r*  r   r   r   r   r$   r6   r  ipr  s       r(   test_aRecordsz BindAuthorityTests.test_aRecords  s    
 	 	GC "11$)2I2I#2N2NOONTb2r  
   	 	r*   c                     |                      | j                            d                    \  \  }\   \   |                     t	          j        dd          |j                   dS )*
        AAAA records are loaded.
        r  2001:db8:10::1r  Nrp  r*  r   r   r   r   r$   r6   r  s     r(   test_aaaaRecordsz#BindAuthorityTests.test_aaaaRecords  st     --I''77
 
"r2 	O   J	
 	
 	
 	
 	
r*   c                     |                      | j                            d                    \  \  }\   \   |                     t	          j        ddd          |j                   dS )(
        MX records are loaded.
        r  rR   zmx.example.comr  )r.  r'  rH   Nrp  r*  r   r   r   r   r$   r*  s     r(   test_mxRecordsz!BindAuthorityTests.test_mxRecords  s}     --I(()@AA
 
"r2 	M%  
 J	
 	
 	
 	
 	
r*   c                     |                      | j                            d                    \  }\   \   |d         }|                     t	          j        dd          |j                   dS )+
        CNAME records are loaded.
           www.example.comr   r  r  r-  Nrp  r*  r   r   r   r   r$   r6   rI  r  s      r(   test_cnameRecordsz$BindAuthorityTests.test_cnameRecords  s     !00I''(:;;
 
"b QZ"   J	
 	
 	
 	
 	
r*   c                     |                      t                    5 }|                     d           ddd           n# 1 swxY w Y   |                     d|j        j        d                    dS )zO
        loadBindString raises NotImplementedError on invalid records.
        s   example.com. IN LOL 192.168.0.1NzRecord type 'LOL' not supportedr   )assertRaisesNotImplementedErrorr  r   	exceptionr  )r6   es     r(   test_invalidRecordClassz*BindAuthorityTests.test_invalidRecordClass%  s     233 	Dq BCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D:AK<LQ<OPPPPPs   =AAc                    dD ]}|                      t                    5 }|                     |dz              ddd           n# 1 swxY w Y   |                     t	          |dz             |j        j        d                    dS )zC
        $INCLUDE and $GENERATE raise NotImplementedError.
        )s   $INCLUDEs	   $GENERATEs    doesNotMatterNs    directive not implementedr   )r7  r8  r  r   r   r9  r  )r6   	directiver:  s      r(   test_invalidDirectivesz)BindAuthorityTests.test_invalidDirectives-  s     5 	 	I""#677 C1##I0A$ABBBC C C C C C C C C C C C C C CY)FFGG #   	 	s   AA	A	N)r7   r8   r9   r  r  r   r  r  r%  r+  r/  r5  r;  r>  r"   r*   r(   r  r    s         0 0 08 8 83 3 3
 
 
  "
 
 

 
 
 
 
 
 Q Q Q
 
 
 
 
r*   r  a  zone = [
    SOA(
        # For whom we are the authority
        'example.com',

        # This nameserver's name
        mname = "dns.example.com",

        # Mailbox of individual who handles this
        rname = "root.example.com",

        # Unique serial identifying this SOA data
        serial = 86400,

        # Time interval before zone should be refreshed
        refresh = "2H",

        # Interval before failed refresh should be retried
        retry = "1H",

        # Upper limit on time interval before expiry
        expire = "1H",

        # Minimum TTL
        minimum = "3H"

    ),

    AAAA('example.com', '2001:db8:10::1'),
    A('example.com', '10.0.0.1'),
    NS('example.com', 'dns.example.com'),
    A('no-in.example.com', '10.0.0.2'),
    PTR('2.0.0.10.in-addr.arpa', 'no-in.example.com'),

    CNAME('www.example.com', 'example.com'),
    CNAME('ftp.example.com', 'example.com'),

    MX('not-fqdn.example.com', 10, 'mail.example.com'),
]
c                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )PySourceAuthorityTestszA
    Tests for L{twisted.names.authority.PySourceAuthority}.
    c                     t          |                                           }t          |j        d          5 }|                    |           ddd           n# 1 swxY w Y   t          j        |j                  S )a  
        Create a new L{twisted.names.authority.PySourceAuthority} from C{s}.

        @param s: A string with BIND zone data in a Python source file.
        @type s: L{str}

        @return: a new bind authority
        @rtype: L{twisted.names.authority.PySourceAuthority}
        r`  N)r   r  ra  r  writer   PySourceAuthority)r6   r  r  r  s       r(   loadPySourceStringz)PySourceAuthorityTests.loadPySourceStringj  s     dkkmm$$"'3 	1GGAJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 *27333s   AA Ac                 D    |                      t                    | _        d S r1   )rD  samplePySourcer*  r   s    r(   r   zPySourceAuthorityTests.setUpz  s    ++N;;			r*   c                     dD ]g\  }}|                      | j                            |                    \  \  }\   \   |                     t	          j        |          |j                   hdS )r  r   Nr"  r#  s       r(   r%  z$PySourceAuthorityTests.test_aRecords}  s}    
 	 	GC "11$)2I2I#2N2NOONTb2rR  
   	 	r*   c                     |                      | j                            d                    \  \  }\   \   |                     t	          j        d          |j                   dS )r'  r  r(  Nr)  r*  s     r(   r+  z'PySourceAuthorityTests.test_aaaaRecords  sk     --I''77
 
"r2 	O,--J	
 	
 	
 	
 	
r*   c                     |                      | j                            d                    \  \  }\   \   |                     t	          j        dd          |j                   dS )r-  r  rR   zmail.example.com)r.  r'  Nr.  r*  s     r(   r/  z%PySourceAuthorityTests.test_mxRecords  sz     --I(()@AA
 
"r2 	M'   J	
 	
 	
 	
 	
r*   c                     |                      | j                            d                    \  }\   \   |d         }|                     t	          j        d          |j                   dS )r1  r2  r   r  r'  Nr3  r4  s      r(   r5  z(PySourceAuthorityTests.test_cnameRecords  s     !00I''(:;;
 
"b QZ"   J		
 	
 	
 	
 	
r*   c                     |                      | j                            d                    \  }\   \   |d         }|                     t	          j        d          |j                   dS )z)
        PTR records are loaded.
        s   2.0.0.10.in-addr.arpar   r!  rK  N)rp  r*  r   r   r   r   r$   r4  s      r(   r   zPySourceAuthorityTests.test_PTR  s     !00I##$<==
 
"b QZN)   J		
 	
 	
 	
 	
r*   c                 L    d}|                      t          | j        |           dS )z1
        Input file has no zone variable
        znothing = []N)r7  
ValueErrorrD  )r6   badPySources     r(   test_badInputNoZonez*PySourceAuthorityTests.test_badInputNoZone  s*     %*d&={KKKKKr*   N)r7   r8   r9   r  rD  r   r%  r+  r/  r5  r   rP  r"   r*   r(   r@  r@  e  s         4 4 4 < < <  

 

 


 
 

 
 

 
 
L L L L Lr*   r@  )Yr  r   r  r   	functoolsr   r   ior   structr   twisted.internetr   r   r	   twisted.internet.deferr
   twisted.internet.testingr   r   r   twisted.namesr   r   r   r   r   twisted.names.clientr   twisted.names.dnsr   r   r   r   r   r   twisted.names.errorr   twisted.names.secondaryr   r   twisted.python.compatr   twisted.python.filepathr   twisted.trialr   r-   FileAuthorityr/   r   reverse_soar   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r|   r   r}   r~   TestCasers   r  r"  rT  re  r  r  r  r  r  r  rF  r@  r"   r*   r(   <module>rb     s   
    % % % % % % % %             2 2 2 2 2 2 2 2 2 2 * * * * * *         
 A @ @ @ @ @ @ @ @ @ @ @ @ @ ) ) ) ) ) ) Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q + + + + + + Q Q Q Q Q Q Q Q . . . . . . , , , , , , " " " " " "+ + +. . . . .i- . . . S^

 
		 	 	
 cn
"
"
		 	 	 


'

 
 
 "/	Z( CL&&CM/**CNABBCN13TUUCM"455C.IJJJC233CM455CM122CN35FGGCM!]C00CM"l,?@@CM!DFVWWCNJKKCM677C]MJJJCQ1IJJJCM28IJJJCN 24S  CRz+O  COFGG5
: CN3u.FGG&
 CL((CL(("
 CL+,,CL$$&
 $43#34F#G#G"H$0CL$<$<#=[. .1 1 1f !	!;/$CN:;;'
    	6"CL...CM-U333CM-T222CN3u.FDQQQ
  W
 W
 W
 W
 W
X& W
 W
 W
t
    (#   W5 W5 W5 W5 W5! W5 W5 W5t    h/   {/ {/ {/ {/ {/X& {/ {/ {/|[5 [5 [5 [5 [5 1 [5 [5 [5|-X -X -X -X -XX. -X -X -X`ED ED ED ED EDX%6 ED ED EDPj
 j
 j
 j
 j
h/ j
 j
 j
Z+&~ ~ ~ ~ ~* ~ ~ ~B(VdL dL dL dL dLX. dL dL dL dL dLr*   