+
    DfjR6                        R 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IHt ^ RIHt ^ RIHt  ! R	 R
4      t ! R R]P(                  4      t ! R R]P(                  4      t ! R R]P(                  4      t ! R R]
P0                  4      t ! R R]P(                  4      t ! R R]P(                  4      t ! R R]P(                  4      t ! R R]P(                  4      tR# )z7
Tests for L{twisted.words.protocols.jabber.component}
)sha1)verifyObject)failure)unittest)	componentijabber	xmlstream)JID)domish)XmlPipec                   ,   a  ] tR t^t o R tR tRtV tR# )DummyTransportc                    Wn         R # Nlist)selfr   s   &&I/usr/lib/python3/dist-packages/twisted/words/test/test_jabbercomponent.py__init__DummyTransport.__init__   s    	    c                <    V P                   P                  V4       R # r   )r   append)r   bytess   &&r   writeDummyTransport.write   s    		r   r   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s        r   r   c                   ,   a  ] tR t^t o R tR tRtV tR# )#ComponentInitiatingInitializerTestsc                   . V n         \        P                  ! 4       V n        R V P                  n        \        P
                  ! V P                  4      V n        RV P                  n        V P                   P                  V P                  n        V P                  P                  4        V P                  P                  R4       RV P                  n        \        P                  ! V P                  4      V n        R# )secrettest:componentz<stream:stream xmlns='test:component' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>12345N)outputr   Authenticatorauthenticatorpassword	XmlStream	namespacer   sendconnectionMadedataReceivedsidr   ComponentInitiatingInitializerinitr   s   &r   setUp)ComponentInitiatingInitializerTests.setUp   s    &446&.#",,T-?-?@#3 "kk00%%'##;	

 %<<T^^L	r   c                   V P                   P                  4       pV P                  R,          pV P                  RVP                  4       V P                  RVP
                  4       V P                  \        R4      P                  4       \        V4      4       . Vn	        V P                  P                  VP                  4       4       V# )z/
Test basic operations of component handshake.
	handshaker(      12345secret)r5   
initializer*   assertEqualnameurir   	hexdigeststrchildrenr   r2   toXml)r   dr:   s   &  r   testHandshake1ComponentInitiatingInitializerTests.testHandshake-   s    
 II  " KKO	inn5)9==923==?YP  	##IOO$56r   )r,   r5   r*   r   N)r   r   r   r   r7   rF   r    r!   r"   s   @r   r%   r%      s     M" r   r%   c                   ,   a  ] tR t^Ct o R tR tRtV tR# )ComponentAuthTestsc                    R V n         R# TNauthComplete)r   streams   &&r   
authPassedComponentAuthTests.authPassedD   s
     r   c                    R V n         . p\        P                  ! RR4      p\        P                  ! V4      p\        V4      Vn        VP                  \        P                  V P                  4       VP                  4        VP                  R4       \        R
4      P                  4       P                  R4      pV P                  V^,          RV,           R,           4       VP                  R4       V P                  V P                   R4       R	# )Fcjidr'   sv   <stream:stream xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams' from='cjid' id='12345'>asciis   <handshake>s   </handshake><handshake/>TNr<   )rM   r   ConnectComponentAuthenticatorr   r.   r   	transportaddObserverSTREAM_AUTHD_EVENTrO   r1   r2   r   rA   encoder>   )r   outlistcaxshvs   &    r   testAuthComponentAuthTests.testAuthG   s    !44VXF  $%g.
y33T__E 	
 F	

 &'113::7C^b%8?%JK
'**D1r   rL   N)r   r   r   r   rO   r^   r    r!   r"   s   @r   rI   rI   C   s     !2 2r   rI   c                   *   a  ] tR t^at o RtR tRtV tR# )ServiceTestsz!
Tests for L{component.Service}.
c                d    \         P                  ! 4       p\        \        P                  V4       R# )z6
L{component.Service} implements L{ijabber.IService}.
N)r   Servicer   r   IService)r   services   & r   test_interfaceServiceTests.test_interfacef   s"     ##%W%%w/r    N)r   r   r   r   __doc__rf   r    r!   r"   s   @r   ra   ra   a   s     0 0r   ra   c                   8   a  ] tR t^nt o R tR tR tR tRtV t	R# )JabberServiceHarnessc                0    R V n         R V n        R V n        R# )FNcomponentConnectedFlagcomponentDisconnectedFlagtransportConnectedFlagr6   s   &r   r   JabberServiceHarness.__init__o   s    &+#).&&+#r   c                    R V n         R# rK   )rn   r   r   s   &&r   componentConnected'JabberServiceHarness.componentConnectedt   
    &*#r   c                    R V n         R# rK   )ro   r6   s   &r   componentDisconnected*JabberServiceHarness.componentDisconnectedw   s
    )-&r   c                    R V n         R# rK   )rp   rs   s   &&r   transportConnected'JabberServiceHarness.transportConnectedz   rv   r   rm   N)
r   r   r   r   r   rt   rx   r{   r    r!   r"   s   @r   rk   rk   n   s     ,
+.+ +r   rk   c                   &   a  ] tR t^~t o R tRtV tR# )JabberServiceManagerTestsc                   \         P                  ! R R4      p\        4       pVP                  V4       . pVP	                  4       P                  R4      pWn        VP                  VP                  n        VP                  4        V P                  RVP                  4       VP                  V\        P                  4       V P                  RVP                  4       VP!                  R4       V P                  RVP"                  4       R# )foor-   NT)r   ServiceManagerrk   setServiceParent
getFactorybuildProtocolrV   r   r   r1   r>   rp   dispatchr   rX   rn   connectionLostro   )r   smsvcwlistr\   s   &    r   testSM JabberServiceManagerTests.testSM   s    %%eZ8"$R   ]]_**40"\\ 	 	s99: 	B	445 	s99: 	$ 	s<<=r   rh   N)r   r   r   r   r   r    r!   r"   s   @r   r~   r~   ~   s     > >r   r~   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )RouterTestsz 
Tests for L{component.Router}.
c                  a \         P                  ! 4       p. oV3R lVn        \        4       pVP	                  RVP
                  4       V P                  ^\        VP                  4      4       V P                  VP
                  VP                  R,          4       \        P                  ! R4      pVP                  P                  V4       V P                  V.S4       R# )z:
Test route registration and routing on incoming stanzas.
c                 &   < SP                  V 4      # r   r   )elementrouteds   &r   <lambda>+RouterTests.test_addRoute.<locals>.<lambda>   s    v}}W'=r   zexample.orgN)testnstest)r   Routerrouter   addRoutesinkr>   lenroutesr
   Elementsourcer0   )r   routerpiper   r   s   &   @r   test_addRouteRouterTests.test_addRoute   s     !!#=ytyy1C./FMM-$@A..!34!'F+r   c                  a \        4       p\        4       p\        P                  ! 4       pVP                  RVP                  4       VP                  RVP                  4       . oVP
                  P                  RV3R l4       \        P                  ! R4      pRVR&   RVR&   VP
                  P                  V4       V P                  V.S4       R# )	z
Test routing of a message.
component1.example.orgzcomponent2.example.org/*c                 &   < SP                  V 4      # r   r   r   outgoings   &r   r   (RouterTests.test_route.<locals>.<lambda>   s    HOOG<Tr   NfromtoNpresencer   r   r   r   r   r   rW   r
   r   r0   r>   )r   
component1
component2r   stanzar   s   &    @r   
test_routeRouterTests.test_route   s     Y
Y
!!#0*//B0*//B%%d,TU 231v/tv&&8,r   c                  a \        4       p\        4       p\        P                  ! 4       pVP                  RVP                  4       VP                  RVP                  4       . oVP
                  P                  RV3R l4       \        P                  ! R4      pRVR&   RVR&   VP
                  P                  V4       V P                  V.S4       R# )	z
Test routing of a message using the default route.

The default route is the one with L{None} as its key in the
routing table. It is taken when there is no more specific route
in the routing table that matches the stanza's destination.
r   Nr   c                 &   < SP                  V 4      # r   r   r   s   &r   r   /RouterTests.test_routeDefault.<locals>.<lambda>   s    X__W5Mr   r   zexample.comr   r   r   )r   r   s2sr   r   r   s   &    @r   test_routeDefaultRouterTests.test_routeDefault   s     Y
i!!#0*//Bchh'

t%MN 231v$tv&&8,r   rh   N)
r   r   r   r   ri   r   r   r   r    r!   r"   s   @r   r   r      s     ,"-$- -r   r   c                   Z   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V tR# )!ListenComponentAuthenticatorTestsz6
Tests for L{component.ListenComponentAuthenticator}.
c                    . V n         \        P                  ! R 4      p\        P                  ! V4      V n        V P                   P
                  V P                  n        R# )r'   N)r*   r   ListenComponentAuthenticatorr   r.   r   r0   )r   r,   s   & r   r7   'ListenComponentAuthenticatorTests.setUp   sA    !>>xH",,];"kk00r   c                <    V P                   P                  R4       R# )z1
Stub loseConnection because we are a transport.
z	no reasonN)r   r   r6   s   &r   loseConnection0ListenComponentAuthenticatorTests.loseConnection   s     	%%k2r   c                  a . oV3R lpV P                   pWn        VP                  V 4       V P                  RVP                  4       V P                  VP                  4       VP                  R4       V P                  RVP                  4       V P                  RVP                  4       V P                  VP                  4       V P                  RVP                  P                  3SR,          4       R# )z;
The received stream header should set several attributes.
c                 ,   < SP                  W34       R # r   r   )event
observerfn	observerss   &&r   addOnetimeObserverPListenComponentAuthenticatorTests.test_streamStarted.<locals>.addOnetimeObserver   s    e01r   Nzz<stream:stream xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams' to='component.example.org'>r   )    r   r;   )r   r   makeConnectionassertIdenticalr3   assertFalse_headerSentr2   r>   versionassertNotIdentical
assertTruer,   	onElement)r   r   r\   r   s   &  @r   test_streamStarted4ListenComponentAuthenticatorTests.test_streamStarted   s     		2 ^^ 2
$T266*(
*	

 	,bff-'$ 0 0 : :;Yr]Kr   c                   . pV P                   pVP                  Vn        VP                  V 4       VP	                  R4       V P                  ^\        V4      4       V P                  RVR,          P                  4       R# )z=
The received stream header should have a correct namespace.
zp<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='component.example.org'>zinvalid-namespaceNr;   r   r   sendStreamErrorr   r2   r>   r   	conditionr   streamErrorsr\   s   &  r    test_streamStartedWrongNamespaceBListenComponentAuthenticatorTests.test_streamStartedWrongNamespace
  sr     ^^)00
$
*	

 	C-.,l2.>.H.HIr   c                   . pV P                   pVP                  Vn        VP                  V 4       VP	                  R4       V P                  ^\        V4      4       V P                  RVR,          P                  4       R# )z:
The received stream header should have a 'to' attribute.
z_<stream:stream xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>zimproper-addressingNr;   r   r   s   &  r   test_streamStartedNoTo8ListenComponentAuthenticatorTests.test_streamStartedNoTo  sr     ^^)00
$
?	
 	C-..R0@0J0JKr   c                   . pV P                   pVP                  VP                  n        \        P
                  ! R4      pVP                  R4       VP                  P                  V4       V P                  RVR,          4       R# )z,
We expect a handshake element with a hash.
1234N)jabber:component:acceptr:   r;   )	r   r   r,   onHandshaker
   r   
addContentr   r>   )r   
handshakesr\   r:   s   &   r   test_onElement0ListenComponentAuthenticatorTests.test_onElement+  sk     
^^'1'8'8$NN#KL	V$
""9-B0r   c                H   . p. pV P                   pVP                  VP                  n        VP                  Vn        \
        P                  ! R4      pVP                  P                  V4       V P                  V4       V P                  RVR,          P                  4       R# )z)
Reject elements that are not handshakes
not-authorizedN)r   messager;   )r   r   r,   r   r   r
   r   r   r   r>   r   )r   r   r   r\   r   s   &    r   test_onElementNotHandshake<ListenComponentAuthenticatorTests.test_onElementNotHandshake9  s     
^^'1'8'8$)00..!GH
""7+$)<+;+E+EFr   c                4  a . oV3R lpV P                   pVP                  \         P                  V4       RVn        RpVP                  P                  V4       V P                  RV P                  R,          4       V P                  ^\        S4      4       R# )zE
Receiving a handshake matching the secret authenticates the stream.
c                 *   < SP                  V 4       R # r   r   r\   authds   &r   authenticatedIListenComponentAuthenticatorTests.test_onHandshake.<locals>.authenticatedO      LLr   r   (32532c0f7dbf1253c095b18b18e36d38d94c1256rT   Nr;   )	r   r   rX   r3   r,   r   r>   r*   r   )r   r   r\   theHashr   s   &   @r   test_onHandshake2ListenComponentAuthenticatorTests.test_onHandshakeI  s|     	 ^^
i::MJ<
$$W-R9CJ'r   c                Z  a . p. oV3R lpV P                   pVP                  \         P                  V4       VP                  Vn        RVn        RpVP                  P                  V4       V P                  RVR,          P                  4       V P                  ^ \        S4      4       R# )z8
Receiving a bad handshake should yield a stream error.
c                 *   < SP                  V 4       R # r   r   r   s   &r   r   RListenComponentAuthenticatorTests.test_onHandshakeWrongHash.<locals>.authenticateda  r   r   r   r   Nr;   )r   r   rX   r   r   r3   r,   r   r>   r   r   )r   r   r   r\   r   r   s   &    @r   test_onHandshakeWrongHash;ListenComponentAuthenticatorTests.test_onHandshakeWrongHashZ  s     	 ^^
i::MJ)00
$$W-)<+;+E+EFCJ'r   )r*   r   N)r   r   r   r   ri   r7   r   r   r   r   r   r   r   r   r    r!   r"   s   @r   r   r      s@     13L4J"L 1G ("( (r   r   c                   H   a  ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )XMPPComponentServerFactoryTestsio  z4
Tests for L{component.XMPPComponentServerFactory}.
c                    \         P                  ! 4       V n        \         P                  ! V P                  R 4      V n        V P                  P                  R4      V n        \        R4      V P                  n        R# )r'   Ncomponent.example.org)	r   r   r   XMPPComponentServerFactoryfactoryr   r   r	   
thisEntityr6   s   &r   r7   %XMPPComponentServerFactoryTests.setUpt  sR    &&( ;;DKKR33D9$'(?$@!r   c                   V P                   P                  V P                   \         P                  4       V P                  ^ V P                   P                  4       V P                  ^V P
                  P                  4       V P                  RV P                   P                  4       V P                  RV P                   P                  4       R# )zI
A new connection increases the stream serial count. No logs by default.
N)	r   r   STREAM_CONNECTED_EVENTr>   serialr  r   rawDataInFnrawDataOutFnr6   s   &r   test_makeConnection3XMPPComponentServerFactoryTests.test_makeConnectionz  s     		0P0PQDNN112DLL//0T4>>#=#=>T4>>#>#>?r   c                (   RV P                   n        V P                  P                  V P                  \        P                  4       V P                  RV P                  P                  4       V P                  RV P                  P                  4       R# )z4
Setting logTraffic should set up raw data loggers.
TN)r  
logTrafficr   r   r  r   r  r  r6   s   &r   test_makeConnectionLogTraffic=XMPPComponentServerFactoryTests.test_makeConnectionLogTraffic  sb     #'	0P0PQdnn&@&@Adnn&A&ABr   c                j   V P                   P                  V P                   \         P                  4        ! R R\        4      p\        P
                  ! V! 4       4      pV P                   P                  V\         P                  4       V P                  ^\        V P                  V4      4      4       R# )zA
An observer for stream errors should trigger onError to log it.
c                       ] tR tRtRtR# )?XMPPComponentServerFactoryTests.test_onError.<locals>.TestErrori  rh   N)r   r   r   r   r    rh   r   r   	TestErrorr    s    r   r  N)
r   r   r  	Exceptionr   FailureSTREAM_ERROR_EVENTr>   r   flushLoggedErrors)r   r  reasons   &  r   test_onError,XMPPComponentServerFactoryTests.test_onError  sz     		0P0PQ		 	 -	(D(DEC 6 6y ABCr   c                (   V P                   P                  V P                   \         P                  4       V P                  RV P                  P
                  4       V P                  V P                   V P                  P
                  R,          4       R# )z7
Make sure a new stream is added to the routing table.
r   N)r   r   rX   assertInr   r   r   r6   s   &r   test_connectionInitialized:XMPPComponentServerFactoryTests.test_connectionInitialized  sb     		0L0LM-t{{/A/ABNNDKK../FG	
r   c                   V P                   P                  V P                   \         P                  4       V P                   P                  R\         P                  4       V P	                  RV P
                  P                  4       R# )zE
Make sure a stream is removed from the routing table on disconnect.
Nr   )r   r   rX   STREAM_END_EVENTassertNotInr   r   r6   s   &r   test_connectionLost3XMPPComponentServerFactoryTests.test_connectionLost  sW     		0L0LMi&@&@A0$++2D2DEr   )r  r   r   N)r   r   r   r   ri   r7   r	  r  r  r  r!  r    r!   r"   s   @r   r   r   o  s3     A@CD
F Fr   r   N)ri   hashlibr   zope.interface.verifyr   twisted.pythonr   twisted.trialr   twisted.words.protocols.jabberr   r   r   "twisted.words.protocols.jabber.jidr	   twisted.words.xishr
   twisted.words.xish.utilityr   r   TestCaser%   rI   ra   rc   rk   r~   r   r   r   rh   r   r   <module>r,     s     . " " H H 2 % .   %(*;*; %P2** 2<
08$$ 
0+9,, + > 1 1 >D<-(## <-~M((9(9 M(`;Fh&7&7 ;Fr   