Ë
    oj2d  ã                   óÎ  — d Z ddlmZ ddlmZ ddl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mZmZmZmZmZmZmZmZmZmZmZmZ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l'm(Z( ddl)m*Z*m+Z+ d„ Z,d„ Z- G d„ de+«      Z. G d„ de/«      Z0d„ Z1 G d„ de+«      Z2g d¢Z3 ee«       G d„ d«      «       Z4 eee4«        G d„ de*«      Z5 G d„ d«      Z6 e(jn                  e8d¬«      Z9y )!z.
Test cases for Twisted.names' root resolver.
é    )Úimplementer)ÚverifyClass)ÚDeferredÚTimeoutErrorÚgatherResultsÚsucceed)ÚIResolverSimple)ÚclientÚroot)ÚCNAMEÚENAMEÚHSÚINÚNSÚOKÚAÚMessageÚNameÚQueryÚRecord_AÚRecord_CNAMEÚ	Record_NSÚRRHeader)ÚDNSNameErrorÚResolverError)ÚResolver)ÚMemoryReactor)Úmsg)Úutil)ÚSynchronousTestCaseÚTestCasec                 ó,   — | \  }}}|d   j                   S )z”
    From the result of a L{Deferred} returned by L{IResolver.lookupAddress},
    return the payload of the first record in the answer section.
    r   ©Úpayload©ÚresultsÚansÚauthÚadds       úE/usr/lib/python3/dist-packages/twisted/names/test/test_rootresolve.pyÚgetOnePayloadr+   &   s   € ð
 �N€CˆˆsØˆq‰6�>‰>Ðó    c                 ó4   — t        | «      j                  «       S )z�
    From the result of a L{Deferred} returned by L{IResolver.lookupAddress},
    return the first IPv4 address from the answer section.
    )r+   Ú
dottedQuad©r&   s    r*   ÚgetOneAddressr0   /   s   € ô
 ˜Ó!×,Ñ,Ó.Ð.r,   c                   ó‚   — e Zd ZdZd„ Zd„ Zd„ Zg g g efd„Zd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y)ÚRootResolverTestsz3
    Tests for L{twisted.names.root.Resolver}.
    c                 ó`  — t        «       }t        g |¬«      }|j                  t        dt        t
        «      dgd|«      }|j                  j                  «       \  }}|j                  \  \  }}t        «       }	|	j                  |«       | j                  |	j                  t        dt        t
        «      g«       | j                  |	j                  g «       | j                  |	j                  g «       | j                  |	j                  g «       g }
|j!                  |
j"                  «       | j                  |
g «       |	j                  dd…= d|	_        |	j                  j#                  t'        dt)        d«      ¬«      «       |j*                  j-                  |	j/                  «       d«       |
d	   S )
aK  
        Invoke L{Resolver._query} and verify that it sends the correct DNS
        query.  Deliver a canned response to the query and return whatever the
        L{Deferred} returned by L{Resolver._query} fires with.

        @param filter: The value to pass for the C{filter} parameter to
            L{Resolver._query}.
        )Úreactoró   foo.example.com)ú1.1.2.3i  )é   Né   ú	5.8.13.21r#   r   )r   r   Ú_queryr   r   r   ÚudpPortsÚpopitemÚ_sentPacketsr   ÚfromStrÚassertEqualÚqueriesÚanswersÚ	authorityÚ
additionalÚaddCallbackÚappendÚanswerr   r   Ú	_protocolÚdatagramReceivedÚtoStr)ÚselfÚfilterr4   ÚresolverÚdÚ
portNumberÚ	transportÚpacketÚaddressÚmessageÚresponses              r*   Ú
_queryTestzRootResolverTests._queryTest<   sg  € ô  “/ˆÜ˜B¨Ô0ˆØ�O‰OÜÐ$¤a¬Ó,Ð/@Ð.AÀ5È&ó
ˆð
 !(× 0Ñ 0× 8Ñ 8Ó :Ñˆ
�Ið (×4Ñ4ÑÑ	ˆ&�'ä“)ˆØ�‰˜Ôð 	×Ñ˜Ÿ™¬5Ð1CÄQÌÓ+KÐ*LÔMØ×Ñ˜Ÿ™¨"Ô-Ø×Ñ˜×*Ñ*¨BÔ/Ø×Ñ˜×+Ñ+¨RÔ0àˆØ	�‰�h—o‘oÔ&Ø×Ñ˜ 2Ô&ð �O‰OšAÐØˆŒØ�‰×ÑÜÐ'´¸+Ó1FÔGô	
ð 	×Ñ×,Ñ,¨W¯]©]«_Ð>OÔPØ˜‰{Ðr,   c           
      óÈ   — | j                  d«      \  }}}| j                  |t        dt        dd¬«      ¬«      g«       | j                  |g «       | j                  |g «       y)a)  
        L{Resolver._query} accepts a L{Query} instance and an address, issues
        the query, and returns a L{Deferred} which fires with the response to
        the query.  If a true value is passed for the C{filter} parameter, the
        result is a three-tuple of lists of records.
        Tr5   r9   r   ©Úttlr#   N)rT   r?   r   r   )rJ   rF   rB   rC   s       r*   Útest_filteredQueryz$RootResolverTests.test_filteredQueryg   sa   € ð )-¯©¸Ó(=Ñ%ˆ�	˜:Ø×ÑØ”XÐ0¼(À;ÐTUÔ:VÔWÐXô	
ð 	×Ñ˜ BÔ'Ø×Ñ˜ RÕ(r,   c           
      ó`  — | j                  d«      }| j                  |t        «       | j                  |j                  g «       | j                  |j
                  t        dt        dd¬«      ¬«      g«       | j                  |j                  g «       | j                  |j                  g «       y)zÃ
        Similar to L{test_filteredQuery}, but for the case where a false value
        is passed for the C{filter} parameter.  In this case, the result is a
        L{Message} instance.
        Fr5   r9   r   rV   r#   N)
rT   ÚassertIsInstancer   r?   r@   rA   r   r   rB   rC   )rJ   rR   s     r*   Útest_unfilteredQueryz&RootResolverTests.test_unfilteredQueryu   sŽ   € ð —/‘/ %Ó(ˆØ×Ñ˜g¤wÔ/Ø×Ñ˜Ÿ™¨"Ô-Ø×ÑØ�O‰OÜÐ(´(¸;ÈAÔ2NÔOÐPô	
ð 	×Ñ˜×*Ñ*¨BÔ/Ø×Ñ˜×+Ñ+¨RÕ0r,   c                 ó   — t        |¬«      }|j                  |f|j                  |f|j                  |ffD ]O  \  }}|j	                  |D ��	cg c]-  \  }}	t        ||	j                  t        |	dt        «      |	¬«      ‘Œ/ c}	}«       ŒQ |S c c}	}w )a£  
        Create a L{Message} suitable for use as a response to a query.

        @param answers: A C{list} of two-tuples giving data for the answers
            section of the message.  The first element of each tuple is a name
            for the L{RRHeader}.  The second element is the payload.
        @param authority: A C{list} like C{answers}, but for the authority
            section of the response.
        @param additional: A C{list} like C{answers}, but for the
            additional section of the response.
        @param rCode: The response code the message will be created with.

        @return: A new L{Message} initialized with the given values.
        )ÚrCodeÚCLASSr#   )	r   rA   rB   rC   Úextendr   ÚTYPEÚgetattrr   )
rJ   rA   rB   rC   r]   rS   ÚsectionÚdataÚnameÚrecords
             r*   Ú_respondzRootResolverTests._respond…   s¡   € ô  Ô'ˆà×Ñ˜wÐ'Ø×Ñ Ð+Ø× Ñ  *Ð-ð
ò 	‰MˆG�Tð
 �N‰Nð
 +/÷	ñ '˜˜vô Ø˜fŸk™k¬7°6¸7ÄBÓ+GÐQWöóõð	ð ˆùós   Á2B
c                 óB   ‡ ‡— dg}t        ||«      }ˆ ˆfd„}||_        |S )a   
        Create and return a new L{root.Resolver} modified to resolve queries
        against the record data represented by C{servers}.

        @param serverResponses: A mapping from dns server addresses to
            mappings.  The inner mappings are from query two-tuples (name,
            type) to dictionaries suitable for use as **arguments to
            L{_respond}.  See that method for details.
        r6   c                 óö   •— t        d| j                  › d|›�«       |D ]I  }	 ‰|   }|| j                  j                  | j                  f   }t	         ‰j
                  di |¤Ž«      c S  y # t        $ r Y ŒXw xY w)NzQuery for QNAME z at © )r   rd   ÚKeyErrorÚtyper   rf   )	ÚqueryÚserverAddressesÚtimeoutrK   ÚaddrÚserverÚrecordsrJ   ÚserverResponsess	          €€r*   rl   z-RootResolverTests._getResolver.<locals>.query±   s†   ø€ ÜÐ" 5§:¡: ,¨d°?Ð2EÐFÔGØ'ò 9�ðØ,¨TÑ2�Fð ! §¡§¡°%·*±*Ð!<Ñ=�Ü˜}˜tŸ}™}Ñ7¨wÑ7Ó8Ò8ñ9øô  ò Ùðús   £A,Á,	A8Á7A8)r   r:   )rJ   rr   ÚmaximumQueriesÚrootsrL   rl   s   ``    r*   Ú_getResolverzRootResolverTests._getResolver¤   s+   ù€ ð �ˆÜ˜E >Ó2ˆõ	9ð  ˆŒØˆr,   c                 ó(  — dt         fdt        d«      fgdt        d«      fgdœidt         fddt        d«      fgiidœ}| j                  |«      }|j	                  d«      }|j                  t        «       |j                  | j                  d«       |S )a  
        L{root.Resolver.lookupAddress} looks up the I{A} records for the
        specified hostname by first querying one of the root servers the
        resolver was created with and then following the authority delegations
        until a result is received.
        r5   ó   ns1.example.comú34.55.89.144©rB   rC   rA   ú10.0.0.1)©r6   é5   )rx   r|   ©r   r   r   ru   ÚlookupAddressrD   r0   r?   ©rJ   ÚserversrL   rM   s       r*   Útest_lookupAddressz$RootResolverTests.test_lookupAddress¾   s­   € ð $¤QÐ'Ø#5´yÐASÓ7TÐ"UÐ!VØ$6¼ÀÓ8PÐ#QÐ"Rñ*ðð $¤QÐ'ØÐ!3´X¸jÓ5IÐ JÐKð*ð#ñ
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ"Ð#5Ó6ˆØ	�‰”mÔ$Ø	�‰�d×&Ñ&¨
Ô3Øˆr,   c                 ón  — t        d«      }t        |_        dt        fd|fgdt	        d«      fgdt        d«      fgdœidt        fddt        d«      fgiidœ}| j                  |«      }|j                  d«      }|j                  t        «       |j                  | j                  t        d«      «       |S )	zÄ
        If a response includes a record with a class different from the one
        in the query, it is ignored and lookup continues until a record with
        the right class is found.
        rz   r5   rw   ú10.0.0.2)rA   rB   rC   rA   ú10.0.0.3)r{   ©rƒ   r|   )
r   r   r^   r   r   ru   r~   rD   r+   r?   )rJ   ÚbadClassr€   rL   rM   s        r*   Útest_lookupChecksClassz(RootResolverTests.test_lookupChecksClassØ   sÐ   € ô ˜JÓ'ˆÜˆŒð $¤QÐ'Ø!3°XÐ >Ð?Ø#5´yÐASÓ7TÐ"UÐ!VØ$6¼ÀÓ8LÐ#MÐ"Nñ*ðð $¤QÐ'ØÐ!3´X¸jÓ5IÐ JÐKð*ðñ
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ"Ð#5Ó6ˆØ	�‰”mÔ$Ø	�‰�d×&Ñ&¬°Ó(<Ô=Øˆr,   c                 ó:  — dt         fddt        d«      fgidt         fddt        d«      fgiidt         fddt        d«      fgiidœ}| j                  |«      }|j	                  d«      }|j                  t        «       |j                  | j                  d«       |S )z–
        If an intermediate response includes no glue records for the
        authorities, separate queries are made to find those addresses.
        r5   rB   s   ns1.example.orgrA   rz   rƒ   )r{   )rz   r|   r}   r   s       r*   Útest_missingGluez"RootResolverTests.test_missingGlueô   sÂ   € ð $¤QÐ'ØÐ#5´yÐASÓ7TÐ"UÐ!Vð*ð $¤QÐ'ØÐ!3´X¸jÓ5IÐ JÐKð*ðð $¤QÐ'ØÐ!3´X¸jÓ5IÐ JÐKð*ðñ
ˆð  ×$Ñ$ WÓ-ˆØ×"Ñ"Ð#5Ó6ˆØ	�‰”mÔ$Ø	�‰�d×&Ñ&¨
Ô3Øˆr,   c                 ó–   — ddt         fdt        iii}| j                  |«      }|j                  d«      }| j	                  |t
        «      S )z�
        If a name is missing, L{Resolver.lookupAddress} returns a L{Deferred}
        which fails with L{DNSNameError}.
        r{   r5   r]   )r   r   ru   r~   ÚassertFailurer   r   s       r*   Útest_missingNamez"RootResolverTests.test_missingName  s[   € ð Ø#¤QÐ'ØœUð*ðð
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ"Ð#5Ó6ˆØ×!Ñ! !¤\Ó2Ð2r,   c                 óŠ   — ddt         fi ii}| j                  |«      }|j                  d«      }| j                  |t        «      S )z¶
        If a query is responded to with no answers or nameserver records, the
        L{Deferred} returned by L{Resolver.lookupAddress} fires with
        L{ResolverError}.
        r{   ó   example.com)r   ru   r~   r‹   r   r   s       r*   Útest_answerlessz!RootResolverTests.test_answerless  sR   € ð Ø¤Ð# Rðð
ˆð
 ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤]Ó3Ð3r,   c                 óÂ   — ddt         fddt        d«      fgidt         fdt        iii}| j                  |«      }|j	                  d«      }| j                  |t        «      S )z¶
        If there is an error resolving the nameserver in a delegation response,
        the L{Deferred} returned by L{Resolver.lookupAddress} fires with that
        error.
        r{   rŽ   rB   rw   r]   )r   r   r   ru   r~   r‹   r   r   s       r*   Útest_delegationLookupErrorz,RootResolverTests.test_delegationLookupError.  s|   € ð Ø¤Ð#Ø >´9Ð=OÓ3PÐ"QÐ!Rð&ð $¤QÐ'ØœUð*ð	ð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤\Ó2Ð2r,   c                 ó¶   — ddt         fddt        d«      fgidt         fi ii}| j                  |«      }|j                  d«      }| j	                  |t
        «      S )zÄ
        If there are no records in the response to a lookup of a delegation
        nameserver, the L{Deferred} returned by L{Resolver.lookupAddress} fires
        with L{ResolverError}.
        r{   rŽ   rB   rw   )r   r   ru   r~   r‹   r   r   s       r*   Útest_delegationLookupEmptyz,RootResolverTests.test_delegationLookupEmptyB  st   € ð Ø¤Ð#Ø >´9Ð=OÓ3PÐ"QÐ!Rð&ð $¤QÐ'¨ð	ð
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤]Ó3Ð3r,   c           	      ó  — ddt         fdt        idt        fddt        d«      fgiii}| j	                  |«      }|j                  d«      }d„ }|j                  |«       |j                  | j                  t        d«      «       |S )z—
        L{Resolver.lookupNameservers} is like L{Resolver.lookupAddress}, except
        it queries for I{NS} records instead of I{A} records.
        r{   rŽ   r]   rA   rw   c                 ó@   — | \  }}}|d   j                   j                  S ©Nr   )r$   rd   r%   s       r*   Ú
getOneNamez<RootResolverTests.test_lookupNameservers.<locals>.getOneNamef  s!   € Ø$‰NˆC��sØ�q‘6—>‘>×&Ñ&Ð&r,   )	r   r   r   r   ru   ÚlookupNameserversrD   r?   r   )rJ   r€   rL   rM   r—   s        r*   Útest_lookupNameserversz(RootResolverTests.test_lookupNameserversT  s›   € ð Ø¤Ð#ØœUð&ð  ¤Ð$Ø ´Ð;MÓ1NÐ OÐPð'ð	ð	
ˆð ×$Ñ$ WÓ-ˆØ×&Ñ& ~Ó6ˆò	'ð 	
�‰�jÔ!Ø	�‰�d×&Ñ&¬Ð-?Ó(@ÔAØˆr,   c                 óZ  — ddt         fddt        d«      fdt        d«      fgiii}| j                  |«      }|j	                  d«      }|j                  d„ «       |j                  | j                  t        dt        t        d«      ¬«      t        dt         t        d«      ¬«      g«       |S )z–
        If a I{CNAME} record is encountered as the answer to a query for
        another record type, that record is returned as the answer.
        r{   rŽ   rA   ó   example.netz10.0.0.7c                 ó   — | d   S r–   ri   r/   s    r*   ú<lambda>z<RootResolverTests.test_returnCanonicalName.<locals>.<lambda>  ó
   €  g¨a¡j€ r,   r#   ©	r   r   r   ru   r~   rD   r?   r   r   r   s       r*   Útest_returnCanonicalNamez*RootResolverTests.test_returnCanonicalNamen  s´   € ð Ø¤Ð#ØØ'¬°nÓ)EÐFØ'¬°*Ó)=Ð>ð ð&ðð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ	�‰Ñ0Ô1Ø	�‰Ø×Ñä˜¬¼À^Ó8TÔUÜ˜¬´H¸ZÓ4HÔIðô	
ð ˆr,   c                 ón  — ddt         fddt        d«      fgidt         fddt        d«      fgiii}| j                  |«      }|j	                  d«      }|j                  d„ «       |j                  | j                  t        dt        t        d«      ¬«      t        dt         t        d«      ¬«      g«       |S )zÌ
        If no record of the requested type is included in a response, but a
        I{CNAME} record for the query name is included, queries are made to
        resolve the value of the I{CNAME}.
        r{   rŽ   rA   r›   z10.0.0.5c                 ó   — | d   S r–   ri   r/   s    r*   r�   z<RootResolverTests.test_followCanonicalName.<locals>.<lambda>›  rž   r,   r#   rŸ   r   s       r*   Útest_followCanonicalNamez*RootResolverTests.test_followCanonicalName‰  sÅ   € ð Ø¤Ð#Ø ´¸nÓ1MÐ NÐOð&ð  ¤Ð#Ø ´¸*Ó1EÐ FÐGð&ð	ð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ	�‰Ñ0Ô1Ø	�‰Ø×Ñä˜¬¼À^Ó8TÔUÜ˜¬´H¸ZÓ4HÔIðô	
ð ˆr,   c                 ó¾   — ddt         fddt        d«      fdt        d«      fgiii}| j                  |«      }|j                  d«      }| j	                  |t
        «      S )z½
        If there is a cycle between I{CNAME} records in a response, this is
        detected and the L{Deferred} returned by the lookup method fails
        with L{ResolverError}.
        r{   rŽ   rA   r›   )r   r   ru   r~   r‹   r   r   s       r*   Útest_detectCanonicalNameLoopz.RootResolverTests.test_detectCanonicalNameLoop¥  sw   € ð Ø¤Ð#ØØ'¬°nÓ)EÐFØ'¬°nÓ)EÐFð ð&ðð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤]Ó3Ð3r,   c                 ó  — dt         fddt        d«      fgidt         fddt        d«      fgiidt         fdt        d«      fgdt        d«      fgdœidt         fddt        d	«      fgiid
œ}| j                  |d«      }| j	                  |j                  d«      t        «      }| j                  |d«      }|j                  d«      }|j                  t        «       |j                  | j                  t        d	«      «       t        ||g«      S )zŒ
        L{Resolver.lookupAddress} won't issue more queries following
        delegations than the limit passed to its initializer.
        rŽ   rB   rw   rA   rƒ   s   ns2.example.comr„   ry   z10.0.0.4)r{   r…   )r„   r|   é   é   )r   r   r   ru   r‹   r~   r   rD   r+   r?   r   )rJ   r€   ÚfailerÚfailDÚ	succeederÚsucceedDs         r*   Útest_boundedQueriesz%RootResolverTests.test_boundedQueries¹  s:  € ð  ¤Ð#Ø >´9Ð=OÓ3PÐ"QÐ!Rð&ð
 $¤QÐ'ØÐ!3´X¸jÓ5IÐ JÐKð*ðð   ¤Ð#Ø#1´9Ð=OÓ3PÐ"QÐ!RØ$6¼ÀÓ8LÐ#MÐ"Nñ&ð	ð  ¤Ð#Ø ´¸*Ó1EÐ FÐGð&ðñ-
ˆðB ×"Ñ" 7¨AÓ.ˆØ×"Ñ" 6×#7Ñ#7¸Ó#GÌÓWˆà×%Ñ% g¨qÓ1ˆ	Ø×*Ñ*¨>Ó:ˆØ×Ñœ]Ô+Ø×Ñ˜T×-Ñ-¬x¸
Ó/CÔDä˜e XÐ.Ó/Ð/r,   N)é
   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rT   rX   r[   r   rf   ru   r�   r‡   r‰   rŒ   r�   r‘   r“   r™   r    r£   r¥   r­   ri   r,   r*   r2   r2   7   sh   „ ñò)òV)ò1ð   "¨R¸BÀbó ó>ò4ò4ò8ò63ò 4ò3ò(4ò$ò4ò6ò84ó(.0r,   r2   c                   ó   — e Zd ZdZd„ Zy)ÚResolverFactoryArgumentszf
    Raised by L{raisingResolverFactory} with the *args and **kwargs passed to
    that function.
    c                 ó    — || _         || _        y)z™
        Store the supplied args and kwargs as attributes.

        @param args: Positional arguments.
        @param kwargs: Keyword arguments.
        N©ÚargsÚkwargs)rJ   r·   r¸   s      r*   Ú__init__z!ResolverFactoryArguments.__init__ð  s   € ð ˆŒ	Øˆ�r,   N)r¯   r°   r±   r²   r¹   ri   r,   r*   r´   r´   ê  s   „ ñó
r,   r´   c                  ó   — t        | |«      ‚)a=  
    Raise a L{ResolverFactoryArguments} exception containing the
    positional and keyword arguments passed to resolverFactory.

    @param args: A L{list} of all the positional arguments supplied by
        the caller.

    @param kwargs: A L{list} of all the keyword arguments supplied by
        the caller.
    )r´   r¶   s     r*   ÚraisingResolverFactoryr»   û  s   € ô # 4¨Ó
0Ð0r,   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)Ú RootResolverResolverFactoryTestsz6
    Tests for L{root.Resolver._resolverFactory}.
    c                 óh   — t        dgt        ¬«      }| j                  |j                  t        «       y)z…
        L{root.Resolver.__init__} accepts a C{resolverFactory}
        argument and assigns it to C{self._resolverFactory}.
        N)ÚhintsÚresolverFactory)r   r»   ÚassertIsÚ_resolverFactory©rJ   Úrs     r*   Ú#test_resolverFactoryArgumentPresentzDRootResolverResolverFactoryTests.test_resolverFactoryArgumentPresent  s(   € ô
 ˜D˜6Ô3IÔJˆØ�‰�a×(Ñ(Ô*@ÕAr,   c                 ór   — t        dg¬«      }| j                  |j                  t        j                   «       y)z 
        L{root.Resolver.__init__} sets L{client.Resolver} as the
        C{_resolverFactory} if a C{resolverFactory} argument is not
        supplied.
        N)r¿   )r   rÁ   rÂ   r
   rÃ   s     r*   Ú"test_resolverFactoryArgumentAbsentzCRootResolverResolverFactoryTests.test_resolverFactoryArgumentAbsent  s(   € ô ˜D˜6Ô"ˆØ�‰�a×(Ñ(¬&¯/©/Õ:r,   c                 óÜ   — t        «       }t        dgt        |¬«      }| j                  t        |j
                  d«      }| j                  d|dgdœf|j                  |j                  f«       y)zy
        L{root.Resolver._resolverFactory} is supplied with C{reactor} and
        C{servers} keyword arguments.
        ú192.0.2.101)r¿   rÀ   r4   zexample.comri   )rÉ   r|   )r4   r€   N)	Úobjectr   r»   ÚassertRaisesr´   r~   r?   r·   r¸   )rJ   ÚdummyReactorrÄ   Úes       r*   Ú)test_resolverFactoryOnlyExpectedArgumentszJRootResolverResolverFactoryTests.test_resolverFactoryOnlyExpectedArguments  sj   € ô
 “xˆÜØ �/Ü2Ø ô
ˆð ×ÑÔ6¸¿¹ÈÓWˆà×ÑØ˜\Ð7JÐ6KÑLÐMØ�V‰V�Q—X‘XÐõ	
r,   N)r¯   r°   r±   r²   rÅ   rÇ   rÎ   ri   r,   r*   r½   r½   	  s   „ ñòBò;ó
r,   r½   )za.root-servers.netzb.root-servers.netzc.root-servers.netzd.root-servers.netze.root-servers.netzf.root-servers.netzg.root-servers.netzh.root-servers.netzi.root-servers.netzj.root-servers.netzk.root-servers.netzl.root-servers.netzm.root-servers.netc                   ó   — e Zd ZdZd„ Zd„ Zy)ÚStubResolverz²
    An L{IResolverSimple} implementer which traces all getHostByName
    calls and their deferred results. The deferred results can be
    accessed and fired synchronously.
    c                 ó    — g | _         g | _        y)zâ
        @type calls: L{list} of L{tuple} containing C{args} and
            C{kwargs} supplied to C{getHostByName} calls.
        @type pendingResults: L{list} of L{Deferred} returned by
            C{getHostByName}.
        N)ÚcallsÚpendingResults)rJ   s    r*   r¹   zStubResolver.__init__L  s   € ð ˆŒ
Ø ˆÕr,   c                 óŠ   — | j                   j                  ||f«       t        «       }| j                  j                  |«       |S )al  
        A fake implementation of L{IResolverSimple.getHostByName}

        @param args: A L{list} of all the positional arguments supplied by
           the caller.

        @param kwargs: A L{list} of all the keyword arguments supplied by
           the caller.

        @return: A L{Deferred} which may be fired later from the test
            fixture.
        )rÒ   rE   r   rÓ   )rJ   r·   r¸   rM   s       r*   ÚgetHostByNamezStubResolver.getHostByNameV  s:   € ð 	�
‰
×Ñ˜4 ˜.Ô)Ü‹JˆØ×Ñ×"Ñ" 1Ô%Øˆr,   N)r¯   r°   r±   r²   r¹   rÕ   ri   r,   r*   rÐ   rÐ   D  s   „ ñò!ór,   rÐ   c                   ó:   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
y	)
ÚBootstrapTestsz%
    Tests for L{root.bootstrap}
    c                 ó~   — t        j                  t        «       «      }| j                  |t         j                  «       y)zl
        L{root.bootstrap} returns an object which is initially a
        L{root.DeferredResolver}.
        N)r   Ú	bootstraprÐ   rZ   ÚDeferredResolver)rJ   ÚdeferredResolvers     r*   Útest_returnsDeferredResolverz+BootstrapTests.test_returnsDeferredResolverq  s,   € ô
  Ÿ>™>¬,«.Ó9ÐØ×ÑÐ.´×0EÑ0EÕFr,   c                 ó®   — t        «       }t        j                  |«       | j                  |j                  t
        D �cg c]  }|fi f‘Œ	 c}«       yc c}w )zŽ
        The L{IResolverSimple} supplied to L{root.bootstrap} is used to lookup
        the IP addresses of the 13 root name servers.
        N)rÐ   r   rÙ   r?   rÒ   ÚROOT_SERVERS)rJ   ÚstubResolverÚss      r*   Útest_resolves13RootServersz)BootstrapTests.test_resolves13RootServersy  sA   € ô
 $“~ˆÜ�‰�|Ô$Ø×Ñ˜×+Ñ+Ä,Ö-O¸Q°¨t°RªjÒ-OÕPùÒ-Os   ¾A
c                 ó²   — t        «       }t        j                  |«      }|j                  D ]  }|j	                  d«       Œ | j                  |t        «       y)zÇ
        The L{root.DeferredResolver} initially returned by L{root.bootstrap}
        becomes a L{root.Resolver} when the supplied resolver has successfully
        looked up all root hints.
        rÉ   N)rÐ   r   rÙ   rÓ   ÚcallbackrZ   r   ©rJ   rß   rÛ   rM   s       r*   Útest_becomesResolverz#BootstrapTests.test_becomesResolver‚  sL   € ô $“~ˆÜŸ>™>¨,Ó7ÐØ×,Ñ,ò 	&ˆAØ�J‰J�}Õ%ð	&à×ÑÐ.´Õ9r,   c                 óÆ   — t        «       }t        j                  |«      }|j                  D ]  }|j	                  d«       Œ | j                  |j                  dgdz  «       y)z›
        The L{root.Resolver} which eventually replaces L{root.DeferredResolver}
        is supplied with the IP addresses of the 13 root servers.
        rÉ   é   N)rÐ   r   rÙ   rÓ   rã   r?   r¿   rä   s       r*   Útest_resolverReceivesRootHintsz-BootstrapTests.test_resolverReceivesRootHintsŽ  sY   € ô
 $“~ˆÜŸ>™>¨,Ó7ÐØ×,Ñ,ò 	&ˆAØ�J‰J�}Õ%ð	&à×ÑÐ)×/Ñ/°-°À2Ñ1EÕFr,   c                 ó  ‡ ‡— t        «       }t        j                  |«      Št        |j                  «      }t        |«      }|D ]  }|j                  d«       Œ |j                  t        «       «       ˆˆ fd„}|j                  |«       y)zÇ
        The L{root.Resolver} is eventually created, even if some of the root
        hint lookups fail. Only the working root hint IP addresses are supplied
        to the L{root.Resolver}.
        rÉ   c                 óF   •— ‰j                  ‰j                  dgdz  «       y )NrÉ   é   ©r?   r¿   ©ÚresrÛ   rJ   s    €€r*   Ú
checkHintszFBootstrapTests.test_continuesWhenSomeRootHintsFail.<locals>.checkHints§  s!   ø€ Ø×ÑÐ-×3Ñ3°m°_ÀrÑ5IÕJr,   N)
rÐ   r   rÙ   ÚiterrÓ   Únextrã   Úerrbackr   ÚaddBoth©rJ   rß   r&   Úd1rM   rï   rÛ   s   `     @r*   Ú#test_continuesWhenSomeRootHintsFailz2BootstrapTests.test_continuesWhenSomeRootHintsFail™  sq   ù€ ô $“~ˆÜŸ>™>¨,Ó7ÐÜ�|×2Ñ2Ó3ˆÜ�'‹]ˆØò 	&ˆAØ�J‰J�}Õ%ð	&à
�
‰
”<“>Ô"õ	Kð 	�
‰
�:Õr,   c                 óf  ‡ ‡— t        «       }t        j                  |«      Št        |j                  «      }t        |«      }|D ]  }|j                  t        «       «       Œ |j                  t        «       «       ˆˆ fd„}|j                  |«       ‰ j                  ‰ j                  t        «       y)z´
        The L{root.Resolver} is eventually created, even if all of the root hint
        lookups fail. Pending and new lookups will then fail with
        AttributeError.
        c                 ó>   •— ‰j                  ‰j                  g «       y ©Nrì   rí   s    €€r*   rï   zEBootstrapTests.test_continuesWhenAllRootHintsFail.<locals>.checkHintsº  s   ø€ Ø×ÑÐ-×3Ñ3°RÕ8r,   N)rÐ   r   rÙ   rð   rÓ   rñ   rò   r   ró   Ú
addCleanupÚflushLoggedErrorsrô   s   `     @r*   Ú"test_continuesWhenAllRootHintsFailz1BootstrapTests.test_continuesWhenAllRootHintsFail¬  s†   ù€ ô $“~ˆÜŸ>™>¨,Ó7ÐÜ�|×2Ñ2Ó3ˆÜ�'‹]ˆØò 	&ˆAØ�I‰I”l“nÕ%ð	&à
�
‰
”<“>Ô"õ	9ð 	�
‰
�:Ôà�‰˜×.Ñ.´Õ=r,   c                 óÒ   — t        «       }t        j                  |t        ¬«      }|j                  D ]  }|j                  d«       Œ | j                  |j                  t        «       y)z»
        L{root.bootstrap} accepts a C{resolverFactory} argument which is passed
        as an argument to L{root.Resolver} when it has successfully looked up
        root hints.
        )rÀ   rÉ   N)rÐ   r   rÙ   r»   rÓ   rã   rÁ   rÂ   rä   s       r*   Útest_passesResolverFactoryz)BootstrapTests.test_passesResolverFactoryÁ  s[   € ô $“~ˆÜŸ>™>ØÔ*@ô
Ðð ×,Ñ,ò 	&ˆAØ�J‰J�}Õ%ð	&ð 	�‰Ð&×7Ñ7Ô9OÕPr,   N)r¯   r°   r±   r²   rÜ   rá   rå   rè   rö   rü   rþ   ri   r,   r*   r×   r×   l  s.   „ ñòGòQò
:ò	Gòò&>ó*Qr,   r×   c                   ó   — e Zd ZdZd„ Zy)ÚStubDNSDatagramProtocolz›
    A do-nothing stand-in for L{DNSDatagramProtocol} which can be used to avoid
    network traffic in tests where that kind of thing doesn't matter.
    c                 ó   — t        «       S rù   )r   )rJ   ÚaÚkws      r*   rl   zStubDNSDatagramProtocol.queryØ  s
   € Ü‹zÐr,   N)r¯   r°   r±   r²   rl   ri   r,   r*   r   r   Ò  s   „ ñó
r,   r   zbtwisted.names.root.retry is deprecated since Twisted 10.0.  Use a Resolver object for retry logic.)ÚcategoryrR   N):r²   Úzope.interfacer   Úzope.interface.verifyr   Útwisted.internet.deferr   r   r   r   Útwisted.internet.interfacesr	   Útwisted.namesr
   r   Útwisted.names.dnsr   r   r   r   r   r   r   r   r   r   r   r   r   r   Útwisted.names.errorr   r   Útwisted.names.rootr   Útwisted.names.test.test_utilr   Útwisted.python.logr   Útwisted.trialr   Útwisted.trial.unittestr    r!   r+   r0   r2   Ú	Exceptionr´   r»   r½   rÞ   rÐ   r×   r   ÚsuppressÚDeprecationWarningÚ_retrySuppressionri   r,   r*   ú<module>r     sæ   ðñõ 'Ý -ç QÓ QÝ 7ß &÷÷ ÷ ÷ ÷  <Ý 'Ý 6Ý "Ý ß @òò/ôp0˜ô p0ôf˜yô ò"1ô'
 xô '
òT€ñ" ˆ_Ó÷!ð !ó ð!ñH ˆO˜\Ô *ôcQÐ(ô cQ÷Lñ ð "�D—M‘MØð	+ôÑ r,   