+
    üÐjø  ã                   óÀ   € R t ^ RIHt ^ RIHt ^ RIHt ^ RI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  ! R
 R]4      t ! R R]4      t ! R R]4      tR# )z!
Tests for L{twisted.web.vhost}.
)ÚgatherResults)ÚTestCase)Ú	NOT_FOUND)Ú
NoResource)ÚSite)ÚData)Ú_render)ÚDummyRequest)ÚNameVirtualHostÚVHostMonsterResourceÚ_HostResourcec                   ó*   a € ] tR t^t o RtR tRtV tR# )ÚHostResourceTestsz
Tests for L{_HostResource}.
c                ó(  € \        RR4      p\        RR4      p\        RR4      pVP                  RV4       VP                  RV4       \        4       p\        4       p\        RR4      Vn        VP                  RV4       \        RR.4      p. ROVn        \        V4      Vn	        R	 Vn
        R
Vn        VP                  RV4      pV P                  V\         4       \        RR.4      pVP                  RV4      pV P                  V\        4       R# )z¸
L{_HostResource.getChild} returns the proper I{Resource} for the vhost
embedded in the URL.  Verify that returning the proper I{Resource}
required changing the I{Host} in the header.
s	   root dataÚ s   uri datas	   test datas   tests   uris   default dataó   baz.comc                  ó   € R # )F© r   ó    Ú=/usr/lib/python3/dist-packages/twisted/web/test/test_vhost.pyÚ<lambda>Ú1HostResourceTests.test_getChild.<locals>.<lambda>-   s   € ¡5r   r   N)s   baró   httpr   )r   ÚputChildr   r
   ÚdefaultÚaddHostr	   Úprepathr   ÚsiteÚisSecureÚhostÚgetChildÚassertIsInstancer   )ÚselfÚbazrootÚbazuriÚbaztestÚhrÚrootÚrequestÚsteps   &       r   Útest_getChildÚHostResourceTests.test_getChild   sð   € ô �| RÓ(ˆÜ�k 2Ó&ˆÜ�| RÓ(ˆØ�‰˜ Ô)Ø×Ñ˜ Ô(Ü‹_ˆäÓ ˆÜ˜O¨RÓ0ˆŒØ�‰�Z Ô)ä ¨Ð0Ó1ˆÚ7ˆŒÜ˜D“zˆŒÙ(ˆÔØˆŒà�{‰{˜: wÓ/ˆØ×Ñ˜d¤DÔ)ä ¨Ð0Ó1ˆØ�}‰}˜V WÓ-ˆØ×Ñ˜d¤JÖ/r   r   N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r*   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      s   ø‡ € ñ÷0ð 0r   r   c                   óN   a € ] tR t^8t o RtR tR tR tR tR t	R t
R tR	tV tR
# )ÚNameVirtualHostTestsz
Tests for L{NameVirtualHost}.
c                ó–   € \        4       p\        RR4      Vn        \        R.4      pV P	                  VP                  V4      R4       R# )z™
L{NameVirtualHost.render} returns the result of rendering the
instance's C{default} if it is not L{None} and there is no I{Host}
header in the request.
s   correct resultr   r   N)r
   r   r   r	   ÚassertEqualÚrender©r"   ÚvirtualHostResourcer(   s   &  r   Útest_renderWithoutHostÚ+NameVirtualHostTests.test_renderWithoutHost=   sG   € ô .Ó/ÐÜ&*Ð+<¸bÓ&AÐÔ#Ü ˜uÓ%ˆØ×ÑÐ,×3Ñ3°GÓ<Ð>OÖPr   c                ó~   a a€ \        4       p\        R.4      o\        VS4      pVV 3R lpVP                  V4       V# )z£
L{NameVirtualHost.render} returns a response with a status of I{NOT
FOUND} if the instance's C{default} is L{None} and there is no I{Host}
header in the request.
r   c                 óH   <€ SP                  SP                  \        4       R # ©N©r9   ÚresponseCoder   ©Úignoredr(   r"   s   &€€r   Ú
cbRenderedÚHNameVirtualHostTests.test_renderWithoutHostNoDefault.<locals>.cbRenderedR   ó   ø€ Ø×Ñ˜W×1Ñ1´9Ö=r   )r
   r	   r   ÚaddCallback©r"   r<   ÚdrF   r(   s   f   @r   Útest_renderWithoutHostNoDefaultÚ4NameVirtualHostTests.test_renderWithoutHostNoDefaultH   s?   ù€ ô .Ó/ÐÜ ˜uÓ%ˆÜÐ'¨Ó1ˆö	>ð 	
�‰�jÔ!Øˆr   c                ó�  a € \        4       pVP                  R\        RR4      4       \        R.4      pVP                  P                  RR4       \        W4      pV 3R lpVP                  WB4       \        R.4      pVP                  P                  RR4       \        W4      pV 3R lpVP                  WE4       \        W6.4      # )	zÖ
L{NameVirtualHost.render} returns the result of rendering the resource
which is the value in the instance's C{host} dictionary corresponding
to the key indicated by the value of the I{Host} header in the request.
s   example.orgó   winnerr   r   ó   hostc                 ó^   <€ SP                  R P                  VP                  4      R4       R# ©r   rO   N©r9   ÚjoinÚwrittenrD   s   &&€r   rF   Ú<NameVirtualHostTests.test_renderWithHost.<locals>.cbRenderede   s    ø€ Ø×Ñ˜SŸX™X g§o¡oÓ6¸	ÖBr   s   example.org:8000c                 ó^   <€ SP                  R P                  VP                  4      R4       R# rR   rS   )rE   ÚrequestWithPortr"   s   &&€r   rF   rV   o   s"   ø€ Ø×Ñ˜SŸX™X o×&=Ñ&=Ó>À	ÖJr   )	r
   r   r   r	   ÚrequestHeadersÚaddRawHeaderr   rI   r   )r"   r<   r(   rK   rF   rX   Ú	dWithPorts   f      r   Útest_renderWithHostÚ(NameVirtualHostTests.test_renderWithHostX   s¹   ø€ ô .Ó/ÐØ×#Ñ# N´D¸ÀBÓ4GÔHä ˜uÓ%ˆØ×Ñ×+Ñ+¨G°^ÔDÜÐ'Ó1ˆõ	Cð 	
�‰�jÔ*ô '¨ uÓ-ˆØ×&Ñ&×3Ñ3°GÐ=PÔQÜÐ/ÓAˆ	õ	Kð 	×Ñ˜jÔ:ä˜a˜^Ó,Ð,r   c                óØ   a a€ \        4       p\        RR4      Vn        \        R.4      oSP                  P                  RR4       \        VS4      pVV 3R lpVP                  V4       V# )z¸
L{NameVirtualHost.render} returns the result of rendering the
instance's C{default} if it is not L{None} and there is no host
matching the value of the I{Host} header in the request.
ó   correct datar   r   rP   ó   example.comc                 ó^   <€ SP                  R P                  SP                  4      R4       R# )r   r_   NrS   rD   s   &€€r   rF   ÚCNameVirtualHostTests.test_renderWithUnknownHost.<locals>.cbRendered‚   s    ø€ Ø×Ñ˜SŸX™X g§o¡oÓ6¸ÖHr   )r
   r   r   r	   rY   rZ   r   rI   rJ   s   f   @r   Útest_renderWithUnknownHostÚ/NameVirtualHostTests.test_renderWithUnknownHostv   sf   ù€ ô .Ó/ÐÜ&*¨?¸BÓ&?ÐÔ#Ü ˜uÓ%ˆØ×Ñ×+Ñ+¨G°^ÔDÜÐ'¨Ó1ˆö	Ið 	
�‰�jÔ!Øˆr   c                ó¶   a a€ \        4       p\        R.4      oSP                  P                  RR4       \	        VS4      pVV 3R lpVP                  V4       V# )zÂ
L{NameVirtualHost.render} returns a response with a status of I{NOT
FOUND} if the instance's C{default} is L{None} and there is no host
matching the value of the I{Host} header in the request.
r   rP   r`   c                 óH   <€ SP                  SP                  \        4       R # rA   rB   rD   s   &€€r   rF   ÚLNameVirtualHostTests.test_renderWithUnknownHostNoDefault.<locals>.cbRendered“   rH   r   )r
   r	   rY   rZ   r   rI   rJ   s   f   @r   Ú#test_renderWithUnknownHostNoDefaultÚ8NameVirtualHostTests.test_renderWithUnknownHostNoDefaultˆ   sU   ù€ ô .Ó/ÐÜ ˜uÓ%ˆØ×Ñ×+Ñ+¨G°^ÔDÜÐ'¨Ó1ˆö	>ð 	
�‰�jÔ!Øˆr   c              ƒ  óò   "  € \        4       p\        R.4      pVP                  P                  RR4       \	        W4      G Rj  x€L
  V P                  RRP                  VP                  4      4       R#  L15i)z[
L{NameVirtualHost.render} doesn't echo unescaped HTML when present in
the I{Host} header.
r   rP   s   <b>example</b>.comNs   <b>)r
   r	   rY   rZ   r   ÚassertNotInrT   rU   r;   s   &  r   Útest_renderWithHTMLHostÚ,NameVirtualHostTests.test_renderWithHTMLHost™   sd   é € ô
 .Ó/ÐÜ ˜uÓ%ˆØ×Ñ×+Ñ+¨GÐ5JÔKäÐ)Ó3×3Ð3à×Ñ˜ §¡¨'¯/©/Ó!:Ö;ñ 	4ùs   ‚AA7ÁA5Á2A7c                óØ  € \        4       p\        RR4      pRVn        \        RR4      pVP                  RV4       VP                  RV4       \	        . 4      pVP
                  P                  RR4       R.Vn        V P                  VP                  RV4      \        4       V P                  VP                  R.4       V P                  VP                  . 4       \	        . 4      pVP
                  P                  RR4       R.Vn        V P                  VP                  RV4      \        4       V P                  VP                  . 4       V P                  VP                  R.4       R	# )
z•
L{NameVirtualHost.getChild} returns correct I{Resource} based off
the header and modifies I{Request} to ensure proper prepath and
postpath are set.
s	   leaf datar   Ts	   norm datas   leaf.example.orgs   norm.example.orgrP   r   N)r
   r   ÚisLeafr   r	   rY   rZ   r   r!   r    r   r9   Úpostpath)r"   r<   ÚleafResourceÚnormResourcer(   s   &    r   r*   Ú"NameVirtualHostTests.test_getChild¦   s7  € ô .Ó/ÐÜ˜L¨"Ó-ˆØ"ˆÔÜ˜L¨"Ó-ˆØ×#Ñ#Ð$7¸ÔFØ×#Ñ#Ð$7¸ÔFä˜rÓ"ˆØ×Ñ×+Ñ+¨GÐ5HÔIØ˜%ˆŒà×ÑÐ1×:Ñ:¸3ÀÓHÌ*ÔUØ×Ñ˜Ÿ™¨3¨%Ô0Ø×Ñ˜×)Ñ)¨2Ô.ä˜rÓ"ˆØ×Ñ×+Ñ+¨GÐ5HÔIØ˜%ˆŒà×ÑÐ1×:Ñ:¸3ÀÓHÌ$ÔOØ×Ñ˜Ÿ™¨"Ô-Ø×Ñ˜×)Ñ)¨C¨5Ö1r   r   N)r-   r.   r/   r0   r1   r=   rL   r\   rc   rh   rl   r*   r2   r3   r4   s   @r   r7   r7   8   s3   ø‡ € ñò	Qòò -ò<ò$ò"<÷2ð 2r   r7   c                   ó*   a € ] tR t^Ät o RtR tRtV tR# )ÚVHostMonsterResourceTestsz$
Tests for L{VHostMonsterResource}.
c                óZ  € \        4       p\        . 4      pV P                  VP                  RV4      \        4       V P                  VP                  4       4       \        . 4      pV P                  VP                  RV4      \        4       V P                  VP                  4       4       R# )zu
L{VHostMonsterResource.getChild} returns I{_HostResource} and modifies
I{Request} with correct L{Request.isSecure}.
r   s   httpsN)r   r	   r!   r    r   ÚassertFalser   Ú
assertTrue)r"   Úvhmr(   s   &  r   r*   Ú'VHostMonsterResourceTests.test_getChildÉ   s‚   € ô
 #Ó$ˆÜ˜rÓ"ˆØ×Ñ˜cŸl™l¨7°GÓ<¼mÔLØ×Ñ˜×)Ñ)Ó+Ô,ä˜rÓ"ˆØ×Ñ˜cŸl™l¨8°WÓ=¼}ÔMØ�‰˜×(Ñ(Ó*Ö+r   r   Nr,   r4   s   @r   ru   ru   Ä   s   ø‡ € ñ÷,ð ,r   ru   N)r1   Útwisted.internet.deferr   Útwisted.trial.unittestr   Útwisted.web.httpr   Útwisted.web.resourcer   Útwisted.web.serverr   Útwisted.web.staticr   Útwisted.web.test._utilr   Útwisted.web.test.test_webr	   Útwisted.web.vhostr
   r   r   r   r7   ru   r   r   r   Ú<module>r„      sR   ðñõ
 1Ý +Ý &Ý +Ý #Ý #Ý *Ý 2ß RÑ Rô!0˜ô !0ôHI2˜8ô I2ôX, ö ,r   