+
    Dfj'                        R 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 ^ RIHt ^ RIHt ^ R	IHtHtHtHt ^ R
IHt ^ RIHt  ^ RIHt ]tR5t^ RIHt ^ RIH t  Rt" ! R R]PF                  4      t$ ! R R]PF                  4      t% ! R R]PF                  4      t& ! R R]'4      t( ! R R]PF                  4      t) ! R R]PF                  4      t* ! R R]PF                  4      t+ ! R R ]PF                  4      t, ! R! R"]PZ                  4      t. ! R# R$]PF                  4      t/ ! R% R&]PF                  4      t0 ! R' R(4      t1 ! R) R*]Pd                  4      t3 ! R+ R,]Pd                  4      t4 ! R- R.]PF                  4      t5 ! R/ R0]PF                  4      t6 ! R1 R2]PF                  4      t7 ! R3 R4]4      t8R#   ]! d	    RtR6t ELmi ; i)7z8
Tests for L{twisted.words.protocols.jabber.xmlstream}.
)skipIf)verifyObject)defertask)ConnectionLost)IProtocolFactory)failure)proto_helpers)unittest)errorijabberjid	xmlstream)!GenericXmlStreamFactoryTestsMixin)domish)ssl)ClientTLSOptions)CertificateOptionsNurn:ietf:params:xml:ns:xmpp-tlsc                   <   a  ] tR t^$t o RtR tR tR tR tRt	V t
R# )HashPasswordTestsz&
Tests for L{xmlstream.hashPassword}.
c                X    \         P                  ! RR4      pV P                  RV4       R# )zC
The sid and secret are concatenated to calculate sha1 hex digest.
12345secret(99567ee91b2c7cabf607f10cb9f4a3634fa820e0Nr   hashPasswordassertEqualselfhashs   & I/usr/lib/python3/dist-packages/twisted/words/test/test_jabberxmlstream.py
test_basicHashPasswordTests.test_basic)   s'     %%gx8CTJ    c                R    V P                  \        \        P                  RR4       R# )z2
The session identifier must be a unicode object.
s   ¹2345r   NassertRaises	TypeErrorr   r   r   s   &r!   test_sidNotUnicode$HashPasswordTests.test_sidNotUnicode0   s     	)Y%;%;_hWr$   c                R    V P                  \        \        P                  RR4       R# )z(
The password must be a unicode object.
r   s   secrétNr&   r)   s   &r!   test_passwordNotUnicode)HashPasswordTests.test_passwordNotUnicode6   s     	)Y%;%;WFVWr$   c                X    \         P                  ! RR4      pV P                  RV4       R# )zL
The concatenated sid and password must be encoded to UTF-8 before hashing.
r   u   secrét(659bf88d8f8e179081f7f3b4a8e7d224652d2853Nr   r   s   & r!   test_unicodeSecret$HashPasswordTests.test_unicodeSecret<   s'     %%g}=CTJr$    N)__name__
__module____qualname____firstlineno____doc__r"   r*   r-   r1   __static_attributes____classdictcell____classdict__s   @r!   r   r   $   s(     KXXK Kr$   r   c                   l   a  ] tR t^Dt 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V tR# )IQTestsz?
Tests both IQ and the associated IIQResponseTracker callback.
c                   \         P                  ! R 4      pRVn        \         P                  ! V4      V n         \        P
                  ! 4       V n        V P                  P                  V P                   n        V P                   P                  \        P                  ! 4       4       V P                   P                  R4       \         P                  ! V P                   R4      V n        R# )	otherhosttestnszm<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='testns' from='otherhost' version='1.0'>getN)r   ConnectAuthenticator	namespace	XmlStreamr   Clockclock	callLater
_callLatermakeConnectionr	   StringTransportdataReceivedIQiq)r   authenticators   & r!   setUpIQTests.setUpI   s    !66{C"*",,];ZZ\
$(JJ$8$8!%%m&C&C&EF##=	
 ,,t~~u5r$   c                    V P                  V P                  R ,          R4       V P                  V P                  R,          4       R# )typerB   idN)r   rN   
assertTruer)   s   &r!   	testBasicIQTests.testBasicV   s.    %0&r$   c                j   V P                   P                  P                  4        V P                  P	                  4        V P                  R ,          P                  R4      pV P                  V P                   P                  P                  4       RV,           R,           RV,           R,           .4       R# )rT   zutf-8s   <iq type='get' id='s   '/>s   <iq id='s   ' type='get'/>N)r   	transportclearrN   sendencodeassertInvalue)r   idBytess   & r!   testSendIQTests.testSendZ   s      &&(''$-&&w/NN$$**,&069g%(99	
r$   c                   a  V 3R  lpS P                   P                  4       pVP                  V4       S P                  pVP	                  RS P                   R,          ,          4       V# )c                 :   < SP                  V R ,          R4       R# )rS   resultN)r   )rd   r   s   &r!   cb&IQTests.testResultResponse.<locals>.cbg   s    VF^X6r$   <iq type='result' id='%s'/>rT   )rN   r[   addCallbackr   rL   )r   re   dxss   f   r!   testResultResponseIQTests.testResultResponsef   sM    	7 GGLLN	b^^
5EFr$   c                    V P                   P                  4       pV P                  V\        P                  4       V P
                  pVP                  R V P                   R,          ,          4       V# )z<iq type='error' id='%s'/>rT   )rN   r[   assertFailurer   StanzaErrorr   rL   r   ri   rj   s   &  r!   testErrorResponseIQTests.testErrorResponseq   sO    GGLLN1e//0^^
4twwt}DEr$   c                   a  S P                   p\         P                  ! V4       S P                  VP                  4       V 3R lpVP	                  RVR4       VP                  R4       R# )z
Test that untracked iq responses don't trigger any action.

Untracked means that the id of the incoming response iq is not
in the stream's C{iqDeferreds} dictionary.
c                 @   < SP                  \        V R R4      4       R# )handledFN)assertFalsegetattr)rN   r   s   &r!   re   *IQTests.testNonTrackedResponse.<locals>.cb   s    WRE:;r$   z/iqz<iq type='result' id='test'/>N)r   upgradeWithIQResponseTrackerrv   iqDeferredsaddObserverrL   )r   rj   re   s   f  r!   testNonTrackedResponseIQTests.testNonTrackedResponsey   sV     ^^..r2 	(
	< 	ub"% 	78r$   c                    V P                   P                  4       pV P                  pVP                  RV P                   R,          ,          4       V P	                  V P                   R,          VP
                  4       V# )z
Test if the deferred associated with an iq request is removed
from the list kept in the L{XmlStream} object after it has
been fired.
rg   rT   )rN   r[   r   rL   assertNotInr{   rp   s   &  r!   testCleanupIQTests.testCleanup   sW     GGLLN^^
5EF7r$   c                    V P                   P                  4       pV P                  pVP                  R4       V P	                  V\
        4       V# )zq
Test if deferreds for iq's that haven't yet received a response
have their errback called on stream disconnect.
Closed by peer)rN   r[   r   connectionLostrn   r   rp   s   &  r!   testDisconnectCleanupIQTests.testDisconnectCleanup   s@     GGLLN^^
*+1n-r$   c                   a a VV 3R loS P                   P                  4       pVP                  S4       S P                  P	                  R4       V# )zf
Test to make sure the errbacks cannot cause the iteration of the
iqDeferreds to blow up in our face.
c                    < \         P                  ! SP                   4      P                  4       pVP                  S4       R # N)r   rM   r[   
addErrback)r   ri   ebr   s   & r!   r   'IQTests.testNoModifyingDict.<locals>.eb   s*    T^^,113ALLr$   r   )rN   r[   r   r   r   )r   ri   r   s   f @r!   testNoModifyingDictIQTests.testNoModifyingDict   s=    	 GGLLN	R%%&67r$   c                j   ^<V P                   n        V P                   P                  4       pV P                  V\        P
                  4       V P                  P                  ^^<.4       V P                  V P                  P                  4       V P                  V P                  P                  4       V# )z;
Test that an iq request with a defined timeout times out.
)rN   timeoutr[   rn   r   TimeoutErrorrG   pumprv   callsr{   r   ri   s   & r!   testRequestTimingOutIQTests.testRequestTimingOut   s}     GGLLN1i445

B ))*334r$   c                r   ^<V P                   n        V P                   P                  4       pV P                  P	                  ^V P
                  P                  RV P                   R,          ,          4       V P                  P                  ^^.4       V P                  V P                  P                  4       V# )z
Test that an iq request with a defined timeout does not time out
when a response was received before the timeout period elapsed.
rg   rT   )
rN   r   r[   rG   rH   r   rL   r   rv   r   r   s   & r!   testRequestNotTimingOutIQTests.testRequestNotTimingOut   s    
 GGLLN

NN'')DGGDM9	

 	

A))*r$   c                   ^<V P                   n        V P                   P                  4       pV P                  pVP	                  R4       V P                  V\        4       V P                  V P                  P                  4       V# )zd
Test if timeouts for iq's that haven't yet received a response
are cancelled on stream disconnect.
r   )
rN   r   r[   r   r   rn   r   rv   rG   r   rp   s   &  r!   !testDisconnectTimeoutCancellation)IQTests.testDisconnectTimeoutCancellation   sc     GGLLN^^
*+1n-))*r$   )rG   rN   r   N)r4   r5   r6   r7   r8   rP   rV   r`   rk   rq   r}   r   r   r   r   r   r   r9   r:   r;   s   @r!   r>   r>   D   sK     6'

	90
  r$   r>   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V tR# )XmlStreamTestsc                    R V n         R# TN)gotStreamStartr   objs   &&r!   onStreamStartXmlStreamTests.onStreamStart   
    "r$   c                    R V n         R# r   )gotStreamEndr   s   &&r!   onStreamEndXmlStreamTests.onStreamEnd   s
     r$   c                    R V n         R# r   )gotStreamErrorr   s   &&r!   onStreamErrorXmlStreamTests.onStreamError   r   r$   c                   RV n         RV n        RV n        \        P                  ! \        P
                  ! 4       4      pVP                  RV P                  4       VP                  RV P                  4       VP                  RV P                  4       VP                  \        P                  ! 4       4       WP                  n        RVn        RVn        Wn        R# )z)
Set up XmlStream and several observers.
Fz//event/stream/start//event/stream/endz//event/stream/errorrA   N       )r   r   r   r   rE   Authenticatorr|   r   r   r   rJ   r	    StringTransportWithDisconnectionrY   protocolrD   versionr   rj   s   & r!   rP   XmlStreamTests.setUp   s     $!#  !8!8!:;
-t/A/AB
+T-=-=>
-t/A/AB
-HHJK "
r$   c                p   V P                   pVP                  4        V P                   P                  P                  4       ^ R P	                  R4      pV P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  VP                  4       R# )z.
Basic test on the header sent by sendHeader.
       <stream:stream/   xmlns:stream='http://etherx.jabber.org/streams'   xmlns='testns'   version='1.0'Nry   )r   
sendHeaderrY   r^   splitr]   rU   _headerSentr   rj   splitHeaders   &  r!   test_sendHeaderBasic#XmlStreamTests.test_sendHeaderBasic  s     ^^
nn..446q<BB4H'5H+V'5&4'r$   c                   V P                   pRVP                  R&   VP                  4        V P                   P                  P	                  4       ^ R
 P                  R4      pV P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  VP                  4       R	# )z-
Test for additional namespace declarations.
dbzjabber:server:dialbackr   r   r   s!   xmlns:db='jabber:server:dialback'r   r   Nry   )	r   prefixesr   rY   r^   r   r]   rU   r   r   s   &  r!   #test_sendHeaderAdditionalNamespaces2XmlStreamTests.test_sendHeaderAdditionalNamespaces  s     ^^04,-
nn..446q<BB4H'5H+V:KH'5&4'r$   c                X   V P                   p\        P                  ! R4      Vn        \        P                  ! R4      Vn        RVn        VP                  4        VP                  P                  4       ^ R P                  R4      pV P                  RV4       V P                  RV4       R# )	z+
Test addressing when initiating a stream.
thisHost	otherHostTr      to='otherhost'   from='thishost'Nry   )r   r   JID
thisEntityotherEntity
initiatingr   rY   r^   r   r]   r   s   &  r!   test_sendHeaderInitiating(XmlStreamTests.test_sendHeaderInitiating  s     ^^
+-
ll((*1R066t<'5(+6r$   c                   V P                   p\        P                  ! R4      Vn        \        P                  ! R4      Vn        RVn        RVn        VP                  4        VP                  P                  4       ^ R
 P                  R4      pV P                  RV4       V P                  RV4       V P                  RV4       R	# )z*
Test addressing when receiving a stream.
r   r   F	session01r   r   r   s   id='session01'Nry   )r   r   r   r   r   r   sidr   rY   r^   r   r]   r   s   &  r!   test_sendHeaderReceiving'XmlStreamTests.test_sendHeaderReceiving*  s     ^^
+-
ll((*1R066t<'5(+6'5r$   c                    V P                   pVP                  R4       VP                  R4       V P                  V P                  4       V P                  V P                  4       R# )z.
Test events when a stream error is received.
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>z<stream:error/>N)r   rL   rU   r   r   r   s   & r!   test_receiveStreamError&XmlStreamTests.test_receiveStreamError9  sQ     ^^
;	

 	)*++,))*r$   c                T   V P                   pRVn        VP                  4        VP                  P	                  4        VP                  \        P                  ! R4      4       V P                  RVP                  P                  4       4       V P                  V P                  4       R# )z{
Test sendStreamError on an initiating xmlstream with a header sent.

An error should be sent out and the connection lost.
Tversion-unsupportedr$   Nr   r   r   rY   rZ   sendStreamErrorr   StreamErrorassertNotEqualr^   rU   r   r   s   & r!   test_sendStreamErrorInitiating-XmlStreamTests.test_sendStreamErrorInitiatingG  sv     ^^


5,,-BCDC!3!3!56))*r$   c                j   V P                   pRVn        VP                  P                  4        VP	                  \
        P                  ! R4      4       V P                  VP                  4       V P                  RVP                  P                  4       4       V P                  V P                  4       R# )z
Test sendStreamError on an initiating xmlstream without having sent a
header.

In this case, no header should be generated. Also, the error should
not be sent out on the stream. Just closing the connection.
Tr   r$   N)r   r   rY   rZ   r   r   r   	assertNotr   r   r^   rU   r   r   s   & r!   &test_sendStreamErrorInitiatingNoHeader5XmlStreamTests.test_sendStreamErrorInitiatingNoHeaderU  s}     ^^

5,,-BCDr~~&bll0023))*r$   c                T   V P                   pRVn        VP                  4        VP                  P	                  4        VP                  \        P                  ! R4      4       V P                  RVP                  P                  4       4       V P                  V P                  4       R# )zy
Test sendStreamError on a receiving xmlstream with a header sent.

An error should be sent out and the connection lost.
Fr   r$   Nr   r   s   & r!   test_sendStreamErrorReceiving,XmlStreamTests.test_sendStreamErrorReceivinge  sv     ^^


5,,-BCDC!3!3!56))*r$   c                j   V P                   pRVn        VP                  P                  4        VP	                  \
        P                  ! R4      4       V P                  VP                  4       V P                  RVP                  P                  4       4       V P                  V P                  4       R# )z
Test sendStreamError on a receiving xmlstream without having sent a
header.

In this case, a header should be generated. Then, the error should
be sent out on the stream followed by closing the connection.
Fr   r$   N)r   r   rY   rZ   r   r   r   rU   r   r   r^   r   r   s   & r!   %test_sendStreamErrorReceivingNoHeader4XmlStreamTests.test_sendStreamErrorReceivingNoHeaders  s}     ^^

5,,-BCD'C!3!3!56))*r$   c                    V P                   pVP                  4        VP                  pVP                  4        V P	                  W!P                  4       V P                  VP                  4       R# )z5
Test resetting the XML stream to start a new layer.
N)r   r   streamresetr   r   r   )r   rj   r   s   &  r!   
test_resetXmlStreamTests.test_reset  sJ     ^^


FII.r~~&r$   c                @   V P                   pVP                  R4       V P                  VP                  P	                  4       R4       VP                  P                  4        \        P                  ! R4      pVP                  V4       V P                  VP                  P	                  4       R4       VP                  P                  4        \        P                  ! R4      pVP                  V4       V P                  VP                  P	                  4       R4       R# )z*
Test send with various types of objects.
<presence/>   <presence/>s   <stream:features/>N)rA   presence)z http://etherx.jabber.org/streamsfeatures)r   r[   r   rY   r^   rZ   r   Element)r   rj   els   &  r!   	test_sendXmlStreamTests.test_send  s     ^^
++-~>
^^23
++-~>
^^LM
++-/DEr$   c                z  aaa . o. o. o ! VVV3R lR4      pV! 4       p\         P                  ! V4      pV P                  V.S4       VP                  4        V P                  R.S4       VP	                  R4       V P                  ^\        S4      4       VP                  4        V P                  R.S4       R# )z=
Test that the associated authenticator is correctly called.
c                   F   <a  ] tR tRt o V3R ltV3R ltV3R ltRtV tR# )<XmlStreamTests.test_authenticator.<locals>.TestAuthenticatori  c                *   < SP                  R 4       R # r   append)r   connectionMadeCallss   &r!   connectionMadeKXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.connectionMade  s    #**40r$   c                *   < SP                  V4       R # r   r  )r   rootElementstreamStartedCallss   &&r!   streamStartedJXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.streamStarted  s    "))+6r$   c                *   < SP                  V4       R # r   r  )r   rj   associateWithStreamCallss   &&r!   associateWithStreamPXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.associateWithStream  s    (//3r$   r3   N)	r4   r5   r6   r7   r  r  r  r9   r:   )r<   r  r  r  s   @r!   TestAuthenticatorr    s     174 4r$   r  Ns<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345'>)r   rE   r   r  rL   lenr   )r   r  arj   r  r  r  s   &   @@@r!   test_authenticator!XmlStreamTests.test_authenticator  s     !#% 	4 	4   #"78
$!45
-	

 	C 234

$!45r$   )r   r   r   r   N)r4   r5   r6   r7   r   r   r   rP   r   r   r   r   r   r   r   r   r   r   r   r  r9   r:   r;   s   @r!   r   r      s[     #!#"((76+++ ++ 	'F$6 6r$   r   c                       ] tR tRtRtR# )	TestErrori  r3   N)r4   r5   r6   r7   r9   r3   r$   r!   r  r    s    r$   r  c                   >   a  ] tR tRt o R tR tR tR tR tRt	V t
R# )	AuthenticatorTestsi  c                    \         P                  ! 4       V n        \         P                  ! V P                  4      V n         R # r   )r   r   rO   rE   r)   s   &r!   rP   AuthenticatorTests.setUp  s+    &446",,T-?-?@r$   c                   V P                   pVP                  \        P                  ! 4       4       VP	                  R4       V P                  RVP                  4       V P                  RVP                  4       V P                  RVP                  4       V P                  RVP                  4       V P                  RVP                  4       R# )M
Test streamStart to fill the appropriate attributes from the
stream header.
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.org' to='example.com' id='12345' version='1.0'>Ninvalidr   )r   rJ   r	   rK   rL   r   r   assertIdenticalr   rD   r   r   r   s   & r!   test_streamStart#AuthenticatorTests.test_streamStart  s    
 ^^
-779:
	
 	,T266*BLL1T2>>2r}}-r$   c                    V P                   pVP                  \        P                  ! 4       4       VP	                  R4       V P                  RVP                  4       R# )zg
Test streamStart to fill the appropriate attributes from the
stream header for a pre-XMPP-1.0 header.
r  Nr   r   r   rJ   r	   rK   rL   r   r   r   s   & r!   test_streamStartLegacy)AuthenticatorTests.test_streamStartLegacy  sK    
 ^^
-779:
-	

 	,r$   c                    V P                   pVP                  \        P                  ! 4       4       VP	                  R4       V P                  RVP                  4       R# )zo
Test streamStart to fill the appropriate attributes from the
stream header for a version with only one digit.
z<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1'>Nr'  r(  r   s   & r!   test_streamBadVersionOneDigit0AuthenticatorTests.test_streamBadVersionOneDigit  sK    
 ^^
-779:
9	

 	,r$   c                    V P                   pVP                  \        P                  ! 4       4       VP	                  R4       V P                  RVP                  4       R# )ze
Test streamStart to fill the appropriate attributes from the
stream header for a malformed version.
z<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='blah'>Nr'  r(  r   s   & r!   test_streamBadVersionNoNumber0AuthenticatorTests.test_streamBadVersionNoNumber  sK    
 ^^
-779:
<	

 	,r$   rO   r   N)r4   r5   r6   r7   rP   r$  r)  r,  r/  r9   r:   r;   s   @r!   r  r    s$     A.&--- -r$   r  c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
ConnectAuthenticatorTestsi  c                :   R V n         RV n        \        P                  ! R4      V n        \        P
                  ! V P                  4      V n        V P                  P                  RV P                  4       V P                  P                  RV P                  4       R# )FNr   //event/stream/authd//event/xmpp/initfailed)	gotAuthenticatedinitFailurer   rC   rO   rE   r|   onAuthenticatedonInitFailedr)   s   &r!   rP   ConnectAuthenticatorTests.setUp	  ss     %&;;KH",,T-?-?@""#94;O;OP""#<d>O>OPr$   c                    R V n         R# r   )r7  r   s   &&r!   r9  )ConnectAuthenticatorTests.onAuthenticated  s
     $r$   c                    Wn         R # r   )r8  )r   r   s   &&r!   r:  &ConnectAuthenticatorTests.onInitFailed  s    "r$   c                    ! R R4      pV! 4       pV.V P                   n        V P                  P                  4        V P	                  . V P                   P                  4       V P                  V P                  4       R# )z7
Test successful completion of an initialization step.
c                   &   a  ] tR tRt o R tRtV tR# )9ConnectAuthenticatorTests.testSucces.<locals>.Initializeri  c                    R # r   r3   r)   s   &r!   
initializeDConnectAuthenticatorTests.testSucces.<locals>.Initializer.initialize  s    r$   r3   Nr4   r5   r6   r7   rD  r9   r:   r;   s   @r!   InitializerrB    s      r$   rG  N)r   initializersrO   initializeStreamr   rU   r7  r   rG  inits   &  r!   
testSucces$ConnectAuthenticatorTests.testSucces  sa    
	 	 }'+f#++-T^^889--.r$   c                    ! R R4      pV! 4       pV.V P                   n        V P                  P                  4        V P	                  V.V P                   P                  4       V P                  V P                  4       V P                  RV P                  4       V P                  V P                  P                  \        4      4       R# )z)
Test failure of an initialization step.
c                   &   a  ] tR tRt o R tRtV tR# ):ConnectAuthenticatorTests.testFailure.<locals>.Initializeri,  c                    \         hr   )r  r)   s   &r!   rD  EConnectAuthenticatorTests.testFailure.<locals>.Initializer.initialize-  s    r$   r3   NrF  r;   s   @r!   rG  rP  ,  s        r$   rG  N)r   rH  rO   rI  r   rv   r7  assertNotIdenticalr8  rU   checkr  rJ  s   &  r!   testFailure%ConnectAuthenticatorTests.testFailure'  s    
	  	  }'+f#++-$!<!<=../d&6&67((..y9:r$   c                   RV P                   n        V P                  pVP                  \        P
                  ! 4       4       VP                  R4       V P                  RVP                  4       V P                  RVP                  4       V P                  RVP                  4       V P                  RVP                  P                  4       V P                  RVP                  4       V P                  V P                  4       VP                  R4       V P!                  RVP"                  4       V P%                  V P                  4       R# )	r   rA   z<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' to='example.org' id='12345' version='1.0'>r   example.comNz9<stream:features><test xmlns='testns'/></stream:features>r   rA   test)rO   rD   r   rJ   r	   rK   rL   r   r   r   r   hostr#  r   r   r7  r]   r   rU   r   s   & r!   r$  *ConnectAuthenticatorTests.test_streamStart9  s    
 (0$^^
-779:
	
 	,"&&)2<<0(;(;<T2==1t,,-
M	
 	("++6--.r$   )rO   r7  r8  r   N)r4   r5   r6   r7   rP   r9  r:  rL  rU  r$  r9   r:   r;   s   @r!   r3  r3    s)     Q%#/ ;$/ /r$   r3  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )ListenAuthenticatorTestsiT  z,
Tests for L{xmlstream.ListenAuthenticator}
c                    \         P                  ! 4       V n        \         P                  ! V P                  4      V n         R # r   )r   ListenAuthenticatorrO   rE   r)   s   &r!   rP   ListenAuthenticatorTests.setUpY  s+    &::<",,T-?-?@r$   c                $   V P                   pVP                  \        P                  ! 4       4       V P	                  RVP
                  4       VP                  R4       V P                  RVP                  4       V P                  RVP
                  4       V P                  RVP
                  4       V P                  RVP                  4       V P	                  RVP                  4       V P                  RVP                  P                  4       R# )r   Nr!  r   jabber:clientrX  r   )r   rJ   r	   rK   r#  r   rL   r   r   rS  r   rD   r   r   r[  r   s   & r!   r$  )ListenAuthenticatorTests.test_streamStart]  s    
 ^^
-779:T266*
	
 	,bff-GRVV,",,7T2>>2(:(:;r$   c                    V P                   pVP                  \        P                  ! 4       4       VP	                  R4       V P                  VP                  \        4       R# )z4
The generated session id must be a unicode object.
r!  N)r   rJ   r	   rK   rL   assertIsInstancer   strr   s   & r!    test_streamStartUnicodeSessionID9ListenAuthenticatorTests.test_streamStartUnicodeSessionIDr  sK     ^^
-779:
	
 	bffc*r$   r1  N)
r4   r5   r6   r7   r8   rP   r$  rh  r9   r:   r;   s   @r!   r^  r^  T  s     A<*+ +r$   r^  c                      a  ] tR tRt o R tR tR t]! ]!  R 4       t	]! ]!  R 4       t
]! ]!  R 4       tR tR	 tR
 tR tR tRtV tR# )TLSInitiatingInitializerTestsi  c                   . V n         . V n        \        P                  V n        \        P
                  ! R 4      V n        \        P                  ! V P                  4      V n        V P                   P                  V P                  n	        V P                  P                  4        V P                  P                  R4       \        P                  ! V P                  4      V n        R# )rX  r   N)outputdoner   r   savedSSLrC   rO   rE   r  r[   r  rL   TLSInitiatingInitializerrK  r)   s   &r!   rP   #TLSInitiatingInitializerTests.setUp  s    	!&;;MJ",,T-?-?@"kk00%%'##;	

 66t~~F	r$   c                0    V P                   \        n        R # r   )ro  r   r   r)   s   &r!   tearDown&TLSInitiatingInitializerTests.tearDown  s    	r$   c                    \         P                  ! V P                   RR7      V n        V P                  V P                  P                  4       R# )z.
Passing required sets the instance variable.
T)requiredN)r   rp  rK  rU   rv  r)   s   &r!   test_initRequired/TLSInitiatingInitializerTests.test_initRequired  s3     66t~~PTU			**+r$   c                  a  \         P                  ! 4       S P                  n        V 3R lS P                  P                  n        V 3R lS P                  n        V 3R lS P                  n        S P                  P                  4       pVP                  S P                  \        P                  4       S P                  ^\        S P                  4      4       S P                  ^,          pS P                  RVP                  4       S P                  \        VP                   4       S P                  P#                  R\        ,          4       S P                  . ROS P$                  4       V# )z>
When TLS is wanted and SSL available, StartTLS is initiated.
c                 :   < SP                   P                  R 4      # )TLSrn  r  )ctxr   s   &r!   <lambda>DTLSInitiatingInitializerTests.test_wantedSupported.<locals>.<lambda>  s    		8H8H8Or$   c                  :   < S P                   P                  R 4      # r   r|  r)   s   r!   r~  r        tyy'7'7'@r$   c                  :   < S P                   P                  R 4      # headerr|  r)   s   r!   r~  r        DII,<,<X,Fr$   starttls<proceed xmlns='%s'/>r{  r   r  )r	   rK   r   rY   startTLSr   r   rK  startrh   r   Resetr  rm  nameNS_XMPP_TLSurirL   rn  )r   ri   r  s   f  r!   test_wantedSupported2TLSInitiatingInitializerTests.test_wantedSupported  s    
 $1#@#@#B ,O  )@$F!IIOO	d&&	8C,-;;q>X]]3hll3##$;k$IJ3TYY?r$   c                  a  V 3R lp\         P                  ! 4       S P                  n        VS P                  P                  n        V 3R lS P                  n        V 3R lS P                  n        S P                  P                  4       pS P                  P                  R\        ,          4       S P                  . ROS P                  4       V# )z*
The server certificate will be verified.
c                    < SP                  V \        4       SP                  V P                  R 4       SP                  P                  R4       R# )rX  r{  N)rf  r   r   	_hostnamern  r  )contextFactoryr   s   &r!   fakeStartTLSJTLSInitiatingInitializerTests.test_certificateVerify.<locals>.fakeStartTLS  s<    !!.2BC^55}EIIU#r$   c                  :   < S P                   P                  R 4      # r  r|  r)   s   r!   r~  FTLSInitiatingInitializerTests.test_certificateVerify.<locals>.<lambda>  r  r$   c                  :   < S P                   P                  R 4      # r  r|  r)   s   r!   r~  r    r  r$   r  r  )r	   rK   r   rY   r  r   r   rK  r  rL   r  r   rn  )r   r  ri   s   f  r!   test_certificateVerify4TLSInitiatingInitializerTests.test_certificateVerify  s    	$
 $1#@#@#B ,8  )@$F!IIOO##$;k$IJ3TYY?r$   c                *  a a \        4       o\        P                  ! S P                  SR7      S n        SS P                  n        VV 3R lp\
        P                  ! 4       S P                  n        VS P                  P                  n        V 3R lS P                  n	        V 3R lS P                  n
        S P                  P                  4       pS P                  P                  R\        ,          4       S P                  . ROS P                  4       V# )z8
A custom contextFactory is passed through to startTLS.
)configurationForTLSc                 b   < SP                  SV 4       SP                  P                  R 4       R# )r{  N)assertIsrn  r  )r  r}  r   s   &r!   r  QTLSInitiatingInitializerTests.test_certificateVerifyContext.<locals>.fakeStartTLS  s#    MM#~.IIU#r$   c                  :   < S P                   P                  R 4      # r  r|  r)   s   r!   r~  MTLSInitiatingInitializerTests.test_certificateVerifyContext.<locals>.<lambda>  r  r$   c                  :   < S P                   P                  R 4      # r  r|  r)   s   r!   r~  r    r  r$   r  r  )r   r   rp  rK  r  r	   rK   rY   r  r   r   r  rL   r  r   rn  )r   r  ri   r}  s   f  @r!   test_certificateVerifyContext;TLSInitiatingInitializerTests.test_certificateVerifyContext  s    
 !"66NN
	 $'		 	$ $1#@#@#B ,8  )@$F!IIOO##$;k$IJ3TYY?r$   c                    R\         n        RV P                  n        V P                  P	                  4       pVP                  V P                  R4       V P                  ^\        V P                  4      4       V# )zH
No StartTLS is initiated when wanted, not required, SSL not available.
NF)	r   r   rK  rv  r  rh   r   r  rm  r   s   & r!   "test_wantedNotSupportedNotRequired@TLSInitiatingInitializerTests.test_wantedNotSupportedNotRequired  sY     	"		IIOO	d&&-C,-r$   c                    R\         n        RV P                  n        V P                  P	                  4       pV P                  V\         P                  4       V P                  ^\        V P                  4      4       V# )zC
TLSNotSupported is raised when TLS is required but not available.
NT)
r   r   rK  rv  r  rn   TLSNotSupportedr   r  rm  r   s   & r!   test_wantedNotSupportedRequired=TLSInitiatingInitializerTests.test_wantedNotSupportedRequired  s[     	!		IIOO1i778C,-r$   c                   \         P                  ! R4      pVP                  R4       VP                  VP                  3V/V P
                  n        RV P                  n        V P                  P                  4       pV P                  ^\        V P                  4      4       V P                  V\
        P                  4       V# )zG
TLSRequired is raised when TLS is not wanted, but required by server.
rv  Fr   r  )r   r   
addElementr  r  r   r   rK  wantedr  r   r  rm  rn   TLSRequiredr   tlsri   s   &  r!   test_notWantedRequired4TLSInitiatingInitializerTests.test_notWantedRequired  s     nnLMz"$'GGSXX#6"< 		IIOOC,-1i334r$   c                ~   \         P                  ! R4      pVP                  VP                  3V/V P                  n        RV P                  n        RV P                  n        V P                  P                  4       pVP                  V P                  R4       V P                  ^\        V P                  4      4       V# )z<
No StartTLS is initiated when not wanted and not required.
FNr  )r   r   r  r  r   r   rK  r  rv  r  rh   r   r  rm  r  s   &  r!   test_notWantedNotRequired7TLSInitiatingInitializerTests.test_notWantedNotRequired
  s     nnLM$'GGSXX#6"< 		"		IIOO	d&&-C,-r$   c                    ^\         n        V P                  P                  4       pV P	                  V\         P
                  4       V P                   P                  R\        ,          4       V# )z>
TLSFailed is raised when the server responds with a failure.
z<failure xmlns='%s'/>)r   r   rK  r  rn   	TLSFailedrL   r  r   s   & r!   test_failed)TLSInitiatingInitializerTests.test_failed  sN     	IIOO1i112##$;k$IJr$   )rO   rn  rK  rm  ro  r   N)r4   r5   r6   r7   rP   rs  rw  r   skipWhenNoSSLr  r  r  r  r  r  r  r  r9   r:   r;   s   @r!   rk  rk    s~     G"&, ] ( ] ( ] 2 r$   rk  c                   *   a  ] tR tRt o RtR tRtV tR# )TestFeatureInitializeri'  c                .    \         P                  ! R 4      # r   )r   succeedr)   s   &r!   r  TestFeatureInitializer.start*  s    }}T""r$   r3   NrY  )r4   r5   r6   r7   featurer  r9   r:   r;   s   @r!   r  r  '  s      G# #r$   r  c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )%BaseFeatureInitiatingInitializerTestsi.  c                    \         P                  ! \         P                  ! 4       4      V n         \        V P                   4      V n        R # r   )r   rE   r   r  rK  r)   s   &r!   rP   +BaseFeatureInitiatingInitializerTests.setUp/  s-    ",,Y-D-D-FG*4>>:	r$   c                    V P                   P                  \        P                  ! V P                   P                  4      /V P                  n        V P                   P                  4       # )zG
Test that an advertized feature results in successful initialization.
)rK  r  r   r   r   r   rD  r)   s   &r!   testAdvertized4BaseFeatureInitiatingInitializerTests.testAdvertized3  sE     $(99#4#4fnnTYYEVEV6W"Xyy##%%r$   c                    RV P                   n        V P                  \        P                  V P                   P
                  4       R# )zh
Test that when the feature is not advertized, but required by the
initializer, an exception is raised.
TN)rK  rv  r'   r   FeatureNotAdvertizedrD  r)   s   &r!   testNotAdvertizedRequired?BaseFeatureInitiatingInitializerTests.testNotAdvertizedRequired:  s0    
 "		)88$)):N:NOr$   c                |    RV P                   n        V P                  RV P                   P                  4       4       R# )zw
Test that when the feature is not advertized, and not required by the
initializer, the initializer silently succeeds.
FN)rK  rv  r#  rD  r)   s   &r!   testNotAdvertizedNotRequiredBBaseFeatureInitiatingInitializerTests.testNotAdvertizedNotRequiredB  s-    
 #		T499#7#7#9:r$   )rK  r   N)
r4   r5   r6   r7   rP   r  r  r  r9   r:   r;   s   @r!   r  r  .  s     ;&P; ;r$   r  c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
ToResponseTestsiK  c                r   \         P                  ! R4      pRVR&   RVR&   RVR&   RVR&   \        P                  ! VR	4      pV P	                  W4       V P                  VR,          R4       V P                  VR,          R4       V P                  VR,          R	4       V P                  VR,          R4       R
# )zC
Test that a response stanza is generated with addressing swapped.
rB   rS   user1@example.comtouser2@example.com/resourcefromstanza1rT   rd   Nrc  rN   )r   r   r   
toResponserS  r   r   stanzaresponses   &  r!   test_toResponseToResponseTests.test_toResponseL  s      78v*t5v t''91&)+>?$)EF&)84$3r$   c                    \         P                  ! R4      pRVR&   RVR&   \        P                  ! V4      pV P	                  VR,          R4       V P                  VP                  R4      4       R# )zI
Test that a response is generated from a stanza without a from address.
rB   rS   r  r  r  Nr  )r   r   r   r  r   rv   hasAttributer  s   &  r!   test_toResponseNoFrom%ToResponseTests.test_toResponseNoFrom\  sd      78v*t''/&)+>?..t45r$   c                    \         P                  ! R4      pRVR&   RVR&   \        P                  ! V4      pV P	                  VP                  R4      4       V P                  VR,          R4       R# )zG
Test that a response is generated from a stanza without a to address.
rB   rS   r  r  r  Nr  )r   r   r   r  rv   r  r   r  s   &  r!   test_toResponseNoTo#ToResponseTests.test_toResponseNoTog  sc      78v5v''/..v67$)EFr$   c                    \         P                  ! R4      pRVR&   \        P                  ! V4      pV P	                  VP                  R4      4       V P	                  VP                  R4      4       R# )zI
Test that a response is generated from a stanza without any addressing.
chatrS   r  r  Nrc  messager   r   r   r  rv   r  r  s   &  r!   test_toResponseNoAddressing+ToResponseTests.test_toResponseNoAddressingr  s^      <=v''/..t45..v67r$   c                    \         P                  ! R4      p\        P                  ! V4      pV P	                  VP                  R4      4       R# )z@
Test that a proper response is generated without id attribute.
rT   Nr  r  r  s   &  r!   	test_noIDToResponseTests.test_noID|  s<      <=''/..t45r$   c                    \         P                  ! R4      p\        P                  ! V4      pV P	                  VP                  R4      4       R# )zB
Test that a proper response is generated without type attribute.
rS   Nr  r  r  s   &  r!   test_noTypeToResponseTests.test_noType  s<      <=''/..v67r$   r3   N)r4   r5   r6   r7   r  r  r  r  r  r  r9   r:   r;   s   @r!   r  r  K  s)     4 	6	G868 8r$   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )DummyFactoryi  zB
Dummy XmlStream factory that only registers bootstrap observers.
c                    / V n         R # r   	callbacksr)   s   &r!   __init__DummyFactory.__init__  s	    r$   c                "    W P                   V&   R # r   r  )r   eventcallbacks   &&&r!   addBootstrapDummyFactory.addBootstrap  s     (ur$   r  N)	r4   r5   r6   r7   r8   r  r   r9   r:   r;   s   @r!   r  r    s     ) )r$   r  c                   B   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
DummyXMPPHandleri  zG
Dummy XMPP subprotocol handler to count the methods are called on it.
c                0    ^ V n         ^ V n        ^ V n        R# )r   N)doneMadedoneInitializeddoneLostr)   s   &r!   r  DummyXMPPHandler.__init__  s     r$   c                &    V P                  4        R # r   )r  r   s   &&r!   rJ   DummyXMPPHandler.makeConnection  s    r$   c                8    V ;P                   ^,          un         R# r   Nr  r)   s   &r!   r  DummyXMPPHandler.connectionMade      r$   c                8    V ;P                   ^,          un         R# r  )r  r)   s   &r!   connectionInitialized&DummyXMPPHandler.connectionInitialized  s    !r$   c                8    V ;P                   ^,          un         R# r  )r  r   reasons   &&r!   r   DummyXMPPHandler.connectionLost  r  r$   )r  r  r  N)r4   r5   r6   r7   r8   r  rJ   r  r  r   r9   r:   r;   s   @r!   r  r    s(     
" r$   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )FailureReasonXMPPHandleri  z6
Dummy handler specifically for failure Reason tests.
c                    R V n         R# )FNgotFailureReasonr)   s   &r!   r  !FailureReasonXMPPHandler.__init__  s
     %r$   c                X    \        V\        P                  4      '       d
   R V n        R# R# r   )
isinstancer   Failurer  r  s   &&r!   r   'FailureReasonXMPPHandler.connectionLost  s     fgoo..$(D! /r$   r  N)	r4   r5   r6   r7   r8   r  r   r9   r:   r;   s   @r!   r  r    s     &) )r$   r  c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	XMPPHandlerTestsi  z%
Tests for L{xmlstream.XMPPHandler}.
c                `    \        \        P                  \        P                  ! 4       4       R# )z>
L{xmlstream.XMPPHandler} implements L{ijabber.IXMPPHandler}.
N)r   r   IXMPPHandlerr   XMPPHandlerr)   s   &r!   test_interfaceXMPPHandlerTests.test_interface  s     	W))9+@+@+BCr$   c                     ! R R4      p\         P                  ! 4       pV! 4       Vn        VP                  R4       V P	                  R.VP                  P
                  4       R# )z@
Test that data is passed on for sending by the stream manager.
c                   ,   a  ] tR tRt o R tR tRtV tR# )6XMPPHandlerTests.test_send.<locals>.DummyStreamManageri  c                    . V n         R # r   outlistr)   s   &r!   r  ?XMPPHandlerTests.test_send.<locals>.DummyStreamManager.__init__  s	    !r$   c                <    V P                   P                  V4       R # r   )r-  r  )r   datas   &&r!   r[   ;XMPPHandlerTests.test_send.<locals>.DummyStreamManager.send  s    ##D)r$   r,  N)r4   r5   r6   r7   r  r[   r9   r:   r;   s   @r!   DummyStreamManagerr*    s     "* *r$   r2  r   N)r   r%  parentr[   r   r-  )r   r2  handlers   &  r!   r   XMPPHandlerTests.test_send  sN    
	* 	* '')+-]#-'..*@*@Ar$   c                &    ! R R\         P                  4      pV! 4       p\         P                  ! \         P                  ! 4       4      pVP	                  V4       V P                  VP                  4       V P                  W2P                   4       R# )zI
Test that makeConnection saves the XML stream and calls connectionMade.
c                   &   a  ] tR tRt o R tRtV tR# )=XMPPHandlerTests.test_makeConnection.<locals>.TestXMPPHandleri  c                    R V n         R# r   r  r)   s   &r!   r  LXMPPHandlerTests.test_makeConnection.<locals>.TestXMPPHandler.connectionMade  s	     $r$   r  N)r4   r5   r6   r7   r  r9   r:   r;   s   @r!   TestXMPPHandlerr8    s     % %r$   r;  N)r   r%  rE   r   rJ   rU   r  r#  )r   r;  r4  rj   s   &   r!   test_makeConnection$XMPPHandlerTests.test_makeConnection  sk    
	%i33 	% "#  !8!8!:;r"(()R!2!23r$   c                   \         P                  ! 4       p\         P                  ! \         P                  ! 4       4      pVP	                  V4       VP                  \        4       4       V P                  RVP                   4       R# )z2
Test that connectionLost forgets the XML stream.
N)r   r%  rE   r   rJ   r   	Exceptionr#  )r   r4  rj   s   &  r!   test_connectionLost$XMPPHandlerTests.test_connectionLost  s_     '')  !8!8!:;r"y{+T7#4#45r$   r3   N)r4   r5   r6   r7   r8   r&  r   r<  r@  r9   r:   r;   s   @r!   r"  r"    s%     DB"46 6r$   r"  c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	XMPPHandlerCollectionTestsi  z/
Tests for L{xmlstream.XMPPHandlerCollection}.
c                :    \         P                  ! 4       V n        R # r   )r   XMPPHandlerCollection
collectionr)   s   &r!   rP    XMPPHandlerCollectionTests.setUp  s    #99;r$   c                N    \        \        P                  V P                  4       R# )zJ
L{xmlstream.StreamManager} implements L{ijabber.IXMPPHandlerCollection}.
N)r   r   IXMPPHandlerCollectionrF  r)   s   &r!   r&  )XMPPHandlerCollectionTests.test_interface  s     	W33T__Er$   c                    \        4       pVP                  V P                  4       V P                  WP                  4       V P	                  V P                  VP
                  4       R# )z*
Test the addition of a protocol handler.
N)r  setHandlerParentrF  r]   r#  r3  r   r4  s   & r!   test_addHandler*XMPPHandlerCollectionTests.test_addHandler  sF     #$  1g/T__gnn=r$   c                    \        4       pVP                  V P                  4       VP                  V P                  4       V P	                  WP                  4       V P                  RVP                  4       R# )z%
Test removal of a protocol handler.
N)r  rL  rF  disownHandlerParentr   r#  r3  rM  s   & r!   test_removeHandler-XMPPHandlerCollectionTests.test_removeHandler
  sV     #$  1##DOO4//2T7>>2r$   )rF  N)r4   r5   r6   r7   r8   rP   r&  rN  rR  r9   r:   r;   s   @r!   rC  rC    s$     <F>3 3r$   rC  c                   x   a  ] tR tR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V tR# )StreamManagerTestsi  z'
Tests for L{xmlstream.StreamManager}.
c                P    \        4       p\        P                  ! V4      V n        R # r   )r  r   StreamManagerstreamManager)r   factorys   & r!   rP   StreamManagerTests.setUp  s    .&44W=r$   c                F   V P                   pV P                  RVP                  4       V P                  . VP                  4       V P                  VP
                  VP                  P                  R,          4       V P                  VP                  VP                  P                  R,          4       V P                  VP                  VP                  P                  R,          4       V P                  VP                  VP                  P                  R,          4       R# )z=
Test correct initialization and setup of factory observers.
Nz//event/stream/connectedr5  r   r6  )rX  r#  r   r   handlers
_connectedrY  r  _authd_disconnectedinitializationFailed)r   sms   & r!   r"   StreamManagerTests.test_basic  s     T2<<0R[[)MM2:://0JK	
 	BJJ$8$89O$PQ))2::+?+?@T+UV##RZZ%9%9:S%T	
r$   c                p   V P                   p\        4       pVP                  V4       \        P                  ! \        P
                  ! 4       4      pVP                  V4       V P                  ^VP                  4       V P                  ^ VP                  4       V P                  ^ VP                  4       R# )zg
Test that protocol handlers have their connectionMade method called
when the XML stream is connected.
N)rX  r  rL  r   rE   r   r]  r   r  r  r  r   ra  r4  rj   s   &   r!   test_connected!StreamManagerTests.test_connected.  s    
 "$  $  !8!8!:;
bG,,-G334G,,-r$   c                8   V P                   p\        4       pVP                  V4       \        P                  ! \        P
                  ! 4       4      pVP                  V4       V P                  RVP                  4       V P                  RVP                  4       R# )z@
Test raw data functions unset when logTraffic is set to False.
N)
rX  r  rL  r   rE   r   r]  r#  rawDataInFnrawDataOutFnrd  s   &   r!   test_connectedLogTrafficFalse0StreamManagerTests.test_connectedLogTrafficFalse<  sr     "$  $  !8!8!:;
bT2>>2T2??3r$   c                F   V P                   pRVn        \        4       pVP                  V4       \        P
                  ! \        P                  ! 4       4      pVP                  V4       V P                  RVP                  4       V P                  RVP                  4       R# )z=
Test raw data functions set when logTraffic is set to True.
TN)rX  
logTrafficr  rL  r   rE   r   r]  rS  rh  ri  rd  s   &   r!   test_connectedLogTrafficTrue/StreamManagerTests.test_connectedLogTrafficTrueH  sy     "$  $  !8!8!:;
bbnn5boo6r$   c                p   V P                   p\        4       pVP                  V4       \        P                  ! \        P
                  ! 4       4      pVP                  V4       V P                  ^ VP                  4       V P                  ^VP                  4       V P                  ^ VP                  4       R# )zp
Test that protocol handlers have their connectionInitialized method
called when the XML stream is initialized.
N)rX  r  rL  r   rE   r   r^  r   r  r  r  rd  s   &   r!   
test_authdStreamManagerTests.test_authdU  s    
 "$  $  !8!8!:;
		"G,,-G334G,,-r$   c                p   V P                   p\        4       pVP                  V4       \        P                  ! \        P
                  ! 4       4      pVP                  V4       V P                  ^ VP                  4       V P                  ^ VP                  4       V P                  ^VP                  4       R# )zj
Test that protocol handlers have their connectionLost method
called when the XML stream is disconnected.
N)rX  r  rL  r   rE   r   r_  r   r  r  r  rd  s   &   r!   test_disconnected$StreamManagerTests.test_disconnectedc  s    
 "$  $  !8!8!:;
G,,-G334G,,-r$   c                    V P                   p\        4       pVP                  V4       VP                  \        P
                  ! \        R4      4      4       V P                  RVP                  4       R# )z
A L{STREAM_END_EVENT} results in L{StreamManager} firing the handlers
L{connectionLost} methods, passing a L{failure.Failure} reason.
z	no reasonTN)	rX  r  rL  r_  r   r  r?  r   r  r   ra  r4  s   &  r!   test_disconnectedReason*StreamManagerTests.test_disconnectedReasonq  sW    
 *,  $
;)?@Aw778r$   c                    V P                   p\        4       pVP                  V4       V P                  ^ VP                  4       V P                  ^ VP
                  4       V P                  ^ VP                  4       R# )z>
Test the addition of a protocol handler while not connected.
N)rX  r  rL  r   r  r  r  rw  s   &  r!   rN  "StreamManagerTests.test_addHandler|  sg     "$  $G,,-G334G,,-r$   c                   V P                   p\        P                  ! \        P                  ! 4       4      pVP	                  V4       VP                  V4       \        4       pVP                  V4       V P                  ^VP                  4       V P                  ^VP                  4       V P                  ^ VP                  4       R# )z
Test the addition of a protocol handler after the stream
have been initialized.

Make sure that the handler will have the connected stream
passed via C{makeConnection} and have C{connectionInitialized}
called.
N)rX  r   rE   r   r]  r^  r  rL  r   r  r  r  )r   ra  rj   r4  s   &   r!   test_addHandlerInitialized-StreamManagerTests.test_addHandlerInitialized  s       !8!8!:;
b
		""$  $G,,-G334G,,-r$   c                   \         P                  ! \         P                  ! 4       4      p\         P                  ! V4      pVP	                  R4      p\
        P                  ! 4       Vn        VP                  4        VP                  R4       VP                  VR4       VP                  R4       V P                  RVP                  P                  4       4       R# )zh
Test send when the stream has been initialized.

The data should be sent directly over the XML stream.
Nr  r5  r   r   )r   XmlStreamFactoryr   rW  buildProtocolr	   rK   rY   r  rL   dispatchr[   r   r^   r   rY  ra  rj   s   &   r!   test_sendInitialized'StreamManagerTests.test_sendInitialized  s     ,,Y-D-D-FG$$W-""4($446

-	

 	B./
););)=>r$   c                V   \         P                  ! \         P                  ! 4       4      p\         P                  ! V4      p\	        4       pVP                  V4       VP                  R4      p\        P                  ! 4       Vn	        VP                  R4       V P                  RVP                  P                  4       4       V P                  RVP                  ^ ,          4       VP                  4        V P                  RVP                  P                  4       4       V P                  RVP                  ^ ,          4       VP                  R4       VP!                  VR4       V P                  RVP                  P                  4       4       V P#                  VP                  4       R# )z
Test send when there is no established XML stream.

The data should be cached until an XML stream has been established and
initialized.
Nr   r$   r  r5  r   )r   r  r   rW  r  
addHandlerr  r	   rK   rY   r[   r   r^   _packetQueuer  rL   r  rv   r   rY  ra  r4  rj   s   &    r!   test_sendNotConnected(StreamManagerTests.test_sendNotConnected  s6    ,,Y-D-D-FG$$W-"$
g""4($446
bll0023(:;
bll0023(:;
-	

 	B./););)=>)r$   c                   \         P                  ! \         P                  ! 4       4      p\         P                  ! V4      pVP	                  R4      p\
        P                  ! 4       Vn        VP                  4        VP                  R4       VP                  R4       V P                  RVP                  P                  4       4       V P                  RVP                  ^ ,          4       R# )z
Test send when the stream is connected but not yet initialized.

The data should be cached until the XML stream has been initialized.
Nr  r   r$   )r   r  r   rW  r  r	   rK   rY   r  rL   r[   r   r^   r  r  s   &   r!   test_sendNotInitialized*StreamManagerTests.test_sendNotInitialized  s     ,,Y-D-D-FG$$W-""4($446

-	

 	bll0023(:;r$   c                   \         P                  ! \         P                  ! 4       4      p\         P                  ! V4      p\	        4       pVP                  V4       VP                  R4      pVP                  4        \        P                  ! 4       Vn
        VP                  R4       VP                  R4       V P                  RVP                  P                  4       4       V P                  RVP                  ^ ,          4       R# )z
Test send after XML stream disconnection.

The data should be cached until a new XML stream has been established
and initialized.
Nr   r$   )r   r  r   rW  r  r  r  r  r	   rK   rY   r   r[   r   r^   r  r  s   &    r!   test_sendDisconnected(StreamManagerTests.test_sendDisconnected  s     ,,Y-D-D-FG$$W-"$
g""4(
$446
$
bll0023(:;r$   )rX  N)r4   r5   r6   r7   r8   rP   r"   re  rj  rn  rq  rt  rx  rN  r}  r  r  r  r  r9   r:   r;   s   @r!   rU  rU    sV     >
 .
47..	9
..(?(*@<(< <r$   rU  c                   B   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
XmlStreamServerFactoryTestsi  z0
Tests for L{xmlstream.XmlStreamServerFactory}.
c                ^   a  ! R R4      oV3R lp\         P                  ! V4      V n        R# )zA
Set up a server factory with an authenticator factory function.
c                   ,   a  ] tR tRt o R tR tRtV tR# )<XmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticatori  c                    . V n         R # r   
xmlstreamsr)   s   &r!   r  EXmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticator.__init__  s	    "$r$   c                <    V P                   P                  V4       R # r   )r  r  r   s   &&r!   r  PXmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticator.associateWithStream  s    &&r*r$   r  N)r4   r5   r6   r7   r  r  r9   r:   r;   s   @r!   r  r    s     %+ +r$   r  c                     < S ! 4       # r   r3   )r  s   r!   authenticatorFactory?XmlStreamServerFactoryTests.setUp.<locals>.authenticatorFactory  s    $&&r$   N)r   XmlStreamServerFactoryrY  )r   r  r  s   & @r!   rP   !XmlStreamServerFactoryTests.setUp  s'    
	+ 	+	' !778LMr$   c                :    \        \        V P                  4       R# )z,
L{XmlStreamServerFactory} is a L{Factory}.
N)r   r   rY  r)   s   &r!   r&  *XmlStreamServerFactoryTests.test_interface  s     	%t||4r$   c                    V P                   P                  R4      pV P                  V.VP                  P                  4       R# )aS  
The authenticator factory should be used to instantiate the
authenticator and pass it to the protocol.

The default protocol, L{XmlStream} stores the authenticator it is
passed, and calls its C{associateWithStream} method. so we use that to
check whether our authenticator factory is used and the protocol
instance gets an authenticator.
N)rY  r  r   rO   r  r   s   & r!   ,test_buildProtocolAuthenticatorInstantiationHXmlStreamServerFactoryTests.test_buildProtocolAuthenticatorInstantiation  s6     \\''-"r//::;r$   c                |    V P                   P                  R4      pV P                  V\        P                  4       R# )zF
The protocol factory creates Jabber XML Stream protocols by default.
N)rY  r  rf  r   rE   r   s   & r!   test_buildProtocolXmlStream7XmlStreamServerFactoryTests.test_buildProtocolXmlStream#  s.     \\''-b)"5"56r$   c                    V P                   P                  R4      pV P                   P                  R4      pV P                  W4       V P                  VP                  VP                  4       R# )zz
Subsequent calls to buildProtocol should result in different instances
of the protocol, as well as their authenticators.
N)rY  r  rS  rO   )r   xs1xs2s   &  r!   test_buildProtocolTwice3XmlStreamServerFactoryTests.test_buildProtocolTwice*  sV    
 ll((.ll((.) 1 133D3DEr$   )rY  N)r4   r5   r6   r7   r8   rP   r&  r  r  r  r9   r:   r;   s   @r!   r  r    s+     N"5<7F Fr$   r  )F )TzSSL not available)9r8   r
   r   zope.interface.verifyr   twisted.internetr   r   twisted.internet.errorr   twisted.internet.interfacesr   twisted.pythonr   twisted.testr	   twisted.trialtwisted.words.protocols.jabberr   r   r   r   !twisted.words.test.test_xmlstreamr   twisted.words.xishr   r   _sslr  twisted.internet._sslverifyr   twisted.internet.sslr   ImportErrorr  TestCaser   r>   r   r?  r  r  r3  r^  rk   BaseFeatureInitiatingInitializerr  r  r  r  r%  r  r  r"  rC  rU  r  r3   r$   r!   <module>r     s    . ( 1 8 " & " I I O %	8,
 CM<7/K)) K@_h _DX6X&& X6v		 	@-** @-FI/ 1 1 I/X*+x00 *+ZcH$5$5 cL#YGG #;H,=,= ;:?8h'' ?8D	) 	)y,, .
)y44 
)36x(( 36l3!2!2 3Db<** b<J8F"C 8FE'  0
C/M0s   G GG