
    Vh\                        d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZmZmZ ddlmZ ddlmZmZmZ dd	lmZmZmZmZmZ dd
lmZ ddlmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. d Z/ G d dej`                        Z1 ejD                  dddddddd      Z2 ejD                  ddddd d!d"d#      Z3 ejD                  d$d%d&d'dd(d)      Z4 e1de2fe2 ejB                  d*       ejj                  d+       ejl                  d,       ejl                  d-d.       ejn                  d/d0       ejp                  d1d23       ejr                  d4       ejt                  d5       ejv                  d6       ejx                  d7d8       ejz                  dd9d:       ejz                  d;d<d=       ejz                  d>d?d@       ejx                  dA       ej|                  dB       ej~                  dCdDE       ej                  ddFG       ej                  dHdIJ       ej                  dKej                  dL       ej                  dd/dMdNdO       ej                  dP      g ej                  dQdRdSdT      g ejB                  dU       ejB                  dV      g ejB                  dW       ejB                  dX      g ejr                  d      g ejB                  dY      gdZ[      ZG e1de3fd\ ej                  d]      e3gi[      ZI e1d^e4fd^e4 ejB                  dYd_`       ejj                  dadb`       ejj                  dcdd`       ej                  dQdRdSdTde`      gi[      ZJ G df dge.j                        ZL G dh die.j                        ZM G dj dke.j                        ZN G dl dme.j                        ZO G dn doe.j                        ZP G dp dqe.j                        ZQ G dr dse.j                        ZR G dt due.j                        ZS G dv dwe.j                        ZTdxZU G dy dze.j                        ZVd{ZW G d| d}e.j                        ZXy)~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                 F    | d   D cg c]  }|j                    c}S c c}w Nr   payload)resultsrs     M/home/dcms/DCMS/lib/python3.12/site-packages/twisted/names/test/test_names.pyjustPayloadr'   !   s    &qz*!AII***s   c                       e Zd Zd Zy)NoFileAuthorityc                 `    t         j                  j                  |        ||c| _        | _        y N)r   ResolverBase__init__soarecords)selfr.   r/   s      r&   r-   zNoFileAuthority.__init__&   s&    $$T*!$g$,    N)__name__
__module____qualname__r-    r1   r&   r)   r)   %   s    .r1   r)      test-domain.comzroot.test-domain.comd     i  H?&      mnamernameserialrefreshminimumexpireretryttls   93.84.28.in-addr.arpax   i1  i~  Ϊ       my-domain.coms   postmaster.test-domain.com   i90  i?B )r=   r>   r?   r@   rA   rB   rC   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::4321r1      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)r6   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rD   s
   ns1.domains   2Ms
   ns2.domain3H4Dc                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z y) ServerDNSTestsz/
    Test cases for DNS server and client.
    c                 >   t        j                  t        t        t        gd      | _        t        j                  | j
                        }	 t        j                  d| j
                  d      }| j                  |j                         |j                         j                  }	 t        j                  ||d      }| j                  |j                         	 || _        || _        t'        j(                  d|fg      | _        y # t        j                   $ r Y nw xY w)N   )verboser   	127.0.0.1)	interfaceservers)r   DNSServerFactorytest_domain_comreverse_domainmy_domain_comfactoryr   DNSDatagramProtocolr	   	listenTCP
addCleanupstopListeninggetHostport	listenUDPr   CannotListenErrorlistenerTCPlistenerUDPr   r   resolver)r0   pr   r   r   s        r&   setUpzServerDNSTests.setUp   s    ..nm<a
 ##DLL1!++At||{SK OOK556&&(--D%//a;O  9 9:&&+t1D0EF **  s   $D DDc                     | j                   j                  dd D ]  }|j                  j                           t	        t
        | j                   j                  dd       S )zu
        Clean up any server connections associated with the
        L{DNSServerFactory} created in L{setUp}
        N)r{   connections	transportloseConnectionr   r	   )r0   conns     r&   tearDownzServerDNSTests.tearDown   sP     LL,,Q/ 	,DNN))+	, (1I1I!1LMMr1   c                 8      fd}|j                  |       |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                 d    t        |       }j                  t              t        |             y r+   )r'   assertEqualset)responsereceivedRecordsexpectedRecordsr0   s     r&   checkResultsz.ServerDNSTests.namesTest.<locals>.checkResults   s'    )(3OS133GHr1   )addCallback)r0   queryingr   r   s   ` ` r&   	namesTestzServerDNSTests.namesTest   s     	I 	\*r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )z"Test simple DNS 'A' record queriestest-domain.comrs   r9   rk   r   r   lookupAddressr   r   r0   s    r&   test_addressRecord1z"ServerDNSTests.test_addressRecord1   s7    ~~MM''(9:\\+845
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      t        j                  dd      g      S )z1Test DNS 'A' record queries with multiple answersrO   z123.242.1.5r9   rk   z0.255.0.255r   r   s    r&   test_addressRecord2z"ServerDNSTests.test_addressRecord2   sG    ~~MM''(>?]9]9
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      t        j                  dd      g      S )z+Test DNS 'A' record queries with edge caseszhost-two.test-domain.comz255.255.255.254r9   rk   0.0.0.0r   r   s    r&   test_addressRecord3z"ServerDNSTests.test_addressRecord3   sH    ~~MM''(BC.H=YH5
 	
r1   c                 b    | j                  | j                  j                  d      t        g      S )zTest DNS 'SOA' record queriesr   )r   r   lookupAuthority
soa_recordr   s    r&   test_authorityzServerDNSTests.test_authority   s*    ~~MM))*;<zl
 	
r1   c           	          | j                  | j                  j                  d      t        j                  ddd      t        j
                  dd      t        j
                  dd      g      S )z
        The DNS client can issue an MX query and receive a response including
        an MX record as well as any A record hints.
        r6   rN   rh   r9   rk   rf   rg   )r   r   lookupMailExchanger   	Record_MXr   r   s    r&   test_mailExchangeRecordz&ServerDNSTests.test_mailExchangeRecord   sZ    
 ~~MM,,-?@b"9xH^:^:
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )zTest DNS 'NS' record queriesr   z39.28.189.39r9   rk   )r   r   lookupNameserversr   	Record_NSr   s    r&   test_nameserverzServerDNSTests.test_nameserver  s7    ~~MM++,=>]]>x89
 	
r1   c                     | j                  | j                  j                  d      t        j                  ddd      g      S )zTest DNS 'HINFO' record queriesr   rP   rQ   r9   )rR   rS   rD   )r   r   lookupHostInfor   Record_HINFOr   s    r&   
test_HINFOzServerDNSTests.test_HINFO  sA    ~~MM(():;  %@h
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )zTest DNS 'PTR' record queriesz123.93.84.28.in-addr.arpaztest.host-reverse.lookup.comrF   rk   )r   r   lookupPointerr   
Record_PTRr   s    r&   test_PTRzServerDNSTests.test_PTR   s8    ~~MM''(CD^^:IJ
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )zTest DNS 'CNAME' record queriesr   zcanonical.name.comr9   rk   )r   r   lookupCanonicalNamer   Record_CNAMEr   s    r&   
test_CNAMEzServerDNSTests.test_CNAME'  s:    ~~MM--.?@2AB
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )zTest DNS 'MB' record queriesr   zmailbox.test-domain.comr9   rk   )r   r   lookupMailBoxr   	Record_MBr   s    r&   test_MBzServerDNSTests.test_MB.  s8    ~~MM''(9:]]4(CD
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )zTest DNS 'MG' record queriesr   zmail.group.someplacer9   rk   )r   r   lookupMailGroupr   	Record_MGr   s    r&   test_MGzServerDNSTests.test_MG5  s8    ~~MM))*;<]]1x@A
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )zTest DNS 'MR' record queriesr   zmail.redirect.or.whateverr9   rk   )r   r   lookupMailRenamer   	Record_MRr   s    r&   test_MRzServerDNSTests.test_MR<  s8    ~~MM**+<=]]6HEF
 	
r1   c                     | j                  | j                  j                  d      t        j                  ddd      g      S )zTest DNS 'MINFO' record queriesr   z
r mail boxz
e mail boxr9   )rY   rZ   rD   )r   r   lookupMailboxInfor   Record_MINFOr   s    r&   
test_MINFOzServerDNSTests.test_MINFOC  s@    ~~MM++,=>  (,H
 	
r1   c           
          | j                  | j                  j                  d      t        j                  ddddd      g      S )zTest DNS 'SRV' record querieszhttp.tcp.test-domain.comrc   rd   re   some.other.place.foolr9   rk   )r   r   lookupServicer   
Record_SRVr   s    r&   test_SRVzServerDNSTests.test_SRVN  s>    ~~MM''(BC^^C/FHUV
 	
r1   c                     | j                  | j                  j                  d      t        j                  ddd      g      S )zTest DNS 'AFSDB' record queriesr   r;   zafsdb.test-domain.comr9   )r[   r\   rD   )r   r   lookupAFSDatabaser   Record_AFSDBr   s    r&   
test_AFSDBzServerDNSTests.test_AFSDBU  sA    ~~MM++,=>  (?X
 	
r1   c                     | j                  | j                  j                  d      t        j                  ddd      g      S )zTest DNS 'RP' record queriesr   zwhatever.i.dunnozsome.more.textr9   )r]   r^   rD   )r   r   lookupResponsibilityr   	Record_RPr   s    r&   test_RPzServerDNSTests.test_RP`  s?    ~~MM../@A+1Ax
 	
r1   c                     | j                  | j                  j                  d      t        j                  ddd      t        j                  dd      g      S )zTest DNS 'TXT' record queriesr   rT   rU   r9   rk   rX   )r   r   
lookupTextr   
Record_TXTr   s    r&   test_TXTzServerDNSTests.test_TXTk  sR    ~~MM$$%67,.?X C	

 
	
r1   c           	          | j                  | j                  j                  d      t        j                  dd      t        j                  ddd      g      S )zH
        L{DNSServerFactory} can serve I{SPF} resource records.
        r   rK   r9   rk   rL   rM   )r   r   lookupSenderPolicyr   
Record_SPFr   s    r&   test_spfzServerDNSTests.test_spfy  sQ     ~~MM,,->?E8T*5 

 
	
r1   c           	          | j                  | j                  j                  d      t        j                  dt
        j                  dd      g      S )zTest DNS 'WKS' record queriesr   z12.54.78.12r_   r9   rk   )r   r   lookupWellKnownServicesr   
Record_WKSsocketIPPROTO_TCPr   s    r&   test_WKSzServerDNSTests.test_WKS  sI    ~~MM112CD!&&3 	

 
	
r1   c                 l   t        j                   t              }t        j                  |_        | j	                  | j
                  j                  d      |t        j                  dd      t        j                  dd      t        j                  dd      t        j                  d	d
ddd      g      S )NrI   1.2.3.4rj   rk   z
ns1.domain2Mz
ns2.domainrl   rc   rd   re   r   rm   )copymy_soarB   rD   r   r   lookupAllRecordsr   r   r   r   )r0   
result_soas     r&   test_someRecordsWithTTLsz'ServerDNSTests.test_someRecordsWithTTLs  s    YYv&

~~MM**?;YD1l5l5sE52ItT	
 		
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )z%Test DNS 'AAAA' record queries (IPv6)r   z'AF43:5634:1294:AFCB:56AC:48EF:34C3:01FFr9   rk   )r   r   lookupIPV6Addressr   Record_AAAAr   s    r&   	test_AAAAzServerDNSTests.test_AAAA  s8    ~~MM++,=>__FHUV
 	
r1   c                     | j                  | j                  j                  d      t        j                  dddd      t        j                  ddd	d      t        j                  d
ddd      g      S )z#Test DNS 'A6' record queries (IPv6)r   r   z
ABCD::4321 r9   rk   rV   z	0:0069::0zsome.network.tldrW   z$0:5634:1294:AFCB:56AC:48EF:34C3:01FFztra.la.la.net)r   r   lookupAddress6r   	Record_A6r   s    r&   test_A6zServerDNSTests.test_A6  sh    ~~MM(():;arx@b+/AxP:# 		
 	
r1   c                    t         j                  }t        t        j                  t
        j                  j                               D cg c]  }t        j                  |       }}|D ]  }|j                  ||_	         | j                  | j                  j                  d      j                  d       |      S c c}w )z9
        Test DNS 'AXFR' queries (Zone transfer)
        r   c                     | d   d d fS )Nr   r5   )r%   s    r&   <lambda>z2ServerDNSTests.test_zoneTransfer.<locals>.<lambda>  s    1Q49, r1   )r   rB   r   operatoraddrx   r/   valuesr   rD   r   r   
lookupZoner   )r0   default_ttlr%   r$   s       r&   test_zoneTransferz ServerDNSTests.test_zoneTransfer  s     !''"(7N7N7U7U7W"X
DIIaL
 
  	$Auu}#	$ ~~MM$$%67CC& 	
 	

s   	B=c                 z    t        dg      }| j                  |j                  d      t        j                        S )zu
        A failed AXFR TCP connection errbacks the L{Deferred} returned
        from L{Resolver.lookupZone}.
        )znameserver.invalid5   ru   zimpossible.invalid)r   assertFailurer   r   DNSLookupError)r0   r   s     r&    test_zoneTransferConnectionFailsz/ServerDNSTests.test_zoneTransferConnectionFails  s<    
 %?$@A!! 45u7K7K
 	
r1   c                     | j                  | j                  j                  d      t        j                  dd      g      S )z6Tests that unrelated zones don't mess with each other.zanothertest-domain.comr   r9   rk   r   r   s    r&   test_similarZonesDontInterferez-ServerDNSTests.test_similarZonesDontInterfere  s7    ~~MM''(@A\\)23
 	
r1   c                     | j                  | j                  j                  d      t        j                  dddddd      g      S )	z2
        Test DNS 'NAPTR' record queries.
        r   r7   rN   r`   ra   rb   r9   rk   )r   r   lookupNamingAuthorityPointerr   Record_NAPTRr   s    r&   
test_NAPTRzServerDNSTests.test_NAPTR  sM     ~~MM667HI  8 	
 	
r1   N)!r2   r3   r4   __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  r5   r1   r&   ro   ro      s    G<N.





	





	

	
	


 



 
$


r1   ro   c                       e Zd Zd Zy)HelperTestsc                     | j                         }t        j                  |      }t        d      D ]-  }t        j                  |      }| j	                  ||k         |}/ y )N   )mktempr   	getSerialrange
assertTrue)r0   faibs        r&   test_serialGeneratorz HelperTests.test_serialGenerator  sU    KKM"r 	A##A&AOOAE"A	r1   N)r2   r3   r4   r  r5   r1   r&   r  r    s    r1   r  c                   *    e Zd Zd Zd Zd Zd Zd Zy)	AXFRTestsc                    d | _         t        j                         | _        | j                  j	                  | j
                         t        j                  d| j                        | _        t        j                  dt        j                  t        j                  ddt        j                  ddddddd	d
            | _        | j                  t        j                  dt        j                  t        j                  ddt        j                   dd            t        j                  dt        j"                  t        j                  ddt        j$                  ddd            t        j                  dt        j&                  t        j                  ddt        j(                  dd            | j                  g| _        y )N	fooby.comiQ Fzhooj.fooby.comr7      i,  i  i  iX  )r=   r>   r?   r@   rC   rB   rA   rD   nametypeclsrD   authr#     ns.twistedmatrix.comr"  rD   rN   zmail.mv3d.com)
preferenceexchangerD   z64.123.27.105)addressrD   )r$   r   Deferreddr   _gotResultsr   AXFRController
controllerr   r   r   INr   r.   NSr   MXr   Ar   r/   r   s    r&   r   zAXFRTests.setUp  sH   !4++, //TVVD<<NN!&	
& HHLL VVFF+AsK LL VVFFoSVW LL UUFF_#F HH5
r1   c                 >    t        j                  ddddddddd	      S )N  r;   r   	idansweropCoderecDesrecAvr%  rCodetruncmaxSize)r   r   r   s    r&   _makeMessagezAXFRTests._makeMessage2  s.    {{

 
	
r1   c                 <   | j                         }t        j                  dt        j                  t        j                        g|_        | j                  |_        | j                  j                  |d        | j                  | j                  | j                         y )Nr  )r@  r   r   AXFRr1  queriesr/   answersr0  messageReceivedr   r$   )r0   ms     r&   test_bindAndTNamesStylez!AXFRTests.test_bindAndTNamesStyle@  sf    YY{CHHcff=>	LL	''40t||4r1   c                     || _         y r+   )r$   )r0   results     r&   r.  zAXFRTests._gotResultsH  s	    r1   c                    | j                   d d  }|rM| j                         }g |_        |j                  d      g|_        | j
                  j                  |d        |rM| j                  | j                  | j                          y r!   )	r/   r@  rC  poprD  r0  rE  r   r$   )r0   r/   rF  s      r&   test_DJBStylezAXFRTests.test_DJBStyleK  sl    ,,q/!!#AAI Q(AIOO++At4	 
 	t||4r1   N)r2   r3   r4   r   r@  rG  r.  rL  r5   r1   r&   r  r    s    3
j
55r1   r  c                       e Zd Zd Zd Zy)ResolvConfHandlingTestsc                     | j                         }t        j                  |      }| j                  |j                  dg       |j
                  j                          y )Nresolvrs   r  )r  r   r   r   
dynServers
_parseCallcancelr0   
resolvConfr%   s      r&   test_missingz$ResolvConfHandlingTests.test_missingW  sC    [[]
OO:.(9':;	r1   c                     | j                         }t        |d      j                          t        j                  |      }| j                  |j                  dg       |j                  j                          y )NwrP  rR  )	r  opencloser   r   r   rS  rT  rU  rV  s      r&   
test_emptyz"ResolvConfHandlingTests.test_empty]  sV    [[]
Z##%OO:.(9':;	r1   N)r2   r3   r4   rX  r]  r5   r1   r&   rN  rN  V  s    r1   rN  c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
AuthorityTestszs
    Tests for the basic response record selection code in L{FileAuthority}
    (independent of its fileness).
    c                     t         }d|j                  d   z   }| j                  |j                  |            }| j	                  |j
                  t               y)aJ  
        L{FileAuthority} lookup methods errback with L{DomainError} if
        the requested C{name} shares a common suffix with its zone but
        is not actually a descendant of its zone, in terms of its
        sequence of DNS name labels. eg www.the-example.com has
        nothing to do with the zone example.com.
           nonexistent.prefix-r   N)rx   r.   failureResultOfr   assertIsInstancevaluer   )r0   
testDomaintestDomainNamer  s       r&   'test_domainErrorForNameWithCommonSuffixz6AuthorityTests.test_domainErrorForNameWithCommonSuffixk  sK     %
/*..2CC  !9!9.!IJagg{3r1   c           
      H   t        t        j                  j                  t        ft        j                  j                  t        t	        j
                  d      gi      }| j                   |j                  t        j                  j                              \  }}}| j                  |g        | j                  |t	        j                  t        j                  j                  t        j                  t        j                  t        d      g       | j                  |g        y)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   ri   TrD   r#   r%  N)r)   r   r=   r"  r   r   successResultOfr   r   r   TYPErB   )r0   r   r9  
additionals       r&   test_recordMissingz!AuthorityTests.test_recordMissingx  s     $!!&&
3  %%MM),(
	 )-(<(<#I##J$4$4$9$9:)
%	: 	$$$))OO"))&	
 	R(r1   c                    t         }d|j                  d   z   }t        t        j                        dz   }| j                  |j                  t        ||                  }| j                  |j                  t               y)z
        Requesting a record of unknown type where no records exist for the name
        in question results in L{DomainError}.
        ra  r   r;   r"  r#  N)rx   r.   maxr   typeToMethodrb  queryr   rc  rd  r   )r0   re  rf  unknownTyper  s        r&   test_unknownTypeNXDOMAINz'AuthorityTests.test_unknownTypeNXDOMAIN  sl    
 %
/*..2CC&--.2  U[IJ
 	agg{3r1   c                     t        t        j                        dz   }| j                  t        j                  t        d|                  \  }}}| j                  |g        y)z
        Requesting a record of unknown type where other records exist for the
        name in question results in an empty answer set.
        r;   rI   ro  N)rp  r   rq  rj  rz   rr  r   r   )r0   rs  r9  r   rl  s        r&   test_unknownTypeMissingz&AuthorityTests.test_unknownTypeMissing  sW    
 &--.2(,(<(<? MN)
%	: 	$r1   c           
         dt         j                  j                  z   }t        j                  d      }t        t         j                  j                  t         f||gi      } t        ||      |      }| j                  |      \  }}}| j                  |g        | j                  |t        j                  |t        j                  t         j                  |d      g       | j                  |g        y)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   ri   Fri  N)r   r=   r"  r   r   r)   getattrrj  r   r   r2  rB   )r0   method	subdomain
nameserverr   r-  r9  rl  s           r&   _referralTestzAuthorityTests._referralTest  s      *"2"2"7"77	]]9-
#!!&&
3
	 'GIv&y1(,(<(<Q(?%	:$FF"))&	
 	R(r1   c                 &    | j                  d       y)a  
        When an I{NS} record is found for a child zone, it is included in the
        authority section of the response. It is marked as non-authoritative if
        the authority is not also authoritative for the child zone (RFC 2181,
        section 6.1).
        r   Nr|  r   s    r&   test_referralzAuthorityTests.test_referral  s     	?+r1   c                 &    | j                  d       y)zT
        A referral is also generated for a request of type C{ALL_RECORDS}.
        r   Nr~  r   s    r&   test_allRecordsReferralz&AuthorityTests.test_allRecordsReferral  s     	-.r1   N)r2   r3   r4   r  rg  rm  rt  rv  r|  r  r  r5   r1   r&   r_  r_  e  s,    
4 )D4	%)B,/r1   r_  c                       e Zd ZdZ ej
                  d      Z ej                  d      Zd Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)AdditionalProcessingTestszz
    Tests for L{FileAuthority}'s additional processing for those record types
    which require it (MX, CNAME, etc).
    s   10.0.0.1s   f080::1c                     t        |j                  j                  |f|j                  j                   ||      g||i      } t        ||      t        j                  j                        S )a  
        Perform a DNS lookup against a L{FileAuthority} configured with records
        as defined by C{makeRecord} and C{addresses}.

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

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

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

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

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

        @return: A L{Deferred} that fires with the result of the resolver
            method give by C{method}.
        ri   )r)   r=   r"  rx  r   )r0   ry  r.   
makeRecordtarget	addressesr   s          r&   _lookupSomeRecordsz,AdditionalProcessingTests._lookupSomeRecords  s_    : $%		F!3 4	
	 *wy&)**:*:*?*?@@r1   c                 Z    d }| j                  t        ||      t        ||             y)a  
        Assert that the L{RRHeader} instances given by C{expected} and
        C{computed} carry all the same information but without requiring the
        records appear in the same order.

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

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

        @raise self.failureException: If the two collections of records
            disagree.
        c                     | j                   S r+   )r#  )rrs    r&   r   z>AdditionalProcessingTests.assertRecordsMatch.<locals>.<lambda>$  s
     r1   )keyN)r   sorted)r0   expectedcomputedr  s       r&   assertRecordsMatchz,AdditionalProcessingTests.assertRecordsMatch  s'    $ !c2F84MNr1   c                 D   dt         j                  j                  z   }| j                  |t         |||      }| j	                  |      \  }}}| j                  |D 	cg c]4  }	t        j                  ||	j                  t         j                  |	d      6 c}	|       yc c}	w )aT  
        Verify that certain address records are included in the I{additional}
        section of a response generated by L{FileAuthority}.

        @param method: See L{_lookupSomeRecords}

        @param makeRecord: See L{_lookupSomeRecords}

        @param addresses: A L{list} of L{IRecord} providers which the
            I{additional} section of the response is required to match
            (ignoring order).

        @raise self.failureException: If the I{additional} section of the
            response consists of different records than those given by
            C{addresses}.
        s   mail.Tri  N)
r   r=   r"  r  rj  r  r   r   rk  rB   )
r0   ry  r  r  r  r-  r9  r   rl  r+  s
             r&   _additionalTestz)AdditionalProcessingTests._additionalTest'  s    " J,,111##FJ
FIV(,(<(<Q(?%	:  )	  LL"))#	 	
	s   9Bc                 Z    | j                  dt        t        j                  d      |       y)z
        Verify that a response to an MX query has certain records in the
        I{additional} section.

        @param addresses: See C{_additionalTest}
        r   rN   N)r  r   r   r   r0   r  s     r&   _additionalMXTestz+AdditionalProcessingTests._additionalMXTestJ  s$     	 '#--"<i	
r1   c                 <    | j                  | j                  g       y)z
        If the name of the MX response has A records, they are included in the
        additional section of the response.
        N)r  _Ar   s    r&   test_mailExchangeAdditionalAz6AdditionalProcessingTests.test_mailExchangeAdditionalAU      
 	y)r1   c                 <    | j                  | j                  g       y)z
        If the name of the MX response has AAAA records, they are included in
        the additional section of the response.
        N)r  _AAAAr   s    r&   test_mailExchangeAdditionalAAAAz9AdditionalProcessingTests.test_mailExchangeAdditionalAAAA\      
 	

|,r1   c                 R    | j                  | j                  | j                  g       y)z
        If the name of the MX response has both A and AAAA records, they are
        all included in the additional section of the response.
        N)r  r  r  r   s    r&   test_mailExchangeAdditionalBothz9AdditionalProcessingTests.test_mailExchangeAdditionalBothc      
 	45r1   c                 F    | j                  dt        j                  |       y)z
        Verify that a response to an NS query has certain records in the
        I{additional} section.

        @param addresses: See C{_additionalTest}
        r   N)r  r   r   r  s     r&   _additionalNSTestz+AdditionalProcessingTests._additionalNSTestj  s     	0#--Kr1   c                 <    | j                  | j                  g       y)z
        If the name of the NS response has A records, they are included in the
        additional section of the response.
        N)r  r  r   s    r&   test_nameserverAdditionalAz4AdditionalProcessingTests.test_nameserverAdditionalAs  r  r1   c                 <    | j                  | j                  g       y)z
        If the name of the NS response has AAAA records, they are included in
        the additional section of the response.
        N)r  r  r   s    r&   test_nameserverAdditionalAAAAz7AdditionalProcessingTests.test_nameserverAdditionalAAAAz  r  r1   c                 R    | j                  | j                  | j                  g       y)z
        If the name of the NS response has both A and AAAA records, they are
        all included in the additional section of the response.
        N)r  r  r  r   s    r&   test_nameserverAdditionalBothz7AdditionalProcessingTests.test_nameserverAdditionalBoth  r  r1   c                 *   dt         j                  j                  z   }| j                  dt         t        j
                  ||      }| j                  |      \  }}}t	        j                  t         j                  j                  t        j                  t         j                  t	        j
                  |      d      }| j                  |D cg c]4  }t	        j                  ||j                  t         j                  |d      6 c}|gz   |       yc c}w )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   Tri  N)r   r=   r"  r  r   r   rj  r   CNAMErB   r  rk  )	r0   r  r  r-  r9  r   rl  aliasr+  s	            r&   _answerCNAMETestz*AdditionalProcessingTests._answerCNAMETest  s     :++000##!:s/?/?
 )-(<(<Q(?%	:!!II!!$$V,
 	  )	  LL"))#	 g
 	
	s   
9Dc                 <    | j                  | j                  g       y)z
        If the name of the CNAME response has A records, they are included in
        the answer section of the response.
        N)r  r  r   s    r&   test_canonicalNameAnswerAz3AdditionalProcessingTests.test_canonicalNameAnswerA  s    
 	twwi(r1   c                 <    | j                  | j                  g       y)z
        If the name of the CNAME response has AAAA records, they are included
        in the answer section of the response.
        N)r  r  r   s    r&   test_canonicalNameAnswerAAAAz6AdditionalProcessingTests.test_canonicalNameAnswerAAAA  s    
 	tzzl+r1   c                 R    | j                  | j                  | j                  g       y)z
        If the name of the CNAME response has both A and AAAA records, they are
        all included in the answer section of the response.
        N)r  r  r  r   s    r&   test_canonicalNameAnswerBothz6AdditionalProcessingTests.test_canonicalNameAnswerBoth  s    
 	tww

34r1   N)r2   r3   r4   r  r   r   r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r5   r1   r&   r  r    sz    
 
k	"BCOOJ'E$ALO*!
F	
*-6L*-6!
F),5r1   r  c                       e Zd Zd Zy)NoInitialResponseTestsc                    fd}d }t        dg      }||_        g | j                  t        j                  d|       t        j
                  dt        j                  t        j                  ddt        j                  d	d
            g}t        j                  ddddddddd	      }||_
        j                  |       | j                  |j                  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                 8    t        j                  d            S r!   )r
   rK  )r0   argsmessagess     r&   rr  z3NoInitialResponseTests.test_noAnswer.<locals>.query  s     8<<?++r1   c                 R    t        j                  t        j                  d            S )NzCouldn't connect)r   failr   gaierror)r0   r  kwargss      r&   queryProtocolz;NoInitialResponseTests.test_noAnswer.<locals>.queryProtocol  s    ::foo.@ABBr1   )r   r   ru   rr  z	fooba.comr&  Fr'  r(  r!  r6  r;   r   r7  r  )r   _querypatchr   r|   r   r2  r1  r   r   rD  appendr  getHostByNamer   r  )r0   rr  r  r   r/   rF  r  s         @r&   test_noAnswerz$NoInitialResponseTests.test_noAnswer  s    	,
	C ^$45 	

3**G]C LL VVFF+AsK	
 KK

 	!!("8"8"EvWWr1   N)r2   r3   r4   r  r5   r1   r&   r  r    s    ,Xr1   r  c                   "    e Zd ZdZd Zd Zd Zy)SecondaryAuthorityServiceTestsz
    Tests for L{SecondaryAuthorityService}, a service which keeps one or more
    authorities up to date by doing zone transfers from a master.
    c                    d}t        |ddg      }| j                  |j                  |       | j                  |j                  d       | j                  |j                  d   j                  |       | j                  |j                  d   j                  d       | j                  |j                  d   j
                  d       | j                  |j                  d   j                  |       | j                  |j                  d   j                  d       | j                  |j                  d   j
                  d       y)	a  
        L{SecondaryAuthorityService} can be constructed with a C{str} giving a
        master server address and several domains, causing the creation of a
        secondary authority for each domain and that master server address and
        the default DNS port.
        192.168.1.2   example.comzexample.orgr  r   r;   s   example.orgN)r   r   primary_portdomainsdomainr0   r  services      r&   test_constructAuthorityFromHostz>SecondaryAuthorityServiceTests.test_constructAuthorityFromHost  s      +Gnm5TU'2++33W=+1126+22NC+33W=+1126+22NCr1   c                    d}d}t        j                  ||fddg      }| j                  |j                  |       | j                  |j                  d       | j                  |j
                  d   j                  |       | j                  |j
                  d   j                  |       | j                  |j
                  d   j                  d       | j                  |j
                  d   j                  |       | j                  |j
                  d   j                  |       | j                  |j
                  d   j                  d       y)	a\  
        L{SecondaryAuthorityService.fromServerAddressAndDomains} constructs a
        new L{SecondaryAuthorityService} from a C{str} giving a master server
        address and DNS port and several domains, causing the creation of a secondary
        authority for each domain and that master server address and the given
        DNS port.
        192.168.1.3i  zexample.net   example.edur      example.netr;   N)r   fromServerAddressAndDomainsr   r  r  r  r  )r0   r  r   r  s       r&   &test_constructAuthorityFromHostAndPortzESecondaryAuthorityServiceTests.test_constructAuthorityFromHostAndPort  s     +GGdOm^<
 	'2-+33W=+1148+22NC+33W=+1148+22NCr1   c                    d}t        |j                         ddg      }| j                  |j                  |       | j                  |j                  d   j                  |       | j                  |j                  d   j
                  d       | j                  |j                  d   j                  |       | j                  |j                  d   j
                  d       y)aQ  
        L{SecondaryAuthorityService.fromServerAddressAndDomains} constructs a
        new L{SecondaryAuthorityService} from a C{bytes} giving a master server
        address and several domains, causing the creation of a secondary
        authority for each domain and that master server address and the given
        DNS port.
        r  r  zexample.edur   r;   r  N)r   encoder   r  r  r  r  s      r&    test_constructAuthorityFromBytesz?SecondaryAuthorityServiceTests.test_constructAuthorityFromBytes#  s      +NN]+
 	'2+33W=+22NC+33W=+22NCr1   N)r2   r3   r4   r  r  r  r  r5   r1   r&   r  r    s    
D(D0Dr1   r  c                   (    e Zd ZdZd Zd Zd Zd Zy)SecondaryAuthorityTestsz
    L{twisted.names.secondary.SecondaryAuthority} correctly constructs objects
    with a specified IP address and optionally specified DNS port.
    c                     t        dd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       y)zp
        When constructed using L{SecondaryAuthority.__init__}, the default port
        of 53 is used.
        192.168.1.1
inside.comr  
   inside.comN)r   r   r  r  r  r0   	secondarys     r&   test_defaultPortz(SecondaryAuthorityTests.test_defaultPort?  sP    
 '}lC	**M:"-))=9r1   c                     t        j                  dd      }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       y)z~
        When constructed using L{SecondaryAuthority.fromServerAddressAndDomain},
        the specified port is used.
        )r    r  r  r  r  N)r   fromServerAddressAndDomainr   r  r  r  r  s     r&   test_explicitPortz)SecondaryAuthorityTests.test_explicitPortI  s[    
 'AA!<
	 	**M:$/))=9r1   c                 ^   t        j                  dd      }t               x|_        }|j	                          |j
                  j                  d      \  }}}}}| j                  |d       | j                  |d       |j                  ||f      }t               }	|j                  |	       t               }
|
j                  t        |	j                         dd              | j                  t        j                   dt        j"                  t        j$                        g|
j&                         y)z
        An attempt is made to transfer the zone for the domain the
        L{SecondaryAuthority} was constructed with from the server address it
        was constructed with when L{SecondaryAuthority.transfer} is called.
        r  r8   example.comr   r  r8   rq   N)r   r  r   _reactortransfer
tcpClientsrK  r   buildProtocolr   makeConnectionr   decoder   rd  r   r   rB  r1  rC  )r0   r  r	   hostr   r{   timeoutbindAddressprotor   msgs              r&   test_transferz%SecondaryAuthorityTests.test_transferU  s     'AA!=
	 (:';;	W 5<4F4F4J4J14M1dGWk}-t$ %%tTl3#%	Y'i 	

79??,QR012#))M388SVVDEs{{Sr1   c           
      t   t        j                  dd      }t               x|_        }|j	                          |j
                  j                  d      \  }}}}}|j                  ||f      }t               }	|j                  |	       t        dd      }
|
j                  t        |	j                         dd              t        dd	d
ddddd      }t        dd      }t        |
j                   dd      }|j"                  j%                  t'        dt(        |      t'        d|      t'        dt(        |      g       |j+                         }|j-                  t/        dt1        |            |z          | j3                  |j5                  d            }| j7                  t'        d|d      gg g f|       y)z
        L{SecondaryAuthority.lookupAddress} returns a L{Deferred} that fires
        with the I{A} records the authority has cached from the primary.
        r  r  r   r;   )r9  r%  rq   Ns   ns1.example.comzadmin.example.comi@ i  i  i   i%  i.  r<   s   192.168.1.2rk   )r8  r9  r%  )r#  r#   r"   z!Hr  T)r#   r%  )r   r  r   r  r  r  rK  r  r   r  r   r  r   rd  r   r   r8  rD  extendr   r   toStrdataReceivedr   lenrj  r   r   )r0   r  r	   r  r   r{   r  r  r  r   rr  r.   r  r9  datarI  s                   r&   test_lookupAddressz*SecondaryAuthorityTests.test_lookupAddresss  s   
 'AA!>
	 (:';;	W4;4F4F4J4J14M1dGWk%%tTl3#%	Y'qq)WY__.qr234 $%	
 ^+EHHQQ7c3?3c3?	
 ||~4c$i0478%%i&=&=m&LM~qt<=r2F	
r1   N)r2   r3   r4   r  r  r  r  r  r5   r1   r&   r  r  9  s    
:
:T<0
r1   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                   L    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)BindAuthorityTestsz=
    Tests for L{twisted.names.authority.BindAuthority}.
    c                     t        | j                         j                  d            }|j                  |       t	        j
                  |j                        S )z
        Create a new L{twisted.names.authority.BindAuthority} from C{s}.

        @param s: A string with BIND zone data.
        @type s: bytes

        @return: a new bind authority
        @rtype: L{twisted.names.authority.BindAuthority}
        ascii)r   r  r  
setContentr   BindAuthoritypath)r0   sfps      r&   loadBindStringz!BindAuthorityTests.loadBindString  s@     dkkm**734
a&&rww//r1   c                 8    | j                  t              | _        y r+   )r  sampleBindZoner%  r   s    r&   r   zBindAuthorityTests.setUp  s    ''7	r1   c                     | j                   j                  j                         D ]>  }| j                   j                  |   D ]   }| j                  d|j                  k(         " @ y)zG
        Loads the default $TTL and applies it to all records.
        :	 N)r%  r/   keysr  rD   )r0   domrecs      r&   test_ttlzBindAuthorityTests.test_ttl  sY     99$$))+ 	3Cyy((- 3#'' 123	3r1   c                     | j                  d| j                  j                         | j                  d| j                  j                         y)z,
        Loads the default $ORIGIN.
        s   example.com.   not-fqdn.example.comN)r   r%  originassertInr/   r   s    r&   test_originFromFilez&BindAuthorityTests.test_originFromFile  s@     	II	
 	#II	
r1   c                     dD ]g  \  }}| j                  | j                  j                  |            \  \  }\   \   | j                  t	        j
                  |d      |j                         i y)'
        A records are loaded.
        )r  z10.0.0.1)   no-in.example.comz10.0.0.2r  Nrj  r%  r   r   r   r   r#   r0   r
  ipr  s       r&   test_aRecordsz BindAuthorityTests.test_aRecords  si    
 	GC "11$))2I2I#2NONTb2r 

	r1   c                     | j                  | j                  j                  d            \  \  }\   \   | j                  t	        j
                  dd      |j                         y)*
        AAAA records are loaded.
        r  2001:db8:10::1r  Nrj  r%  r   r   r   r   r#   r0   r  s     r&   test_aaaaRecordsz#BindAuthorityTests.test_aaaaRecords  sY     --II''7
"r2 	OO  JJ	
r1   c                     | j                  | j                  j                  d            \  \  }\   \   | j                  t	        j
                  ddd      |j                         y)(
        MX records are loaded.
        r  rN   zmx.example.comr  )r)  r"  rD   Nrj  r%  r   r   r   r   r#   r  s     r&   test_mxRecordsz!BindAuthorityTests.test_mxRecords  s]     --II(()@A
"r2 	MM%
 JJ	
r1   c                     | j                  | j                  j                  d            \  }\   \   |d   }| j                  t	        j
                  dd      |j                         y)+
        CNAME records are loaded.
           www.example.comr   r  r  r(  Nrj  r%  r   r   r   r   r#   r0   rD  r  s      r&   test_cnameRecordsz$BindAuthorityTests.test_cnameRecords  sd     !00II''(:;
"b QZ" JJ	
r1   c                     | j                  t              5 }| j                  d       ddd       | j                  dj                  j
                  d          y# 1 sw Y   3xY w)zO
        loadBindString raises NotImplementedError on invalid records.
        s   example.com. IN LOL 192.168.0.1NzRecord type 'LOL' not supportedr   )assertRaisesNotImplementedErrorr  r   	exceptionr  )r0   es     r&   test_invalidRecordClassz*BindAuthorityTests.test_invalidRecordClass%  s]     23 	Dq BC	D:AKK<L<LQ<OP	D 	Ds   AA#c                     dD ]i  }| j                  t              5 }| j                  |dz          ddd       | j                  t	        |dz         j
                  j                  d          k y# 1 sw Y   AxY w)zC
        $INCLUDE and $GENERATE raise NotImplementedError.
        )s   $INCLUDEs	   $GENERATEs    doesNotMatterNs    directive not implementedr   )r+  r,  r  r   r   r-  r  )r0   	directiver.  s      r&   test_invalidDirectivesz)BindAuthorityTests.test_invalidDirectives-  s     5 	I""#67 C1##I0A$ABCY)FFG  #	C Cs   A00A9	N)r2   r3   r4   r  r  r   r  r  r  r  r#  r)  r/  r2  r5   r1   r&   r  r    s:    083
"

 
 Q
r1   r  a  zone = [
    SOA(
        # For whom we are the authority
        'example.com',

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

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

        # Unique serial identifying this SOA data
        serial = 86400,

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

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

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

        # Minimum TTL
        minimum = "3H"

    ),

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

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

    MX('not-fqdn.example.com', 10, 'mail.example.com'),
]
c                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)PySourceAuthorityTestszA
    Tests for L{twisted.names.authority.PySourceAuthority}.
    c                     t        | j                               }t        |j                  d      5 }|j	                  |       ddd       t        j                  |j                        S # 1 sw Y   (xY w)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}
        rZ  N)r   r  r[  r  writer   PySourceAuthority)r0   r  r  r  s       r&   loadPySourceStringz)PySourceAuthorityTests.loadPySourceStringj  s[     dkkm$"''3 	1GGAJ	 **27733	 	s   A))A2c                 8    | j                  t              | _        y r+   )r8  samplePySourcer%  r   s    r&   r   zPySourceAuthorityTests.setUpz  s    ++N;	r1   c                     dD ]f  \  }}| j                  | j                  j                  |            \  \  }\   \   | j                  t	        j
                  |      |j                         h y)r  r  Nr  r  s       r&   r  z$PySourceAuthorityTests.test_aRecords}  sa    
 	GC "11$))2I2I#2NONTb2rR 

	r1   c                     | j                  | j                  j                  d            \  \  }\   \   | j                  t	        j
                  d      |j                         y)r  r  r  Nr  r  s     r&   r  z'PySourceAuthorityTests.test_aaaaRecords  sR     --II''7
"r2 	OO,-JJ	
r1   c                     | j                  | j                  j                  d            \  \  }\   \   | j                  t	        j
                  dd      |j                         y)r!  r  rN   zmail.example.com)r)  r"  Nr"  r  s     r&   r#  z%PySourceAuthorityTests.test_mxRecords  sZ     --II(()@A
"r2 	MM' JJ	
r1   c                     | j                  | j                  j                  d            \  }\   \   |d   }| j                  t	        j
                  d      |j                         y)r%  r&  r   r  r"  Nr'  r(  s      r&   r)  z(PySourceAuthorityTests.test_cnameRecords  sa     !00II''(:;
"b QZ" JJ		
r1   c                     | j                  | j                  j                  d            \  }\   \   |d   }| j                  t	        j
                  d      |j                         y)z)
        PTR records are loaded.
        s   2.0.0.10.in-addr.arpar   r  r?  N)rj  r%  r   r   r   r   r#   r(  s      r&   r   zPySourceAuthorityTests.test_PTR  s_     !00II##$<=
"b QZNN) JJ		
r1   c                 J    d}| j                  t        | j                  |       y)z1
        Input file has no zone variable
        znothing = []N)r+  
ValueErrorr8  )r0   badPySources     r&   test_badInputNoZonez*PySourceAuthorityTests.test_badInputNoZone  s!     %*d&=&={Kr1   N)r2   r3   r4   r  r8  r   r  r  r#  r)  r   rD  r5   r1   r&   r4  r4  e  s0    4 <




Lr1   r4  )Yr  r   r   r   	functoolsr   r   ior   structr   twisted.internetr   r   r	   twisted.internet.deferr
   twisted.internet.testingr   r   r   twisted.namesr   r   r   r   r   twisted.names.clientr   twisted.names.dnsr   r   r   r   r   r   twisted.names.errorr   twisted.names.secondaryr   r   twisted.python.compatr   twisted.python.filepathr   twisted.trialr   r'   FileAuthorityr)   r   reverse_soar   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   rx   r   ry   rz   TestCasero   r  r  rN  r_  r  r  r  r  r  r  r:  r4  r5   r1   r&   <module>rV     s  
    %   2 2 * 
 A @ ) Q Q + Q . , "+.i-- . S^^

 
		
 cnn
"
"
		 


'

 "	Z( CLL&CMM/*CNNABCNN13TUCMM"45C.IJC23CMM45CMM12CNN35FGCMM!]C0CMM"l,?@CMM!DFVWCNNJKCMM67C]MJCQ1IJCMM28IJCNN 2 24S CRz+O COOFG5
: CNN3u.FG&
 CLL(CLL("
 CLL+,CLL$&
 $43#3#34F#G"H$0CLL$<#=[.1f !	!;/$CNN:;'
  	6"CLL.CMM-U3CMM-T2CNN3u.FDQ
W
X&& W
t
(## W5!! W5th// {/X&& {/|[5 1 1 [5|-XX.. -X`EDX%6%6 EDPj
h// j
Z+&~** ~B(VdLX.. dLr1   