+
    Dfjp/                    `   R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
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 ^ RIHt ^ RIHt ^ RIHtHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t%H&t& ^ RI'H(t(H)t)H*t*H+t+ ^ RI,H-t- ^ RI.H/t/ ^ RI0H1t1 ]2! 4       t3 ! R R]4      t4 ! R R]4      t5R# )z
Tests for L{twisted.web.tap}.
)annotationsN)cast)skipIf)	endpointsreactor)IReactorCoreIReactorUNIX)FilePath)requireModule)
ThreadPool)
UsageError)PBServerFactory)TestCase)demo)ResourcePublisherUserDirectory)PythonScript)Site)DataFile)Options_AddHeadersResourcemakePersonalServerFactorymakeService)DummyRequest)	CGIScript)WSGIResourcec                      ] tR t^(tRtR R ltR R lt]! ]P                  ! ]
4      '       * R4      R R l4       tR	 R
 ltR R ltR R ltR R lt]! ]P                  ! ]
4      '       * R4      R R l4       t]! ]P                  ! ]
4      '       * R4      R R l4       tR R ltR R ltR R ltR R lt]! ]! R4      RJR4      R  R! l4       t]! ]! R4      RJ R"4      R# R$ l4       tR% R& ltR' R( ltR) R* ltR+ R, ltR- R. ltR/tR# )0ServiceTestsz<
Tests for the service creation APIs in L{twisted.web.tap}.
c                   V ^8  d   QhRR/# )   returnztuple[FilePath[str], File] )formats   ";/usr/lib/python3/dist-packages/twisted/web/test/test_tap.py__annotate__ServiceTests.__annotate__-   s      7     c                    \        V P                  4       4      pVP                  4        \        4       pVP	                  RVP
                  .4       VR,          pW3# )aK  
Helper for the I{--path} tests which creates a directory and creates
an L{Options} object which uses that directory as its static
filesystem root.

@return: A two-tuple of a L{FilePath} referring to the directory and
    the value associated with the C{'root'} key in the L{Options}
    instance after parsing a I{--path} option.
--pathroot)r	   mktempmakedirsr   parseOptionspath)selfr.   optionsr*   s   &   r$   _pathOptionServiceTests._pathOption-   sL     &)h		23vzr'   c                   V ^8  d   QhRR/# r    r!   Noner"   )r#   s   "r$   r%   r&   >   s     / /4 /r'   c                    V P                  4       w  rV P                  V\        4       V P                  VP                  VP                  4       R# )zr
The I{--path} option causes L{Options} to create a root resource
which serves responses from the specified path.
N)r1   assertIsInstancer   assertEqualr.   r/   r.   r*   s   &  r$   	test_pathServiceTests.test_path>   s<    
 %%'
dD)DII.r'   z0The reactor does not support UNIX domain socketsc                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&   K   s     > > >r'   c                2   \        V P                  4       4      pVP                  4        V P                  4       p\        4       pVP	                  RRV,           RVP
                  .4       \        V4      pVP                  4        V P                  VP                  4       V P                  VP                  ^ ,          P                  P                  \        4       V P                  VP                  ^ ,          P                  P                  P
                  VP
                  4       V P!                  \"        P
                  P%                  V4      4       V P!                  \&        P(                  ! \"        P&                  ! V4      P*                  4      4       R# )z
The I{--path} option to L{makeService} causes it to return a service
which will listen on the server address given by the I{--port} option.
--portunix:r)   N)r	   r+   r,   r   r-   r.   r   startService
addCleanupstopServicer7   servicesfactoryresourcer   r8   
assertTrueosexistsstatS_ISSOCKst_mode)r/   r.   portr0   services   &    r$   test_pathServerServiceTests.test_pathServerG   s
    &{{})h$$))LMg&++,g..q199BBDI))!,44==BBDIINt,-bggdm&;&;<=r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&   ]   s     I I4 Ir'   c                    V P                  4       w  rVP                  R4      P                  R4       V P                  VP	                  RR4      \
        4       R# )z
The I{--path} option creates a root resource which serves a
L{CGIScript} instance for any child with the C{".cgi"} extension.
zfoo.cgir'   N)r1   child
setContentr7   getChildr   r9   s   &  r$   test_cgiProcessorServiceTests.test_cgiProcessor]   sF    
 %%'


9((-dmmIt<iHr'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&   f   s     L L4 Lr'   c                    V P                  4       w  rVP                  R4      P                  R4       V P                  VP	                  RR4      \
        4       R# )z
The I{--path} option creates a root resource which serves a
L{PythonScript} instance for any child with the C{".epy"} extension.
zfoo.epyr'   N)r1   rR   rS   r7   rT   r   r9   s   &  r$   test_epyProcessorServiceTests.test_epyProcessorf   sF    
 %%'


9((-dmmIt<lKr'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&   o   s     4 44 4r'   c                *   V P                  4       w  rVP                  R4      P                  R4       VP                  RR4      pV P	                  V\
        4       V P                  VP                  R4       V P                  VP                  R4       R# )z
The I{--path} option creates a root resource which serves the
C{resource} global defined by the Python source in any child with
the C{".rpy"} extension.
zfoo.rpysN   from twisted.web.static import Data
resource = Data('content', 'major/minor')
Ncontentzmajor/minor)	r1   rR   rS   rT   r7   r   r8   datatype)r/   r.   r*   rR   s   &   r$   test_rpyProcessorServiceTests.test_rpyProcessoro   sz     %%'


9((;	
 i.eT*Y/]3r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     < < <r'   c                    \        \        RR4      4      p\        V4      pV P                  V\        4       V P                  VP
                  \        4       V P                  VP
                  P                  V4       R# )zo
L{makePersonalServerFactory} returns a PB server factory which has
as its root object a L{ResourcePublisher}.
s   foo barz
text/plainN)	r   r   r   r7   r   r*   r   assertIdenticalsite)r/   re   serverFactorys   &  r$   test_makePersonalServerFactory+ServiceTests.test_makePersonalServerFactory   sb     D\231$7m_=m002CD]//44d;r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     > >T >r'   c                   V P                  4       p\        4       pVP                  RRV,           R.4       \        V4      pVP	                  4        V P                  VP                  4       V P                  \        P                  P                  V4      4       V P                  \        P                  ! \        P                  ! V4      P                  4      4       R# )z
The I{--personal} option to L{makeService} causes it to return a
service which will listen on the server address given by the I{--port}
option.
r>   r?   
--personalN)r+   r   r-   r   r@   rA   rB   rF   rG   r.   rH   rI   rJ   rK   )r/   rL   r0   rM   s   &   r$   test_personalServer ServiceTests.test_personalServer   s     {{})h$EFg&++,t,-bggdm&;&;<=r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     	> 	>$ 	>r'   c                   \        4       pVP                  R.4       \        P                  P	                  \        P                  P                  R\        P                  4      4      pV P                  VR,          ^ ,          RV 24       R# )z
If the I{--port} option not specified but the I{--personal} option is,
L{Options} defaults the port to C{UserDirectory.userSocketName} in the
user's home directory.
rk   ~portsr?   N)	r   r-   rG   r.   
expanduserjoinr   userSocketNamer8   )r/   r0   r.   s   &  r$   test_defaultPersonalPath%ServiceTests.test_defaultPersonalPath   sd     )l^,ww!!"'',,sM4P4P"QR)!,dVn=r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     	
 	
$ 	
r'   c                    \        4       pVP                  . 4       V P                  \        P                  ! VR,          ^ ,          R4      R,          R4       R# )zT
If the I{--port} option is not specified, L{Options} defaults the port
to C{8080}.
rq   N:Nr    N)TCP)i  N)r   r-   r8   r   _parseServerr/   r0   s   & r$   test_defaultPortServiceTests.test_defaultPort   sI    
 )R ""77#3A#6=bACX	
r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     3 3t 3r'   c                    \        4       pVP                  . RO4       V P                  RVR,          ^ ,          4       V P                  RVR,          ^,          4       R# )zA
If the I{--http} option is given twice, there are two listeners
8001rq   8002N)--listenztcp:8001r   ztcp:8002r   r-   assertInr{   s   & r$   test_twoPortsServiceTests.test_twoPorts   sJ     )MNfgg.q12fgg.q12r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     1 14 1r'   c                   \        4       pVP                  R\        R,           .4       VR,          pV P                  V\        4       V P                  VP                  \        4       V P                  \        VP                  \        4      4       V P                  VP                  \        4       V P                  VP                  P                  4       \        \         \        4      P#                  R4       V P                  VP                  P                  4       V P                  VP                  P$                  4       \        \         \        4      P#                  R4       V P                  VP                  P$                  4       R# )z
The I{--wsgi} option takes the fully-qualifed Python name of a WSGI
application object and creates a L{WSGIResource} at the root which
serves that application.
--wsgiz.applicationr*   startupshutdownN)r   r-   __name__rF   r   rd   _reactorr   
isinstance_threadpoolr   _applicationapplicationassertFalsestartedr   r   fireSystemEventjoined)r/   r0   r*   s   &  r$   	test_wsgiServiceTests.test_wsgi   s    )h>(ABCvl+T]]G4
4#3#3Z@AT..< 	))112\7#33I>((001))001\7#33J?((//0r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     N N Nr'   c                    \        4       p\        R,           R3 FE  pV P                  \        VP                  RV.4      pV P                  \        V4      RV: 24       KG  	  R# )zV
If I{--wsgi} is given an invalid name, L{Options.parseOptions}
raises L{UsageError}.
z.nosuchthingzfoo.r   zNo such WSGI application: N)r   r   assertRaisesr   r-   r8   str)r/   r0   nameexcs   &   r$   test_invalidApplication$ServiceTests.test_invalidApplication   s[    
 ).7D##J0D0DxQUFVWCSX)CD8'LM 8r'   zOpenSSL.SSLNzSSL module is available.c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     	I 	It 	Ir'   c                    \        4       pV P                  \        VP                  R.4      pV P	                  RVP
                  ^ ,          4       R# )zX
An L{UsageError} is raised when C{https} is requested but there is no
support for SSL.
--https=443zSSL support not installedN)r   r   r   r-   r8   args)r/   r0   	exceptions   &  r$   test_HTTPSFailureOnMissingSSL*ServiceTests.test_HTTPSFailureOnMissingSSL   sA     )%%j'2F2FX	4innQ6GHr'   zSSL module is not available.c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     	2 	2$ 	2r'   c                    \        4       pVP                  R.4       V P                  RVR,          ^ ,          4       V P                  RVR,          ^ ,          4       R# )z=
When SSL support is present, it accepts the --https option.
r   sslrq   443Nr   r{   s   & r$    test_HTTPSAcceptedOnAvailableSSL-ServiceTests.test_HTTPSAcceptedOnAvailableSSL   sK    
 )m_-eWW-a01eWW-a01r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&      s     P P Pr'   c                v    \        4       pVP                  . RO4       V P                  VR,          RR.4       R# )z5
When --add-header is specific, the value is parsed.
extraHeadersN--add-headerzK1: V1r   zK2: V2K1V1K2V2)r   r-   r8   r{   s   & r$   test_add_header_parsing$ServiceTests.test_add_header_parsing   s4     )QR0<2NOr'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&     s     E E$ Er'   c                `   \        4       pVP                  . RO4       \        V4      pVP                  ^ ,          P                  P
                  pV P                  V\        4       V P                  VP                  RR.4       V P                  VP                  \        P                  4       R# )zR
When --add-header is specified, the resource is a composition that adds
headers.
Nr   r   r   )r   r-   r   rC   rD   rE   r7   r   r8   _headers_originalResourcer   Test)r/   r0   rM   rE   s   &   r$   test_add_header_resource%ServiceTests.test_add_header_resource  s    
 )QRg&##A&..77h(;<**\<,HIh88$))Dr'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&     s     + +d +r'   c                J   \        4       pVP                  R.4       \        V4       V P                  V P                  .4      pV P                  V^ ,          R,          \        4       V P                  V^ ,          R,          R4       V P                  \        V4      ^4       R# )z'
Passing --notracebacks is deprecated.
z--notracebackscategorymessagez/--notracebacks was deprecated in Twisted 19.7.0N)r   r-   r   flushWarningstest_noTracebacksDeprecationr8   DeprecationWarninglen)r/   r0   warningss   &  r$   r   )ServiceTests.test_noTracebacksDeprecation  s     )./0G%%t'H'H&IJ!Z02DEQK	"$U	
 	X*r'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&     s     G G Gr'   c                    \        4       pVP                  R.4       \        V4      pV P                  VP                  ^ ,          P
                  P                  4       R# )zU
Passing --display-tracebacks will enable traceback rendering on the
generated Site.
z--display-tracebacksN)r   r-   r   rF   rC   rD   displayTracebacksr/   r0   rM   s   &  r$   test_displayTracebacks#ServiceTests.test_displayTracebacks  sJ    
 )456g&((+33EEFr'   c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   r&   (  s     H H Hr'   c                    \        4       pVP                  . 4       \        V4      pV P                  VP                  ^ ,          P
                  P                  4       R# )z\
Not passing --display-tracebacks will leave traceback rendering on the
generated Site off.
N)r   r-   r   r   rC   rD   r   r   s   &  r$   test_displayTracebacksNotGiven+ServiceTests.test_displayTracebacksNotGiven(  sH    
 )R g&))!,44FFGr'   r"   )r   
__module____qualname____firstlineno____doc__r1   r:   r   r   
providedByr   rN   rU   rY   r`   rg   rl   ru   r|   r   r   r   r
   r   r   r   r   r   r   r   __static_attributes__r"   r'   r$   r   r   (   s6   "/ ##G,,:>	>$IL4 < ##G,,:>	> ##G,,:	>		>	
31,N M-(46PQ	I R	I M-(D02PQ	2 R	2PE+GH Hr'   r   c                  "    ] tR tRtR R ltRtR# )AddHeadersResourceTestsi3  c                   V ^8  d   QhRR/# r4   r"   )r#   s   "r$   r%   $AddHeadersResourceTests.__annotate__4  s     N N$ Nr'   c                4   \        \        P                  ! 4       . RO4      p\        . 4      pVP	                  RV4       V P                  VP                  P                  R4      RR.4       V P                  VP                  P                  R4      R.4       R# )	zK
When getChildWithDefault is invoked, it adds the headers to the
response.
r   r   r   r   V3 N)r   r   )r   r   )r   r   r   r   getChildWithDefaultr8   responseHeadersgetRawHeaders)r/   rE   requests   &  r$   test_getChildWithDefault0AddHeadersResourceTests.test_getChildWithDefault4  s~    
 'IIKC
 r"$$R100>>tDtTlS00>>tDtfMr'   r"   N)r   r   r   r   r   r   r"   r'   r$   r   r   3  s    N Nr'   r   )6r   
__future__r   rG   rI   typingr   unittestr   twisted.internetr   r   twisted.internet.interfacesr   r   twisted.python.filepathr	   twisted.python.reflectr
   twisted.python.threadpoolr   twisted.python.usager   twisted.spread.pbr   twisted.trial.unittestr   twisted.webr   twisted.web.distribr   r   twisted.web.scriptr   twisted.web.serverr   twisted.web.staticr   r   twisted.web.tapr   r   r   r   twisted.web.test.requesthelperr   twisted.web.twcgir   twisted.web.wsgir   objectr   r   r   r"   r'   r$   <module>r      s}    # 	    / B , 0 0 + - +  @ + # )  8 ' )hHH8 HHVNh Nr'   