ó
    ×›‘h'°  ã                   ó¦  • S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr  SS
KJrJrJrJr  SSKJr  SSKJr   SSKJr  \rSrSSKJr  SSKJ r   Sr" " S S\RF                  5      r$ " S S\RF                  5      r% " S S\RF                  5      r& " S S\'5      r( " S S\RF                  5      r) " S S\RF                  5      r* " S  S!\RF                  5      r+ " S" S#\RF                  5      r, " S$ S%\RZ                  5      r. " S& S'\RF                  5      r/ " S( S)\RF                  5      r0 " S* S+5      r1 " S, S-\Rd                  5      r3 " S. S/\Rd                  5      r4 " S0 S1\RF                  5      r5 " S2 S3\RF                  5      r6 " S4 S5\RF                  5      r7 " S6 S7\5      r8g! \! a    SrSr GNkf = f)8z8
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)FÚ )ÚClientTLSOptions)ÚCertificateOptionsN)TzSSL not availableúurn:ietf:params:xml:ns:xmpp-tlsc                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚHashPasswordTestsé$   z&
Tests for L{xmlstream.hashPassword}.
c                 óV   • [         R                  " SS5      nU R                  SU5        g)zC
The sid and secret are concatenated to calculate sha1 hex digest.
Ú12345ÚsecretÚ(99567ee91b2c7cabf607f10cb9f4a3634fa820e0N©r   ÚhashPasswordÚassertEqual©ÚselfÚhashs     ÚkC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/words/test/test_jabberxmlstream.pyÚ
test_basicÚHashPasswordTests.test_basic)   s'   € ô ×%Ò% g¨xÓ8ˆØ×ÑÐCÀTÕJó    c                 óP   • U R                  [        [        R                  SS5        g)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                 óP   • U R                  [        [        R                  SS5        g)z(
The password must be a unicode object.
r   s   secrÃ©tNr)   r,   s    r$   Útest_passwordNotUnicodeÚ)HashPasswordTests.test_passwordNotUnicode6   s   € ð 	×Ñœ)¤Y×%;Ñ%;¸WÐFVÕWr'   c                 óV   • [         R                  " SS5      nU R                  SU5        g)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¨}Ó=ˆØ×ÑÐCÀTÕJr'   © N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r%   r-   r0   r4   Ú__static_attributes__r6   r'   r$   r   r   $   s   † ñòKòXòXõKr'   r   c                   ó`   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rSrg)ÚIQTestséD   z?
Tests both IQ and the associated IIQResponseTracker callback.
c                 óÐ  • [         R                  " S5      nSUl        [         R                  " U5      U l         [        R
                  " 5       U l        U R                  R                  U R                   l        U R                   R                  [        R                  " 5       5        U R                   R                  S5        [         R                  " U R                   S5      U l        g )NÚ	otherhostÚtestnszm<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='testns' from='otherhost' version='1.0'>Úget)r   ÚConnectAuthenticatorÚ	namespaceÚ	XmlStreamr   ÚClockÚclockÚ	callLaterÚ
_callLaterÚmakeConnectionr
   ÚStringTransportÚdataReceivedÚIQÚiq)r"   Úauthenticators     r$   ÚsetUpÚIQTests.setUpI   s™   € Ü!×6Ò6°{ÓCˆØ"*ˆÔÜ"×,Ò,¨]Ó;ˆŒÜ—Z’Z“\ˆŒ
Ø$(§J¡J×$8Ñ$8ˆ�‰Ô!Ø�‰×%Ñ%¤m×&CÒ&CÓ&EÔFØ�‰×#Ñ#ð=ô	
ô —,’,˜tŸ~™~¨uÓ5ˆ�r'   c                 ó~   • U R                  U R                  S   S5        U R                  U R                  S   5        g )NÚtyperC   Úid)r    rO   Ú
assertTruer,   s    r$   Ú	testBasicÚIQTests.testBasicV   s.   € Ø×Ñ˜Ÿ™ ™¨%Ô0Ø�‰˜Ÿ™ ™Õ&r'   c                 ó@  • U R                   R                  R                  5         U R                  R	                  5         U R                  S   R                  S5      nU R                  U R                   R                  R                  5       SU-   S-   SU-   S-   /5        g )NrU   zutf-8s   <iq type='get' id='s   '/>s   <iq id='s   ' type='get'/>)r   Ú	transportÚclearrO   ÚsendÚencodeÚassertInÚvalue)r"   ÚidBytess     r$   ÚtestSendÚIQTests.testSendZ   s   € Ø�‰× Ñ ×&Ñ&Ô(Ø�‰�‰ŒØ—'‘'˜$‘-×&Ñ& wÓ/ˆØ�‰Ø�N‰N×$Ñ$×*Ñ*Ó,à&¨Ñ0°6Ñ9Ø˜gÑ%Ð(9Ñ9ðõ	
r'   c                 óÄ   ^ • U 4S jnT R                   R                  5       nUR                  U5        T R                  nUR	                  ST R                   S   -  5        U$ )Nc                 ó0   >• TR                  U S   S5        g )NrT   Úresult)r    )re   r"   s    €r$   ÚcbÚ&IQTests.testResultResponse.<locals>.cbg   s   ø€ Ø×Ñ˜V F™^¨XÕ6r'   ú<iq type='result' id='%s'/>rU   )rO   r\   ÚaddCallbackr   rM   )r"   rf   ÚdÚxss   `   r$   ÚtestResultResponseÚIQTests.testResultResponsef   sM   ø€ õ	7ð �G‰G�L‰L‹NˆØ	�‰�bÔà�^‰^ˆØ
�‰Ð5¸¿¹À¹ÑEÔFØˆr'   c                 óÔ   • U R                   R                  5       nU R                  U[        R                  5        U R
                  nUR                  SU R                   S   -  5        U$ )Nz<iq type='error' id='%s'/>rU   )rO   r\   ÚassertFailurer   ÚStanzaErrorr   rM   ©r"   rj   rk   s      r$   ÚtestErrorResponseÚIQTests.testErrorResponseq   sO   € Ø�G‰G�L‰L‹NˆØ×Ñ˜1œe×/Ñ/Ô0à�^‰^ˆØ
�‰Ð4°t·w±w¸t±}ÑDÔEØˆr'   c                 óÔ   ^ • T R                   n[         R                  " U5        T R                  UR                  5        U 4S jnUR	                  SUS5        UR                  S5        g)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                 ó>   >• TR                  [        U SS5      5        g )NÚhandledF)ÚassertFalseÚgetattr)rO   r"   s    €r$   rf   Ú*IQTests.testNonTrackedResponse.<locals>.cb‰   s   ø€ Ø×ÑœW R¨°EÓ:Õ;r'   z/iqéÿÿÿÿz<iq type='result' id='test'/>N)r   ÚupgradeWithIQResponseTrackerrw   ÚiqDeferredsÚaddObserverrM   )r"   rk   rf   s   `  r$   ÚtestNonTrackedResponseÚIQTests.testNonTrackedResponsey   sV   ø€ ð �^‰^ˆÜ×.Ò.¨rÔ2ð 	×Ñ˜Ÿ™Ô(õ
	<ð 	�‰�u˜b "Ô%ð 	�‰Ð7Õ8r'   c                 óæ   • U R                   R                  5       nU R                  nUR                  SU R                   S   -  5        U R	                  U R                   S   UR
                  5        U$ )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.
rh   rU   )rO   r\   r   rM   ÚassertNotInr|   rq   s      r$   ÚtestCleanupÚIQTests.testCleanup‘   sW   € ð �G‰G�L‰L‹NˆØ�^‰^ˆØ
�‰Ð5¸¿¹À¹ÑEÔFØ×Ñ˜Ÿ™ ™¨¯©Ô7Øˆr'   c                 ó    • U R                   R                  5       nU R                  nUR                  S5        U R	                  U[
        5        U$ )zq
Test if deferreds for iq's that haven't yet received a response
have their errback called on stream disconnect.
úClosed by peer)rO   r\   r   ÚconnectionLostro   r   rq   s      r$   ÚtestDisconnectCleanupÚIQTests.testDisconnectCleanupž   s@   € ð �G‰G�L‰L‹NˆØ�^‰^ˆØ
×ÑÐ*Ô+Ø×Ñ˜1œnÔ-Øˆr'   c                 ó¤   ^ ^• UU 4S jmT R                   R                  5       nUR                  T5        T R                  R	                  S5        U$ )zf
Test to make sure the errbacks cannot cause the iteration of the
iqDeferreds to blow up in our face.
c                 ó„   >• [         R                  " TR                   5      R                  5       nUR                  T5        g ©N)r   rN   r\   Ú
addErrback)r	   rj   Úebr"   s     €€r$   r�   Ú'IQTests.testNoModifyingDict.<locals>.eb°   s*   ø€ Ü—’˜TŸ^™^Ó,×1Ñ1Ó3ˆAØ�L‰L˜Õr'   r…   )rO   r\   rŒ   r   r†   )r"   rj   r�   s   ` @r$   ÚtestNoModifyingDictÚIQTests.testNoModifyingDictª   s=   ù€ ö	ð �G‰G�L‰L‹NˆØ	�‰�RÔØ�‰×%Ñ%Ð&6Ô7Øˆr'   c                 ój  • SU R                   l        U R                   R                  5       nU R                  U[        R
                  5        U R                  R                  SS/5        U R                  U R                  R                  5        U R                  U R                  R                  5        U$ )z;
Test that an iq request with a defined timeout times out.
é<   é   )rO   Útimeoutr\   ro   r   ÚTimeoutErrorrH   Úpumprw   Úcallsr|   ©r"   rj   s     r$   ÚtestRequestTimingOutÚIQTests.testRequestTimingOut¹   s}   € ð ˆ�‰ŒØ�G‰G�L‰L‹NˆØ×Ñ˜1œi×4Ñ4Ô5à�
‰
�‰˜˜B˜Ô Ø×Ñ˜Ÿ™×)Ñ)Ô*Ø×Ñ˜Ÿ™×3Ñ3Ô4Øˆr'   c                 ób  • SU R                   l        U R                   R                  5       nU R                  R	                  SU R
                  R                  SU R                   S   -  5        U R                  R                  SS/5        U R                  U R                  R                  5        U$ )z‚
Test that an iq request with a defined timeout does not time out
when a response was received before the timeout period elapsed.
r’   r“   rh   rU   )
rO   r”   r\   rH   rI   r   rM   r–   rw   r—   r˜   s     r$   ÚtestRequestNotTimingOutÚIQTests.testRequestNotTimingOutÆ   sƒ   € ð
 ˆ�‰ŒØ�G‰G�L‰L‹NˆØ�
‰
×ÑØØ�N‰N×'Ñ'Ø)¨D¯G©G°D©MÑ9ô	
ð
 	�
‰
�‰˜˜A˜ÔØ×Ñ˜Ÿ™×)Ñ)Ô*Øˆr'   c                 ó  • SU R                   l        U R                   R                  5       nU R                  nUR	                  S5        U R                  U[        5        U R                  U R                  R                  5        U$ )zd
Test if timeouts for iq's that haven't yet received a response
are cancelled on stream disconnect.
r’   r…   )
rO   r”   r\   r   r†   ro   r   rw   rH   r—   rq   s      r$   Ú!testDisconnectTimeoutCancellationÚ)IQTests.testDisconnectTimeoutCancellationÖ   sc   € ð ˆ�‰ŒØ�G‰G�L‰L‹Nˆà�^‰^ˆØ
×ÑÐ*Ô+Ø×Ñ˜1œnÔ-Ø×Ñ˜Ÿ™×)Ñ)Ô*Øˆr'   )rH   rO   r   N)r7   r8   r9   r:   r;   rQ   rW   ra   rl   rr   r~   r‚   r‡   r�   r™   rœ   rŸ   r<   r6   r'   r$   r>   r>   D   sC   † ñò6ò'ò

ò	òò9ò0ò
òòòõ r'   r>   c                   ót   • \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rSrg)ÚXmlStreamTestséæ   c                 ó   • SU l         g ©NT)ÚgotStreamStart©r"   Úobjs     r$   ÚonStreamStartÚXmlStreamTests.onStreamStartç   ó
   € Ø"ˆÕr'   c                 ó   • SU l         g r¥   )ÚgotStreamEndr§   s     r$   ÚonStreamEndÚXmlStreamTests.onStreamEndê   s
   € Ø ˆÕr'   c                 ó   • SU l         g r¥   )ÚgotStreamErrorr§   s     r$   ÚonStreamErrorÚXmlStreamTests.onStreamErrorí   r«   r'   c                 ó¸  • SU l         SU l        SU l        [        R                  " [        R
                  " 5       5      nUR                  SU R                  5        UR                  SU R                  5        UR                  SU R                  5        UR                  [        R                  " 5       5        XR                  l        SUl        SUl        Xl        g)z)
Set up XmlStream and several observers.
Fz//event/stream/startú//event/stream/endz//event/stream/errorrB   ©r“   r   N)r¦   r­   r±   r   rF   ÚAuthenticatorr}   r©   r®   r²   rK   r
   Ú StringTransportWithDisconnectionrZ   ÚprotocolrE   Úversion©r"   rk   s     r$   rQ   ÚXmlStreamTests.setUpð   s¨   € ð $ˆÔØ!ˆÔØ#ˆÔÜ× Ò ¤×!8Ò!8Ó!:Ó;ˆØ
�‰Ð-¨t×/AÑ/AÔBØ
�‰Ð+¨T×-=Ñ-=Ô>Ø
�‰Ð-¨t×/AÑ/AÔBØ
×Ñœ-×HÒHÓJÔKØ "�‰ÔØˆŒØˆŒ
Ø�r'   c                 ón  • U R                   nUR                  5         U R                   R                  R                  5       SS R	                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  UR                  5        g)	z.
Basic test on the header sent by sendHeader.
r   rz   ó    ó   <stream:streamó/   xmlns:stream='http://etherx.jabber.org/streams'ó   xmlns='testns'ó   version='1.0'N)r   Ú
sendHeaderrZ   r_   Úsplitr^   rV   Ú_headerSent©r"   rk   ÚsplitHeaders      r$   Útest_sendHeaderBasicÚ#XmlStreamTests.test_sendHeaderBasic  sŒ   € ð �^‰^ˆØ
�‰ŒØ—n‘n×.Ñ.×4Ñ4Ó6°q¸Ð<×BÑBÀ4ÓHˆØ�‰Ð'¨Ô5Ø�‰ÐHÈ+ÔVØ�‰Ð'¨Ô5Ø�‰Ð&¨Ô4Ø�‰˜Ÿ™Õ'r'   c                 ó°  • U R                   nSUR                  S'   UR                  5         U R                   R                  R	                  5       SS R                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  S	U5        U R                  S
U5        U R                  UR                  5        g)z-
Test for additional namespace declarations.
Údbzjabber:server:dialbackr   rz   r¾   r¿   rÀ   s!   xmlns:db='jabber:server:dialback'rÁ   rÂ   N)	r   ÚprefixesrÃ   rZ   r_   rÄ   r^   rV   rÅ   rÆ   s      r$   Ú#test_sendHeaderAdditionalNamespacesÚ2XmlStreamTests.test_sendHeaderAdditionalNamespaces  sª   € ð �^‰^ˆØ04ˆ�‰Ð,Ñ-Ø
�‰ŒØ—n‘n×.Ñ.×4Ñ4Ó6°q¸Ð<×BÑBÀ4ÓHˆØ�‰Ð'¨Ô5Ø�‰ÐHÈ+ÔVØ�‰Ð:¸KÔHØ�‰Ð'¨Ô5Ø�‰Ð&¨Ô4Ø�‰˜Ÿ™Õ'r'   c                 óV  • U R                   n[        R                  " S5      Ul        [        R                  " S5      Ul        SUl        UR                  5         UR                  R                  5       SS R                  S5      nU R                  SU5        U R                  SU5        g	)
z+
Test addressing when initiating a stream.
ÚthisHostÚ	otherHostTr   rz   r¾   ó   to='otherhost'ó   from='thishost'N)r   r   ÚJIDÚ
thisEntityÚotherEntityÚ
initiatingrÃ   rZ   r_   rÄ   r^   rÆ   s      r$   Útest_sendHeaderInitiatingÚ(XmlStreamTests.test_sendHeaderInitiating  s   € ð �^‰^ˆÜŸš 
Ó+ˆŒÜŸš Ó-ˆŒØˆŒØ
�‰ŒØ—l‘l×(Ñ(Ó*¨1¨RÐ0×6Ñ6°tÓ<ˆØ�‰Ð'¨Ô5Ø�‰Ð(¨+Õ6r'   c                 óˆ  • U R                   n[        R                  " S5      Ul        [        R                  " S5      Ul        SUl        SUl        UR                  5         UR                  R                  5       SS R                  S5      nU R                  SU5        U R                  S	U5        U R                  S
U5        g)z*
Test addressing when receiving a stream.
rÐ   rÑ   FÚ	session01r   rz   r¾   rÒ   rÓ   s   id='session01'N)r   r   rÔ   rÕ   rÖ   r×   ÚsidrÃ   rZ   r_   rÄ   r^   rÆ   s      r$   Útest_sendHeaderReceivingÚ'XmlStreamTests.test_sendHeaderReceiving*  s•   € ð �^‰^ˆÜŸš 
Ó+ˆŒÜŸš Ó-ˆŒØˆŒØˆŒØ
�‰ŒØ—l‘l×(Ñ(Ó*¨1¨RÐ0×6Ñ6°tÓ<ˆØ�‰Ð'¨Ô5Ø�‰Ð(¨+Ô6Ø�‰Ð'¨Õ5r'   c                 óÌ   • U R                   nUR                  S5        UR                  S5        U R                  U R                  5        U R                  U R                  5        g)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   rM   rV   r±   r­   r»   s     r$   Útest_receiveStreamErrorÚ&XmlStreamTests.test_receiveStreamError9  sQ   € ð �^‰^ˆØ
�‰ð;ô	
ð
 	�‰Ð)Ô*Ø�‰˜×+Ñ+Ô,Ø�‰˜×)Ñ)Õ*r'   c                 óR  • U R                   nSUl        UR                  5         UR                  R	                  5         UR                  [        R                  " S5      5        U R                  SUR                  R                  5       5        U R                  U R                  5        g)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Ã   rZ   r[   ÚsendStreamErrorr   ÚStreamErrorÚassertNotEqualr_   rV   r­   r»   s     r$   Útest_sendStreamErrorInitiatingÚ-XmlStreamTests.test_sendStreamErrorInitiatingG  sv   € ð �^‰^ˆØˆŒØ
�‰ŒØ
�‰×ÑÔØ
×Ñœ5×,Ò,Ð-BÓCÔDØ×Ñ˜C §¡×!3Ñ!3Ó!5Ô6Ø�‰˜×)Ñ)Õ*r'   c                 óh  • U R                   nSUl        UR                  R                  5         UR	                  [
        R                  " S5      5        U R                  UR                  5        U R                  SUR                  R                  5       5        U R                  U R                  5        g)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×   rZ   r[   ræ   r   rç   Ú	assertNotrÅ   r    r_   rV   r­   r»   s     r$   Ú&test_sendStreamErrorInitiatingNoHeaderÚ5XmlStreamTests.test_sendStreamErrorInitiatingNoHeaderU  s}   € ð �^‰^ˆØˆŒØ
�‰×ÑÔØ
×Ñœ5×,Ò,Ð-BÓCÔDØ�‰�r—~‘~Ô&Ø×Ñ˜˜bŸl™l×0Ñ0Ó2Ô3Ø�‰˜×)Ñ)Õ*r'   c                 óR  • U R                   nSUl        UR                  5         UR                  R	                  5         UR                  [        R                  " S5      5        U R                  SUR                  R                  5       5        U R                  U R                  5        g)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                 óh  • U R                   nSUl        UR                  R                  5         UR	                  [
        R                  " S5      5        U R                  UR                  5        U R                  SUR                  R                  5       5        U R                  U R                  5        g)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×   rZ   r[   ræ   r   rç   rV   rÅ   rè   r_   r­   r»   s     r$   Ú%test_sendStreamErrorReceivingNoHeaderÚ4XmlStreamTests.test_sendStreamErrorReceivingNoHeaders  s}   € ð �^‰^ˆØˆŒØ
�‰×ÑÔØ
×Ñœ5×,Ò,Ð-BÓCÔDØ�‰˜Ÿ™Ô'Ø×Ñ˜C §¡×!3Ñ!3Ó!5Ô6Ø�‰˜×)Ñ)Õ*r'   c                 óà   • U R                   nUR                  5         UR                  nUR                  5         U R	                  X!R                  5        U R                  UR                  5        g)z5
Test resetting the XML stream to start a new layer.
N)r   rÃ   ÚstreamÚresetrè   rì   rÅ   )r"   rk   rö   s      r$   Ú
test_resetÚXmlStreamTests.test_resetƒ  sJ   € ð �^‰^ˆØ
�‰ŒØ—‘ˆØ
�‰Œ
Ø×Ñ˜F§I¡IÔ.Ø�‰�r—~‘~Õ&r'   c                 ó>  • U R                   nUR                  S5        U R                  UR                  R	                  5       S5        UR                  R                  5         [        R                  " S5      nUR                  U5        U R                  UR                  R	                  5       S5        UR                  R                  5         [        R                  " S5      nUR                  U5        U R                  UR                  R	                  5       S5        g)z*
Test send with various types of objects.
ú<presence/>ó   <presence/>)rB   Úpresence)z http://etherx.jabber.org/streamsÚfeaturess   <stream:features/>N)r   r\   r    rZ   r_   r[   r   ÚElement)r"   rk   Úels      r$   Ú	test_sendÚXmlStreamTests.test_sendŽ  sÅ   € ð �^‰^ˆØ
�‰�ÔØ×Ñ˜Ÿ™×+Ñ+Ó-¨~Ô>à
�‰×ÑÔÜ�^Š^Ð2Ó3ˆØ
�‰�ŒØ×Ñ˜Ÿ™×+Ñ+Ó-¨~Ô>à
�‰×ÑÔÜ�^Š^ÐLÓMˆØ
�‰�ŒØ×Ñ˜Ÿ™×+Ñ+Ó-Ð/DÕEr'   c                 óx  ^^^• / m/ m/ m " UUU4S jS5      nU" 5       n[         R                  " U5      nU R                  U/T5        UR                  5         U R                  S/T5        UR	                  S5        U R                  S[        T5      5        UR                  5         U R                  S/T5        g)z=
Test that the associated authenticator is correctly called.
c                   ó:   >• \ rS rSrU4S jrU4S jrU 4S jrSrg)Ú<XmlStreamTests.test_authenticator.<locals>.TestAuthenticatori¨  c                 ó(   >• TR                  S 5        g r‹   ©Úappend)r"   ÚconnectionMadeCallss    €r$   ÚconnectionMadeÚKXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.connectionMade©  s   ø€ Ø#×*Ñ*¨4Õ0r'   c                 ó(   >• TR                  U5        g r‹   r  )r"   ÚrootElementÚstreamStartedCallss     €r$   ÚstreamStartedÚJXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.streamStarted¬  s   ø€ Ø"×)Ñ)¨+Õ6r'   c                 ó(   >• TR                  U5        g r‹   r  )r"   rk   ÚassociateWithStreamCallss     €r$   ÚassociateWithStreamÚPXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.associateWithStream¯  s   ø€ Ø(×/Ñ/°Õ3r'   r6   N)r7   r8   r9   r:   r
  r  r  r<   )r  r	  r  s   €€€r$   ÚTestAuthenticatorr  ¨  s   ø† õ1õ7÷4ð 4r'   r  Nús<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345'>r“   )r   rF   r    r
  rM   Úlenr÷   )r"   r  Úark   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)r7   r8   r9   r:   r©   r®   r²   rQ   rÈ   rÍ   rØ   rÝ   rá   ré   rí   rð   ró   rø   r  r  r<   r6   r'   r$   r¢   r¢   æ   sS   † ò#ò!ò#òò"(ò(ò7ò6ò+ò+ò+ò +ò+ò 	'òFõ$6r'   r¢   c                   ó   • \ rS rSrSrg)Ú	TestErroriÁ  r6   N)r7   r8   r9   r:   r<   r6   r'   r$   r  r  Á  s   † Úr'   r  c                   ó2   • \ rS rSrS rS rS rS rS rSr	g)	ÚAuthenticatorTestsiÅ  c                 ó‚   • [         R                  " 5       U l        [         R                  " U R                  5      U l         g r‹   )r   r·   rP   rF   r,   s    r$   rQ   ÚAuthenticatorTests.setUpÆ  s+   € Ü&×4Ò4Ó6ˆÔÜ"×,Ò,¨T×-?Ñ-?Ó@ˆ�r'   c                 óž  • U R                   nUR                  [        R                  " 5       5        UR	                  S5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        g)ú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'>r¶   NÚinvalid)r   rK   r
   rL   rM   r    rº   ÚassertIdenticalrÜ   rE   rÖ   rÕ   r»   s     r$   Útest_streamStartÚ#AuthenticatorTests.test_streamStartÊ  s›   € ð
 �^‰^ˆØ
×Ñœ-×7Ò7Ó9Ô:Ø
�‰ðô	
ð 	×Ñ˜ §¡Ô,Ø×Ñ˜T 2§6¡6Ô*Ø×Ñ˜ B§L¡LÔ1Ø×Ñ˜T 2§>¡>Ô2Ø×Ñ˜˜rŸ}™}Õ-r'   c                 ó¾   • U R                   nUR                  [        R                  " 5       5        UR	                  S5        U R                  SUR                  5        g)zg
Test streamStart to fill the appropriate attributes from the
stream header for a pre-XMPP-1.0 header.
r  ©r   r   N©r   rK   r
   rL   rM   r    rº   r»   s     r$   Útest_streamStartLegacyÚ)AuthenticatorTests.test_streamStartLegacyÝ  sK   € ð
 �^‰^ˆØ
×Ñœ-×7Ò7Ó9Ô:Ø
�‰ð-ô	
ð
 	×Ñ˜ §¡Õ,r'   c                 ó¾   • U R                   nUR                  [        R                  " 5       5        UR	                  S5        U R                  SUR                  5        g)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'>r)  Nr*  r»   s     r$   Útest_streamBadVersionOneDigitÚ0AuthenticatorTests.test_streamBadVersionOneDigitë  sK   € ð
 �^‰^ˆØ
×Ñœ-×7Ò7Ó9Ô:Ø
�‰ð9ô	
ð
 	×Ñ˜ §¡Õ,r'   c                 ó¾   • U R                   nUR                  [        R                  " 5       5        UR	                  S5        U R                  SUR                  5        g)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'>r)  Nr*  r»   s     r$   Útest_streamBadVersionNoNumberÚ0AuthenticatorTests.test_streamBadVersionNoNumberù  sK   € ð
 �^‰^ˆØ
×Ñœ-×7Ò7Ó9Ô:Ø
�‰ð<ô	
ð
 	×Ñ˜ §¡Õ,r'   ©rP   r   N)
r7   r8   r9   r:   rQ   r&  r+  r.  r1  r<   r6   r'   r$   r  r  Å  s   † òAò.ò&-ò-õ-r'   r  c                   ó8   • \ rS rSrS rS rS rS rS rS r	Sr
g	)
ÚConnectAuthenticatorTestsi  c                 ó8  • SU l         S U l        [        R                  " S5      U l        [        R
                  " U R                  5      U l        U R                  R                  SU R                  5        U R                  R                  SU R                  5        g )NFrÑ   ú//event/stream/authdú//event/xmpp/initfailed)	ÚgotAuthenticatedÚinitFailurer   rD   rP   rF   r}   ÚonAuthenticatedÚonInitFailedr,   s    r$   rQ   ÚConnectAuthenticatorTests.setUp	  ss   € Ø %ˆÔØˆÔÜ&×;Ò;¸KÓHˆÔÜ"×,Ò,¨T×-?Ñ-?Ó@ˆŒØ�‰×"Ñ"Ð#9¸4×;OÑ;OÔPØ�‰×"Ñ"Ð#<¸d×>OÑ>OÕPr'   c                 ó   • SU l         g r¥   )r9  r§   s     r$   r;  Ú)ConnectAuthenticatorTests.onAuthenticated  s
   € Ø $ˆÕr'   c                 ó   • Xl         g r‹   )r:  )r"   r	   s     r$   r<  Ú&ConnectAuthenticatorTests.onInitFailed  s   € Ø"Õr'   c                 ó   •  " S S5      nU" 5       nU/U R                   l        U R                  R                  5         U R	                  / U R                   R                  5        U R                  U R                  5        g)z7
Test successful completion of an initialization step.
c                   ó   • \ rS rSrS rSrg)Ú9ConnectAuthenticatorTests.testSucces.<locals>.Initializeri  c                 ó   • g r‹   r6   r,   s    r$   Ú
initializeÚDConnectAuthenticatorTests.testSucces.<locals>.Initializer.initialize  s   € Ør'   r6   N©r7   r8   r9   r:   rF  r<   r6   r'   r$   ÚInitializerrD    s   † õr'   rI  N)r   ÚinitializersrP   ÚinitializeStreamr    rV   r9  ©r"   rI  Úinits      r$   Ú
testSuccesÚ$ConnectAuthenticatorTests.testSucces  sa   € ÷
	ñ 	ñ ‹}ˆØ'+ fˆ�‰Ô#à×Ñ×+Ñ+Ô-Ø×Ñ˜˜TŸ^™^×8Ñ8Ô9Ø�‰˜×-Ñ-Õ.r'   c                 ó–  •  " S S5      nU" 5       nU/U R                   l        U R                  R                  5         U R	                  U/U R                   R                  5        U R                  U R                  5        U R                  SU R                  5        U R                  U R                  R                  [        5      5        g)z)
Test failure of an initialization step.
c                   ó   • \ rS rSrS rSrg)Ú:ConnectAuthenticatorTests.testFailure.<locals>.Initializeri,  c                 ó   • [         er‹   )r  r,   s    r$   rF  ÚEConnectAuthenticatorTests.testFailure.<locals>.Initializer.initialize-  s   € Ü�r'   r6   NrH  r6   r'   r$   rI  rR  ,  s   † õ r'   rI  N)r   rJ  rP   rK  r    rw   r9  ÚassertNotIdenticalr:  rV   Úcheckr  rL  s      r$   ÚtestFailureÚ%ConnectAuthenticatorTests.testFailure'  s˜   € ÷
	 ñ 	 ñ ‹}ˆØ'+ fˆ�‰Ô#à×Ñ×+Ñ+Ô-Ø×Ñ˜$˜ §¡×!<Ñ!<Ô=Ø×Ñ˜×.Ñ.Ô/Ø×Ñ  d×&6Ñ&6Ô7Ø�‰˜×(Ñ(×.Ñ.¬yÓ9Õ:r'   c                 óš  • SU R                   l        U R                  nUR                  [        R
                  " 5       5        UR                  S5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  R                  5        U R                  SUR                  5        U R                  U R                  5        UR                  S5        U R!                  SUR"                  5        U R%                  U R                  5        g)	r"  rB   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¶   r   úexample.comNz9<stream:features><test xmlns='testns'/></stream:features>©rB   Útest)rP   rE   r   rK   r
   rL   rM   r    rº   rÜ   rÖ   Úhostr%  rÕ   rì   r9  r^   rþ   rV   r»   s     r$   r&  Ú*ConnectAuthenticatorTests.test_streamStart9  s÷   € ð
 (0ˆ×ÑÔ$Ø�^‰^ˆØ
×Ñœ-×7Ò7Ó9Ô:Ø
�‰ðô	
ð 	×Ñ˜ §¡Ô,Ø×Ñ˜ "§&¡&Ô)Ø×Ñ˜ 2§<¡<Ô0Ø×Ñ˜¨¯©×(;Ñ(;Ô<Ø×Ñ˜T 2§=¡=Ô1Ø�‰�t×,Ñ,Ô-Ø
�‰ØMô	
ð 	�‰Ð(¨"¯+©+Ô6Ø�‰˜×-Ñ-Õ.r'   )rP   r9  r:  r   N)r7   r8   r9   r:   rQ   r;  r<  rN  rW  r&  r<   r6   r'   r$   r5  r5    s!   † òQò%ò#ò/ò ;õ$/r'   r5  c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚListenAuthenticatorTestsiT  z,
Tests for L{xmlstream.ListenAuthenticator}
c                 ó‚   • [         R                  " 5       U l        [         R                  " U R                  5      U l         g r‹   )r   ÚListenAuthenticatorrP   rF   r,   s    r$   rQ   ÚListenAuthenticatorTests.setUpY  s+   € Ü&×:Ò:Ó<ˆÔÜ"×,Ò,¨T×-?Ñ-?Ó@ˆ�r'   c                 ó"  • U R                   nUR                  [        R                  " 5       5        U R	                  SUR
                  5        UR                  S5        U R                  SUR                  5        U R                  SUR
                  5        U R                  SUR
                  5        U R                  SUR                  5        U R	                  SUR                  5        U R                  SUR                  R                  5        g)r"  Nr#  r¶   r   újabber:clientrZ  )r   rK   r
   rL   r%  rÜ   rM   r    rº   rU  rè   rE   rÖ   rÕ   r]  r»   s     r$   r&  Ú)ListenAuthenticatorTests.test_streamStart]  sÉ   € ð
 �^‰^ˆØ
×Ñœ-×7Ò7Ó9Ô:Ø×Ñ˜T 2§6¡6Ô*Ø
�‰ðô	
ð 	×Ñ˜ §¡Ô,Ø×Ñ  b§f¡fÔ-Ø×Ñ˜G R§V¡VÔ,Ø×Ñ˜¨"¯,©,Ô7Ø×Ñ˜T 2§>¡>Ô2Ø×Ñ˜¨¯©×(:Ñ(:Õ;r'   c                 óÆ   • U R                   nUR                  [        R                  " 5       5        UR	                  S5        U R                  UR                  [        5        g)z4
The generated session id must be a unicode object.
r#  N)r   rK   r
   rL   rM   ÚassertIsInstancerÜ   Ústrr»   s     r$   Ú test_streamStartUnicodeSessionIDÚ9ListenAuthenticatorTests.test_streamStartUnicodeSessionIDr  sK   € ð �^‰^ˆØ
×Ñœ-×7Ò7Ó9Ô:Ø
�‰ðô	
ð 	×Ñ˜bŸf™f¤cÕ*r'   r3  N)	r7   r8   r9   r:   r;   rQ   r&  rj  r<   r6   r'   r$   r`  r`  T  s   † ñòAò<õ*+r'   r`  c                   ó†   • \ rS rSrS rS rS r\" \6 S 5       r	\" \6 S 5       r
\" \6 S 5       rS rS	 rS
 rS rS rSrg)ÚTLSInitiatingInitializerTestsi�  c                 óÈ  • / U l         / U l        [        R                  U l        [        R
                  " S5      U l        [        R                  " U R                  5      U l        U R                   R                  U R                  l	        U R                  R                  5         U R                  R                  S5        [        R                  " U R                  5      U l        g )NrZ  rà   )ÚoutputÚdoner   r   ÚsavedSSLrD   rP   rF   r  r\   r
  rM   ÚTLSInitiatingInitializerrM  r,   s    r$   rQ   Ú#TLSInitiatingInitializerTests.setUp‚  s›   € ØˆŒØˆŒ	ä!Ÿ™ˆŒä&×;Ò;¸MÓJˆÔÜ"×,Ò,¨T×-?Ñ-?Ó@ˆŒØ"Ÿk™k×0Ñ0ˆ�‰ÔØ�‰×%Ñ%Ô'Ø�‰×#Ñ#ð;ô	
ô
 ×6Ò6°t·~±~ÓFˆ�	r'   c                 ó.   • U R                   [        l        g r‹   )rq  r   r   r,   s    r$   ÚtearDownÚ&TLSInitiatingInitializerTests.tearDown“  s   € ØŸ™Œ	�r'   c                 ó–   • [         R                  " U R                   SS9U l        U R                  U R                  R                  5        g)z.
Passing required sets the instance variable.
T)ÚrequiredN)r   rr  rM  rV   rx  r,   s    r$   Útest_initRequiredÚ/TLSInitiatingInitializerTests.test_initRequired–  s3   € ô ×6Ò6°t·~±~ÐPTÑUˆŒ	Ø�‰˜Ÿ	™	×*Ñ*Õ+r'   c                 óÊ  ^ • [         R                  " 5       T R                  l        U 4S jT R                  R                  l        U 4S jT R                  l        U 4S jT R                  l        T R                  R                  5       nUR                  T R                  [        R                  5        T R                  S[        T R                  5      5        T R                  S   nT R                  SUR                  5        T R                  [        UR                   5        T R                  R#                  S[        -  5        T R                  / SQT R$                  5        U$ )	z>
When TLS is wanted and SSL available, StartTLS is initiated.
c                 ó:   >• TR                   R                  S5      $ ©NÚTLS©rp  r  )Úctxr"   s    €r$   Ú<lambda>ÚDTLSInitiatingInitializerTests.test_wantedSupported.<locals>.<lambda>£  s   ø€ ¸¿	¹	×8HÑ8HÈÔ8Or'   c                  ó:   >• T R                   R                  S5      $ ©Nr÷   r  r,   s   €r$   r�  r‚  ¤  ó   ø€  t§y¡y×'7Ñ'7¸Ô'@r'   c                  ó:   >• T R                   R                  S5      $ ©NÚheaderr  r,   s   €r$   r�  r‚  ¥  ó   ø€ ¨D¯I©I×,<Ñ,<¸XÔ,Fr'   é   r“   Ústarttlsú<proceed xmlns='%s'/>©r~  r÷   rˆ  )r
   rL   r   rZ   ÚstartTLSr÷   rÃ   rM  Ústartri   r    ÚResetr  ro  ÚnameÚNS_XMPP_TLSÚurirM   rp  )r"   rj   r‹  s   `  r$   Útest_wantedSupportedÚ2TLSInitiatingInitializerTests.test_wantedSupported�  sì   ø€ ô
 $1×#@Ò#@Ó#Bˆ�‰Ô Ü,Oˆ�‰× Ñ Ô)Ü@ˆ�‰ÔÜ$Fˆ�‰Ô!à�I‰I�O‰OÓˆØ	�‰�d×&Ñ&¬	¯©Ô8Ø×Ñ˜œC §¡Ó,Ô-Ø—;‘;˜q‘>ˆØ×Ñ˜ X§]¡]Ô3Ø×Ñœ h§l¡lÔ3Ø�‰×#Ñ#Ð$;¼kÑ$IÔJØ×ÑÒ3°T·Y±YÔ?àˆr'   c                 óš  ^ • U 4S jn[         R                  " 5       T R                  l        UT R                  R                  l        U 4S jT R                  l        U 4S jT R                  l        T R                  R                  5       nT R                  R                  S[        -  5        T R                  / SQT R                  5        U$ )z*
The server certificate will be verified.
c                 ó    >• TR                  U [        5        TR                  U R                  S5        TR                  R                  S5        g )NrZ  r~  )rh  r   r    Ú	_hostnamerp  r  )ÚcontextFactoryr"   s    €r$   ÚfakeStartTLSÚJTLSInitiatingInitializerTests.test_certificateVerify.<locals>.fakeStartTLS¸  s<   ø€ Ø×!Ñ! .Ô2BÔCØ×Ñ˜^×5Ñ5°}ÔEØ�I‰I×Ñ˜UÕ#r'   c                  ó:   >• T R                   R                  S5      $ r„  r  r,   s   €r$   r�  ÚFTLSInitiatingInitializerTests.test_certificateVerify.<locals>.<lambda>¿  r…  r'   c                  ó:   >• T R                   R                  S5      $ r‡  r  r,   s   €r$   r�  r�  À  r‰  r'   rŒ  r�  )r
   rL   r   rZ   rŽ  r÷   rÃ   rM  r�  rM   r’  r    rp  )r"   rš  rj   s   `  r$   Útest_certificateVerifyÚ4TLSInitiatingInitializerTests.test_certificateVerify²  s‹   ø€ õ	$ô
 $1×#@Ò#@Ó#Bˆ�‰Ô Ø,8ˆ�‰× Ñ Ô)Ü@ˆ�‰ÔÜ$Fˆ�‰Ô!à�I‰I�O‰OÓˆØ�‰×#Ñ#Ð$;¼kÑ$IÔJØ×ÑÒ3°T·Y±YÔ?Øˆr'   c                 ó  ^ ^• [        5       m[        R                  " T R                  TS9T l        TT R                  l        UU 4S jn[
        R                  " 5       T R                  l        UT R                  R                  l        U 4S jT R                  l	        U 4S jT R                  l
        T R                  R                  5       nT R                  R                  S[        -  5        T R                  / SQT R                  5        U$ )z8
A custom contextFactory is passed through to startTLS.
)ÚconfigurationForTLSc                 ó`   >• TR                  TU 5        TR                  R                  S5        g r}  )ÚassertIsrp  r  )r™  r€  r"   s    €€r$   rš  ÚQTLSInitiatingInitializerTests.test_certificateVerifyContext.<locals>.fakeStartTLSÓ  s#   ø€ Ø�M‰M˜#˜~Ô.Ø�I‰I×Ñ˜UÕ#r'   c                  ó:   >• T R                   R                  S5      $ r„  r  r,   s   €r$   r�  ÚMTLSInitiatingInitializerTests.test_certificateVerifyContext.<locals>.<lambda>Ù  r…  r'   c                  ó:   >• T R                   R                  S5      $ r‡  r  r,   s   €r$   r�  r§  Ú  r‰  r'   rŒ  r�  )r   r   rr  rM  r™  r
   rL   rZ   rŽ  r÷   rÃ   r�  rM   r’  r    rp  )r"   rš  rj   r€  s   `  @r$   Útest_certificateVerifyContextÚ;TLSInitiatingInitializerTests.test_certificateVerifyContextÇ  s¾   ù€ ô
 !Ó"ˆÜ×6Ò6Ø�N‰N°ñ
ˆŒ	ð $'ˆ�	‰	Ô ö	$ô $1×#@Ò#@Ó#Bˆ�‰Ô Ø,8ˆ�‰× Ñ Ô)Ü@ˆ�‰ÔÜ$Fˆ�‰Ô!à�I‰I�O‰OÓˆØ�‰×#Ñ#Ð$;¼kÑ$IÔJØ×ÑÒ3°T·Y±YÔ?Øˆr'   c                 óô   • S[         l        SU R                  l        U R                  R	                  5       nUR                  U R                  S5        U R                  S[        U R                  5      5        U$ )zH
No StartTLS is initiated when wanted, not required, SSL not available.
NFr“   )	r   r   rM  rx  r�  ri   r    r  ro  r˜   s     r$   Ú"test_wantedNotSupportedNotRequiredÚ@TLSInitiatingInitializerTests.test_wantedNotSupportedNotRequiredá  sY   € ð Œ	ŒØ"ˆ�	‰	Ôà�I‰I�O‰OÓˆØ	�‰�d×&Ñ&¨Ô-Ø×Ñ˜œC §¡Ó,Ô-àˆr'   c                 óü   • S[         l        SU R                  l        U R                  R	                  5       nU R                  U[         R                  5        U R                  S[        U R                  5      5        U$ )zC
TLSNotSupported is raised when TLS is required but not available.
NTr“   )
r   r   rM  rx  r�  ro   ÚTLSNotSupportedr    r  ro  r˜   s     r$   Útest_wantedNotSupportedRequiredÚ=TLSInitiatingInitializerTests.test_wantedNotSupportedRequiredî  s[   € ð Œ	ŒØ!ˆ�	‰	Ôà�I‰I�O‰OÓˆØ×Ñ˜1œi×7Ñ7Ô8Ø×Ñ˜œC §¡Ó,Ô-àˆr'   c                 ó†  • [         R                  " S5      nUR                  S5        UR                  UR                  4U0U R
                  l        SU R                  l        U R                  R                  5       nU R                  S[        U R                  5      5        U R                  U[
        R                  5        U$ )zG
TLSRequired is raised when TLS is not wanted, but required by server.
©r   r‹  rx  Fr“   )r   rÿ   Ú
addElementr“  r‘  r   rþ   rM  Úwantedr�  r    r  ro  ro   ÚTLSRequired©r"   Útlsrj   s      r$   Útest_notWantedRequiredÚ4TLSInitiatingInitializerTests.test_notWantedRequiredû  s�   € ô �nŠnÐLÓMˆØ�‰�zÔ"Ø$'§G¡G¨S¯X©XÐ#6¸Ð"<ˆ�‰ÔØ ˆ�	‰	Ôà�I‰I�O‰OÓˆØ×Ñ˜œC §¡Ó,Ô-Ø×Ñ˜1œi×3Ñ3Ô4àˆr'   c                 ó~  • [         R                  " S5      nUR                  UR                  4U0U R                  l        SU R                  l        SU R                  l        U R                  R                  5       nUR                  U R                  S5        U R                  S[        U R                  5      5        U$ )z<
No StartTLS is initiated when not wanted and not required.
r³  FNr“   )r   rÿ   r“  r‘  r   rþ   rM  rµ  rx  r�  ri   r    r  ro  r·  s      r$   Útest_notWantedNotRequiredÚ7TLSInitiatingInitializerTests.test_notWantedNotRequired
  s‹   € ô �nŠnÐLÓMˆØ$'§G¡G¨S¯X©XÐ#6¸Ð"<ˆ�‰ÔØ ˆ�	‰	ÔØ"ˆ�	‰	Ôà�I‰I�O‰OÓˆØ	�‰�d×&Ñ&¨Ô-Ø×Ñ˜œC §¡Ó,Ô-Øˆr'   c                 óÔ   • S[         l        U R                  R                  5       nU R	                  U[         R
                  5        U R                   R                  S[        -  5        U$ )z>
TLSFailed is raised when the server responds with a failure.
r“   z<failure xmlns='%s'/>)r   r   rM  r�  ro   Ú	TLSFailedrM   r’  r˜   s     r$   Útest_failedÚ)TLSInitiatingInitializerTests.test_failed  sN   € ð Œ	Œà�I‰I�O‰OÓˆØ×Ñ˜1œi×1Ñ1Ô2Ø�‰×#Ñ#Ð$;¼kÑ$IÔJØˆr'   )rP   rp  rM  ro  rq  r   N)r7   r8   r9   r:   rQ   ru  ry  r   ÚskipWhenNoSSLr”  rŸ  r©  r¬  r°  r¹  r¼  rÀ  r<   r6   r'   r$   rm  rm  �  sv   † òGò"&ò,ñ ˆ]Ðñó ðñ( ˆ]Ðñó ðñ( ˆ]Ðñó ðò2òòòõr'   rm  c                   ó   • \ rS rSrSrS rSrg)ÚTestFeatureInitializeri'  r[  c                 ó.   • [         R                  " S 5      $ r‹   )r   Úsucceedr,   s    r$   r�  ÚTestFeatureInitializer.start*  s   € Ü�}Š}˜TÓ"Ð"r'   r6   N)r7   r8   r9   r:   Úfeaturer�  r<   r6   r'   r$   rÄ  rÄ  '  s   † Ø €Gõ#r'   rÄ  c                   ó,   • \ rS rSrS rS rS rS rSrg)Ú%BaseFeatureInitiatingInitializerTestsi.  c                 ó”   • [         R                  " [         R                  " 5       5      U l         [        U R                   5      U l        g r‹   )r   rF   r·   rÄ  rM  r,   s    r$   rQ   Ú+BaseFeatureInitiatingInitializerTests.setUp/  s-   € Ü"×,Ò,¬Y×-DÒ-DÓ-FÓGˆŒÜ*¨4¯>©>Ó:ˆ�	r'   c                 óÔ   • U R                   R                  [        R                  " U R                   R                  5      0U R                  l        U R                   R                  5       $ )zG
Test that an advertized feature results in successful initialization.
)rM  rÈ  r   rÿ   r   rþ   rF  r,   s    r$   ÚtestAdvertizedÚ4BaseFeatureInitiatingInitializerTests.testAdvertized3  sE   € ð $(§9¡9×#4Ñ#4´f·n²nÀTÇYÁY×EVÑEVÓ6WÐ"Xˆ�‰ÔØ�y‰y×#Ñ#Ó%Ð%r'   c                 óŽ   • SU R                   l        U R                  [        R                  U R                   R
                  5        g)zh
Test that when the feature is not advertized, but required by the
initializer, an exception is raised.
TN)rM  rx  r*   r   ÚFeatureNotAdvertizedrF  r,   s    r$   ÚtestNotAdvertizedRequiredÚ?BaseFeatureInitiatingInitializerTests.testNotAdvertizedRequired:  s0   € ð
 "ˆ�	‰	ÔØ×Ñœ)×8Ñ8¸$¿)¹)×:NÑ:NÕOr'   c                 óz   • SU R                   l        U R                  SU R                   R                  5       5        g)zw
Test that when the feature is not advertized, and not required by the
initializer, the initializer silently succeeds.
FN)rM  rx  r%  rF  r,   s    r$   ÚtestNotAdvertizedNotRequiredÚBBaseFeatureInitiatingInitializerTests.testNotAdvertizedNotRequiredB  s-   € ð
 #ˆ�	‰	ÔØ×Ñ˜T 4§9¡9×#7Ñ#7Ó#9Õ:r'   )rM  r   N)	r7   r8   r9   r:   rQ   rÎ  rÒ  rÕ  r<   r6   r'   r$   rÊ  rÊ  .  s   † ò;ò&òPõ;r'   rÊ  c                   ó8   • \ rS rSrS rS rS rS rS rS r	Sr
g	)
ÚToResponseTestsiK  c                 óP  • [         R                  " S5      nSUS'   SUS'   SUS'   SUS	'   [        R                  " US
5      nU R	                  X5        U R                  US   S5        U R                  US   S5        U R                  US   S
5        U R                  US	   S5        g)zC
Test that a response stanza is generated with addressing swapped.
©re  rO   rC   rT   úuser1@example.comÚtoúuser2@example.com/resourceÚfromÚstanza1rU   re   N)r   rÿ   r   Ú
toResponserU  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                 óÚ   • [         R                  " S5      nSUS'   SUS'   [        R                  " U5      nU R	                  US   S5        U R                  UR                  S5      5        g)zI
Test that a response is generated from a stanza without a from address.
rÚ  rC   rT   rÛ  rÜ  rÞ  N)r   rÿ   r   rà  r    rw   ÚhasAttributerá  s      r$   Útest_toResponseNoFromÚ%ToResponseTests.test_toResponseNoFrom\  sd   € ô —’Ð 7Ó8ˆØˆˆv‰Ø*ˆˆt‰Ü×'Ò'¨Ó/ˆØ×Ñ˜ &Ñ)Ð+>Ô?Ø×Ñ˜×.Ñ.¨tÓ4Õ5r'   c                 óÚ   • [         R                  " S5      nSUS'   SUS'   [        R                  " U5      nU R	                  UR                  S5      5        U R                  US   S5        g)zG
Test that a response is generated from a stanza without a to address.
rÚ  rC   rT   rÝ  rÞ  rÜ  N)r   rÿ   r   rà  rw   rç  r    rá  s      r$   Útest_toResponseNoToÚ#ToResponseTests.test_toResponseNoTog  sc   € ô —’Ð 7Ó8ˆØˆˆv‰Ø5ˆˆv‰Ü×'Ò'¨Ó/ˆØ×Ñ˜×.Ñ.¨vÓ6Ô7Ø×Ñ˜ $™Ð)EÕFr'   c                 óæ   • [         R                  " S5      nSUS'   [        R                  " U5      nU R	                  UR                  S5      5        U R	                  UR                  S5      5        g)zI
Test that a response is generated from a stanza without any addressing.
©re  ÚmessageÚchatrT   rÜ  rÞ  N©r   rÿ   r   rà  rw   rç  rá  s      r$   Útest_toResponseNoAddressingÚ+ToResponseTests.test_toResponseNoAddressingr  s^   € ô —’Ð <Ó=ˆØˆˆv‰Ü×'Ò'¨Ó/ˆØ×Ñ˜×.Ñ.¨tÓ4Ô5Ø×Ñ˜×.Ñ.¨vÓ6Õ7r'   c                 óœ   • [         R                  " S5      n[        R                  " U5      nU R	                  UR                  S5      5        g)z@
Test that a proper response is generated without id attribute.
rî  rU   Nrñ  rá  s      r$   Ú	test_noIDÚToResponseTests.test_noID|  s<   € ô —’Ð <Ó=ˆÜ×'Ò'¨Ó/ˆØ×Ñ˜×.Ñ.¨tÓ4Õ5r'   c                 óœ   • [         R                  " S5      n[        R                  " U5      nU R	                  UR                  S5      5        g)zB
Test that a proper response is generated without type attribute.
rî  rT   Nrñ  rá  s      r$   Útest_noTypeÚToResponseTests.test_noType„  s<   € ô —’Ð <Ó=ˆÜ×'Ò'¨Ó/ˆØ×Ñ˜×.Ñ.¨vÓ6Õ7r'   r6   N)r7   r8   r9   r:   rä  rè  rë  rò  rõ  rø  r<   r6   r'   r$   rØ  rØ  K  s!   † ò4ò 	6ò	Gò8ò6õ8r'   rØ  c                   ó$   • \ rS rSrSrS rS rSrg)ÚDummyFactoryi�  zB
Dummy XmlStream factory that only registers bootstrap observers.
c                 ó   • 0 U l         g r‹   ©Ú	callbacksr,   s    r$   Ú__init__ÚDummyFactory.__init__’  s	   € Øˆ�r'   c                 ó    • X R                   U'   g r‹   rý  )r"   ÚeventÚcallbacks      r$   ÚaddBootstrapÚDummyFactory.addBootstrap•  s   € Ø (�‰�uÒr'   rý  N)r7   r8   r9   r:   r;   rÿ  r  r<   r6   r'   r$   rû  rû  �  s   † ñòõ)r'   rû  c                   ó6   • \ rS rSrSrS rS rS rS rS r	Sr
g	)
ÚDummyXMPPHandleri™  zG
Dummy XMPP subprotocol handler to count the methods are called on it.
c                 ó.   • SU l         SU l        SU l        g )Nr   )ÚdoneMadeÚdoneInitializedÚdoneLostr,   s    r$   rÿ  ÚDummyXMPPHandler.__init__ž  s   € ØˆŒØ ˆÔØˆ�r'   c                 ó$   • U R                  5         g r‹   )r
  r»   s     r$   rK   ÚDummyXMPPHandler.makeConnection£  s   € Ø×ÑÕr'   c                 ó.   • U =R                   S-  sl         g ©Nr“   ©r	  r,   s    r$   r
  ÚDummyXMPPHandler.connectionMade¦  ó   € Ø�Š˜ÑŽr'   c                 ó.   • U =R                   S-  sl         g r  )r
  r,   s    r$   ÚconnectionInitializedÚ&DummyXMPPHandler.connectionInitialized©  s   € Ø×Ò Ñ!Ör'   c                 ó.   • U =R                   S-  sl         g r  )r  ©r"   Úreasons     r$   r†   ÚDummyXMPPHandler.connectionLost¬  r  r'   )r
  r  r	  N)r7   r8   r9   r:   r;   rÿ  rK   r
  r  r†   r<   r6   r'   r$   r  r  ™  s    † ñòò
òò"õr'   r  c                   ó$   • \ rS rSrSrS rS rSrg)ÚFailureReasonXMPPHandleri°  z6
Dummy handler specifically for failure Reason tests.
c                 ó   • SU l         g )NF©ÚgotFailureReasonr,   s    r$   rÿ  Ú!FailureReasonXMPPHandler.__init__µ  s
   € Ø %ˆÕr'   c                 óR   • [        U[        R                  5      (       a  SU l        g g r¥   )Ú
isinstancer	   ÚFailurer  r  s     r$   r†   Ú'FailureReasonXMPPHandler.connectionLost¸  s    € Ü�fœgŸo™o×.Ñ.Ø$(ˆDÕ!ð /r'   r  N)r7   r8   r9   r:   r;   rÿ  r†   r<   r6   r'   r$   r  r  °  s   † ñò&õ)r'   r  c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚXMPPHandlerTestsi½  z%
Tests for L{xmlstream.XMPPHandler}.
c                 ó^   • [        [        R                  [        R                  " 5       5        g)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                 óÊ   •  " S S5      n[         R                  " 5       nU" 5       Ul        UR                  S5        U R	                  S/UR                  R
                  5        g)z@
Test that data is passed on for sending by the stream manager.
c                   ó    • \ rS rSrS rS rSrg)Ú6XMPPHandlerTests.test_send.<locals>.DummyStreamManageriÍ  c                 ó   • / U l         g r‹   ©Úoutlistr,   s    r$   rÿ  Ú?XMPPHandlerTests.test_send.<locals>.DummyStreamManager.__init__Î  s	   € Ø!�•r'   c                 ó:   • U R                   R                  U5        g r‹   )r1  r  )r"   Údatas     r$   r\   Ú;XMPPHandlerTests.test_send.<locals>.DummyStreamManager.sendÑ  s   € Ø—‘×#Ñ# DÕ)r'   r0  N)r7   r8   r9   r:   rÿ  r\   r<   r6   r'   r$   ÚDummyStreamManagerr.  Í  s   † ò"õ*r'   r6  rû   N)r   r)  Úparentr\   r    r1  )r"   r6  Úhandlers      r$   r  ÚXMPPHandlerTests.test_sendÈ  sN   € ÷
	*ñ 	*ô ×'Ò'Ó)ˆÙ+Ó-ˆŒØ�‰�]Ô#Ø×Ñ˜-˜¨'¯.©.×*@Ñ*@ÕAr'   c                 ó$  •  " S S[         R                  5      nU" 5       n[         R                  " [         R                  " 5       5      nUR	                  U5        U R                  UR                  5        U R                  X2R                   5        g)zI
Test that makeConnection saves the XML stream and calls connectionMade.
c                   ó   • \ rS rSrS rSrg)Ú=XMPPHandlerTests.test_makeConnection.<locals>.TestXMPPHandleriÞ  c                 ó   • SU l         g r¥   r  r,   s    r$   r
  ÚLXMPPHandlerTests.test_makeConnection.<locals>.TestXMPPHandler.connectionMadeß  s	   € Ø $�•r'   r  N)r7   r8   r9   r:   r
  r<   r6   r'   r$   ÚTestXMPPHandlerr<  Þ  s   † õ%r'   r?  N)r   r)  rF   r·   rK   rV   r	  r%  )r"   r?  r8  rk   s       r$   Útest_makeConnectionÚ$XMPPHandlerTests.test_makeConnectionÙ  sk   € ô
	%œi×3Ñ3ô 	%ñ "Ó#ˆÜ× Ò ¤×!8Ò!8Ó!:Ó;ˆØ×Ñ˜rÔ"Ø�‰˜×(Ñ(Ô)Ø×Ñ˜R×!2Ñ!2Õ3r'   c                 ó  • [         R                  " 5       n[         R                  " [         R                  " 5       5      nUR	                  U5        UR                  [        5       5        U R                  SUR                   5        g)z2
Test that connectionLost forgets the XML stream.
N)r   r)  rF   r·   rK   r†   Ú	Exceptionr%  )r"   r8  rk   s      r$   Útest_connectionLostÚ$XMPPHandlerTests.test_connectionLostè  s_   € ô ×'Ò'Ó)ˆÜ× Ò ¤×!8Ò!8Ó!:Ó;ˆØ×Ñ˜rÔ"Ø×Ñœy›{Ô+Ø×Ñ˜T 7×#4Ñ#4Õ5r'   r6   N)
r7   r8   r9   r:   r;   r*  r  r@  rD  r<   r6   r'   r$   r&  r&  ½  s   † ñòDòBò"4õ6r'   r&  c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚXMPPHandlerCollectionTestsió  z/
Tests for L{xmlstream.XMPPHandlerCollection}.
c                 ó8   • [         R                  " 5       U l        g r‹   )r   ÚXMPPHandlerCollectionÚ
collectionr,   s    r$   rQ   Ú XMPPHandlerCollectionTests.setUpø  s   € Ü#×9Ò9Ó;ˆ�r'   c                 óL   • [        [        R                  U R                  5        g)zJ
L{xmlstream.StreamManager} implements L{ijabber.IXMPPHandlerCollection}.
N)r   r   ÚIXMPPHandlerCollectionrJ  r,   s    r$   r*  Ú)XMPPHandlerCollectionTests.test_interfaceû  s   € ô 	”W×3Ñ3°T·_±_ÕEr'   c                 óÐ   • [        5       nUR                  U R                  5        U R                  XR                  5        U R	                  U R                  UR
                  5        g)z*
Test the addition of a protocol handler.
N)r  ÚsetHandlerParentrJ  r^   r%  r7  ©r"   r8  s     r$   Útest_addHandlerÚ*XMPPHandlerCollectionTests.test_addHandler  sF   € ô #Ó$ˆØ× Ñ  §¡Ô1Ø�‰�gŸ™Ô/Ø×Ñ˜TŸ_™_¨g¯n©nÕ=r'   c                 óò   • [        5       nUR                  U R                  5        UR                  U R                  5        U R	                  XR                  5        U R                  SUR                  5        g)z%
Test removal of a protocol handler.
N)r  rP  rJ  ÚdisownHandlerParentr�   r%  r7  rQ  s     r$   Útest_removeHandlerÚ-XMPPHandlerCollectionTests.test_removeHandler
  sV   € ô #Ó$ˆØ× Ñ  §¡Ô1Ø×#Ñ# D§O¡OÔ4Ø×Ñ˜§/¡/Ô2Ø×Ñ˜T 7§>¡>Õ2r'   )rJ  N)
r7   r8   r9   r:   r;   rQ   r*  rR  rV  r<   r6   r'   r$   rG  rG  ó  s   † ñò<òFò>õ3r'   rG  c                   ól   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rSrg)ÚStreamManagerTestsi  z'
Tests for L{xmlstream.StreamManager}.
c                 óN   • [        5       n[        R                  " U5      U l        g r‹   )rû  r   ÚStreamManagerÚstreamManager)r"   Úfactorys     r$   rQ   ÚStreamManagerTests.setUp  s   € Ü“.ˆÜ&×4Ò4°WÓ=ˆÕr'   c                 ó$  • U R                   nU R                  SUR                  5        U R                  / UR                  5        U R                  UR
                  UR                  R                  S   5        U R                  UR                  UR                  R                  S   5        U R                  UR                  UR                  R                  S   5        U R                  UR                  UR                  R                  S   5        g)z=
Test correct initialization and setup of factory observers.
Nz//event/stream/connectedr7  rµ   r8  )r\  r%  r   r    ÚhandlersÚ
_connectedr]  rþ  Ú_authdÚ_disconnectedÚinitializationFailed)r"   Úsms     r$   r%   ÚStreamManagerTests.test_basic  sÓ   € ð ×ÑˆØ×Ñ˜T 2§<¡<Ô0Ø×Ñ˜˜RŸ[™[Ô)Ø×ÑØ�M‰M˜2Ÿ:™:×/Ñ/Ð0JÑKô	
ð 	×Ñ˜Ÿ™ B§J¡J×$8Ñ$8Ð9OÑ$PÔQØ×Ñ˜×)Ñ)¨2¯:©:×+?Ñ+?Ð@TÑ+UÔVØ×ÑØ×#Ñ# R§Z¡Z×%9Ñ%9Ð:SÑ%Tõ	
r'   c                 ón  • U R                   n[        5       nUR                  U5        [        R                  " [        R
                  " 5       5      nUR                  U5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        g)zg
Test that protocol handlers have their connectionMade method called
when the XML stream is connected.
r“   r   N)r\  r  rP  r   rF   r·   ra  r    r	  r
  r  ©r"   re  r8  rk   s       r$   Útest_connectedÚ!StreamManagerTests.test_connected.  sŒ   € ð
 ×ÑˆÜ"Ó$ˆØ× Ñ  Ô$Ü× Ò ¤×!8Ò!8Ó!:Ó;ˆØ
�‰�bÔØ×Ñ˜˜G×,Ñ,Ô-Ø×Ñ˜˜G×3Ñ3Ô4Ø×Ñ˜˜G×,Ñ,Õ-r'   c                 ó6  • U R                   n[        5       nUR                  U5        [        R                  " [        R
                  " 5       5      nUR                  U5        U R                  SUR                  5        U R                  SUR                  5        g)z@
Test raw data functions unset when logTraffic is set to False.
N)
r\  r  rP  r   rF   r·   ra  r%  ÚrawDataInFnÚrawDataOutFnrh  s       r$   Útest_connectedLogTrafficFalseÚ0StreamManagerTests.test_connectedLogTrafficFalse<  sr   € ð ×ÑˆÜ"Ó$ˆØ× Ñ  Ô$Ü× Ò ¤×!8Ò!8Ó!:Ó;ˆØ
�‰�bÔØ×Ñ˜T 2§>¡>Ô2Ø×Ñ˜T 2§?¡?Õ3r'   c                 óD  • U R                   nSUl        [        5       nUR                  U5        [        R
                  " [        R                  " 5       5      nUR                  U5        U R                  SUR                  5        U R                  SUR                  5        g)z=
Test raw data functions set when logTraffic is set to True.
TN)r\  Ú
logTrafficr  rP  r   rF   r·   ra  rU  rl  rm  rh  s       r$   Útest_connectedLogTrafficTrueÚ/StreamManagerTests.test_connectedLogTrafficTrueH  sy   € ð ×ÑˆØˆŒÜ"Ó$ˆØ× Ñ  Ô$Ü× Ò ¤×!8Ò!8Ó!:Ó;ˆØ
�‰�bÔØ×Ñ  b§n¡nÔ5Ø×Ñ  b§o¡oÕ6r'   c                 ón  • U R                   n[        5       nUR                  U5        [        R                  " [        R
                  " 5       5      nUR                  U5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        g)zp
Test that protocol handlers have their connectionInitialized method
called when the XML stream is initialized.
r   r“   N)r\  r  rP  r   rF   r·   rb  r    r	  r
  r  rh  s       r$   Ú
test_authdÚStreamManagerTests.test_authdU  s‹   € ð
 ×ÑˆÜ"Ó$ˆØ× Ñ  Ô$Ü× Ò ¤×!8Ò!8Ó!:Ó;ˆØ
�	‰	�"ŒØ×Ñ˜˜G×,Ñ,Ô-Ø×Ñ˜˜G×3Ñ3Ô4Ø×Ñ˜˜G×,Ñ,Õ-r'   c                 ón  • U R                   n[        5       nUR                  U5        [        R                  " [        R
                  " 5       5      nUR                  U5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        g)zj
Test that protocol handlers have their connectionLost method
called when the XML stream is disconnected.
r   r“   N)r\  r  rP  r   rF   r·   rc  r    r	  r
  r  rh  s       r$   Útest_disconnectedÚ$StreamManagerTests.test_disconnectedc  sŽ   € ð
 ×ÑˆÜ"Ó$ˆØ× Ñ  Ô$Ü× Ò ¤×!8Ò!8Ó!:Ó;ˆØ
×Ñ˜ÔØ×Ñ˜˜G×,Ñ,Ô-Ø×Ñ˜˜G×3Ñ3Ô4Ø×Ñ˜˜G×,Ñ,Õ-r'   c                 óæ   • U R                   n[        5       nUR                  U5        UR                  [        R
                  " [        S5      5      5        U R                  SUR                  5        g)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)	r\  r  rP  rc  r	   r#  rC  r    r  ©r"   re  r8  s      r$   Útest_disconnectedReasonÚ*StreamManagerTests.test_disconnectedReasonq  sW   € ð
 ×ÑˆÜ*Ó,ˆØ× Ñ  Ô$Ø
×ÑœŸš¬°;Ó)?Ó@ÔAØ×Ñ˜˜w×7Ñ7Õ8r'   c                 óú   • U R                   n[        5       nUR                  U5        U R                  SUR                  5        U R                  SUR
                  5        U R                  SUR                  5        g)z>
Test the addition of a protocol handler while not connected.
r   N)r\  r  rP  r    r	  r
  r  r{  s      r$   rR  Ú"StreamManagerTests.test_addHandler|  sg   € ð ×ÑˆÜ"Ó$ˆØ× Ñ  Ô$à×Ñ˜˜G×,Ñ,Ô-Ø×Ñ˜˜G×3Ñ3Ô4Ø×Ñ˜˜G×,Ñ,Õ-r'   c                 ó�  • U R                   n[        R                  " [        R                  " 5       5      nUR	                  U5        UR                  U5        [        5       nUR                  U5        U R                  SUR                  5        U R                  SUR                  5        U R                  SUR                  5        g)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.
r“   r   N)r\  r   rF   r·   ra  rb  r  rP  r    r	  r
  r  )r"   re  rk   r8  s       r$   Útest_addHandlerInitializedÚ-StreamManagerTests.test_addHandlerInitializedˆ  s—   € ð ×ÑˆÜ× Ò ¤×!8Ò!8Ó!:Ó;ˆØ
�‰�bÔØ
�	‰	�"ŒÜ"Ó$ˆØ× Ñ  Ô$à×Ñ˜˜G×,Ñ,Ô-Ø×Ñ˜˜G×3Ñ3Ô4Ø×Ñ˜˜G×,Ñ,Õ-r'   c                 ó´  • [         R                  " [         R                  " 5       5      n[         R                  " U5      nUR	                  S5      n[
        R                  " 5       Ul        UR                  5         UR                  S5        UR                  US5        UR                  S5        U R                  SUR                  R                  5       5        g)zh
Test send when the stream has been initialized.

The data should be sent directly over the XML stream.
Nr  r7  rû   rü   )r   ÚXmlStreamFactoryr·   r[  ÚbuildProtocolr
   rL   rZ   r
  rM   Údispatchr\   r    r_   ©r"   r]  re  rk   s       r$   Útest_sendInitializedÚ'StreamManagerTests.test_sendInitializedœ  s¤   € ô ×,Ò,¬Y×-DÒ-DÓ-FÓGˆÜ×$Ò$ WÓ-ˆØ×"Ñ" 4Ó(ˆÜ$×4Ò4Ó6ˆŒØ
×ÑÔØ
�‰ð-ô	
ð
 	�‰�BÐ.Ô/Ø
�‰�ÔØ×Ñ˜¨¯©×);Ñ);Ó)=Õ>r'   c                 óD  • [         R                  " [         R                  " 5       5      n[         R                  " U5      n[	        5       nUR                  U5        UR                  S5      n[        R                  " 5       Ul	        UR                  S5        U R                  SUR                  R                  5       5        U R                  SUR                  S   5        UR                  5         U R                  SUR                  R                  5       5        U R                  SUR                  S   5        UR                  S5        UR!                  US5        U R                  SUR                  R                  5       5        U R#                  UR                  5        g)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   r  r7  rü   )r   r„  r·   r[  r  Ú
addHandlerr…  r
   rL   rZ   r\   r    r_   Ú_packetQueuer
  rM   r†  rw   ©r"   r]  re  r8  rk   s        r$   Útest_sendNotConnectedÚ(StreamManagerTests.test_sendNotConnected°  s6  € ô ×,Ò,¬Y×-DÒ-DÓ-FÓGˆÜ×$Ò$ WÓ-ˆÜ"Ó$ˆØ
�‰�gÔà×"Ñ" 4Ó(ˆÜ$×4Ò4Ó6ˆŒØ
�‰�ÔØ×Ñ˜˜bŸl™l×0Ñ0Ó2Ô3Ø×Ñ˜¨¯©¸Ñ(:Ô;à
×ÑÔØ×Ñ˜˜bŸl™l×0Ñ0Ó2Ô3Ø×Ñ˜¨¯©¸Ñ(:Ô;à
�‰ð-ô	
ð
 	�‰�BÐ.Ô/à×Ñ˜¨¯©×);Ñ);Ó)=Ô>Ø×Ñ˜Ÿ™Õ)r'   c                 óÎ  • [         R                  " [         R                  " 5       5      n[         R                  " U5      nUR	                  S5      n[
        R                  " 5       Ul        UR                  5         UR                  S5        UR                  S5        U R                  SUR                  R                  5       5        U R                  SUR                  S   5        g)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„  r·   r[  r…  r
   rL   rZ   r
  rM   r\   r    r_   rŒ  r‡  s       r$   Útest_sendNotInitializedÚ*StreamManagerTests.test_sendNotInitializedÐ  s®   € ô ×,Ò,¬Y×-DÒ-DÓ-FÓGˆÜ×$Ò$ WÓ-ˆØ×"Ñ" 4Ó(ˆÜ$×4Ò4Ó6ˆŒØ
×ÑÔØ
�‰ð-ô	
ð
 	�‰�ÔØ×Ñ˜˜bŸl™l×0Ñ0Ó2Ô3Ø×Ñ˜¨¯©¸Ñ(:Õ;r'   c                 ó  • [         R                  " [         R                  " 5       5      n[         R                  " U5      n[	        5       nUR                  U5        UR                  S5      nUR                  5         [        R                  " 5       Ul
        UR                  S5        UR                  S5        U R                  SUR                  R                  5       5        U R                  SUR                  S   5        g)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„  r·   r[  r  r‹  r…  r
  r
   rL   rZ   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ˆŒØ
×Ñ˜$Ôà
�‰�ÔØ×Ñ˜˜bŸl™l×0Ñ0Ó2Ô3Ø×Ñ˜¨¯©¸Ñ(:Õ;r'   )r\  N)r7   r8   r9   r:   r;   rQ   r%   ri  rn  rr  ru  rx  r|  rR  r�  rˆ  rŽ  r‘  r”  r<   r6   r'   r$   rY  rY    sN   † ñò>ò
ò .ò
4ò7ò.ò.ò	9ò
.ò.ò(?ò(*ò@<õ(<r'   rY  c                   ó6   • \ rS rSrSrS rS rS rS rS r	Sr
g	)
ÚXmlStreamServerFactoryTestsiú  z0
Tests for L{xmlstream.XmlStreamServerFactory}.
c                 ó\   ^•  " S S5      mU4S jn[         R                  " U5      U l        g)zA
Set up a server factory with an authenticator factory function.
c                   ó    • \ rS rSrS rS rSrg)Ú<XmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticatori  c                 ó   • / U l         g r‹   ©Ú
xmlstreamsr,   s    r$   rÿ  ÚEXmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticator.__init__  s	   € Ø"$�•r'   c                 ó:   • U R                   R                  U5        g r‹   )r�  r  r»   s     r$   r  ÚPXmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticator.associateWithStream  s   € Ø—‘×&Ñ& rÕ*r'   rœ  N)r7   r8   r9   r:   rÿ  r  r<   r6   r'   r$   r  rš    s   † ò%õ+r'   r  c                  ó   >• T " 5       $ r‹   r6   )r  s   €r$   ÚauthenticatorFactoryÚ?XmlStreamServerFactoryTests.setUp.<locals>.authenticatorFactory  s   ø€ Ù$Ó&Ð&r'   N)r   ÚXmlStreamServerFactoryr]  )r"   r¢  r  s     @r$   rQ   Ú!XmlStreamServerFactoryTests.setUpÿ  s'   ø€ ÷
	+ñ 	+õ	'ô !×7Ò7Ð8LÓMˆ�r'   c                 ó8   • [        [        U R                  5        g)z,
L{XmlStreamServerFactory} is a L{Factory}.
N)r   r   r]  r,   s    r$   r*  Ú*XmlStreamServerFactoryTests.test_interface  s   € ô 	Ô% t§|¡|Õ4r'   c                 óˆ   • U R                   R                  S5      nU R                  U/UR                  R                  5        g)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)r]  r…  r    rP   r�  r»   s     r$   Ú,test_buildProtocolAuthenticatorInstantiationÚHXmlStreamServerFactoryTests.test_buildProtocolAuthenticatorInstantiation  s6   € ð �\‰\×'Ñ'¨Ó-ˆØ×Ñ˜"˜˜r×/Ñ/×:Ñ:Õ;r'   c                 óz   • U R                   R                  S5      nU R                  U[        R                  5        g)zF
The protocol factory creates Jabber XML Stream protocols by default.
N)r]  r…  rh  r   rF   r»   s     r$   Útest_buildProtocolXmlStreamÚ7XmlStreamServerFactoryTests.test_buildProtocolXmlStream#  s.   € ð �\‰\×'Ñ'¨Ó-ˆØ×Ñ˜b¤)×"5Ñ"5Õ6r'   c                 óÞ   • U R                   R                  S5      nU R                   R                  S5      nU R                  X5        U R                  UR                  UR                  5        g)zz
Subsequent calls to buildProtocol should result in different instances
of the protocol, as well as their authenticators.
N)r]  r…  rU  rP   )r"   Úxs1Úxs2s      r$   Útest_buildProtocolTwiceÚ3XmlStreamServerFactoryTests.test_buildProtocolTwice*  sV   € ð
 �l‰l×(Ñ(¨Ó.ˆØ�l‰l×(Ñ(¨Ó.ˆØ×Ñ Ô)Ø×Ñ × 1Ñ 1°3×3DÑ3DÕEr'   )r]  N)r7   r8   r9   r:   r;   rQ   r*  r©  r¬  r±  r<   r6   r'   r$   r—  r—  ú  s"   † ñòNò"5ò<ò7õFr'   r—  )9r;   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¢   rC  r  r  r5  r`  rm  Ú BaseFeatureInitiatingInitializerrÄ  rÊ  rØ  rû  r)  r  r  r&  rG  rY  r—  r6   r'   r$   Ú<module>rÃ     s·  ðñõ å .ç (Ý 1Ý 8Ý "Ý &Ý "ß IÓ IÝ OÝ %ð	8Ý,ð
 €CØ€MÝ<Ý7à/€ôK˜×)Ñ)ô Kô@_ˆh×Ñô _ôDX6�X×&Ñ&ô X6ôv	�	ô 	ô@-˜×*Ñ*ô @-ôFI/ × 1Ñ 1ô I/ôX*+˜x×0Ñ0ô *+ôZc H×$5Ñ$5ô côL#˜Y×GÑGô #ô;¨H×,=Ñ,=ô ;ô:?8�h×'Ñ'ô ?8÷D	)ñ 	)ô�y×,Ñ,ô ô.
)˜y×4Ñ4ô 
)ô36�x×(Ñ(ô 36ôl3 ×!2Ñ!2ô 3ôDb<˜×*Ñ*ô b<ôJ8FÐ"Cõ 8FøðE' ó 0Ø
€CØ/ƒMð0ús   ÁG Ç
GÇG