ó
    Ö›‘h2d  ã                   óÈ  • S r SSKJr  SSKJr  SSKJrJrJrJ	r	  SSK
Jr  SSKJrJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSKJrJ r   SS	K!J"r"  SS
K#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*J+r+  S r,S r- " S S\+5      r. " S S\/5      r0S r1 " S S\+5      r2/ SQr3\" \5       " S S5      5       r4\" \\45         " S S\*5      r5 " S S5      r6\(Rn                  " \8SS9r9g )!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                 ó*   • U u  pnUS   R                   $ )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       ÚgC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/names/test/test_rootresolve.pyÚgetOnePayloadr+   &   s   € ð
 �N€CˆsØˆq‰6�>‰>Ðó    c                 ó4   • [        U 5      R                  5       $ )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                   óŽ   • \ rS rSrSrS rS rS r/ / / \4S jr	SS jr
S rS	 rS
 rS rS rS rS rS rS rS rS rS rSrg)ÚRootResolverTestsé7   z+
Tests for L{twisted.names.root.Resolver}.
c                 óP  • [        5       n[        / US9nUR                  [        S[        [
        5      S/SU5      nUR                  R                  5       u  pVUR                  u  u  px[        5       n	U	R                  U5        U R                  U	R                  [        S[        [
        5      /5        U R                  U	R                  / 5        U R                  U	R                  / 5        U R                  U	R                  / 5        / n
UR!                  U
R"                  5        U R                  U
/ 5        U	R                  SS2	 SU	l        U	R                  R#                  ['        S[)        S5      S95        UR*                  R-                  U	R/                  5       S5        U
S	   $ )
a  
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Úfilterr5   ÚresolverÚdÚ
portNumberÚ	transportÚpacketÚaddressÚmessageÚresponses              r*   Ú
_queryTestÚRootResolverTests._queryTest<   sc  € ô  “/ˆÜ˜B¨Ñ0ˆØ�O‰OÜÐ$¤a¬Ó,Ð/@Ð.AÀ5È&ó
ˆð
 !(× 0Ñ 0× 8Ñ 8Ó :Ñˆ
ð (×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                 óº   • U R                  S5      u  pnU R                  U[        S[        SSS9S9/5        U R                  U/ 5        U R                  U/ 5        g)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.
Tr6   r:   r   ©Úttlr#   N)rU   r@   r   r   )rK   rG   rC   rD   s       r*   Útest_filteredQueryÚ$RootResolverTests.test_filteredQueryg   s_   € ð )-¯©¸Ó(=Ñ%ˆ˜:Ø×ÑØ”XÐ0¼(À;ÐTUÑ:VÑWÐXô	
ð 	×Ñ˜ BÔ'Ø×Ñ˜ RÕ(r,   c                 óT  • U R                  S5      nU R                  U[        5        U R                  UR                  / 5        U R                  UR
                  [        S[        SSS9S9/5        U R                  UR                  / 5        U R                  UR                  / 5        g)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.
Fr6   r:   r   rX   r#   N)
rU   ÚassertIsInstancer   r@   rA   rB   r   r   rC   rD   )rK   rS   s     r*   Útest_unfilteredQueryÚ&RootResolverTests.test_unfilteredQueryu   sŽ   € ð —/‘/ %Ó(ˆØ×Ñ˜g¤wÔ/Ø×Ñ˜Ÿ™¨"Ô-Ø×ÑØ�O‰OÜÐ(´(¸;ÈAÑ2NÑOÐPô	
ð 	×Ñ˜×*Ñ*¨BÔ/Ø×Ñ˜×+Ñ+¨RÕ0r,   c                 ó  • [        US9nUR                  U4UR                  U4UR                  U44 HM  u  pgUR	                  U VV	s/ s H)  u  p‰[        X‰R                  [        U	S[        5      U	S9PM+     sn	n5        MO     U$ s  sn	nf )aK  
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   rB   rC   rD   Úextendr   ÚTYPEÚgetattrr   )
rK   rB   rC   rD   ra   rT   ÚsectionÚdataÚnameÚrecords
             r*   Ú_respondÚRootResolverTests._respond…   s�   € ô  Ñ'ˆà×Ñ˜wÐ'Ø×Ñ Ð+Ø× Ñ  *Ð-ó
‰MˆGð
 �N‰Nñ
 +/ô	ò +/™˜ô ØŸk™k¬7°6¸7ÄBÓ+GÐQWôñ +/ò	öñ
ð ˆùós   Á0Bc                 ó@   ^ ^• S/n[        X25      nU U4S jnXTl        U$ )ah  
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.
r7   c                 óü   >• [        SU R                   SU< 35        U HH  n TU   nXPR                  R                  U R                  4   n[	        TR
                  " S0 UD65      s  $    g ! [         a     MZ  f = f)NzQuery for QNAME z at © )r   rh   ÚKeyErrorÚtyper   rj   )	ÚqueryÚserverAddressesÚtimeoutrL   ÚaddrÚserverÚrecordsrK   ÚserverResponsess	          €€r*   rq   Ú-RootResolverTests._getResolver.<locals>.query±   s}   ø€ ÜÐ" 5§:¡: ,¨d°?Ñ2EÐFÔGÛ'�ðØ,¨TÑ2�Fð !§¡§¡°%·*±*Ð!<Ñ=�Ü˜tŸ}š}Ñ7¨wÑ7Ó8Ò8ò (øô  ó Úðús   ¤A-Á-
A;Á:A;)r   r;   )rK   rw   ÚmaximumQueriesÚrootsrM   rq   s   ``    r*   Ú_getResolverÚRootResolverTests._getResolver¤   s'   ù€ ð �ˆÜ˜EÓ2ˆö	9ð  ŒØˆr,   c                 ó(  • S[         4S[        S5      4/S[        S5      4/S.0S[         4SS[        S5      4/00S.nU R                  U5      nUR	                  S5      nUR                  [        5        UR                  U R                  S5        U$ )zæ
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.
r6   ó   ns1.example.comú34.55.89.144©rC   rD   rB   ú10.0.0.1)©r7   é5   )r   rƒ   ©r   r   r   r{   ÚlookupAddressrE   r0   r@   ©rK   ÚserversrM   rN   s       r*   Útest_lookupAddressÚ$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  • [        S5      n[        Ul        S[        4SU4/S[	        S5      4/S[        S5      4/S.0S[        4SS[        S5      4/00S.nU R                  U5      nUR                  S5      nUR                  [        5        UR                  U R                  [        S5      5        U$ )	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.
r�   r6   r~   ú10.0.0.2)rB   rC   rD   rB   ú10.0.0.3)r‚   ©r‹   rƒ   )
r   r   rb   r   r   r{   r…   rE   r+   r@   )rK   ÚbadClassr‡   rM   rN   s        r*   Útest_lookupChecksClassÚ(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                 ó:  • S[         4SS[        S5      4/0S[         4SS[        S5      4/00S[         4SS[        S5      4/00S.nU R                  U5      nUR	                  S5      nUR                  [        5        UR                  U R                  S5        U$ )z~
If an intermediate response includes no glue records for the
authorities, separate queries are made to find those addresses.
r6   rC   s   ns1.example.orgrB   r�   r‹   )r‚   )r�   rƒ   r„   r†   s       r*   Útest_missingGlueÚ"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                 ó–   • SS[         4S[        000nU R                  U5      nUR                  S5      nU R	                  U[
        5      $ )zi
If a name is missing, L{Resolver.lookupAddress} returns a L{Deferred}
which fails with L{DNSNameError}.
r‚   r6   ra   )r   r   r{   r…   ÚassertFailurer   r†   s       r*   Útest_missingNameÚ"RootResolverTests.test_missingName  s[   € ð Ø#¤QÐ'ØœUð*ðð
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ"Ð#5Ó6ˆØ×!Ñ! !¤\Ó2Ð2r,   c                 óŠ   • SS[         40 00nU R                  U5      nUR                  S5      nU R                  U[        5      $ )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   r{   r…   r•   r   r†   s       r*   Útest_answerlessÚ!RootResolverTests.test_answerless  sR   € ð Ø¤Ð# Rðð
ˆð
 ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤]Ó3Ð3r,   c                 óÂ   • SS[         4SS[        S5      4/0S[         4S[        000nU R                  U5      nUR	                  S5      nU R                  U[        5      $ )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™   rC   r~   ra   )r   r   r   r{   r…   r•   r   r†   s       r*   Útest_delegationLookupErrorÚ,RootResolverTests.test_delegationLookupError.  s|   € ð Ø¤Ð#Ø >´9Ð=OÓ3PÐ"QÐ!Rð&ð $¤QÐ'ØœUð*ð	ð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤\Ó2Ð2r,   c                 ó¶   • SS[         4SS[        S5      4/0S[         40 00nU R                  U5      nUR                  S5      nU R	                  U[
        5      $ )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™   rC   r~   )r   r   r{   r…   r•   r   r†   s       r*   Útest_delegationLookupEmptyÚ,RootResolverTests.test_delegationLookupEmptyB  st   € ð Ø¤Ð#Ø >´9Ð=OÓ3PÐ"QÐ!Rð&ð $¤QÐ'¨ð	ð
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤]Ó3Ð3r,   c           	      ó  • SS[         4S[        0S[        4SS[        S5      4/000nU R	                  U5      nUR                  S5      nS nUR                  U5        UR                  U R                  [        S5      5        U$ )z
L{Resolver.lookupNameservers} is like L{Resolver.lookupAddress}, except
it queries for I{NS} records instead of I{A} records.
r‚   r™   ra   rB   r~   c                 ó>   • U u  pnUS   R                   R                  $ ©Nr   )r$   rh   r%   s       r*   Ú
getOneNameÚ<RootResolverTests.test_lookupNameservers.<locals>.getOneNamef  s   € Ø$‰NˆC�sØ�q‘6—>‘>×&Ñ&Ð&r,   )	r   r   r   r   r{   ÚlookupNameserversrE   r@   r   )rK   r‡   rM   rN   r¥   s        r*   Útest_lookupNameserversÚ(RootResolverTests.test_lookupNameserversT  s›   € ð Ø¤Ð#ØœUð&ð  ¤Ð$Ø ´Ð;MÓ1NÐ OÐPð'ð	ð	
ˆð ×$Ñ$ WÓ-ˆØ×&Ñ& ~Ó6ˆò	'ð 	
�‰�jÔ!Ø	�‰�d×&Ñ&¬Ð-?Ó(@ÔAØˆr,   c                 óN  • SS[         4SS[        S5      4S[        S5      4/000nU R                  U5      nUR	                  S5      nUR                  S 5        UR                  U R                  [        S[        [        S5      S9[        S[         [        S5      S9/5        U$ )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™   rB   ó   example.netz10.0.0.7c                 ó   • U S   $ r¤   rn   r/   s    r*   Ú<lambda>Ú<RootResolverTests.test_returnCanonicalName.<locals>.<lambda>  ó   €  g¨a¢jr,   r#   ©	r   r   r   r{   r…   rE   r@   r   r   r†   s       r*   Útest_returnCanonicalNameÚ*RootResolverTests.test_returnCanonicalNamen  s´   € ð Ø¤Ð#ØØ'¬°nÓ)EÐFØ'¬°*Ó)=Ð>ð ð&ðð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ	�‰Ñ0Ô1Ø	�‰Ø×Ñä˜¬¼À^Ó8TÑUÜ˜¬´H¸ZÓ4HÑIðô	
ð ˆr,   c                 ób  • SS[         4SS[        S5      4/0S[         4SS[        S5      4/000nU R                  U5      nUR	                  S5      nUR                  S 5        UR                  U R                  [        S[        [        S5      S9[        S[         [        S5      S9/5        U$ )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™   rB   r«   z10.0.0.5c                 ó   • U S   $ r¤   rn   r/   s    r*   r­   Ú<RootResolverTests.test_followCanonicalName.<locals>.<lambda>›  r¯   r,   r#   r°   r†   s       r*   Útest_followCanonicalNameÚ*RootResolverTests.test_followCanonicalName‰  sÅ   € ð Ø¤Ð#Ø ´¸nÓ1MÐ NÐOð&ð  ¤Ð#Ø ´¸*Ó1EÐ FÐGð&ð	ð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ	�‰Ñ0Ô1Ø	�‰Ø×Ñä˜¬¼À^Ó8TÑUÜ˜¬´H¸ZÓ4HÑIðô	
ð ˆr,   c                 ó¾   • SS[         4SS[        S5      4S[        S5      4/000nU R                  U5      nUR                  S5      nU R	                  U[
        5      $ )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™   rB   r«   )r   r   r{   r…   r•   r   r†   s       r*   Útest_detectCanonicalNameLoopÚ.RootResolverTests.test_detectCanonicalNameLoop¥  sw   € ð Ø¤Ð#ØØ'¬°nÓ)EÐFØ'¬°nÓ)EÐFð ð&ðð	
ˆð ×$Ñ$ WÓ-ˆØ×"Ñ" >Ó2ˆØ×!Ñ! !¤]Ó3Ð3r,   c                 ó  • S[         4SS[        S5      4/0S[         4SS[        S5      4/00S[         4S[        S5      4/S[        S5      4/S.0S[         4SS[        S	5      4/00S
.nU R                  US5      nU R	                  UR                  S5      [        5      nU R                  US5      nUR                  S5      nUR                  [        5        UR                  U R                  [        S	5      5        [        X5/5      $ )zt
L{Resolver.lookupAddress} won't issue more queries following
delegations than the limit passed to its initializer.
r™   rC   r~   rB   r‹   s   ns2.example.comrŒ   r€   z10.0.0.4)r‚   r�   )rŒ   rƒ   é   é   )r   r   r   r{   r•   r…   r   rE   r+   r@   r   )rK   r‡   ÚfailerÚfailDÚ	succeederÚsucceedDs         r*   Útest_boundedQueriesÚ%RootResolverTests.test_boundedQueries¹  s8  € ð  ¤Ð#Ø >´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Ð.Ó/Ð/r,   rn   N)é
   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rU   rZ   r^   r   rj   r{   rˆ   r�   r’   r–   rš   r�   r    r¨   r±   r¶   r¹   rÂ   Ú__static_attributes__rn   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                   ó   • \ rS rSrSrS rSrg)ÚResolverFactoryArgumentsiê  zZ
Raised by L{raisingResolverFactory} with the *args and **kwargs passed to
that function.
c                 ó   • Xl         X l        g)zy
Store the supplied args and kwargs as attributes.

@param args: Positional arguments.
@param kwargs: Keyword arguments.
N©ÚargsÚkwargs)rK   rÏ   rÐ   s      r*   Ú__init__Ú!ResolverFactoryArguments.__init__ð  s   € ð Œ	Ø�r,   rÎ   N)rÅ   rÆ   rÇ   rÈ   rÉ   rÑ   rÊ   rn   r,   r*   rÌ   rÌ   ê  s   † ñõ
r,   rÌ   c                  ó   • [        X5      e)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                   ó*   • \ rS rSrSrS rS rS rSrg)Ú RootResolverResolverFactoryTestsi	  z.
Tests for L{root.Resolver._resolverFactory}.
c                 ób   • [        S/[        S9nU R                  UR                  [        5        g)zm
L{root.Resolver.__init__} accepts a C{resolverFactory}
argument and assigns it to C{self._resolverFactory}.
N)ÚhintsÚresolverFactory)r   rÔ   ÚassertIsÚ_resolverFactory©rK   Úrs     r*   Ú#test_resolverFactoryArgumentPresentÚDRootResolverResolverFactoryTests.test_resolverFactoryArgumentPresent  s(   € ô
 ˜D˜6Ô3IÑJˆØ�‰�a×(Ñ(Ô*@ÕAr,   c                 ól   • [        S/S9nU R                  UR                  [        R                   5        g)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_resolverFactoryArgumentAbsentÚCRootResolverResolverFactoryTests.test_resolverFactoryArgumentAbsent  s(   € ô ˜D˜6Ñ"ˆØ�‰�a×(Ñ(¬&¯/©/Õ:r,   c                 óÖ   • [        5       n[        S/[        US9nU R                  [        UR
                  S5      nU R                  SUS/S.4UR                  UR                  45        g)za
L{root.Resolver._resolverFactory} is supplied with C{reactor} and
C{servers} keyword arguments.
ú192.0.2.101)rØ   rÙ   r5   zexample.comrn   )rä   rƒ   )r5   r‡   N)	Úobjectr   rÔ   ÚassertRaisesrÌ   r…   r@   rÏ   rÐ   )rK   ÚdummyReactorrÝ   Úes       r*   Ú)test_resolverFactoryOnlyExpectedArgumentsÚJRootResolverResolverFactoryTests.test_resolverFactoryOnlyExpectedArguments  sj   € ô
 “xˆÜØ �/Ü2Ø ñ
ˆð ×ÑÔ6¸¿¹ÈÓWˆà×ÑØ˜\Ð7JÐ6KÑLÐMØ�V‰V�Q—X‘XÐõ	
r,   rn   N)	rÅ   rÆ   rÇ   rÈ   rÉ   rÞ   rá   ré   rÊ   rn   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                   ó$   • \ rS rSrSrS rS rSrg)ÚStubResolveriD  z¢
An L{IResolverSimple} implementer which traces all getHostByName
calls and their deferred results. The deferred results can be
accessed and fired synchronously.
c                 ó    • / U l         / U l        g)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)rK   s    r*   rÑ   ÚStubResolver.__init__L  s   € ð ˆŒ
Ø ˆÕr,   c                 óˆ   • U R                   R                  X45        [        5       nU R                  R                  U5        U$ )a,  
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ï   rF   r   rð   )rK   rÏ   rÐ   rN   s       r*   ÚgetHostByNameÚStubResolver.getHostByNameV  s8   € ð 	�
‰
×Ñ˜4˜.Ô)Ü‹JˆØ×Ñ×"Ñ" 1Ô%Øˆr,   rî   N)rÅ   rÆ   rÇ   rÈ   rÉ   rÑ   ró   rÊ   rn   r,   r*   rì   rì   D  s   † ñò!õr,   rì   c                   óB   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)ÚBootstrapTestsil  z
Tests for L{root.bootstrap}
c                 ó€   • [         R                  " [        5       5      nU R                  U[         R                  5        g)zT
L{root.bootstrap} returns an object which is initially a
L{root.DeferredResolver}.
N)r   Ú	bootstraprì   r]   ÚDeferredResolver)rK   ÚdeferredResolvers     r*   Útest_returnsDeferredResolverÚ+BootstrapTests.test_returnsDeferredResolverq  s,   € ô
  Ÿ>š>¬,«.Ó9ÐØ×ÑÐ.´×0EÑ0EÕFr,   c                 ó´   • [        5       n[        R                  " U5        U R                  UR                  [
         Vs/ s H  o"40 4PM	     sn5        gs  snf )zv
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)rK   ÚstubResolverÚss      r*   Útest_resolves13RootServersÚ)BootstrapTests.test_resolves13RootServersy  sC   € ô
 $“~ˆÜ�Š�|Ô$Ø×Ñ˜×+Ñ+Å,Ó-OÂ,¸Q¨t°R«jÁ,Ñ-OÕPùÒ-Os   ¿A
c                 ó¸   • [        5       n[        R                  " U5      nUR                   H  nUR	                  S5        M     U R                  U[        5        g)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ð   Úcallbackr]   r   ©rK   rÿ   rú   rN   s       r*   Útest_becomesResolverÚ#BootstrapTests.test_becomesResolver‚  sG   € ô $“~ˆÜŸ>š>¨,Ó7ÐØ×,Ô,ˆAØ�J‰J�}Ö%ñ -à×ÑÐ.´Õ9r,   c                 óÌ   • [        5       n[        R                  " U5      nUR                   H  nUR	                  S5        M     U R                  UR                  S/S-  5        g)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_resolverReceivesRootHintsÚ-BootstrapTests.test_resolverReceivesRootHintsŽ  sT   € ô
 $“~ˆÜŸ>š>¨,Ó7ÐØ×,Ô,ˆAØ�J‰J�}Ö%ñ -à×ÑÐ)×/Ñ/°-°À2Ñ1EÕFr,   c                 ó  ^ ^• [        5       n[        R                  " U5      m[        UR                  5      n[        U5      nU H  nUR                  S5        M     UR                  [        5       5        UU 4S jnUR                  U5        g)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   >• TR                  TR                  S/S-  5        g )Nrä   é   ©r@   rØ   ©Úresrú   rK   s    €€r*   Ú
checkHintsÚFBootstrapTests.test_continuesWhenSomeRootHintsFail.<locals>.checkHints§  s!   ø€ Ø×ÑÐ-×3Ñ3°m°_ÀrÑ5IÕJr,   N)
rì   r   rø   Úiterrð   Únextr  Úerrbackr   ÚaddBoth©rK   rÿ   r&   Úd1rN   r  rú   s   `     @r*   Ú#test_continuesWhenSomeRootHintsFailÚ2BootstrapTests.test_continuesWhenSomeRootHintsFail™  sl   ù€ ô $“~ˆÜŸ>š>¨,Ó7ÐÜ�|×2Ñ2Ó3ˆÜ�'‹]ˆÛˆAØ�J‰J�}Ö%ñ à
�
‰
”<“>Ô"ö	Kð 	�
‰
�:Õr,   c                 ón  ^ ^• [        5       n[        R                  " U5      m[        UR                  5      n[        U5      nU H  nUR                  [        5       5        M     UR                  [        5       5        UU 4S jnUR                  U5        T R                  T R                  [        5        g)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                 ó>   >• TR                  TR                  / 5        g ©Nr  r  s    €€r*   r  ÚEBootstrapTests.test_continuesWhenAllRootHintsFail.<locals>.checkHintsº  s   ø€ Ø×ÑÐ-×3Ñ3°RÕ8r,   N)rì   r   rø   r  rð   r  r  r   r  Ú
addCleanupÚflushLoggedErrorsr  s   `     @r*   Ú"test_continuesWhenAllRootHintsFailÚ1BootstrapTests.test_continuesWhenAllRootHintsFail¬  s�   ù€ ô $“~ˆÜŸ>š>¨,Ó7ÐÜ�|×2Ñ2Ó3ˆÜ�'‹]ˆÛˆAØ�I‰I”l“nÖ%ñ à
�
‰
”<“>Ô"ö	9ð 	�
‰
�:Ôà�‰˜×.Ñ.´Õ=r,   c                 óÒ   • [        5       n[        R                  " U[        S9nUR                   H  nUR                  S5        M     U R                  UR                  [        5        g)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_passesResolverFactoryÚ)BootstrapTests.test_passesResolverFactoryÁ  sV   € ô $“~ˆÜŸ>š>ØÔ*@ñ
Ðð ×,Ô,ˆAØ�J‰J�}Ö%ñ -ð 	�‰Ð&×7Ñ7Ô9OÕPr,   rn   N)rÅ   rÆ   rÇ   rÈ   rÉ   rû   r  r  r
  r  r"  r%  rÊ   rn   r,   r*   rö   rö   l  s.   † ñòGòQò
:ò	Gòò&>õ*Qr,   rö   c                   ó   • \ rS rSrSrS rSrg)ÚStubDNSDatagramProtocoliÒ  z�
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                 ó   • [        5       $ r  )r   )rK   ÚaÚkws      r*   rq   ÚStubDNSDatagramProtocol.queryØ  s
   € Ü‹zÐr,   rn   N)rÅ   rÆ   rÇ   rÈ   rÉ   rq   rÊ   rn   r,   r*   r(  r(  Ò  s   † ñõ
r,   r(  zbtwisted.names.root.retry is deprecated since Twisted 10.0.  Use a Resolver object for retry logic.)ÚcategoryrS   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Ú_retrySuppressionrn   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ñ ð —M’MØð	+ñÑ r,   