+
    Df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(k2&|R()(_ OR0Z)017Dz({{:w/dD)01}}VW-dJ/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3G<>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   
cbRenderedHNameVirtualHostTests.test_renderWithoutHostNoDefault.<locals>.cbRenderedR       W119=r   )r
   r	   r   addCallbackr"   r<   drF   r(   s   f   @r   test_renderWithoutHostNoDefault4NameVirtualHostTests.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     SXXgoo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"    SXXo&=&=>	Jr   )	r
   r   r   r	   requestHeadersaddRawHeaderr   rI   r   )r"   r<   r(   rK   rF   rX   	dWithPorts   f      r   test_renderWithHost(NameVirtualHostTests.test_renderWithHostX   s     ./##NDB4GHu%++G^D'1	C 	
j* 'u-&&33G=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     SXXgoo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_renderWithUnknownHostNoDefault8NameVirtualHostTests.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%++G5JK)333'//!:; 	4s   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"++G5HI%1::3H*U3%0))2.r"++G5HI%1::3H$O"-))C5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"cll7G<mL))+,r"cll8W=}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 !0HI28 I2X, ,r   