+
    üÐjRF  ã                   ó°  € R t ^ RIHt ^ RIHt  ^ RIt]t^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHtHtHtH t H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't'H(t(  ! R R] PR                  4      t* ! R R]PV                  4      t+ ! R R],4      t- ! R R]4      t. ! R R4      t/ ! R R]4      t0R#   ] d    Rt L¾i ; i)z#
Tests for L{twisted.web.distrib}.
)Úabspath)ÚparseStringN)ÚskipIf)ÚverifyObject)ÚdeferÚreactor)ÚglobalLogPublisher)ÚfailureÚfilepath)Úpb©Ú
SIZE_LIMIT)Úproto_helpers)ÚTestCase)ÚclientÚdistribÚresourceÚserverÚstatic)ÚHeaders)Ú_render)ÚDummyChannelÚDummyRequestc                   ó   € ] tR t^#tRtR# )ÚMySite© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Ú?/usr/lib/python3/dist-packages/twisted/web/test/test_distrib.pyr   r   #   s   † Ûr!   r   c                   ó.   a € ] tR t^'t o RtRtR tRtV tR# )ÚPBServerFactoryz±
A PB server factory which keeps track of the most recent protocol it
created.

@ivar proto: L{None} or the L{Broker} instance most recently returned
    from C{buildProtocol}.
Nc                ób   € \         P                  P                  W4      V n        V P                  # ©N)r   r$   ÚbuildProtocolÚproto)ÚselfÚaddrs   &&r"   r'   ÚPBServerFactory.buildProtocol2   s$   € Ü×'Ñ'×5Ñ5°dÓAˆŒ
Ø�z‰zÐr!   )r(   )	r   r   r   r   Ú__doc__r(   r'   r    Ú__classdictcell__©Ú__classdict__s   @r"   r$   r$   '   s   ø‡ € ñð €E÷ð r!   r$   c                   ó   € ] tR t^7tRtRtR# )ÚArbitraryErrorz
An exception for this test.
r   N)r   r   r   r   r,   r    r   r!   r"   r1   r1   7   s   † õr!   r1   c                   ó~   a € ] tR t^=t o RtRtRtRtR tR t	R t
R tR tR tR tR	 tR
 tR tR tR tR tRtV tR# )ÚDistribTestsNc                ó„  a€ \         P                  ! 4       \         P                  ! 4       .oV P                  eC   V P                  P                  e+   V P                  P                  P	                  V3R l4       MS^ ,          P                  R4       V P                  e…   V P                  P                  em   V P                  P                  P                  P	                  V3R l4       V P                  P                  P                  P                  P                  4        MS^,          P                  R4       V P                  e*   SP                  V P                  P                  4       4       V P                  e*   SP                  V P                  P                  4       4       \         P                  ! S4      # )zs
Clean up all the event sources left behind by either directly by
test methods or indirectly via some distrib API.
Nc                  ó4   <€ S ^ ,          P                  R4      # )é    N©Úcallback©Údls   €r"   Ú<lambda>Ú'DistribTests.tearDown.<locals>.<lambda>J   s   ø€ °R¸µU·^±^ÀDÔ5Ir!   c                  ó4   <€ S ^,          P                  R4      # )é   Nr7   r9   s   €r"   r;   r<   N   s   ø€ ÀÀAÅÇÁÐPTÔAUr!   )r   ÚDeferredÚf1r(   ÚnotifyOnDisconnectr8   ÚsubÚ	publisherÚbrokerÚ	transportÚloseConnectionÚport1ÚappendÚstopListeningÚport2ÚgatherResults)r)   r:   s   &@r"   ÚtearDownÚDistribTests.tearDownC   s  ø€ ô
 �nŠnÓ¤§¢Ó 0Ð1ˆØ�7‰7Ò 4§7¡7§=¡=Ò#<Ø�G‰G�M‰M×,Ñ,Ô-IÕJàˆq�E�N‰N˜4Ô Ø�8‰8Ò D§H¡H×$6Ñ$6Ò$BØ�H‰H×Ñ×%Ñ%×8Ñ8Ô9UÔVØ�H‰H×Ñ×%Ñ%×/Ñ/×>Ñ>Õ@àˆq�E�N‰N˜4Ô Ø�:‰:Ò!Ø�I‰I�d—j‘j×.Ñ.Ó0Ô1Ø�:‰:Ò!Ø�I‰I�d—j‘j×.Ñ.Ó0Ô1Ü×"Ò" 2Ó&Ð&r!   c                óª  € \         P                  ! 4       pVP                  R \        P                  ! RR4      4       \
        P                  ! V4      p\        \        P                  ! V4      4      V n
        \        P                  ! ^ V P                  4      V n        \        P                  ! RV P                  P                  4       P                   4      V n        \         P                  ! 4       pVP                  RV P"                  4       \%        V4      p\        P                  ! ^ V4      V n        \(        P*                  ! \        4      pRV P&                  P                  4       P                    R2pVP-                  R4      pVP/                  RV4      pVP1                  \(        P2                  4       VP1                  V P4                  R4       V# )	s   theres   rootz
text/plainú	127.0.0.1s   herezhttp://127.0.0.1:z/here/thereÚasciió   GET)r   ÚResourceÚputChildr   ÚDatar   ÚSiter$   r   ÚResourcePublisherr@   r   Ú	listenTCPrG   ÚResourceSubscriptionÚgetHostÚportrB   r   rJ   r   ÚAgentÚencodeÚrequestÚaddCallbackÚreadBodyÚassertEqual)r)   Úr1Úsite1Úr2Úf2ÚagentÚurlÚds   &       r"   ÚtestDistribÚDistribTests.testDistribX   s@  € ä×ÒÓ ˆØ
�‰�HœfŸkšk¨'°<Ó@ÔAÜ—’˜B“ˆÜ!¤'×";Ò";¸EÓ"BÓCˆŒÜ×&Ò& q¨$¯'©'Ó2ˆŒ
Ü×/Ò/°¸T¿Z¹Z×=OÑ=OÓ=Q×=VÑ=VÓWˆŒÜ×ÒÓ ˆØ
�‰�G˜TŸX™XÔ&Ü�B‹ZˆÜ×&Ò& q¨"Ó-ˆŒ
Ü—’œWÓ%ˆØ! $§*¡*×"4Ñ"4Ó"6×";Ñ";Ð!<¸KÐHˆØ�j‰j˜Ó!ˆØ�M‰M˜& #Ó&ˆØ	�‰”f—o‘oÔ&Ø	�‰�d×&Ñ&¨Ô0Øˆr!   c                ón  € \         P                  ! 4       pVP                  RV4       \        P                  ! V4      p\        \        P                  ! V4      4      ;V n        p\        P                  ! ^ VRR7      pV P                  VP                  4       VP                  4       p\        P                  ! VP                  VP                   4      ;V n        p\        P                  ! V4      p\        P                  ! ^ VRR7      p	V P                  V	P                  4       V	P                  4       p
Wš3# )zÓ
Set up a resource on a distrib site using L{ResourcePublisher}.

@param child: The resource to publish using distrib.

@return: A tuple consisting of the host and port on which to contact
    the created site.
s   childrO   )Ú	interface)r   rR   rS   r   rU   r$   r   rV   r@   r   rW   Ú
addCleanuprI   rY   rX   ÚhostrZ   rB   )r)   ÚchildÚdistribRootÚdistribSiteÚdistribFactoryÚdistribPortr*   ÚmainRootÚmainSiteÚmainPortÚmainAddrs   &&         r"   Ú_setupDistribServerÚ DistribTests._setupDistribServerl   só   € ô ×'Ò'Ó)ˆØ×Ñ˜X uÔ-Ü—k’k +Ó.ˆÜ#2Ü×%Ò% kÓ2ó$
ð 	
ˆŒ�.ô ×'Ò'¨¨>À[ÔQˆØ�‰˜×1Ñ1Ô2Ø×"Ñ"Ó$ˆä%×:Ò:¸4¿9¹9ÀdÇiÁiÓPÐPˆŒ�8Ü—;’;˜xÓ(ˆÜ×$Ò$ Q¨¸KÔHˆØ�‰˜×.Ñ.Ô/Ø×#Ñ#Ó%ˆàÐ!Ð!r!   c                ó"  € V P                  V4      w  r4\        P                  ! \        4      pRVP                   RVP
                   R2pVP                  R4      pVP                  ! RV3/ VB pVP                  \        P                  4       V# )ai  
Set up a resource on a distrib site using L{ResourcePublisher} and
then retrieve it from a L{ResourceSubscription} via an HTTP client.

@param child: The resource to publish using distrib.
@param **kwargs: Extra keyword arguments to pass to L{Agent.request} when
    requesting the resource.

@return: A L{Deferred} which fires with the result of the request.
úhttp://Ú:ú/childrP   rQ   )
rw   r   r[   r   rm   rZ   r\   r]   r^   r_   )r)   rn   Úkwargsru   rv   re   rf   rg   s   &&,     r"   Ú_requestTestÚDistribTests._requestTest‡   sy   € ð "×5Ñ5°eÓ<ÑˆÜ—’œWÓ%ˆØ˜Ÿ™� a¨¯© °fÐ=ˆØ�j‰j˜Ó!ˆØ�MŠM˜& #Ñ0¨Ñ0ˆØ	�‰”f—o‘oÔ&Øˆr!   c                ó  € V P                  V4      w  r4RVP                   RVP                   R2pVP                  R4      p\        P
                  ! \        4      P                  ! RV3/ VB pR pVP                  V4       V# )aó  
Set up a resource on a distrib site using L{ResourcePublisher} and
then retrieve it from a L{ResourceSubscription} via an HTTP client.

@param child: The resource to publish using distrib.
@param **kwargs: Extra keyword arguments to pass to L{Agent.request} when
    requesting the resource.

@return: A L{Deferred} which fires with a tuple consisting of a
    L{twisted.test.proto_helpers.AccumulatingProtocol} containing the
    body of the response and an L{IResponse} with the response itself.
rz   r{   r|   rP   rQ   c                 óº   a a€ \         P                  ! 4       oS P                  S4       \        P                  ! 4       ;pSn        VP                  VV 3R  l4       V# )c                 ó   <€ SS3# r&   r   )Ú_ÚprotocolÚresponses   &€€r"   r;   ÚGDistribTests._requestAgentTest.<locals>.cbCollectBody.<locals>.<lambda>±   s
   ø€  X¨xÑ$8r!   )r   ÚAccumulatingProtocolÚdeliverBodyr   r?   ÚclosedDeferredr^   )r…   rg   r„   s   f @r"   ÚcbCollectBodyÚ5DistribTests._requestAgentTest.<locals>.cbCollectBody­   sE   ù€ Ü$×9Ò9Ó;ˆHØ× Ñ  Ô*Ü*/¯.ª.Ó*:Ð:ˆA�Ô'Ø�M‰MÕ8Ô9ØˆHr!   )	rw   rm   rZ   r\   r   r[   r   r]   r^   )r)   rn   r}   ru   rv   rf   rg   rŠ   s   &&,     r"   Ú_requestAgentTestÚDistribTests._requestAgentTestš   sy   € ð "×5Ñ5°eÓ<Ñˆà˜Ÿ™� a¨¯© °fÐ=ˆØ�j‰j˜Ó!ˆÜ�LŠLœÓ!×)Ò)¨&°#Ñ@¸Ñ@ˆò	ð 	
�‰�mÔ$Øˆr!   c                ó4  a aaaa€ / o\         P                  ! 4       o\        P                  ! S4       R.o ! VV3R lR\        P
                  4      pVVV 3R loS P                  V! 4       \        RR./4      R7      pVVV 3R lpVP                  V4       V# )	zn
The request headers are available on the request object passed to a
distributed resource's C{render} method.
Nc                   ó0   <a € ] tR t^Át o VV3R ltRtV tR# )Ú>DistribTests.test_requestHeaders.<locals>.ReportRequestHeadersc                óv   <€ VS^ &   SP                  \        VP                  P                  4       4      4       R# )r6   r!   )ÚupdateÚdictÚrequestHeadersÚgetAllRawHeaders)r)   r]   Úreqr”   s   &&€€r"   ÚrenderÚEDistribTests.test_requestHeaders.<locals>.ReportRequestHeaders.renderÂ   s1   ø€ Ø ��A‘Ø×%Ñ%¤d¨7×+AÑ+A×+RÑ+RÓ+TÓ&UÔVÙr!   r   N©r   r   r   r   r—   r    r-   )r/   r–   r”   s   @€€r"   ÚReportRequestHeadersr�   Á   s   ù‡ € ÷ô r!   rš   c                  óæ   <€ S U u. uF  q R ,          NK  	  pp SP                  RV4       SP                  RV4       SP                  S^ ,          V4       \        P                  ! S4       R# u up i )Ú
log_formatzconnected to publisherz3could not connect to distributed web service: {msg}N)ÚassertInr   ÚremoveObserver)ÚeÚmsgsÚlogObserverr–   r)   s     €€€r"   Ú
check_logsÚ4DistribTests.test_requestHeaders.<locals>.check_logsÇ   s_   ø€ Ù-8Ó9©[¨�l—O�O©[ˆDÐ9Ø�M‰MÐ2°DÔ9Ø�M‰MÐOÐQUÔVØ�M‰M˜#˜a�& $Ô'Ü×-Ò-¨kÖ:ùò	 :s   †A.ÚfooÚbar)Úheadersc                 ó†   <€ SP                   P                  P                  S4       SP                  SR ,          R.4       R# )s   Foos   barN)r@   r(   rA   r`   )Úresultr¢   r”   r)   s   &€€€r"   ÚcbRequestedÚ5DistribTests.test_requestHeaders.<locals>.cbRequestedÒ   s0   ø€ Ø�G‰G�M‰M×,Ñ,¨ZÔ8Ø×Ñ˜^¨FÕ3°f°XÖ>r!   )	r   ÚEventLoggingObserverr   ÚaddObserverr   rR   r~   r   r^   )r)   rš   r]   r©   r¢   r¡   r–   r”   s   f   @@@@r"   Útest_requestHeadersÚ DistribTests.test_requestHeaders·   sŽ   ü€ ð
 ˆÜ#×8Ò8Ó:ˆÜ×&Ò& {Ô3Øˆfˆ÷	ð 	¤8×#4Ñ#4ô 	÷	;ð ×#Ñ#Ù Ó"¬G°U¸U¸GÐ4DÓ,Eð $ó 
ˆ÷	?ð 	×Ñ˜KÔ(Øˆr!   c                ó”   a €  ! R R\         P                  4      pS P                  V! 4       4      pV 3R lpVP                  V4       V# )zi
The response code can be set by the request object passed to a
distributed resource's C{render} method.
c                   ó&   a € ] tR t^ßt o R tRtV tR# )Ú>DistribTests.test_requestResponseCode.<locals>.SetResponseCodec                ó(   € VP                  ^È4       R# )éÈ   Ú ©ÚsetResponseCode©r)   r]   s   &&r"   r—   ÚEDistribTests.test_requestResponseCode.<locals>.SetResponseCode.renderà   s   € Ø×'Ñ'¨Ô,Ùr!   r   Nr™   r.   s   @r"   ÚSetResponseCoder±   ß   ó   ø‡ € ÷ð r!   r¹   c                 óÚ   <€ SP                  V ^ ,          P                  R4       SP                  V ^,          P                  ^È4       SP                  V ^,          P                  R4       R# )r6   r!   s   OKN©r`   ÚdataÚcodeÚphrase©r¨   r)   s   &€r"   r©   Ú:DistribTests.test_requestResponseCode.<locals>.cbRequestedæ   sM   ø€ Ø×Ñ˜V A�YŸ^™^¨SÔ1Ø×Ñ˜V A�YŸ^™^¨SÔ1Ø×Ñ˜V A�Y×-Ñ-¨uÖ5r!   ©r   rR   rŒ   r^   ©r)   r¹   r]   r©   s   f   r"   Útest_requestResponseCodeÚ%DistribTests.test_requestResponseCodeÙ   sD   ø€ ô	œh×/Ñ/ô 	ð
 ×(Ñ(©Ó):Ó;ˆõ	6ð
 	×Ñ˜KÔ(Øˆr!   c                ó”   a €  ! R R\         P                  4      pS P                  V! 4       4      pV 3R lpVP                  V4       V# )zu
The response code and message can be set by the request object passed to
a distributed resource's C{render} method.
c                   ó&   a € ] tR t^ôt o R tRtV tR# )ÚEDistribTests.test_requestResponseCodeMessage.<locals>.SetResponseCodec                ó*   € VP                  ^ÈR4       R# )r³   ó   some-messager´   rµ   r·   s   &&r"   r—   ÚLDistribTests.test_requestResponseCodeMessage.<locals>.SetResponseCode.renderõ   s   € Ø×'Ñ'¨¨_Ô=Ùr!   r   Nr™   r.   s   @r"   r¹   rÈ   ô   rº   r!   r¹   c                 óÚ   <€ SP                  V ^ ,          P                  R4       SP                  V ^,          P                  ^È4       SP                  V ^,          P                  R4       R# )r6   r!   rÊ   Nr¼   rÀ   s   &€r"   r©   ÚADistribTests.test_requestResponseCodeMessage.<locals>.cbRequestedû   sM   ø€ Ø×Ñ˜V A�YŸ^™^¨SÔ1Ø×Ñ˜V A�YŸ^™^¨SÔ1Ø×Ñ˜V A�Y×-Ñ-¨Ö?r!   rÂ   rÃ   s   f   r"   Útest_requestResponseCodeMessageÚ,DistribTests.test_requestResponseCodeMessageî   sE   ø€ ô	œh×/Ñ/ô 	ð
 ×(Ñ(©Ó):Ó;ˆõ	@ð
 	×Ñ˜KÔ(Øˆr!   c                óÀ   €  ! R R\         P                  4      pV P                  V! 4       4      pVP                  V P                  R\
        ,          R,           4       V# )z¾
If a string longer than the Banana size limit is passed to the
L{distrib.Request} passed to the remote resource, it is broken into
smaller strings to be transported over the PB connection.
c                   ó&   a € ] tR tRt o R tRtV tR# )Ú0DistribTests.test_largeWrite.<locals>.LargeWritei
  c                óˆ   € VP                  R \        ,          R,           4       VP                  4        \        P                  # ©ó   xó   y)Úwriter   Úfinishr   ÚNOT_DONE_YETr·   s   &&r"   r—   Ú7DistribTests.test_largeWrite.<locals>.LargeWrite.render  s.   € Ø—‘˜d¤ZÕ/°$Õ6Ô7Ø—‘Ô Ü×*Ñ*Ð*r!   r   Nr™   r.   s   @r"   Ú
LargeWriterÒ   
  s   ø‡ € ÷+ð +r!   rÛ   rÕ   rÖ   ©r   rR   r~   r^   r`   r   )r)   rÛ   r]   s   &  r"   Útest_largeWriteÚDistribTests.test_largeWrite  sM   € ô	+œ×*Ñ*ô 	+ð ×#Ñ#¡J£LÓ1ˆØ×Ñ˜D×,Ñ,¨d´ZÕ.?À$Õ.FÔGØˆr!   c                óÀ   €  ! R R\         P                  4      pV P                  V! 4       4      pVP                  V P                  R\
        ,          R,           4       V# )zˆ
Like L{test_largeWrite}, but for the case where C{render} returns a
long string rather than explicitly passing it to L{Request.write}.
c                   ó&   a € ] tR tRt o R tRtV tR# )Ú2DistribTests.test_largeReturn.<locals>.LargeReturni  c                ó*   € R \         ,          R,           # rÔ   r   r·   s   &&r"   r—   Ú9DistribTests.test_largeReturn.<locals>.LargeReturn.render  s   € ØœjÕ(¨4Õ/Ð/r!   r   Nr™   r.   s   @r"   ÚLargeReturnrá     s   ø‡ € ÷0ð 0r!   rä   rÕ   rÖ   rÜ   )r)   rä   r]   s   &  r"   Útest_largeReturnÚDistribTests.test_largeReturn  sM   € ô	0œ(×+Ñ+ô 	0ð ×#Ñ#¡K£MÓ2ˆØ×Ñ˜D×,Ñ,¨d´ZÕ.?À$Õ.FÔGØˆr!   c                ó\  a a€ \        \        P                  ! 4       4      ;S n        p\        P
                  ! ^ V4      ;S n        p\        P                  ! RVP                  4       P                  4      ;S n        p\        R.4      o\        VS4      pVV 3R lpVP                  V4       V# )zb
If there is an error issuing the request to the remote publisher, an
error response is returned.
rO   r!   c                 ó  <€ SP                  SP                  R 4       SP                  \        P                  4      pSP                  \        V4      ^4       . ROpSP                  RP                  V4      .SP                  4       R# )iô  ó   
N)
r!   s   <html>s:     <head><title>500 - Server Connection Lost</title></head>s     <body>s#       <h1>Server Connection Lost</h1>s¦       <p>Connection to distributed server lost:<pre>[Failure instance: Traceback from remote host -- twisted.spread.flavors.NoSuchMethod: No such method: remote_requests   ]</pre></p>s	     </body>s   </html>r!   )r`   ÚresponseCodeÚflushLoggedErrorsr   ÚNoSuchMethodÚlenÚjoinÚwritten)ÚignoredÚerrorsÚexpectedr]   r)   s   &  €€r"   Ú
cbRenderedÚ4DistribTests.test_connectionLost.<locals>.cbRendered2  sl   ø€ Ø×Ñ˜W×1Ñ1°3Ô7ð ×+Ñ+¬B¯O©OÓ<ˆFØ×ÑœS ›[¨!Ô,òˆHð  ×Ñ˜eŸj™j¨Ó2Ð3°W·_±_ÖEr!   )r$   r   ÚRootr@   r   rW   rG   r   rX   rY   rZ   rB   r   r   r^   )r)   ÚserverFactoryÚ
serverPortÚsubscriptionrg   ró   r]   s   f     @r"   Útest_connectionLostÚ DistribTests.test_connectionLost"  s•   ù€ ô #2´"·'²'³)Ó"<Ð<ˆŒ�-Ü")×"3Ò"3°A°}Ó"EÐEˆŒ
�Zä")×">Ò">Ø˜×+Ñ+Ó-×2Ñ2ó#
ð 	
ˆŒ�<ô  ˜uÓ%ˆÜ�L 'Ó*ˆö	Fð2 	
�‰�jÔ!Øˆr!   c                óf  € \         P                  P                  V \        4      p\        P
                  ! \        4       4      p\        R.4      p\        P                  ! V4      pVP                  V4       V P                  ^\        V4      4       V P                  RV^ ,          R,          4       R# )zA
When a request fails, the string form of the failure is logged.
r!   zFailure instancerœ   N)r   r«   ÚcreateWithCleanupr   r	   ÚFailurer1   r   r   ÚIssueÚfailedÚassertEqualsrí   r�   )r)   r¡   Úfr]   Úissues   &    r"   Útest_logFailedÚDistribTests.test_logFailedN  s…   € ô $×8Ñ8×JÑJØÔ$ó
ˆô �OŠOœNÓ,Ó-ˆÜ ˜uÓ%ˆÜ—’˜gÓ&ˆØ�‰�QŒØ×Ñ˜!œS Ó-Ô.Ø�‰Ð(¨+°a­.¸Õ*FÖGr!   c                óŒ  € \         P                  P                  V \        4      p\	        4       p\
        P                  ! V4      p\        P                  ! \        4       4      pVP                  V4       V P                  \        4       V P                  ^\        V4      4       V P                  V^ ,          R,          V4       R# )zN
When L{twisted.web.distrib.Request}'s fail is called, the failure
is logged.
Úlog_failureN)r   r«   rü   r   r1   r	   rý   r   ÚRequestr   Úfailrë   r   rí   ÚassertIs)r)   r¡   Úerrr  r–   s   &    r"   Útest_requestFailÚDistribTests.test_requestFail]  s�   € ô
 $×8Ñ8×JÑJØÔ$ó
ˆô ÓˆÜ�OŠO˜CÓ ˆÜ�oŠoœl›nÓ-ˆØ�‰�ŒØ×Ñœ~Ô.Ø×Ñ˜!œS Ó-Ô.Ø�‰�k !•n ]Õ3°QÖ7r!   )r@   rG   rJ   rB   )r   r   r   r   rG   rJ   rB   r@   rL   rh   rw   r~   rŒ   r­   rÄ   rÎ   rÝ   rå   rù   r  r  r    r-   r.   s   @r"   r3   r3   =   sb   ø‡ € Ø€EØ€EØ
€CØ	€Bò'ò*ò("ò6ò&ò: òDò*ò*ò"ò*òXH÷8ð 8r!   r3   c                   ó2   a € ] tR tRt o R tR tR tRtV tR# )Ú_PasswordDatabasein  c                ó   € Wn         R # r&   ©Ú_users)r)   Úuserss   &&r"   Ú__init__Ú_PasswordDatabase.__init__o  s   € ØŽr!   c                ó,   € \        V P                  4      # r&   )Úiterr  ©r)   s   &r"   ÚgetpwallÚ_PasswordDatabase.getpwallr  s   € Ü�D—K‘KÓ Ð r!   c                ó`   € V P                    F  pV^ ,          V8X  g   K  Vu # 	  \        4       h)r6   )r  ÚKeyError)r)   ÚusernameÚusers   && r"   ÚgetpwnamÚ_PasswordDatabase.getpwnamu  s+   € Ø—K”KˆDØ�A�w˜(Ö"Ø’ñ  ô ‹jÐr!   r  N)	r   r   r   r   r  r  r  r    r-   r.   s   @r"   r  r  n  s   ø‡ € òò!÷ð r!   r  c                   óŽ   a € ] tR tRt o RtR tR tV 3R lR ltR tR t	R	 t
R
 tR tR t]! ]'       * R4      R 4       tRtV tR# )ÚUserDirectoryTestsi|  z^
Tests for L{UserDirectory}, a resource for listing all user resources
available on a system.
c                ó  € R R^{RRV P                  4       R3V n        RR^êRRV P                  4       R3V n        \        V P                  V P                  .4      V n        \
        P                  ! V P                  4      V n        R# )	ÚaliceÚxiÈ  zAlice,,,z/bin/shÚbobi7  zBob,,,N)Úmktempr#  r%  r  Údatabaser   ÚUserDirectoryÚ	directoryr  s   &r"   ÚsetUpÚUserDirectoryTests.setUp‚  si   € Ø˜s C¨¨j¸$¿+¹+»-ÈÐSˆŒ
Ø˜3  S¨(°D·K±K³MÀ9ÐMˆŒÜ)¨4¯:©:°t·x±xÐ*@ÓAˆŒÜ ×.Ò.¨t¯}©}Ó=ˆŽr!   c                ól   € V P                  \        \        P                  V P                  4      4       R# )z;
L{UserDirectory} instances provide L{resource.IResource}.
N)Ú
assertTruer   r   Ú	IResourcer)  r  s   &r"   Útest_interfaceÚ!UserDirectoryTests.test_interfaceˆ  s!   € ð 	�‰œ¤X×%7Ñ%7¸¿¹ÓHÖIr!   c                ó$   <€ V ^8„  d   QhRS[ RR/# )é   ÚnameÚreturnN)Úbytes)Úformatr/   s   "€r"   Ú__annotate__ÚUserDirectoryTests.__annotate__Ž  s   ø€ ÷ 	4ñ 	4¡5ð 	4¨Tñ 	4r!   c              ƒ  óÂ   "  € \        V.4      pV P                  P                  W4      p\        W24      pVG Rj  x€L
  V P	                  VP
                  R4       R#  L"5i)zZ
Verify that requesting the C{name} child of C{self.directory} results
in a 404 response.
Ni”  )r   r)  ÚgetChildr   r`   rê   )r)   r3  r]   r¨   rg   s   &&   r"   Ú_404TestÚUserDirectoryTests._404TestŽ  sS   é € ô
  ˜vÓ&ˆØ—‘×(Ñ(¨Ó7ˆÜ�FÓ$ˆØ�ˆØ×Ñ˜×-Ñ-¨sÖ3ñ 	ùs   ‚8AºA»#Ac              ƒ  óD   "  € V P                  R4      G Rj  x€L
  R#  L5i)z�
L{UserDirectory.getChild} returns a resource which renders a 404
response when passed a string which does not correspond to any known
user.
s   carolN©r;  r  s   &r"   Útest_getInvalidUserÚ&UserDirectoryTests.test_getInvalidUser™  ó   é € ð �m‰m˜HÓ%×%Ô%ùó   ‚ —˜ c              ƒ  óD   "  € V P                  R4      G Rj  x€L
  R#  L5i)z¾
L{UserDirectory.getChild} returns a resource which renders a 404
response when passed a string which corresponds to a known user who has
neither a user directory nor a user distrib socket.
s   aliceNr>  r  s   &r"   Útest_getUserWithoutResourceÚ.UserDirectoryTests.test_getUserWithoutResource¡  rA  rB  c                ór  € \         P                  ! V P                  R,          4      pVP                  R4      pVP	                  4        \        R.4      pV P                  P                  RV4      pV P                  V\        P                  4       V P                  VP                  VP                  4       R# )z™
L{UserDirectory.getChild} returns a L{static.File} instance when passed
the name of a user with a home directory containing a I{public_html}
directory.
Úpublic_htmlr%  s   bobNéþÿÿÿ)r
   ÚFilePathr%  rn   Úmakedirsr   r)  r:  ÚassertIsInstancer   ÚFiler`   Úpath)r)   ÚhomerG  r]   r¨   s   &    r"   Útest_getPublicHTMLChildÚ*UserDirectoryTests.test_getPublicHTMLChild©  s†   € ô × Ò  §¡¨"¥Ó.ˆØ—j‘j Ó/ˆØ×ÑÔÜ ˜wÓ'ˆØ—‘×(Ñ(¨°Ó9ˆØ×Ñ˜f¤f§k¡kÔ2Ø×Ñ˜Ÿ™ k×&6Ñ&6Ö7r!   c                ó¼  € \         P                  ! V P                  R,          4      pVP                  4        VP	                  R4      p\        R.4      pV P                  P                  RV4      pV P                  V\        P                  4       V P                  VP                  R4       V P                  \        VP                  4      VP                  4       R# )zÀ
L{UserDirectory.getChild} returns a L{ResourceSubscription} instance
when passed the name of a user suffixed with C{".twistd"} who has a
home directory containing a I{.twistd-web-pb} socket.
ú.twistd-web-pbr%  s
   bob.twistdÚunixNrH  )r
   rI  r%  rJ  rn   r   r)  r:  rK  r   rX   r`   rm   r   rZ   rM  )r)   rN  Úwebr]   r¨   s   &    r"   Útest_getDistribChildÚ'UserDirectoryTests.test_getDistribChild·  s�   € ô × Ò  §¡¨"¥Ó.ˆØ�‰ŒØ�j‰jÐ)Ó*ˆÜ ˜wÓ'ˆØ—‘×(Ñ(¨¸Ó@ˆØ×Ñ˜f¤g×&BÑ&BÔCØ×Ñ˜Ÿ™ fÔ-Ø×Ñœ §¡Ó-¨s¯x©xÖ8r!   c                ó–   € \        R.4      pRVn        V P                  \        P                  V P
                  P                  V4       R# )zZ
L{UserDirectory.render} raises L{UnsupportedMethod} in response to a
non-I{GET} request.
r´   ÚPOSTN)r   ÚmethodÚassertRaisesr   ÚUnsupportedMethodr)  r—   r·   s   & r"   Útest_invalidMethodÚ%UserDirectoryTests.test_invalidMethodÆ  s9   € ô
  ˜tÓ$ˆØˆŒØ×Ñœ&×2Ñ2°D·N±N×4IÑ4IÈ7ÖSr!   c                ó¸  a a€ \         P                  ! S P                  R,          4      P                  R4      pVP	                  4        \         P                  ! S P
                  R,          4      pVP	                  4        VP                  R4      P                  R4       \        R.4      o\        S P                  S4      pVV 3R lpVP                  V4       V# )ze
L{UserDirectory} renders a list of links to available user content
in response to a I{GET} request.
rG  rR  r!   r´   c                 óz  <€ \        R P                  SP                  4      4      pVP                  R4      w  r#SP	                  VP
                  P                  R4       SP	                  VP
                  P                  R4      R4       SP	                  VP
                  P
                  P                  R4       SP	                  VP
                  P                  R4       SP	                  VP
                  P                  R4      R4       SP	                  VP
                  P
                  P                  R4       R# )	r!   ÚliÚaÚhrefzalice/zAlice (file)zbob.twistd/zBob (twistd)N)	r   rî   rï   ÚgetElementsByTagNamer`   Ú
firstChildÚtagNameÚgetAttributer½   )rð   Údocumentr#  r%  r]   r)   s   &   €€r"   ró   Ú2UserDirectoryTests.test_render.<locals>.cbRenderedà  sæ   ø€ Ü" 3§8¡8¨G¯O©OÓ#<Ó=ˆHð $×8Ñ8¸Ó>‰LˆUØ×Ñ˜U×-Ñ-×5Ñ5°sÔ;Ø×Ñ˜U×-Ñ-×:Ñ:¸6ÓBÀHÔMØ×Ñ˜U×-Ñ-×8Ñ8×=Ñ=¸~ÔNØ×Ñ˜SŸ^™^×3Ñ3°SÔ9Ø×Ñ˜SŸ^™^×8Ñ8¸Ó@À-ÔPØ×Ñ˜SŸ^™^×6Ñ6×;Ñ;¸^ÖLr!   rH  )r
   rI  r#  rn   rJ  r%  Ú
setContentr   r   r)  r^   )r)   rG  rT  r¨   ró   r]   s   f    @r"   Útest_renderÚUserDirectoryTests.test_renderÏ  s¦   ù€ ô
 ×'Ò'¨¯
©
°2­Ó7×=Ñ=¸mÓLˆØ×ÑÔÜ×Ò §¡¨¥Ó-ˆØ�‰Œð 	�	‰	Ð"Ó#×.Ñ.¨sÔ3ä ˜tÓ$ˆÜ˜Ÿ™¨Ó1ˆö
	Mð 	×Ñ˜:Ô&Øˆr!   zpwd module requiredc                óp   € \         P                  ! 4       pV P                  VP                  \        4       R# )zl
If L{UserDirectory} is instantiated with no arguments, it uses the
L{pwd} module as its password database.
N)r   r(  ÚassertIdenticalÚ_pwdÚpwd)r)   r)  s   & r"   Útest_passwordDatabaseÚ(UserDirectoryTests.test_passwordDatabaseï  s&   € ô ×)Ò)Ó+ˆ	Ø×Ñ˜YŸ^™^¬SÖ1r!   )r#  r%  r'  r)  N)r   r   r   r   r,   r*  r/  r;  r?  rD  rO  rU  r\  rj  r   ro  rp  r    r-   r.   s   @r"   r!  r!  |  s]   ø‡ € ñò
>òJ÷	4ð 	4ò&ò&ò8ò9òTòñ@ �ŒGÐ*Ó+ñ2ó ,ö2r!   r!  )1r,   Úos.pathr   Úxml.dom.minidomr   ro  rn  ÚImportErrorÚunittestr   Úzope.interface.verifyr   Útwisted.internetr   r   Útwisted.loggerr   Útwisted.pythonr	   r
   Útwisted.spreadr   Útwisted.spread.bananar   Útwisted.testr   Útwisted.trial.unittestr   Útwisted.webr   r   r   r   r   Útwisted.web.http_headersr   Útwisted.web.test._utilr   Útwisted.web.test.requesthelperr   r   rU   r   r$   Ú	Exceptionr1   r3   r  r!  r   r!   r"   Ú<module>rƒ     s·   ðñõ Ý 'ðÛð €Cå å .ç +Ý -ß ,Ý Ý ,Ý &Ý +ß AÕ AÝ ,Ý *ß Eô	ˆV�[‰[ô 	ô�b×(Ñ(ô ô �Yô ôn8�8ô n8÷b	ñ ôz2˜ö z2øð_ ô Ø
‚Cðús   �C	 Ã		CÃC