U
    �Acj\¿  ã                   @   sØ  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d„ Z/G dd„ dej0ƒZ1ej"ddddddddd�Z2ej"dddd d!d"d#d$d�Z3ej"d%d&d'd(dd)dd*�Z4e1de2fe2e !d+¡e 5d,¡e 6d-¡e 6d.d/¡e 7d0d1¡ej8d2d3d4�e 9d5¡e :d6¡e ;d7¡e <d8d9¡e =dd:d;¡e =d<d=d>¡e =d?d@dA¡e <dB¡e >dC¡ej?dDdEdF�ej@ddGdH�ejAdIdJdK�e BdLejCdM¡e Ddd0dNdOdP¡e EdQ¡ge FdRdSdTdU¡ge !dV¡e !dW¡ge !dX¡e !dY¡ge 9d¡ge !dZ¡gd[œd\�ZGe1de3fd]e Hd^¡e3gid\�ZIe1d_e4fd_e4ej!dZd`da�ej5dbdcda�ej5dddeda�ejFdRdSdTdUdfda�gid\�ZJG dgdh„ dhe.jKƒZLG didj„ dje.jKƒZMG dkdl„ dle.jKƒZNG dmdn„ dne.jKƒZOG dodp„ dpe.jKƒZPG dqdr„ dre.jKƒZQG dsdt„ dte.jKƒZRG dudv„ dve.jKƒZSG dwdx„ dxe.jKƒZTdyZUG dzd{„ d{e.jKƒZVd|ZWG d}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                 C   s   dd„ | d D ƒS )Nc                 S   s   g | ]
}|j ‘qS © ©Úpayload©Ú.0Úrr   r   úA/tmp/pip-unpacked-wheel-nrvc_22y/twisted/names/test/test_names.pyÚ
<listcomp>"   s     zjustPayload.<locals>.<listcomp>r   r   ©Úresultsr   r   r%   ÚjustPayload!   s    r)   c                   @   s   e Zd Zdd„ ZdS )ÚNoFileAuthorityc                 C   s   t j | ¡ || | _| _d S ©N)r   ZResolverBaseÚ__init__ÚsoaÚrecords)Úselfr-   r.   r   r   r%   r,   &   s    zNoFileAuthority.__init__N)Ú__name__Ú
__module__Ú__qualname__r,   r   r   r   r%   r*   %   s   r*   ó   test-domain.comzroot.test-domain.coméd   éÒ  iæ  éH?&é   é   ©ÚmnameÚrnameÚserialÚrefreshÚminimumÚexpireÚretryÚttls   93.84.28.in-addr.arpaéx   i1Ô  i~  éÎª é   é   úmy-domain.coms   postmaster.test-domain.comé‚   i90  i?B )r:   r;   r<   r=   r>   r?   r@   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::4321ó    é   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)r3   s   http.tcp.test-domain.comó   host.test-domain.coms   host-two.test-domain.coms   cname.test-domain.coms   anothertest-domain.com©r-   r.   s   123.93.84.28.in-addr.arpas   test.host-reverse.lookup.coms   my-domain.comÚ1S©rA   s
   ns1.domains   2Ms
   ns2.domainÚ3HÚ4Dc                   @   sø   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Z d<S )=ÚServerDNSTestsz/
    Test cases for DNS server and client.
    c                 C   sª   t jtttgdd�| _t | j¡}tj	d| jdd�}|  
|j¡ | ¡ j}ztj||dd�}W n tjk
rt   Y q"X |  
|j¡ q†q"|| _|| _tjd|fgd�| _d S )Né   )Úverboser   ú	127.0.0.1)Z	interface©Zservers)r   ZDNSServerFactoryÚtest_domain_comÚreverse_domainÚmy_domain_comÚfactoryr   ÚDNSDatagramProtocolr   Z	listenTCPZ
addCleanupÚstopListeningZgetHostÚportZ	listenUDPr   ZCannotListenErrorÚlistenerTCPÚlistenerUDPr   r   Úresolver)r/   Úprx   rw   ry   r   r   r%   ÚsetUp�   s"     ÿ
zServerDNSTests.setUpc                 C   s6   | j jdd… D ]}|j ¡  qtt| j jdd… ƒS )zu
        Clean up any server connections associated with the
        L{DNSServerFactory} created in L{setUp}
        N)rt   ÚconnectionsÚ	transportZloseConnectionr   r   )r/   Úconnr   r   r%   ÚtearDown»   s    zServerDNSTests.tearDownc                    s   ‡ ‡fd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                    s    t | ƒ}ˆ tˆ ƒt|ƒ¡ d S r+   )r)   ÚassertEqualÚset)ÚresponseZreceivedRecords©ÚexpectedRecordsr/   r   r%   ÚcheckResultsØ   s    z.ServerDNSTests.namesTest.<locals>.checkResults)ÚaddCallback)r/   Zqueryingr…   r†   r   r„   r%   Ú	namesTestÈ   s    
zServerDNSTests.namesTestc                 C   s    |   | j d¡tjddd�g¡S )z"Test simple DNS 'A' record queriesútest-domain.comro   r6   ri   ©rˆ   rz   ÚlookupAddressr   r   ©r/   r   r   r%   Útest_addressRecord1ß   s    
þz"ServerDNSTests.test_addressRecord1c                 C   s,   |   | j d¡tjddd�tjddd�g¡S )z1Test DNS 'A' record queries with multiple answersrL   z123.242.1.5r6   ri   z0.255.0.255rŠ   rŒ   r   r   r%   Útest_addressRecord2æ   s    
þþz"ServerDNSTests.test_addressRecord2c                 C   s,   |   | j d¡tjddd�tjddd�g¡S )z+Test DNS 'A' record queries with edge caseszhost-two.test-domain.comz255.255.255.254r6   ri   ú0.0.0.0rŠ   rŒ   r   r   r%   Útest_addressRecord3ð   s    
þþz"ServerDNSTests.test_addressRecord3c                 C   s   |   | j d¡tg¡S )zTest DNS 'SOA' record queriesr‰   )rˆ   rz   ZlookupAuthorityÚ
soa_recordrŒ   r   r   r%   Útest_authorityú   s    
 ÿzServerDNSTests.test_authorityc              	   C   s:   |   | j d¡tjdddd�tjddd�tjd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.
        r3   rK   rf   r6   ri   rd   re   )rˆ   rz   ÚlookupMailExchanger   Ú	Record_MXr   rŒ   r   r   r%   Útest_mailExchangeRecord   s    
ýþz&ServerDNSTests.test_mailExchangeRecordc                 C   s    |   | j d¡tjddd�g¡S )zTest DNS 'NS' record queriesr‰   z39.28.189.39r6   ri   )rˆ   rz   ÚlookupNameserversr   Ú	Record_NSrŒ   r   r   r%   Útest_nameserver  s    
þzServerDNSTests.test_nameserverc                 C   s"   |   | j d¡tjdddd�g¡S )zTest DNS 'HINFO' record queriesr‰   rM   rN   r6   )rO   rP   rA   )rˆ   rz   ZlookupHostInfor   ÚRecord_HINFOrŒ   r   r   r%   Ú
test_HINFO  s    
  ÿÿþzServerDNSTests.test_HINFOc                 C   s    |   | j d¡tjddd�g¡S )zTest DNS 'PTR' record queriesz123.93.84.28.in-addr.arpaztest.host-reverse.lookup.comrC   ri   )rˆ   rz   ÚlookupPointerr   Ú
Record_PTRrŒ   r   r   r%   Útest_PTR   s    
þzServerDNSTests.test_PTRc                 C   s    |   | j d¡tjddd�g¡S )zTest DNS 'CNAME' record queriesr‰   zcanonical.name.comr6   ri   )rˆ   rz   ÚlookupCanonicalNamer   ÚRecord_CNAMErŒ   r   r   r%   Ú
test_CNAME'  s    
þzServerDNSTests.test_CNAMEc                 C   s    |   | j d¡tjddd�g¡S )zTest DNS 'MB' record queriesr‰   zmailbox.test-domain.comr6   ri   )rˆ   rz   ZlookupMailBoxr   Ú	Record_MBrŒ   r   r   r%   Útest_MB.  s    
þzServerDNSTests.test_MBc                 C   s    |   | j d¡tjddd�g¡S )zTest DNS 'MG' record queriesr‰   zmail.group.someplacer6   ri   )rˆ   rz   ZlookupMailGroupr   Ú	Record_MGrŒ   r   r   r%   Útest_MG5  s    
þzServerDNSTests.test_MGc                 C   s    |   | j d¡tjddd�g¡S )zTest DNS 'MR' record queriesr‰   zmail.redirect.or.whateverr6   ri   )rˆ   rz   ZlookupMailRenamer   Ú	Record_MRrŒ   r   r   r%   Útest_MR<  s    
þzServerDNSTests.test_MRc                 C   s"   |   | j d¡tjdddd�g¡S )zTest DNS 'MINFO' record queriesr‰   z
r mail boxz
e mail boxr6   )rW   rX   rA   )rˆ   rz   ZlookupMailboxInfor   ÚRecord_MINFOrŒ   r   r   r%   Ú
test_MINFOC  s    
  ÿÿþzServerDNSTests.test_MINFOc              
   C   s&   |   | j d¡tjdddddd�g¡S )zTest DNS 'SRV' record querieszhttp.tcp.test-domain.comra   rb   rc   úsome.other.place.foolr6   ri   )rˆ   rz   ZlookupServicer   Ú
Record_SRVrŒ   r   r   r%   Útest_SRVN  s    
þzServerDNSTests.test_SRVc                 C   s"   |   | j d¡tjdddd�g¡S )zTest DNS 'AFSDB' record queriesr‰   r8   zafsdb.test-domain.comr6   )rY   rZ   rA   )rˆ   rz   ZlookupAFSDatabaser   ÚRecord_AFSDBrŒ   r   r   r%   Ú
test_AFSDBU  s    
  ÿÿþzServerDNSTests.test_AFSDBc                 C   s"   |   | j d¡tjdddd�g¡S )zTest DNS 'RP' record queriesr‰   zwhatever.i.dunnozsome.more.textr6   )r[   r\   rA   )rˆ   rz   ZlookupResponsibilityr   Ú	Record_RPrŒ   r   r   r%   Útest_RP`  s    
  ÿÿþzServerDNSTests.test_RPc                 C   s.   |   | j d¡tjdddd�tjddd�g¡S )zTest DNS 'TXT' record queriesr‰   rQ   rR   r6   ri   rV   )rˆ   rz   Z
lookupTextr   Ú
Record_TXTrŒ   r   r   r%   Útest_TXTk  s    
  ÿ ÿüþzServerDNSTests.test_TXTc              	   C   s.   |   | j d¡tjddd�tjdddd�g¡S )zH
        L{DNSServerFactory} can serve I{SPF} resource records.
        r‰   rH   r6   ri   rI   rJ   )rˆ   rz   ZlookupSenderPolicyr   Ú
Record_SPFrŒ   r   r   r%   Útest_spfy  s    
ýþþzServerDNSTests.test_spfc              	   C   s&   |   | j d¡tjdtjddd�g¡S )zTest DNS 'WKS' record queriesr‰   z12.54.78.12r]   r6   ri   )rˆ   rz   ZlookupWellKnownServicesr   Ú
Record_WKSÚsocketÚIPPROTO_TCPrŒ   r   r   r%   Útest_WKS‰  s    
üÿþzServerDNSTests.test_WKSc                 C   s^   t   t¡}tj|_|  | j d¡|tjddd�tj	ddd�tj	ddd�tj
d	d
dddd�g¡S )NrF   ú1.2.3.4rh   ri   z
ns1.domainZ2Mz
ns2.domainrj   ra   rb   rc   r©   rk   )ÚcopyÚmy_soar?   rA   rˆ   rz   ÚlookupAllRecordsr   r   r—   rª   )r/   Z
result_soar   r   r%   Útest_someRecordsWithTTLs—  s    

ûþz'ServerDNSTests.test_someRecordsWithTTLsc                 C   s    |   | j d¡tjddd�g¡S )z%Test DNS 'AAAA' record queries (IPv6)r‰   z'AF43:5634:1294:AFCB:56AC:48EF:34C3:01FFr6   ri   )rˆ   rz   ÚlookupIPV6Addressr   ÚRecord_AAAArŒ   r   r   r%   Ú	test_AAAA¥  s    
þzServerDNSTests.test_AAAAc                 C   sD   |   | j d¡tjddddd�tjddd	dd�tjd
dddd�g¡S )z#Test DNS 'A6' record queries (IPv6)r‰   r   z
ABCD::4321Ú r6   ri   rT   z	0:0069::0zsome.network.tldrU   z$0:5634:1294:AFCB:56AC:48EF:34C3:01FFztra.la.la.net)rˆ   rz   ZlookupAddress6r   Ú	Record_A6rŒ   r   r   r%   Útest_A6¬  s    
üýþzServerDNSTests.test_A6c                 C   sZ   t j}dd„ ttjtj ¡ ƒD ƒ}|D ]}|jdkr&||_q&|  	| j
 d¡ dd„ ¡|¡S )z9
        Test DNS 'AXFR' queries (Zone transfer)
        c                 S   s   g | ]}t   |¡‘qS r   )r¹   r"   r   r   r%   r&   Á  s    z4ServerDNSTests.test_zoneTransfer.<locals>.<listcomp>Nr‰   c                 S   s   | d d d… fS )Nr   éÿÿÿÿr   )r$   r   r   r%   Ú<lambda>É  rS   z2ServerDNSTests.test_zoneTransfer.<locals>.<lambda>)r‘   r?   r   ÚoperatorÚaddrq   r.   ÚvaluesrA   rˆ   rz   Ú
lookupZoner‡   )r/   Zdefault_ttlr(   r$   r   r   r%   Útest_zoneTransfer¼  s    ÿ
ÿüz ServerDNSTests.test_zoneTransferc                 C   s    t dgd�}|  | d¡tj¡S )zu
        A failed AXFR TCP connection errbacks the L{Deferred} returned
        from L{Resolver.lookupZone}.
        )znameserver.invalidé5   rp   zimpossible.invalid)r   ÚassertFailurerÈ   r   ZDNSLookupError)r/   rz   r   r   r%   Ú test_zoneTransferConnectionFailsÎ  s
     ÿz/ServerDNSTests.test_zoneTransferConnectionFailsc                 C   s    |   | j d¡tjddd�g¡S )z6Tests that unrelated zones don't mess with each other.zanothertest-domain.comr¸   r6   ri   rŠ   rŒ   r   r   r%   Útest_similarZonesDontInterfereØ  s    
þz-ServerDNSTests.test_similarZonesDontInterferec                 C   s(   |   | j d¡tjddddddd�g¡S )	z2
        Test DNS 'NAPTR' record queries.
        r‰   r4   rK   r^   r_   r`   r6   ri   )rˆ   rz   ZlookupNamingAuthorityPointerr   ÚRecord_NAPTRrŒ   r   r   r%   Ú
test_NAPTRß  s    
úÿþzServerDNSTests.test_NAPTRN)!r0   r1   r2   Ú__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   r%   rl   ˜   s<   


rl   c                   @   s   e Zd Zdd„ ZdS )ÚHelperTestsc                 C   s@   |   ¡ }t |¡}tdƒD ] }t |¡}|  ||k ¡ |}qd S )Né   )Úmktempr   Z	getSerialÚrangeÚ
assertTrue)r/   ÚfÚaÚiÚbr   r   r%   Útest_serialGeneratoró  s    

z HelperTests.test_serialGeneratorN)r0   r1   r2   rÚ   r   r   r   r%   rÑ   ò  s   rÑ   c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )Ú	AXFRTestsc                 C   sÚ   d | _ t ¡ | _| j | j¡ t d| j¡| _t	j
dt	jt	jddt	jddddddd	d
d�d�| _| jt	j
dt	jt	jddt	jddd�d�t	j
dt	jt	jddt	jdddd�d�t	j
dt	jt	jddt	jddd�d�| jg| _d S )Nú	fooby.comi€Q Fzhooj.fooby.comr4   éÈ   i,  i�  iô  iX  )r:   r;   r<   r=   r@   r?   r>   rA   ©ÚnameÚtypeÚclsrA   Úauthr!   é¼  úns.twistedmatrix.com©rß   rA   rK   zmail.mv3d.com)Ú
preferenceZexchangerA   z64.123.27.105)ÚaddressrA   )r(   r   ZDeferredÚdr‡   Ú_gotResultsr   ZAXFRControllerÚ
controllerr   r   r   ÚINr   r-   ÚNSr—   ZMXr”   ÚAr   r.   rŒ   r   r   r%   r|   ý  s`    
øúúúúæzAXFRTests.setUpc                 C   s   t jdddddddddd�	S )Néç  r8   r   ©	ÚidÚanswerZopCodeZrecDesZrecAvrâ   ZrCodeÚtruncZmaxSize)r   r   rŒ   r   r   r%   Ú_makeMessage2  s    ÷zAXFRTests._makeMessagec                 C   sH   |   ¡ }t dtjtj¡g|_| j|_| j 	|d ¡ |  
| j| j¡ d S )NrÜ   )ró   r   r   ÚAXFRrë   Úqueriesr.   Úanswersrê   ÚmessageReceivedr�   r(   )r/   Úmr   r   r%   Útest_bindAndTNamesStyle@  s
    z!AXFRTests.test_bindAndTNamesStylec                 C   s
   || _ d S r+   r'   )r/   Úresultr   r   r%   ré   H  s    zAXFRTests._gotResultsc                 C   sR   | j d d … }|r>|  ¡ }g |_| d¡g|_| j |d ¡ q|  | j| j ¡ d S ©Nr   )	r.   ró   rõ   Úpoprö   rê   r÷   r�   r(   )r/   r.   rø   r   r   r%   Útest_DJBStyleK  s    zAXFRTests.test_DJBStyleN)r0   r1   r2   r|   ró   rù   ré   rý   r   r   r   r%   rÛ   ü  s
   5rÛ   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚResolvConfHandlingTestsc                 C   s2   |   ¡ }tj|d�}|  |jdg¡ |j ¡  d S )N©Zresolv©ro   rÊ   )rÓ   r   r   r�   Ú
dynServersÚ
_parseCallÚcancel©r/   Z
resolvConfr$   r   r   r%   Útest_missingW  s    z$ResolvConfHandlingTests.test_missingc                 C   s@   |   ¡ }t|dƒ ¡  tj|d�}|  |jdg¡ |j ¡  d S )NÚwrÿ   r   )	rÓ   ÚopenÚcloser   r   r�   r  r  r  r  r   r   r%   Ú
test_empty]  s
    z"ResolvConfHandlingTests.test_emptyN)r0   r1   r2   r  r	  r   r   r   r%   rþ   V  s   rþ   c                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )ÚAuthorityTestszs
    Tests for the basic response record selection code in L{FileAuthority}
    (independent of its fileness).
    c                 C   s4   t }d|jd  }|  | |¡¡}|  |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)rq   r-   ÚfailureResultOfr‹   ÚassertIsInstanceÚvaluer   )r/   Ú
testDomainÚtestDomainNamerÖ   r   r   r%   Ú'test_domainErrorForNameWithCommonSuffixk  s    z6AuthorityTests.test_domainErrorForNameWithCommonSuffixc              
   C   s‚   t tjjtftjjtt d¡gid�}|  | tjj¡¡\}}}|  |g ¡ |  |tj	tjjtj
tjtd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¸   rg   T©rA   r!   râ   N)r*   r‘   r:   rß   r   r—   ÚsuccessResultOfr‹   r�   r   ÚTYPEr?   )r/   r   rñ   Ú
additionalr   r   r%   Útest_recordMissingx  s0    
þÿþ	ÿ
ûÿþz!AuthorityTests.test_recordMissingc                 C   sJ   t }d|jd  }ttjƒd }|  | t||d�¡¡}|  |j	t
¡ dS )zˆ
        Requesting a record of unknown type where no records exist for the name
        in question results in L{DomainError}.
        r  r   r8   ©rß   rà   N)rq   r-   Úmaxr   ÚtypeToMethodr  Úqueryr   r  r  r   )r/   r  r  ÚunknownTyperÖ   r   r   r%   Útest_unknownTypeNXDOMAINš  s    ÿz'AuthorityTests.test_unknownTypeNXDOMAINc                 C   s<   t tjƒd }|  t td|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.
        r8   rF   r  N)r  r   r  r  rs   r  r   r�   )r/   r  rñ   r   r  r   r   r%   Útest_unknownTypeMissing§  s
    ÿ
z&AuthorityTests.test_unknownTypeMissingc              
   C   sŒ   dt jj }t d¡}tt jjt f||gid�}t||ƒ|ƒ}|  |¡\}}}|  |g ¡ |  |tj	|tj
t j|d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¸   rg   Fr  N)r‘   r:   rß   r   r—   r*   Úgetattrr  r�   r   rì   r?   )r/   ÚmethodZ	subdomainZ
nameserverr   rè   rñ   r  r   r   r%   Ú_referralTest²  s0    

ÿÿþûÿþzAuthorityTests._referralTestc                 C   s   |   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Œ   r   r   r%   Útest_referralÓ  s    zAuthorityTests.test_referralc                 C   s   |   d¡ dS )zT
        A referral is also generated for a request of type C{ALL_RECORDS}.
        r»   Nr!  rŒ   r   r   r%   Útest_allRecordsReferralÜ  s    z&AuthorityTests.test_allRecordsReferralN)r0   r1   r2   rÐ   r  r  r  r  r   r"  r#  r   r   r   r%   r
  e  s   "!	r
  c                   @   sœ   e Zd ZdZe d¡Ze d¡Zdd„ Z	dd„ Z
dd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd 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                 C   s8   t |jj|f|jj||ƒg||id�}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}.
        rg   )r*   r:   rß   r  r‘   )r/   r  r-   Ú
makeRecordÚtargetÚ	addressesr   r   r   r%   Ú_lookupSomeRecordsì  s    
  þþz,AdditionalProcessingTests._lookupSomeRecordsc                 C   s(   dd„ }|   t||d�t||d�¡ 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                 S   s   | j S r+   )rà   )Úrrr   r   r%   rÄ   $  rS   z>AdditionalProcessingTests.assertRecordsMatch.<locals>.<lambda>)ÚkeyN)r�   Úsorted)r/   ÚexpectedZcomputedr*  r   r   r%   ÚassertRecordsMatch  s    z,AdditionalProcessingTests.assertRecordsMatchc                    sL   dt jj ‰ |  |t |ˆ |¡}|  |¡\}}}|  ‡ fd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              	      s$   g | ]}t jˆ |jtj|d d�‘qS ©Tr  ©r   r   r  r‘   r?   ©r#   rç   ©r&  r   r%   r&   =  s   ùûz=AdditionalProcessingTests._additionalTest.<locals>.<listcomp>N)r‘   r:   rß   r(  r  r-  )r/   r  r%  r'  rè   rñ   r   r  r   r1  r%   Ú_additionalTest'  s    
ø
õz)AdditionalProcessingTests._additionalTestc                 C   s   |   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“   rK   N)r2  r   r   r”   ©r/   r'  r   r   r%   Ú_additionalMXTestJ  s
     
 ÿz+AdditionalProcessingTests._additionalMXTestc                 C   s   |   | 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)r4  Ú_ArŒ   r   r   r%   Útest_mailExchangeAdditionalAU  s    z6AdditionalProcessingTests.test_mailExchangeAdditionalAc                 C   s   |   | 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)r4  Ú_AAAArŒ   r   r   r%   Útest_mailExchangeAdditionalAAAA\  s    z9AdditionalProcessingTests.test_mailExchangeAdditionalAAAAc                 C   s   |   | 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)r4  r5  r7  rŒ   r   r   r%   Útest_mailExchangeAdditionalBothc  s    z9AdditionalProcessingTests.test_mailExchangeAdditionalBothc                 C   s   |   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)r2  r   r—   r3  r   r   r%   Ú_additionalNSTestj  s    z+AdditionalProcessingTests._additionalNSTestc                 C   s   |   | 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:  r5  rŒ   r   r   r%   Útest_nameserverAdditionalAs  s    z4AdditionalProcessingTests.test_nameserverAdditionalAc                 C   s   |   | 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:  r7  rŒ   r   r   r%   Útest_nameserverAdditionalAAAAz  s    z7AdditionalProcessingTests.test_nameserverAdditionalAAAAc                 C   s   |   | 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:  r5  r7  rŒ   r   r   r%   Útest_nameserverAdditionalBoth�  s    z7AdditionalProcessingTests.test_nameserverAdditionalBothc                    sv   dt jj ‰ |  dt tjˆ |¡}|  |¡\}}}tjt jjtjt j	t ˆ ¡dd�}|  
‡ fdd„|D ƒ|g |¡ 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ž   Tr  c              	      s$   g | ]}t jˆ |jtj|d d�‘qS r.  r/  r0  r1  r   r%   r&   �  s   ùûz>AdditionalProcessingTests._answerCNAMETest.<locals>.<listcomp>N)r‘   r:   rß   r(  r   rŸ   r  r   ZCNAMEr?   r-  )r/   r'  rè   rñ   r   r  Úaliasr   r1  r%   Ú_answerCNAMETestˆ  s0        ÿû
ø
öôz*AdditionalProcessingTests._answerCNAMETestc                 C   s   |   | 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?  r5  rŒ   r   r   r%   Útest_canonicalNameAnswerA«  s    z3AdditionalProcessingTests.test_canonicalNameAnswerAc                 C   s   |   | 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?  r7  rŒ   r   r   r%   Útest_canonicalNameAnswerAAAA²  s    z6AdditionalProcessingTests.test_canonicalNameAnswerAAAAc                 C   s   |   | 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?  r5  r7  rŒ   r   r   r%   Útest_canonicalNameAnswerBoth¹  s    z6AdditionalProcessingTests.test_canonicalNameAnswerBothN)r0   r1   r2   rÐ   r   r   r5  r¾   r7  r(  r-  r2  r4  r6  r8  r9  r:  r;  r<  r=  r?  r@  rA  rB  r   r   r   r%   r$  ã  s$   

&#	#r$  c                   @   s   e Zd Zdd„ ZdS )ÚNoInitialResponseTestsc                    s    ‡ fdd„}dd„ }t dgd�}||_g ‰ |  tjd|¡ tjdtjtjd	d
tjdd	d�d�g}tj	d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                    s   t ˆ  d¡ƒS rû   )r	   rü   )r/   Úargs©Úmessagesr   r%   r  È  s    z3NoInitialResponseTests.test_noAnswer.<locals>.queryc                 _   s   t  t d¡¡S )NzCouldn't connect)r   Zfailrµ   Úgaierror)r/   rD  Úkwargsr   r   r%   ÚqueryProtocolÍ  s    z;NoInitialResponseTests.test_noAnswer.<locals>.queryProtocol)r�   r   rp   r  z	fooba.comrã   Frä   rå   rÞ   rî   r8   r   rï   rÜ   )r   Z_queryÚpatchr   ru   r   rì   rë   r—   r   rö   ÚappendrË   ZgetHostByNamerµ   rG  )r/   r  rI  rz   r.   rø   r   rE  r%   Útest_noAnswerÂ  s:    úÿ
÷
z$NoInitialResponseTests.test_noAnswerN)r0   r1   r2   rL  r   r   r   r%   rC  Á  s   rC  c                   @   s(   e Zd ZdZdd„ Zdd„ Zd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                 C   sª   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   r8   s   example.orgN)r   r�   ÚprimaryÚ_portÚdomainsÚdomain©r/   rP  Úservicer   r   r%   Útest_constructAuthorityFromHost÷  s    z>SecondaryAuthorityServiceTests.test_constructAuthorityFromHostc                 C   s´   d}d}t  ||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.netr8   N)r   ZfromServerAddressAndDomainsr�   rP  rQ  rR  rS  )r/   rP  rw   rU  r   r   r%   Ú&test_constructAuthorityFromHostAndPort  s     ÿzESecondaryAuthorityServiceTests.test_constructAuthorityFromHostAndPortc                 C   sx   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.
        rW  rY  zexample.edur   r8   rX  N)r   Úencoder�   rP  rR  rS  rT  r   r   r%   Ú test_constructAuthorityFromBytes#  s    þz?SecondaryAuthorityServiceTests.test_constructAuthorityFromBytesN)r0   r1   r2   rÐ   rV  rZ  r\  r   r   r   r%   rM  ñ  s   rM  c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚSecondaryAuthorityTestsz—
    L{twisted.names.secondary.SecondaryAuthority} correctly constructs objects
    with a specified IP address and optionally specified DNS port.
    c                 C   s8   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�   rP  rQ  rS  ©r/   Ú	secondaryr   r   r%   Útest_defaultPort?  s    
z(SecondaryAuthorityTests.test_defaultPortc                 C   s:   t  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^  rd  r`  N)r   ÚfromServerAddressAndDomainr�   rP  rQ  rS  ra  r   r   r%   Útest_explicitPortI  s     ÿz)SecondaryAuthorityTests.test_explicitPortc                 C   s®   t  dd¡}tƒ  |_}| ¡  |j d¡\}}}}}|  |d¡ |  |d¡ | ||f¡}t	ƒ }	| 
|	¡ tƒ }
|
 t|	 ¡ dd… ƒ¡ |  t 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.
        ©rN  r5   úexample.comr   rN  r5   rm   N)r   re  r
   Ú_reactorÚtransferÚ
tcpClientsrü   r�   ÚbuildProtocolr   ÚmakeConnectionr   Údecoder   r  r   r   rô   rë   rõ   )r/   rb  r   Úhostrw   rt   ÚtimeoutÚbindAddressÚprotor~   Úmsgr   r   r%   Útest_transferU  s     ÿ
z%SecondaryAuthorityTests.test_transferc              
   C   s.  t  dd¡}tƒ  |_}| ¡  |j d¡\}}}}}| ||f¡}tƒ }	| 	|	¡ t
ddd�}
|
 t|	 ¡ dd… ƒ¡ tdd	d
dddddd�}tddd�}t
|
jddd�}|j tdt|d�td|d�tdt|d�g¡ | ¡ }| tdt|ƒƒ| ¡ |  | d¡¡}|  td|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.
        rg  rO  r   r8   )rñ   râ   rm   Ns   ns1.example.comzadmin.example.comi@â i  iÀ  i   i€%  ià.  r9   s   192.168.1.2ri   )rð   rñ   râ   )rà   r!   r    z!Hrh  T)r!   râ   )r   re  r
   ri  rj  rk  rü   rl  r   rm  r   rn  r   r  r   r   rð   rö   Úextendr   r   ZtoStrZdataReceivedr   Úlenr  r‹   r�   )r/   rb  r   ro  rw   rt   rp  rq  rr  r~   r  r-   r×   rñ   Údatarú   r   r   r%   Útest_lookupAddresss  sJ     ÿ
ø

ýÿ ÿz*SecondaryAuthorityTests.test_lookupAddressN)r0   r1   r2   rÐ   rc  rf  rt  rx  r   r   r   r%   r]  9  s
   
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                   @   s`   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚBindAuthorityTestsz=
    Tests for L{twisted.names.authority.BindAuthority}.
    c                 C   s(   t |  ¡  d¡ƒ}| |¡ t |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[  Z
setContentr   ZBindAuthorityÚpath)r/   ÚsÚfpr   r   r%   ÚloadBindString¾  s    

z!BindAuthorityTests.loadBindStringc                 C   s   |   t¡| _d S r+   )r~  ÚsampleBindZonerâ   rŒ   r   r   r%   r|   Í  s    zBindAuthorityTests.setUpc                 C   s8   | j j ¡ D ]&}| j j| D ]}|  d|jk¡ qqdS )zG
        Loads the default $TTL and applies it to all records.
        é€:	 N)râ   r.   ÚkeysrÕ   rA   )r/   ÚdomZrecr   r   r%   Útest_ttlÐ  s    zBindAuthorityTests.test_ttlc                 C   s$   |   d| jj¡ |  d| jj¡ dS )z,
        Loads the default $ORIGIN.
        s   example.com.ó   not-fqdn.example.comN)r�   râ   ÚoriginZassertInr.   rŒ   r   r   r%   Útest_originFromFileØ  s    þþz&BindAuthorityTests.test_originFromFilec                 C   sB   dD ]8\}}|   | j |¡¡\\}\ \ |  t |d¡|j¡ qdS )ú'
        A records are loaded.
        ©)rO  z10.0.0.1)ó   no-in.example.comz10.0.0.2r€  N©r  râ   r‹   r�   r   r   r!   ©r/   r‚  Úipr)  r   r   r%   Útest_aRecordså  s    þûz BindAuthorityTests.test_aRecordsc                 C   s4   |   | j d¡¡\\}\ \ |  t dd¡|j¡ dS )ú*
        AAAA records are loaded.
        rO  ú2001:db8:10::1r€  N©r  râ   r½   r�   r   r¾   r!   ©r/   r)  r   r   r%   Útest_aaaaRecordsö  s    
ÿþûz#BindAuthorityTests.test_aaaaRecordsc                 C   s8   |   | j d¡¡\\}\ \ |  tjdddd�|j¡ dS )ú(
        MX records are loaded.
        r„  rK   zmx.example.comr€  )ræ   rß   rA   N©r  râ   r“   r�   r   r”   r!   r‘  r   r   r%   Útest_mxRecords  s    
ÿýúz!BindAuthorityTests.test_mxRecordsc                 C   s<   |   | j d¡¡\}\ \ |d }|  tjddd�|j¡ dS )ú+
        CNAME records are loaded.
        ó   www.example.comr   rh  r€  rå   N©r  râ   r½   r�   r   rŸ   r!   ©r/   rö   r)  r   r   r%   Útest_cnameRecords  s    
ÿ
þûz$BindAuthorityTests.test_cnameRecordsc              	   C   s8   |   t¡�}|  d¡ W 5 Q R X |  d|jjd ¡ dS )zO
        loadBindString raises NotImplementedError on invalid records.
        s   example.com. IN LOL 192.168.0.1zRecord type 'LOL' not supportedr   N)ÚassertRaisesÚNotImplementedErrorr~  r�   Ú	exceptionrD  )r/   Úer   r   r%   Útest_invalidRecordClass%  s    z*BindAuthorityTests.test_invalidRecordClassc              
   C   sN   dD ]D}|   t¡�}|  |d ¡ W 5 Q R X |  t|d ƒ|jjd ¡ qdS )zC
        $INCLUDE and $GENERATE raise NotImplementedError.
        )s   $INCLUDEs	   $GENERATEs    doesNotMatters    directive not implementedr   N)r›  rœ  r~  r�   r   r�  rD  )r/   Ú	directiverž  r   r   r%   Útest_invalidDirectives-  s    

þz)BindAuthorityTests.test_invalidDirectivesN)r0   r1   r2   rÐ   r~  r|   rƒ  r†  r�  r’  r•  rš  rŸ  r¡  r   r   r   r%   ry  ¹  s   ry  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                   @   sP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚPySourceAuthorityTestszA
    Tests for L{twisted.names.authority.PySourceAuthority}.
    c              	   C   s:   t |  ¡ ƒ}t|jdƒ�}| |¡ W 5 Q R X t |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  )r   rÓ   r  r{  Úwriter   ZPySourceAuthority)r/   r|  r}  rÖ   r   r   r%   ÚloadPySourceStringj  s    
z)PySourceAuthorityTests.loadPySourceStringc                 C   s   |   t¡| _d S r+   )r¤  ÚsamplePySourcerâ   rŒ   r   r   r%   r|   z  s    zPySourceAuthorityTests.setUpc                 C   s@   dD ]6\}}|   | j |¡¡\\}\ \ |  t |¡|j¡ qdS )r‡  rˆ  NrŠ  r‹  r   r   r%   r�  }  s    þz$PySourceAuthorityTests.test_aRecordsc                 C   s2   |   | j d¡¡\\}\ \ |  t d¡|j¡ dS )rŽ  rO  r�  Nr�  r‘  r   r   r%   r’  ‹  s    
ÿþz'PySourceAuthorityTests.test_aaaaRecordsc                 C   s6   |   | j d¡¡\\}\ \ |  tjddd�|j¡ dS )r“  r„  rK   zmail.example.com)ræ   rß   Nr”  r‘  r   r   r%   r•  —  s    
ÿþûz%PySourceAuthorityTests.test_mxRecordsc                 C   s:   |   | j d¡¡\}\ \ |d }|  tjdd�|j¡ dS )r–  r—  r   rh  ©rß   Nr˜  r™  r   r   r%   rš  ¦  s    
ÿ
ÿüz(PySourceAuthorityTests.test_cnameRecordsc                 C   s:   |   | j d¡¡\}\ \ |d }|  tjdd�|j¡ dS )z)
        PTR records are loaded.
        s   2.0.0.10.in-addr.arpar   r‰  r¦  N)r  râ   r›   r�   r   rœ   r!   r™  r   r   r%   r�   µ  s    
ÿ
ÿüzPySourceAuthorityTests.test_PTRc                 C   s   d}|   t| j|¡ dS )z1
        Input file has no zone variable
        znothing = []N)r›  Ú
ValueErrorr¤  )r/   ZbadPySourcer   r   r%   Útest_badInputNoZoneÄ  s    z*PySourceAuthorityTests.test_badInputNoZoneN)r0   r1   r2   rÐ   r¤  r|   r�  r’  r•  rš  r�   r¨  r   r   r   r%   r¢  e  s   r¢  )YrÐ   r¹   rÅ   rµ   Ú	functoolsr   r   Úior   Ústructr   Ztwisted.internetr   r   r   Ztwisted.internet.deferr	   Ztwisted.internet.testingr
   r   r   Ztwisted.namesr   r   r   r   r   Ztwisted.names.clientr   Ztwisted.names.dnsr   r   r   r   r   r   Ztwisted.names.errorr   Ztwisted.names.secondaryr   r   Ztwisted.python.compatr   Ztwisted.python.filepathr   Ztwisted.trialr   r)   ZFileAuthorityr*   r‘   Zreverse_soarº   r—   r²   r”   r™   rŸ   r¡   r£   r°   rÁ   r¥   r§   r¬   r®   r´   r¶   rÎ   r¾   rª   rq   rœ   rr   rs   ZTestCaserl   rÑ   rÛ   rþ   r
  r$  rC  rM  r]  r  ry  r¥  r¢  r   r   r   r%   Ú<module>   s   øøù



  ÿ    ÿæÿþ	ú

Óþ3þÿþûÿþ  \
Z~ _0Hm +