ó
    Ö›‘h¶ù  ã                   ó"  • % S r SSKrSSKrSSKrSSKJr  SSKJrJrJ	r	J
r
Jr  SSKJrJr  SSKrSSKrSSKrSSK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Jr  SSKJrJrJrJrJ r J!r!J"r"  SSK#J$r$J%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/J0r0  \	\1   \2S'    SSK3J4r4J5r5  Sr6\Rp                  Rs                  \!5      (       d  Sr6S r:\" \'Rv                  5       " S S5      5       r< " S S5      r= " S S5      r>Sr? " S S5      r@ " S  S!\@\'R‚                  5      rB " S" S#\@\'R†                  5      rD " S$ S%5      rE " S& S'\+RŒ                  5      rG " S( S)\0\E5      rH " S* S+5      rI " S, S-5      rJ " S. S/\J\'R–                  5      rL " S0 S1\J\'Rš                  5      rN " S2 S35      rO " S4 S5\O\05      rP " S6 S7\O\05      rQ\" \R¤                  R,                  5       " S8 S95      5       rS\" \'R¨                  5       " S: S;5      5       rU " S< S=5      rV " S> S?\0\E5      rW " S@ SA\05      rX " SB SC\D5      rY " SD SE\0\E5      rZ " SF SG\05      r[ " SH SI\0\E5      r\ " SJ SK\ Rº                  5      r^ " SL SM\05      r_ " SN SO\05      r`\" \5       " SP SQ5      5       ra " SR SS5      rb " ST SU\05      rc " SV SW\05      rd " SX SY\05      re " SZ S[\05      rf " S\ S]\05      rg " S^ S_\05      rh " S` Sa\%5      ri " Sb Sc\05      rjg! \7 a    Sr6 GNbf = f)dz*
Test cases for twisted.mail.smtp module.
é    N)ÚBytesIO)ÚAnyÚListÚOptionalÚTupleÚType)ÚdirectlyProvidesÚimplementer)Úcred)ÚAllowAnonymousAccessÚICredentialsChecker)Ú
IAnonymous)ÚUnauthorizedLogin)ÚIRealmÚPortal)ÚaddressÚdeferÚerrorÚ
interfacesÚprotocolÚreactorÚtask)ÚMemoryReactorÚStringTransport)Úsmtp)ÚLOGINCredentials)ÚbasicÚloopback)ÚLineLog)ÚTestCaseÚsslSkip)ÚClientTLSContextÚServerTLSContextzOpenSSL not presentzReactor doesn't support SSLc                  ó   • g ©N© )ÚspamÚeggss     Ú_C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/mail/test/test_smtp.pyÚ	spameaterr*   /   s   € Øó    c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚBrokenMessageé3   zÀ
L{BrokenMessage} is an L{IMessage} which raises an unexpected exception
from its C{eomReceived} method.  This is useful for creating a server which
can be used to test client retry behavior.
c                 ó   • g r%   r&   ©ÚselfÚusers     r)   Ú__init__ÚBrokenMessage.__init__;   ó   € Ør+   c                 ó   • g r%   r&   ©r1   Úlines     r)   ÚlineReceivedÚBrokenMessage.lineReceived>   r5   r+   c                 ó   • [        S5      e)Nz"Some problem, delivery is failing.)ÚRuntimeError©r1   s    r)   ÚeomReceivedÚBrokenMessage.eomReceivedA   s   € ÜÐ?Ó@Ð@r+   c                 ó   • g r%   r&   r=   s    r)   ÚconnectionLostÚBrokenMessage.connectionLostD   r5   r+   r&   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r3   r9   r>   rA   Ú__static_attributes__r&   r+   r)   r-   r-   3   s   † ñòòòAõr+   r-   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚDummyMessageéH   zÃ
L{BrokenMessage} is an L{IMessage} which saves the message delivered to it
to its domain object.

@ivar domain: A L{DummyDomain} which will be used to store the message once
    it is received.
c                 ó*   • Xl         X l        / U l        g r%   )Údomainr2   Úbuffer)r1   rM   r2   s      r)   r3   ÚDummyMessage.__init__Q   s   € ØŒØŒ	Øˆ�r+   c                 ót   • [         R                  " SU5      (       d  U R                  R                  U5        g g )Ns/   Received: From yyy.com \(\[.*\]\) by localhost;)ÚreÚmatchrN   Úappendr7   s     r)   r9   ÚDummyMessage.lineReceivedV   s,   € ä�xŠxÐKÈT×RÑRØ�K‰K×Ñ˜tÕ$ð Sr+   c                 ó  • SR                  U R                  5      S-   nU R                  R                  U R                  R
                  R                     R                  U5        [        R                  " 5       nUR                  S5        U$ )Nó   
ó   saved)ÚjoinrN   rM   Úmessagesr2   ÚdestÚlocalrS   r   ÚDeferredÚcallback)r1   ÚmessageÚdeferreds      r)   r>   ÚDummyMessage.eomReceived[   sc   € Ø—*‘*˜TŸ[™[Ó)¨EÑ1ˆØ�‰×Ñ˜TŸY™YŸ^™^×1Ñ1Ñ2×9Ñ9¸'ÔBÜ—>’>Ó#ˆØ×Ñ˜(Ô#Øˆr+   )rN   rM   r2   N)	rC   rD   rE   rF   rG   r3   r9   r>   rH   r&   r+   r)   rJ   rJ   H   s   † ñòò
%õ
r+   rJ   c                   ó$   • \ rS rSrSrS rS rSrg)ÚDummyDomainéc   zZ
L{DummyDomain} is an L{IDomain} which keeps track of messages delivered to
it in memory.
c                 óB   • 0 U l         U H  n/ U R                   U'   M     g r%   ©rY   )r1   ÚnamesÚnames      r)   r3   ÚDummyDomain.__init__i   s!   € ØˆŒÛˆDØ"$ˆD�M‰M˜$Óò r+   c                 óØ   ^ ^• TR                   R                  T R                  ;   a  [        R                  " U U4S j5      $ [        R
                  " [        R                  " T5      5      $ )Nc                  ó   >• [        T T5      $ r%   ©rJ   r0   s   €€r)   Ú<lambda>Ú$DummyDomain.exists.<locals>.<lambda>p   s   ø€ ¬°d¸DÔ)Ar+   )rZ   r[   rY   r   ÚsucceedÚfailr   ÚSMTPBadRcptr0   s   ``r)   ÚexistsÚDummyDomain.existsn   sA   ù€ Ø�9‰9�?‰?˜dŸm™mÓ+Ü—=’=Õ!AÓBÐBÜ�zŠzœ$×*Ò*¨4Ó0Ó1Ð1r+   re   N)rC   rD   rE   rF   rG   r3   rq   rH   r&   r+   r)   rb   rb   c   s   † ñò
%õ
2r+   rb   s   Subject: hello

Goodbye
c                   ó<   • \ rS rSrS
S jrS rS rS rS rS r	S	r
g)ÚMyClienté{   Nc                 ól   • Uc  SS/[        [        5      4nUS   U l        US   U l        US   U l        g )Nzmoshez@foo.barr   é   é   )r   ÚmailÚ_senderÚ
_recipientÚ_data©r1   ÚmessageInfos     r)   r3   ÚMyClient.__init__|   s=   € ØÑØ+Ð.>Ð-?ÄÌÃÐOˆKØ" 1‘~ˆŒØ% a™.ˆŒØ  ‘^ˆ�
r+   c                 ó   • U R                   $ r%   )rz   r=   s    r)   ÚgetMailFromÚMyClient.getMailFromƒ   s   € Ø�|‰|Ðr+   c                 ó   • U R                   $ r%   )r{   r=   s    r)   Ú	getMailToÚMyClient.getMailTo†   s   € Ø�‰Ðr+   c                 ó   • U R                   $ r%   )r|   r=   s    r)   ÚgetMailDataÚMyClient.getMailData‰   s   € Ø�z‰zÐr+   c                 ó   • Xl         g r%   )Ú_error)r1   Úexcs     r)   Ú	sendErrorÚMyClient.sendErrorŒ   s   € Ø�r+   c                 ó.   • S U l         S U l        S U l        g r%   )rz   r{   r|   )r1   ÚcodeÚrespÚnumOkÚ	addressesÚlogs         r)   ÚsentMailÚMyClient.sentMail�   s   € àˆŒØˆŒØˆ�
r+   )r|   rŠ   r{   rz   r%   )rC   rD   rE   rF   r3   r�   r„   r‡   rŒ   r”   rH   r&   r+   r)   rt   rt   {   s    † ô$òòòòõr+   rt   c                   ó   • \ rS rSrSS jrSrg)ÚMySMTPClienté–   Nc                 ón   • [         R                  R                  U S5        [        R                  X5        g ©Ns   foo.baz)r   Ú
SMTPClientr3   rt   r}   s     r)   r3   ÚMySMTPClient.__init__—   s$   € Ü�‰× Ñ   zÔ2Ü×Ñ˜$Õ,r+   r&   r%   ©rC   rD   rE   rF   r3   rH   r&   r+   r)   r—   r—   –   s   † ÷-r+   r—   c                   ó   • \ rS rSrSS jrSrg)ÚMyESMTPClientéœ   Nc                 óp   • [         R                  R                  XUS5        [        R                  U 5        g rš   )r   ÚESMTPClientr3   rt   )r1   ÚsecretÚcontextFactorys      r)   r3   ÚMyESMTPClient.__init__�   s(   € Ü×Ñ×!Ñ! $°À
ÔKÜ×Ñ˜$Õr+   r&   )r+   Nr�   r&   r+   r)   rŸ   rŸ   œ   s   † ÷ r+   rŸ   c                   ó   • \ rS rSrS rSrg)ÚLoopbackMixiné¢   c                 ó.   • [         R                  " X5      $ r%   )r   ÚloopbackTCP)r1   ÚserverÚclients      r)   r   ÚLoopbackMixin.loopback£   s   € Ü×#Ò# FÓ3Ð3r+   r&   N)rC   rD   rE   rF   r   rH   r&   r+   r)   r§   r§   ¢   s   † õ4r+   r§   c                   ó(   • \ rS rSr/ SQrS rS rSrg)ÚFakeSMTPServeré§   )ó	   220 hellos   250 nice to meet youó	   250 greatr²   s   354 go on, ladc                 óÀ   • / U l         U R                  S S  U l        U R                  R                  5         U R                  U R                  R	                  5       5        g r%   )rN   Ú
clientDataÚreverseÚsendLineÚpopr=   s    r)   ÚconnectionMadeÚFakeSMTPServer.connectionMade°   sB   € ØˆŒØŸ/™/©!Ð,ˆŒØ�‰×ÑÔ!Ø�‰�d—o‘o×)Ñ)Ó+Õ,r+   c                 ó¬  • U R                   R                  U5        US:X  a6  U R                  R                  S5        U R                  R	                  5         OBUS:X  a  U R                  R                  S5        O US:X  a  U R                  R	                  5         U R
                  (       a*  U R                  U R
                  R                  5       5        g g )Ns   QUITs   221 see ya around
ó   .s   250 gotcha
ó   RSET)rN   rS   Ú	transportÚwriteÚloseConnectionr´   r¶   r·   r7   s     r)   r9   ÚFakeSMTPServer.lineReceived¶   s”   € Ø�‰×Ñ˜4Ô Ø�7‹?Ø�N‰N× Ñ Ð!9Ô:Ø�N‰N×)Ñ)Õ+Ø�T‹\Ø�N‰N× Ñ Ð!2Õ3Ø�W‹_Ø�N‰N×)Ñ)Ô+à�?�?Ø�M‰M˜$Ÿ/™/×-Ñ-Ó/Õ0ð r+   )rN   r´   N)rC   rD   rE   rF   r´   r¸   r9   rH   r&   r+   r)   r¯   r¯   §   s   † ò€Jò-õ1r+   r¯   c                   óD   • \ rS rSrSrS r/ SQrS rS rS r	S r
S	 rS
rg)ÚSMTPClientTestséÄ   z
Tests for L{smtp.SMTPClient}.
c                 óp  • / n[        5       nUR                  Ul        UR                  [	        5       5        UR                  S5        UR                  5         U R                  US   [        R                  5        U R                  US   R                  5        U R                  [        US   5      S5        g)z~
L{smtp.SMTPClient.timeoutConnection} calls the C{sendError} hook with a
fatal L{SMTPTimeoutError} with the current line log.
r±   r   sH   Timeout waiting for SMTP server response
<<< 220 hello
>>> HELO foo.baz
N)r—   rS   rŒ   ÚmakeConnectionr   r9   ÚtimeoutConnectionÚassertIsInstancer   ÚSMTPTimeoutErrorÚ
assertTrueÚisFatalÚassertEqualÚbytes)r1   Úerrorsr¬   s      r)   Útest_timeoutConnectionÚ&SMTPClientTests.test_timeoutConnectionÉ   s–   € ð
 ˆÜ“ˆØ!Ÿ=™=ˆÔØ×ÑœoÓ/Ô0Ø×Ñ˜LÔ)Ø× Ñ Ô"Ø×Ñ˜f Q™i¬×)>Ñ)>Ô?Ø�‰˜˜q™	×)Ñ)Ô*Ø×ÑÜ�&˜‘)Óð"õ	
r+   )	s   HELO foo.bazs   MAIL FROM:<moshez@foo.bar>s   RCPT TO:<moshez@foo.bar>s   DATAs   Subject: hellor+   s   Goodbyer»   r¼   c                 ó‚   ^ ^• [        5       n[        5       mT R                  TU5      nUR                  U U4S j5        U$ )z®
L{smtp.SMTPClient} sends I{HELO}, I{MAIL FROM}, I{RCPT TO}, and I{DATA}
commands based on the return values of its C{getMailFrom},
C{getMailTo}, and C{getMailData} methods.
c                 óP   >• TR                  TR                  TR                  5      $ r%   )rË   rN   Úexpected_output©Úxr1   r«   s    €€r)   rl   Ú/SMTPClientTests.test_messages.<locals>.<lambda>ò   s   ø€  × 0Ñ 0°·±À×@TÑ@TÔ Ur+   )r—   r¯   r   ÚaddCallback)r1   r¬   Údr«   s   `  @r)   Útest_messagesÚSMTPClientTests.test_messagesé   s6   ù€ ô “ˆÜÓ!ˆØ�M‰M˜& &Ó)ˆØ	�‰ÕUÔVØˆr+   c                 ón  • [        SS/[        S5      45      n[        5       nUR                  U5        UR	                  S5        U R                  UR                  S5        U R                  UR                  5        UR                  R                  5         U R                  UR                  [        5        g)zp
If there is an error while producing the message body to the
connection, the C{sendError} callback is invoked.
zalice@example.comzbob@example.comó   fooó(   220 Ok
250 Ok
250 Ok
250 Ok
354 Ok
N)r—   r   r   rÅ   ÚdataReceivedÚassertNotIdenticalÚproducerÚassertFalseÚ	streamingÚstopProducingrÇ   rŠ   Ú	Exception©r1   r¬   r½   s      r)   Útest_transferErrorÚ"SMTPClientTests.test_transferErrorõ   s¡   € ô
 Ø Ð#4Ð"5´w¸v³ÐGó
ˆô $Ó%ˆ	Ø×Ñ˜iÔ(Ø×Ñðô	
ð 	×Ñ 	× 2Ñ 2°DÔ9Ø×Ñ˜×,Ñ,Ô-ð 	×Ñ×(Ñ(Ô*ð 	×Ñ˜fŸm™m¬YÕ7r+   c                 ó&  • [         R                  " S5      n[        5       nUR                  U5        UR	                  [         R
                  " SSSS95        U R                  UR                  5       S5        U R                  UR                  5        g)z˜
If L{smtp.SMTPClient.sendError} is called with an L{SMTPClientError}
which is fatal, it disconnects its transport without writing anything
more to it.
Nru   ÚfooT©rÊ   r+   )
r   r›   r   rÅ   rŒ   ÚSMTPClientErrorrË   ÚvaluerÉ   Údisconnectingrä   s      r)   Útest_sendFatalErrorÚ#SMTPClientTests.test_sendFatalError  sn   € ô —’ Ó&ˆÜ#Ó%ˆ	Ø×Ñ˜iÔ(Ø×Ñœ×-Ò-¨c°5À$ÑGÔHØ×Ñ˜Ÿ™Ó*¨CÔ0Ø�‰˜	×/Ñ/Õ0r+   c                 ó&  • [         R                  " S5      n[        5       nUR                  U5        UR	                  [         R
                  " SSSS95        U R                  UR                  5       S5        U R                  UR                  5        g)zŸ
If L{smtp.SMTPClient.sendError} is called with an L{SMTPClientError}
which is not fatal, it sends C{"QUIT"} and waits for the server to
close the connection.
Nru   rè   Fré   ó   QUIT
)
r   r›   r   rÅ   rŒ   rê   rË   rë   rà   rì   rä   s      r)   Útest_sendNonFatalErrorÚ&SMTPClientTests.test_sendNonFatalError  sp   € ô —’ Ó&ˆÜ#Ó%ˆ	Ø×Ñ˜iÔ(Ø×Ñœ×-Ò-¨c°5À%ÑHÔIØ×Ñ˜Ÿ™Ó*¨KÔ8Ø×Ñ˜×0Ñ0Õ1r+   c                 ó  • [         R                  " S5      n[        5       nUR                  U5        UR	                  [        S5      5        U R                  UR                  5       S5        U R                  UR                  5        g)z£
If L{smtp.SMTPClient.sendError} is called with an exception which is
not an L{SMTPClientError}, it disconnects its transport without
writing anything more to it.
Nrè   r+   )
r   r›   r   rÅ   rŒ   rã   rË   rë   rÉ   rì   rä   s      r)   Útest_sendOtherErrorÚ#SMTPClientTests.test_sendOtherError+  sd   € ô —’ Ó&ˆÜ#Ó%ˆ	Ø×Ñ˜iÔ(Ø×Ñœ 5Ó)Ô*Ø×Ñ˜Ÿ™Ó*¨CÔ0Ø�‰˜	×/Ñ/Õ0r+   r&   N)rC   rD   rE   rF   rG   rÎ   rÒ   rØ   rå   rí   rñ   rô   rH   r&   r+   r)   rÂ   rÂ   Ä   s,   † ñò
ò(
€Oò
ò8ò81ò2õ1r+   rÂ   c                   ó&   • \ rS rSrS rS rS rSrg)ÚDummySMTPMessagei9  c                 ó*   • Xl         X l        / U l        g r%   )r   ÚusersrN   )r1   r   rù   s      r)   r3   ÚDummySMTPMessage.__init__:  s   € Ø ŒØŒ
Øˆ�r+   c                 ó:   • U R                   R                  U5        g r%   )rN   rS   r7   s     r)   r9   ÚDummySMTPMessage.lineReceived?  s   € Ø�‰×Ñ˜4Õ r+   c                 óŠ  • SR                  U R                  5      S-   nU R                  S   R                  S   [	        U R                  S   R
                  5      p2/ nU R                   H  nUR                  [	        U5      5        M     X#XA4U R                  R                  [        U5      '   [        R                  " S5      $ )NrV   r   rW   )rX   rN   rù   ÚhelorÌ   ÚorigrS   r   r^   Útupler   rn   )r1   r^   rþ   ÚoriginÚ
recipientsr2   s         r)   r>   ÚDummySMTPMessage.eomReceivedB  s˜   € Ø—*‘*˜TŸ[™[Ó)¨EÑ1ˆØ—z‘z !‘}×)Ñ)¨!Ñ,¬e°D·J±J¸q±M×4FÑ4FÓ.GˆfØˆ
Ø—J”JˆDØ×Ñœe D›kÖ*ñ à48À*Ð3Vˆ�‰×Ñœe JÓ/Ñ0Ü�}Š}˜XÓ&Ð&r+   )rN   r   rù   N)rC   rD   rE   rF   r3   r9   r>   rH   r&   r+   r)   r÷   r÷   9  s   † òò
!õ'r+   r÷   c                   ó,   • \ rS rSrS rS rS rS rSrg)Ú
DummyProtoiL  c                 óH   • U R                   R                  U 5        0 U l        g r%   )ÚdummyMixinBaser¸   r^   r=   s    r)   r¸   ÚDummyProto.connectionMadeM  s   € Ø×Ñ×*Ñ*¨4Ô0Øˆ�r+   c                  ó   • g r%   r&   )r'   s    r)   ÚreceivedHeaderÚDummyProto.receivedHeaderQ  ó   € Ør+   c                 ó4   ^ ^• [        S 5      T l        U U4S j$ )Nc                  ó   >• [        T T/5      $ r%   )r÷   r0   s   €€r)   rl   Ú'DummyProto.validateTo.<locals>.<lambda>V  s   ø€ Ô'¨¨t¨fÔ5r+   )ÚSimpleDeliveryÚdeliveryr0   s   ``r)   Ú
validateToÚDummyProto.validateToT  s   ù€ Ü& tÓ,ˆŒÝ5Ð5r+   c                 ó   • U$ r%   r&   ©r1   rþ   r  s      r)   ÚvalidateFromÚDummyProto.validateFromX  ó   € Øˆr+   )r  r^   N)	rC   rD   rE   rF   r¸   r
  r  r  rH   r&   r+   r)   r  r  L  s   † òòò6õr+   r  c                   ó,   • \ rS rSr\R
                  rSrg)Ú	DummySMTPi\  r&   N)rC   rD   rE   rF   r   ÚSMTPr  rH   r&   r+   r)   r  r  \  s   † Ø—Y‘YƒNr+   r  c                   ó,   • \ rS rSr\R
                  rSrg)Ú
DummyESMTPi`  r&   N)rC   rD   rE   rF   r   ÚESMTPr  rH   r&   r+   r)   r  r  `  s   † Ø—Z‘ZƒNr+   r  c                   ó°  • \ rS rSr% Sr\\\R                        \	S'   Sr
\\\R                        \	S'   SSS/SS/S4SS	S
S/S	S
S/S4SSS/SS/S4/r/ SQr\\\\\\4      \	S'   \ Hd  u  rrrrrr\R3                  S\-   S-   SSS45        \ H  r\R3                  S\-   S-   SSS45        M      \R3                  SS\S\\\\4445        Mf     S rSrg)ÚAnotherTestCaseid  NÚserverClassÚclientClassó   foo.coms   moshez@foo.coms   moshez@bar.coms(   From: Moshe
To: Moshe

Hi,
how are you?
s   tttt@rrr.coms   uuu@ooos   yyy@eees   Subject: pass

..rrrr..
s   @this,@is,@ignored:foo@bar.coms   @ignore,@this,@too:bar@foo.coms   foo@bar.coms   bar@foo.coms    Subject: apa
To: foo

123
.
456
))r+   s   220.*
$NN)s   HELO foo.com
ó   250.*
$NN)s   RSET
r$  NNÚdatas   MAIL FROM:<s   >
s   250.*
s	   RCPT TO:<s   DATA
s   354.*
c                 ót  • [        5       nU R                  5       n " S S5      nU" 5       Ul        UR                  U5        U R                   GHU  u  pEpgU(       a  UR                  U5        UR                  5       nUR                  5         [        R                  " XX5      (       d  [        XEU5      eUSS S:X  d  Mq  UR                  5        H,  n	U	(       a  U	SS S:X  a  SU	-   n	UR                  U	S	-   5        M.     UR                  S
5        UR                  5       nUR                  5         Uu  p«[        R                  " X¨5      (       d  [        X¨5      eUS    H@  n[        USS 5      nU/US'   U R                  UR                  U4   [        U5      5        MB     GMX     UR!                  S5        g)zí
Exercise a lot of the SMTP client code.  This is a "shotgun" style unit
test.  It does a lot of things and hopes that something will go really
wrong if it is going to go wrong.  This test should be replaced with a
suite of nicer tests.
c                   ó   • \ rS rSrSrSrg)Ú/AnotherTestCase.test_buffer.<locals>.fooFactoryi±  r#  r&   N)rC   rD   rE   rF   rM   rH   r&   r+   r)   Ú
fooFactoryr(  ±  s   † Ø‹Fr+   r)  Né   s   354r   rw   r»   ó   
s   .
rx   )r   r!  ÚfactoryrÅ   r%  rÝ   rë   ÚclearrQ   rR   ÚAssertionErrorÚ
splitlinesÚlistrË   r^   r   Ú
setTimeout)r1   r½   Úar)  ÚsendÚexpectÚmsgÚ	msgexpectr%  r8   r�   ÚmsgdataÚrecipÚexpecteds                 r)   Útest_bufferÚAnotherTestCase.test_buffer§  st  € ô $Ó%ˆ	Ø×ÑÓˆ÷	 ñ 	 ñ “LˆŒ	Ø	×Ñ˜Ô#Ø,0¯I­IÑ(ˆD˜#ÞØ—‘˜tÔ$Ø—?‘?Ó$ˆDØ�O‰OÔÜ—8’8˜F×)Ñ)Ü$ T°4Ó8Ð8Ø�B�Qˆx˜6Õ!ØŸN™NÖ,�DÞ  Q q 	¨TÓ 1Ø# d™{˜Ø—N‘N 4¨'¡>Ö2ñ -ð —‘˜xÔ(ð !—‘Ó(�Ø—‘Ô!Ø )‘�Ü—x’x ×+Ñ+Ü(¨Ó4Ð4Ø$ QœZ�EÜ# G©A JÓ/�HØ#( '�H˜Q‘KØ×$Ñ$ Q§Y¡Y°¨xÑ%8¼%À»/ÖJô (ñ) -6ð0 	
�‰�TÕr+   r&   )rC   rD   rE   rF   r!  r   r   r   ÚProtocolÚ__annotations__r"  r   r›   rY   r%  r   r   rÌ   r   Úhelo_Úfrom_Úto_ÚrealfromÚrealtor5  rS   Úrcptr:  rH   r&   r+   r)   r   r   d  sW  ‡ Ø59€K�˜$˜x×0Ñ0Ñ1Ñ2Ó9Ø37€K�˜$˜tŸ™Ñ/Ñ0Ó7ð ØØÐØØÐðð	
ð ØØ˜Ð$ØØ˜Ð$ðð	
ð Ø-Ø.Ð/ØØÐðð	
ð7*€HòX1€Dˆ$ˆu�U˜E 3¨Ð+Ñ,Ñ
-ó ó
 5=Ñ0ˆˆu�c˜8 V¨SØ�‰�^ eÑ+¨hÑ6¸ÀdÈDÐQÔRÛˆDØ�K‰K˜¨Ñ,¨xÑ7¸ÀtÈTÐRÖSñ ð 	�‰àØØØ  x°¸Ð=Ð>ð	ö	
ñ 5=õ'r+   r   c                   ó   • \ rS rSr\r\rSrg)ÚAnotherESMTPTestsiÑ  r&   N)	rC   rD   rE   rF   r  r!  rŸ   r"  rH   r&   r+   r)   rE  rE  Ñ  s   † Ø€KØƒKr+   rE  c                   ó   • \ rS rSr\r\rSrg)ÚAnotherSMTPTestsiÖ  r&   N)	rC   rD   rE   rF   r  r!  r—   r"  rH   r&   r+   r)   rG  rG  Ö  s   † Ø€KØƒKr+   rG  c                   ó€   • \ rS rSrSS0r\R                  R                  \R                  R                  4r	S r
S rSrg)ÚDummyCheckeriÛ  ó   testuseró   testpasswordc                 óº   • [         R                  " UR                  U R                  UR                     5      R                  U R                  UR                  5      $ r%   )r   ÚmaybeDeferredÚcheckPasswordrù   ÚusernamerÖ   Ú_cbCheck©r1   Úcredentialss     r)   ÚrequestAvatarIdÚDummyChecker.requestAvatarIdä  sE   € Ü×"Ò"Ø×%Ñ% t§z¡z°+×2FÑ2FÑ'Gó
ç
‰+�d—m‘m [×%9Ñ%9Ó
:ð	;r+   c                 óP   • U(       a  U$ [         R                  R                  5       er%   )r   r   r   )r1   ÚresultrO  s      r)   rP  ÚDummyChecker._cbChecké  s   € ÞØˆOÜ�j‰j×*Ñ*Ó,Ð,r+   r&   N)rC   rD   rE   rF   rù   r   rR  ÚIUsernamePasswordÚIUsernameHashedPasswordÚcredentialInterfacesrS  rP  rH   r&   r+   r)   rI  rI  Û  s>   † à˜/Ð*€Eð 	×Ñ×*Ñ*Ø×Ñ×0Ñ0ðÐò
;õ
-r+   rI  c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	r  iï  zO
L{SimpleDelivery} is a message delivery factory with no interesting
behavior.
c                 ó   • Xl         g r%   ©Ú_messageFactory)r1   ÚmessageFactorys     r)   r3   ÚSimpleDelivery.__init__ö  s   € Ø-Õr+   c                 ó   • g r%   r&   ©r1   rþ   r  r  s       r)   r
  ÚSimpleDelivery.receivedHeaderù  r  r+   c                 ó   • U$ r%   r&   r  s      r)   r  ÚSimpleDelivery.validateFromü  r  r+   c                 ó   ^ ^• U U4S j$ )Nc                  ó&   >• T R                  T5      $ r%   r]  r0   s   €€r)   rl   Ú+SimpleDelivery.validateTo.<locals>.<lambda>   s   ø€ �t×+Ñ+¨DÔ1r+   r&   r0   s   ``r)   r  ÚSimpleDelivery.validateToÿ  s	   ù€ Ý1Ð1r+   r]  N)
rC   rD   rE   rF   rG   r3   r
  r  r  rH   r&   r+   r)   r  r  ï  s   † ñò
.òòõ2r+   r  c                   ó   • \ rS rSrS rSrg)Ú
DummyRealmi  c                 ó<   • [         R                  [        S 5      S 4$ )Nc                  ó   • g r%   r&   r&   r+   r)   rl   Ú*DummyRealm.requestAvatar.<locals>.<lambda>  s   € ÀDr+   )r   ÚIMessageDeliveryr  )r1   ÚavatarIdÚmindr   s       r)   ÚrequestAvatarÚDummyRealm.requestAvatar  s   € Ü×$Ñ$¤n°TÓ&:¹LÐHÐHr+   r&   N)rC   rD   rE   rF   rr  rH   r&   r+   r)   rk  rk    s   † õIr+   rk  c                   ó&   • \ rS rSrS rS rS rSrg)Ú	AuthTestsi  c                 óš  ^ ^• [        5       n[        R                  R                  U5      nUR	                  [        5       5        [        S[        R                  R                  05      mUTl        [        S5      n[        R                  " S5      nUR                  U5        T R                  TU5      nUR                  U U4S j5        U$ )zt
L{ESMTPClient} can authenticate using the I{CRAM-MD5} SASL mechanism.

@see: U{http://tools.ietf.org/html/rfc2195}
s   CRAM-MD5rK  rJ  c                 ó<   >• TR                  TR                  S5      $ )Nrw   )rË   ÚauthenticatedrÓ   s    €€r)   rl   Ú,AuthTests.test_crammd5Auth.<locals>.<lambda>  s   ø€  × 0Ñ 0°×1EÑ1EÀqÔ Ir+   )rk  r   Úportalr   ÚregisterCheckerrI  r  rR  ÚCramMD5CredentialsrŸ   r   ÚCramMD5ClientAuthenticatorÚregisterAuthenticatorr   rÖ   ©r1   ÚrealmÚpr¬   ÚcAuthr×   r«   s   `     @r)   Útest_crammd5AuthÚAuthTests.test_crammd5Auth	  sœ   ù€ ô “ˆÜ�K‰K×Ñ˜uÓ%ˆØ	×Ñœ,›.Ô)ä˜[¬$×*:Ñ*:×*MÑ*MÐNÓOˆØˆŒÜ˜Ó/ˆä×/Ò/°Ó<ˆØ×$Ñ$ UÔ+à�M‰M˜& &Ó)ˆØ	�‰ÕIÔJØˆr+   c                 ór  ^ ^• [        5       n[        R                  R                  U5      nUR	                  [        5       5        [        S[        05      mUTl        [        S5      n[        R                  " S5      nUR                  U5        T R                  TU5      nUR                  U U4S j5        U$ )z–
L{ESMTPClient} can authenticate using the I{LOGIN} SASL mechanism.

@see: U{http://sepp.oetiker.ch/sasl-2.1.19-ds/draft-murchison-sasl-login-00.txt}
ó   LOGINrK  rJ  c                 ó:   >• TR                  TR                  5      $ r%   ©rÉ   rx  rÓ   s    €€r)   rl   Ú*AuthTests.test_loginAuth.<locals>.<lambda>0  ó   ø€  §¡°×0DÑ0DÔ Er+   )rk  r   rz  r   r{  rI  r  r   rŸ   r   ÚLOGINAuthenticatorr~  r   rÖ   r  s   `     @r)   Útest_loginAuthÚAuthTests.test_loginAuth  s‘   ù€ ô “ˆÜ�K‰K×Ñ˜uÓ%ˆØ	×Ñœ,›.Ô)ä˜XÔ'7Ð8Ó9ˆØˆŒÜ˜Ó/ˆä×'Ò'¨Ó4ˆØ×$Ñ$ UÔ+à�M‰M˜& &Ó)ˆØ	�‰ÕEÔFØˆr+   c                 ó†  ^ ^• [        5       n[        R                  R                  U5      nUR	                  [        5       5        [        S[        R                  05      mUTl        [        S5      n[        R                  " S5      nUR                  U5        T R                  TU5      nUR                  U U4S j5        U$ )zæ
When communicating with a server which implements the I{LOGIN} SASL
mechanism using C{"Username:"} as the challenge (rather than C{"User
Name\0"}), L{ESMTPClient} can still authenticate successfully using
the I{LOGIN} mechanism.
r†  rK  rJ  c                 ó:   >• TR                  TR                  5      $ r%   rˆ  rÓ   s    €€r)   rl   Ú8AuthTests.test_loginAgainstWeirdServer.<locals>.<lambda>F  rŠ  r+   )rk  r   rz  r   r{  rI  r  r   r   rŸ   r‹  r~  r   rÖ   r  s   `     @r)   Útest_loginAgainstWeirdServerÚ&AuthTests.test_loginAgainstWeirdServer3  s–   ù€ ô “ˆÜ�K‰K×Ñ˜uÓ%ˆØ	×Ñœ,›.Ô)ä˜X¤t×'<Ñ'<Ð=Ó>ˆØˆŒä˜Ó/ˆÜ×'Ò'¨Ó4ˆØ×$Ñ$ UÔ+à�M‰M˜& &Ó)ˆØ	�‰ÕEÔFØˆr+   r&   N)rC   rD   rE   rF   rƒ  rŒ  r‘  rH   r&   r+   r)   ru  ru    s   † òò*õ*r+   ru  c                   ó8   • \ rS rSrS rS rS rS rS rS r	Sr
g	)
ÚSMTPHelperTestsiJ  c                 ó†   • 0 n[        S5       H0  n[        R                  " S5      nU R                  X1;   5        S X'   M2     g )Niè  Útestcase)Úranger   Ú	messageidrà   )r1   r×   ÚiÚms       r)   ÚtestMessageIDÚSMTPHelperTests.testMessageIDK  s:   € ØˆÜ�t–ˆAÜ—’˜zÓ*ˆAØ×Ñ˜Q™VÔ$ØˆA‹Dò r+   c                 óØ   • SS/SS/[         R                  " S5      S/SS/[         R                  " S5      S//nU H+  u  p#U R                  [         R                  " U5      U5        M-     g )Ns   user@host.names   <user@host.name>s   "User Name" <user@host.name>s   someguy@someplaces   <someguy@someplace>r+   s   <>)r   ÚAddressrË   Ú	quoteaddr)r1   ÚcasesÚcÚes       r)   ÚtestQuoteAddrÚSMTPHelperTests.testQuoteAddrR  sm   € àÐ 3Ð4Ø,Ð.AÐBÜ�\Š\Ð.Ó/Ð1GÐHØ�%ˆLÜ�\Š\˜#Ó Ð&ð
ˆó ‰DˆAØ×ÑœTŸ^š^¨AÓ.°Ö2ò r+   c                 ól   • [         R                  " SSS S 5      nU R                  [        U5      S5        g )Ns	   user@hosts   helo.host.namez	user@host)r   ÚUserrË   Ústr)r1   Úus     r)   ÚtestUserÚSMTPHelperTests.testUser^  s+   € Ü�IŠI�lÐ$5°t¸TÓBˆØ×Ñœ˜Q› Õ-r+   c                 ój  • / SQnU H©  u  p#U R                  [        R                  " U5      U[        U5      45        U R                  UR	                  S5      U5        U R                  [        R
                  " U5      U[        U5      45        U R                  UR                  S5      U5        M«     g )N))úHello worlds   Hello+20world)zHello+worlds   Hello+2Bworld)z s   +00+01+02+03+04+05)ze=mc2@example.coms   e+3Dmc2@example.comÚxtext)rË   r   Úxtext_encodeÚlenÚencodeÚxtext_decodeÚdecode)r1   r   Úcaser9  s       r)   ÚtestXtextEncodingÚ!SMTPHelperTests.testXtextEncodingb  s‘   € ò
ˆó $‰NˆDØ×ÑœT×.Ò.¨tÓ4°xÄÀTÃÐ6KÔLØ×Ñ˜TŸ[™[¨Ó1°8Ô<Ø×ÑœT×.Ò.¨xÓ8¸4ÄÀXÃÐ:OÔPØ×Ñ˜XŸ_™_¨WÓ5°tÖ<ò	 $r+   c                 óì   • SnU R                  [        R                  " US5      UR                  S5      [	        U5      45        U R                  UR                  SS5      UR                  S5      5        g)zŒ
Specifying an error policy to C{unicode.encode} with the
I{xtext} codec should produce the same result as not
specifying the error policy.
r¬  Ústrictr­  N)rË   r   r®  r°  r¯  )r1   Útexts     r)   Útest_encodeWithErrorsÚ%SMTPHelperTests.test_encodeWithErrorsp  sa   € ð ˆØ×ÑÜ×Ò˜d HÓ-°·±¸GÓ0DÄcÈ$ÃiÐ/Pô	
ð 	×Ñ˜Ÿ™ W¨hÓ7¸¿¹ÀWÓ9MÕNr+   c                 óì   • SnU R                  [        R                  " US5      UR                  S5      [	        U5      45        U R                  UR                  SS5      UR                  S5      5        g)z?
Similar to L{test_encodeWithErrors}, but for C{bytes.decode}.
s   Hello worldr·  r­  N)rË   r   r±  r²  r¯  )r1   rÌ   s     r)   Útest_decodeWithErrorsÚ%SMTPHelperTests.test_decodeWithErrors|  sa   € ð ˆØ×ÑÜ×Ò˜e XÓ.°·±¸gÓ1FÌÈEË
Ð0Sô	
ð 	×Ñ˜Ÿ™ g¨xÓ8¸%¿,¹,ÀwÓ:OÕPr+   r&   N)rC   rD   rE   rF   r›  r£  r©  r´  r¹  r¼  rH   r&   r+   r)   r”  r”  J  s"   † òò
3ò.ò=ò
OõQr+   r”  c                   ó   • \ rS rSrSrS rSrg)ÚNoticeTLSClienti‡  Fc                 ó>   • [         R                  XU5        SU l        g ©NT)rŸ   ÚesmtpState_starttlsÚtls)r1   r�   r�   s      r)   rÂ  Ú#NoticeTLSClient.esmtpState_starttlsŠ  s   € Ü×)Ñ)¨$°dÔ;Øˆ�r+   )rÃ  N)rC   rD   rE   rF   rÃ  rÂ  rH   r&   r+   r)   r¿  r¿  ‡  s   † Ø
€Cõr+   r¿  c                   ó   • \ rS rSr\rS rSrg)ÚTLSTestsi�  c                 ó¦   ^ ^^• [        5       n[        5       n[        US9m[        US9mUU U4S jnT R	                  TT5      R                  U5      $ )N)r¤   c                 óv   >• TR                  TR                  S5        TR                  TR                  S5        g rÁ  )rË   rÃ  Ú
startedTLS)Úignoredr¬   r1   r«   s    €€€r)   ÚcheckÚTLSTests.testTLS.<locals>.check™  s-   ø€ Ø×Ñ˜VŸZ™Z¨Ô.Ø×Ñ˜V×.Ñ.°Õ5r+   )r"   r#   r¿  r  r   rÖ   )r1   Ú	clientCTXÚ	serverCTXrË  r¬   r«   s   `   @@r)   ÚtestTLSÚTLSTests.testTLS’  sJ   ú€ Ü$Ó&ˆ	Ü$Ó&ˆ	ä °	Ñ:ˆÜ¨9Ñ5ˆ÷	6ð �}‰}˜V VÓ,×8Ñ8¸Ó?Ð?r+   r&   N)rC   rD   rE   rF   r!   ÚskiprÏ  rH   r&   r+   r)   rÆ  rÆ  �  s   † Ø€Dõ@r+   rÆ  c                   ó   • \ rS rSrS rSrg)ÚEmptyLineTestsi   c                 óŠ  • [         R                  " 5       n[        5       nUR                  U5        UR	                  S5        UR                  S5        UR                  5       R                  5       nU R                  [        U5      S5        U R                  US   R                  S5      5        U R                  US   S5        g)zx
If L{smtp.SMTP} receives an empty line, it responds with a 500 error
response code and a message about a syntax error.
r+   Nrx   r   s   220rw   s   500 Error: bad syntax)r   r  r   rÅ   r9   r1  rë   r/  rË   r¯  rÉ   Ú
startswith)r1   Úprotor½   Úouts       r)   Útest_emptyLineSyntaxErrorÚ(EmptyLineTests.test_emptyLineSyntaxError¡  sš   € ô
 —	’	“ˆÜ#Ó%ˆ	Ø×Ñ˜YÔ'Ø×Ñ˜3ÔØ×Ñ˜Ôà�o‰oÓ×*Ñ*Ó,ˆØ×Ñœ˜S› 1Ô%Ø�‰˜˜A™×)Ñ)¨&Ó1Ô2Ø×Ñ˜˜Q™Ð!9Õ:r+   r&   N)rC   rD   rE   rF   rØ  rH   r&   r+   r)   rÓ  rÓ     s   † õ;r+   rÓ  c                   ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚTimeoutTestsi²  z=
Check that SMTP client factories correctly use the timeout.
c                 ó–  ^ ^• [         R                  " 5       mUR                  [        R                  " SSS5      5      nTR
                  Ul        [        5       nUR                  U5        X4l        UU 4S jnT R                  U[        R                  5      R                  U5      nTR                  S5        TR                  S5        U$ )zB
Connect the clientFactory, and check the timeout on the request.
ÚTCPúexample.neté   c                 óF   >• TR                  TR                  5       S5        g )Nç      à?)rË   Úseconds)ÚignÚclockr1   s    €€r)   rË  Ú(TimeoutTests._timeoutTest.<locals>.checkÄ  s   ø€ Ø×Ñ˜UŸ]™]›_¨cÕ2r+   gš™™™™™¹?gš™™™™™Ù?)r   ÚClockÚbuildProtocolr   ÚIPv4AddressÚ	callLaterr   rÅ   r   ÚassertFailurer   rÈ   rÖ   Úadvance)r1   ÚonDoneÚclientFactoryr¬   ÚtrË  r×   rä  s   `      @r)   Ú_timeoutTestÚTimeoutTests._timeoutTest·  s¢   ù€ ô —
’
“ˆØ×,Ñ,Ü×Ò  }°bÓ9ó
ˆð !Ÿ?™?ˆÔÜÓˆØ×Ñ˜aÔ ØŒ
ö	3ð ×Ñ˜v¤t×'<Ñ'<Ó=×IÑIÈ%ÓPˆà�‰�cÔà�‰�cÔØˆr+   c           	      ó’   • [         R                  " 5       n[        R                  " SS[	        S5      USSS9nU R                  X5      $ )zy
Test timeout for L{smtp.SMTPSenderFactory}: the response L{Deferred}
should be errback with a L{smtp.SMTPTimeoutError}.
úsource@addresss   recipient@addressó   Message bodyr   rá  ©ÚretriesÚtimeout©r   r\   r   ÚSMTPSenderFactoryr   rï  ©r1   rì  rí  s      r)   Útest_SMTPClientRecipientBytesÚ*TimeoutTests.test_SMTPClientRecipientBytesÎ  sJ   € ô
 —’Ó!ˆÜ×.Ò.ØØ Ü�OÓ$ØØØñ
ˆð × Ñ  Ó7Ð7r+   c           	      ó’   • [         R                  " 5       n[        R                  " SS[	        S5      USSS9nU R                  X5      $ )z
Use a L{unicode} recipient.
rò  úrecipient@addressró  r   rá  rô  r÷  rù  s      r)   Útest_SMTPClientRecipientUnicodeÚ,TimeoutTests.test_SMTPClientRecipientUnicodeÞ  sJ   € ô —’Ó!ˆÜ×.Ò.ØØÜ�OÓ$ØØØñ
ˆð × Ñ  Ó7Ð7r+   c           	      ó’   • [         R                  " 5       n[        R                  " SS[	        S5      USSS9nU R                  X5      $ )z
Use a L{list} of recipients.
rò  )zrecipient1@addresss   recipient2@addressró  r   rá  rô  r÷  rù  s      r)   Útest_SMTPClientRecipientListÚ)TimeoutTests.test_SMTPClientRecipientListí  sJ   € ô —’Ó!ˆÜ×.Ò.ØØ9Ü�OÓ$ØØØñ
ˆð × Ñ  Ó7Ð7r+   c                 ó–   • [         R                  " 5       n[        R                  " SSSS[	        S5      USSS9nU R                  X5      $ )	zz
Test timeout for L{smtp.ESMTPSenderFactory}: the response L{Deferred}
should be errback with a L{smtp.SMTPTimeoutError}.
rO  Úpasswordrò  rý  ró  r   rá  rô  )r   r\   r   ÚESMTPSenderFactoryr   rï  rù  s      r)   Útest_ESMTPClientÚTimeoutTests.test_ESMTPClientü  sP   € ô
 —’Ó!ˆÜ×/Ò/ØØØØÜ�OÓ$ØØØñ	
ˆð × Ñ  Ó7Ð7r+   c           	      ó¢  •  " S S5      n/ n[         R                  " 5       nUR                  UR                  5        [        R
                  " SSU" S5      USSS9nS	Ul        [        R                  " 5       nUR                  [        R                  " S
SS5      5      nUR                  Ul        [        5       nUR                  U5        UR                  S5        U R!                  UR"                  S5        U R%                  UR&                  5        UR)                  S5        U R+                  U/ 5        UR"                  R-                  5         UR)                  S5        U R+                  U/ 5        UR"                  R-                  5         UR                  S5        U R+                  U/ 5        U R+                  UR/                  5       S5        g)z‚
The timeout is not allowed to expire after the server has accepted a
DATA command and the client is actively sending data to it.
c                   ó(   • \ rS rSrSrS rSS jrSrg)Ú<TimeoutTests.test_resetTimeoutWhileSending.<locals>.SlowFilei  zp
A file-like which returns one byte from each read call until the
specified number of bytes have been returned.
c                 ó   • Xl         g r%   ©Ú_size)r1   Úsizes     r)   r3   ÚETimeoutTests.test_resetTimeoutWhileSending.<locals>.SlowFile.__init__  s   € Ø!•
r+   Nc                 óR   • U R                   (       a  U =R                   S-  sl         gg)Nrw   ó   xr+   r  )r1   Úmaxs     r)   ÚreadÚATimeoutTests.test_resetTimeoutWhileSending.<locals>.SlowFile.read  s   € Ø—:—:Ø—J’J !‘O•JØØr+   r  r%   )rC   rD   rE   rF   rG   r3   r  rH   r&   r+   r)   ÚSlowFiler
    s   † ñò
"÷r+   r  rò  rý  rw   r   r*  rô  ó   example.orgrÝ  rÞ  rß  rÜ   Nrx   s   250 Ok
s]   HELO example.org
MAIL FROM:<source@address>
RCPT TO:<recipient@address>
DATA
x
.
RSET
)r   r\   Ú
addErrbackrS   r   rø  rM   r   ræ  rç  r   rè  ré  r   rÅ   rÝ   rÞ   rß   rà   rá   rë  rË   ÚresumeProducingrë   )r1   r  Úfailedrì  rí  rä  r¬   r½   s           r)   Útest_resetTimeoutWhileSendingÚ*TimeoutTests.test_resetTimeoutWhileSending  s’  € ÷	ñ 	ð ˆÜ—’Ó!ˆØ×Ñ˜&Ÿ-™-Ô(Ü×.Ò.ØØÙ�Q‹KØØØñ
ˆð  .ˆÔÜ—
’
“ˆØ×,Ñ,Ü×Ò  }°bÓ9ó
ˆð !Ÿ?™?ˆÔÜ#Ó%ˆ	Ø×Ñ˜iÔ(à×Ñðô	
ð 	×Ñ 	× 2Ñ 2°DÔ9Ø×Ñ˜×,Ñ,Ô-ð 	�‰�aÔð 	×Ñ˜ Ô$ð 	×Ñ×*Ñ*Ô,Ø�‰�aÔØ×Ñ˜ Ô$ð 	×Ñ×*Ñ*Ô,Ø×Ñ˜MÔ*Ø×Ñ˜ Ô$ð 	×ÑØ�O‰OÓðõ	
r+   r&   N)rC   rD   rE   rF   rG   rï  rú  rþ  r  r  r  rH   r&   r+   r)   rÛ  rÛ  ²  s&   † ñòò.8ò 8ò8ò8õ$W
r+   rÛ  c                   ó$   • \ rS rSrSrS rS rSrg)Ú(MultipleDeliveryFactorySMTPServerFactoryih  zû
L{MultipleDeliveryFactorySMTPServerFactory} creates SMTP server protocol
instances with message delivery factory objects supplied to it.  Each
factory is used for one connection and then discarded.  Factories are used
in the order they are supplied.
c                 ó   • Xl         g r%   ©Ú_messageFactories)r1   ÚmessageFactoriess     r)   r3   Ú1MultipleDeliveryFactorySMTPServerFactory.__init__p  s   € Ø!1Õr+   c                 ó–   • [         R                  R                  X5      n[        U R                  R                  S5      5      Ul        U$ )Nr   )r   ÚServerFactoryrç  r  r   r·   r  )r1   Úaddrr�  s      r)   rç  Ú6MultipleDeliveryFactorySMTPServerFactory.buildProtocols  s:   € Ü×"Ñ"×0Ñ0°Ó<ˆÜ# D×$:Ñ$:×$>Ñ$>¸qÓ$AÓBˆŒ
Øˆr+   r  N)rC   rD   rE   rF   rG   r3   rç  rH   r&   r+   r)   r  r  h  s   † ñò2õr+   r  c                   ó$   • \ rS rSrSrS rS rSrg)ÚSMTPSenderFactoryTestsiy  z&
Tests for L{smtp.SMTPSenderFactory}.
c                 óT  • [        5       n[        R                  " 5       n[        R                  " SS[        S5      U5      nUR                  " SSU5      nUR                  S5        UR                  U[        R                  " S5      5        U R                  UR                  S5        g)z\
L{smtp.SMTPSenderFactory} removes the current protocol when the client
connection is lost.
rò  rý  ó   messageÚ	localhostrß  NúBye.)r   r   r\   r   rø  r   Ú
connectTCPrç  ÚclientConnectionLostr   ÚConnectionDonerË   ÚcurrentProtocol©r1   r   ÚsentDeferredrí  Ú	connectors        r)   Ú2test_removeCurrentProtocolWhenClientConnectionLostÚISMTPSenderFactoryTests.test_removeCurrentProtocolWhenClientConnectionLost~  s‹   € ô
  “/ˆÜ—~’~Ó'ˆÜ×.Ò.ØÐ1´7¸:Ó3FÈó
ˆð ×&Ò& {°B¸ÓFˆ	Ø×#Ñ# DÔ)Ø×*Ñ*¨9´e×6JÒ6JÈ6Ó6RÔSØ×Ñ˜×6Ñ6¸Õ=r+   c                 óT  • [        5       n[        R                  " 5       n[        R                  " SS[        S5      U5      nUR                  " SSU5      nUR                  S5        UR                  U[        R                  " S5      5        U R                  UR                  S5        g)z^
L{smtp.SMTPSenderFactory} removes the current protocol when the client
connection is failed.
rò  rý  r*  r+  rß  Nr,  )r   r   r\   r   rø  r   r-  rç  ÚclientConnectionFailedr   r/  rË   r0  r1  s        r)   Ú4test_removeCurrentProtocolWhenClientConnectionFailedÚKSMTPSenderFactoryTests.test_removeCurrentProtocolWhenClientConnectionFailed�  s‹   € ô
  “/ˆÜ—~’~Ó'ˆÜ×.Ò.ØÐ1´7¸:Ó3FÈó
ˆð ×&Ò& {°B¸ÓFˆ	Ø×#Ñ# DÔ)Ø×,Ñ,¨Y¼×8LÒ8LÈVÓ8TÔUØ×Ñ˜×6Ñ6¸Õ=r+   r&   N)rC   rD   rE   rF   rG   r4  r8  rH   r&   r+   r)   r(  r(  y  s   † ñò>õ>r+   r(  c                   ó   • \ rS rSrSrS rSrg)ÚSMTPSenderFactoryRetryTestsi�  z<
Tests for the retry behavior of L{smtp.SMTPSenderFactory}.
c                 ób  ^ ^	^
^• SmSm
[        T/5      m	 " U 4S jS[        R                  5      n[        [        U	4S j/5      nXl        [        R                  " SUSS9nUR                  5       nT R                  UR                  5        [        R                  " 5       n[        R                  " S	TS
-   [        T
5      U5      nSUl        [        R                   " UR"                  UR$                  U5      nT R                  UR&                  5        U	U
UU 4S jnUR)                  U5        U$ )z¯
If the protocol created by L{SMTPSenderFactory} loses its connection
before receiving confirmation of message delivery, it reconnects and
tries to deliver the message again.
s   alices   some message textc                   ó&   >• \ rS rSrSrU 4S jrSrg)ÚHSMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.CleanSMTPi¬  z^
An SMTP subclass which ensures that its transport will be
disconnected before the test ends.
c                 óz   >• TR                  UR                  5        [        R                  R	                  X5        g r%   )Ú
addCleanupr¿   r   r  rÅ   )Ú	innerSelfr½   r1   s     €r)   rÅ   ÚWSMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.CleanSMTP.makeConnection²  s'   ø€ Ø—‘ 	× 8Ñ 8Ô9Ü—	‘	×(Ñ(¨Õ>r+   r&   N)rC   rD   rE   rF   rG   rÅ   rH   r=   s   €r)   Ú	CleanSMTPr>  ¬  s   ø† ñ÷
?ð ?r+   rC  c                 ó   >• [        TU 5      $ r%   rk   )r2   rM   s    €r)   rl   ÚGSMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.<lambda>º  s   ø€ ¬°f¸dÔ)Cr+   r   ú	127.0.0.1)Ú	interfaces   bob@example.orgs   @example.comr  c                 ó¬   >• TR                  TR                  TST-   S-   /05        TR                  [        TR                  [        5      5      S5        g)zp
Verify that the message was successfully delivered and flush the
error which caused the first attempt to fail.
rV   rw   N)rË   rY   r¯  ÚflushLoggedErrorsr<   )rÊ  rM   r^   Ú	recipientr1   s    €€€€r)   ÚcbSentÚESMTPSenderFactoryRetryTests.test_retryAfterDisconnect.<locals>.cbSentÐ  sJ   ø€ ð
 ×Ñ˜VŸ_™_¨y¸5À7¹?ÈUÑ;RÐ:SÐ.TÔUà×ÑœS ×!7Ñ!7¼Ó!EÓFÈÕJr+   )rb   r   r  r  r-   r   r   Ú	listenTCPÚgetHostr@  ÚstopListeningr   r\   rø  r   rM   r-  ÚhostÚportÚ
disconnectrÖ   )r1   rC  ÚserverFactoryÚ
serverPortÚ
serverHostr2  rí  ÚclientConnectorrK  rM   r^   rJ  s   `        @@@r)   Útest_retryAfterDisconnectÚ5SMTPSenderFactoryRetryTests.test_retryAfterDisconnect¢  s  û€ ð ˆ	Ø&ˆÜ˜i˜[Ó)ˆ÷	?œŸ	™	ô 	?ô AÜÔCÐDó
ˆð "+ÔÜ×&Ò& q¨-À;ÑOˆ
Ø×'Ñ'Ó)ˆ
Ø�‰˜
×0Ñ0Ô1ô —~’~Ó'ˆÜ×.Ò.ØØ˜Ñ'Ü�GÓØó	
ˆð  .ˆÔÜ!×,Ò,Ø�O‰O˜ZŸ_™_¨mó
ˆð 	�‰˜×2Ñ2Ô3÷	Kð 	Kð 	× Ñ  Ô(ØÐr+   r&   N)rC   rD   rE   rF   rG   rW  rH   r&   r+   r)   r;  r;  �  s   † ñõ8r+   r;  c                   ó$   • \ rS rSrSrS rS rSrg)ÚSingletonRealmiÝ  zŠ
Trivial realm implementation which is constructed with an interface and an
avatar and returns that avatar when asked for that interface.
c                 ó   • Xl         X l        g r%   ©rG  Úavatar)r1   rG  r]  s      r)   r3   ÚSingletonRealm.__init__ä  s   € Ø"ŒØ�r+   c                 óT   • U H"  nX@R                   L d  M  X@R                  S 4s  $    g )Nc                  ó   • g r%   r&   r&   r+   r)   rl   Ú.SingletonRealm.requestAvatar.<locals>.<lambda>ë  s   € °4r+   r\  )r1   rp  rq  r   Úifaces        r)   rr  ÚSingletonRealm.requestAvatarè  s%   € ÛˆEØŸ™Ô&ØŸk™k©<Ð7Ò7ò  r+   )r]  rG  N)rC   rD   rE   rF   rG   r3   rr  rH   r&   r+   r)   rZ  rZ  Ý  s   † ñò
õ8r+   rZ  c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚNotImplementedDeliveryiî  z¹
Non-implementation of L{smtp.IMessageDelivery} which only has methods which
raise L{NotImplementedError}.  Subclassed by various tests to provide the
particular behavior being tested.
c                 ó   • [        S5      e©Nz3This oughtn't be called in the course of this test.©ÚNotImplementedErrorr  s      r)   r  Ú#NotImplementedDelivery.validateFromõ  ó   € Ü!Ð"WÓXÐXr+   c                 ó   • [        S5      erg  rh  r0   s     r)   r  Ú!NotImplementedDelivery.validateToø  rk  r+   c                 ó   • [        S5      erg  rh  rb  s       r)   r
  Ú%NotImplementedDelivery.receivedHeaderû  rk  r+   r&   N)	rC   rD   rE   rF   rG   r  r  r
  rH   r&   r+   r)   re  re  î  s   † ñòYòYõYr+   re  c                   ó~   • \ rS rSrSr\R                  4S jrS rS r	S r
S rS rS	 r\" \5      S
 5       rS rSrg)ÚSMTPServerTestsiÿ  zU
Test various behaviors of L{twisted.mail.smtp.SMTP} and
L{twisted.mail.smtp.ESMTP}.
c                 óÞ   • U" 5       nSUl         [        5       nUR                  U5        UR                  [        R
                  " 5       5        U R                  SUR                  5       5        g)zJ
Test that the specified hostname shows up in the SMTP server's
greeting.
s   example.comN)rP  r   rÅ   rA   r   r/  ÚassertInrë   )r1   r!  Úsrî  s       r)   ÚtestSMTPGreetingHostÚ$SMTPServerTests.testSMTPGreetingHost  sS   € ñ
 ‹MˆØˆŒÜÓˆØ	×Ñ˜ÔØ	×Ñœ×-Ò-Ó/Ô0Ø�‰�n a§g¡g£iÕ0r+   c                 óì   • [         R                  " 5       n[        5       nUR                  U5        UR	                  [
        R                  " 5       5        U R                  SUR                  5       5        g)zÍ
Test that the string "ESMTP" does not appear in the SMTP server's
greeting since that string strongly suggests the presence of support
for various SMTP extensions which are not supported by L{smtp.SMTP}.
ó   ESMTPN)	r   r  r   rÅ   rA   r   r/  ÚassertNotInrë   ©r1   rt  rî  s      r)   ÚtestSMTPGreetingNotExtendedÚ+SMTPServerTests.testSMTPGreetingNotExtended  sR   € ô �IŠI‹KˆÜÓˆØ	×Ñ˜ÔØ	×Ñœ×-Ò-Ó/Ô0Ø×Ñ˜ 1§7¡7£9Õ-r+   c                 óB   • U R                  [        R                  5        g)zC
Similar to testSMTPGreetingHost, but for the L{smtp.ESMTP} class.
N)ru  r   r  r=   s    r)   ÚtestESMTPGreetingHostÚ%SMTPServerTests.testESMTPGreetingHost  s   € ð 	×!Ñ!¤$§*¡*Õ-r+   c                 óì   • [         R                  " 5       n[        5       nUR                  U5        UR	                  [
        R                  " 5       5        U R                  SUR                  5       5        g)z£
Test that the string "ESMTP" does appear in the ESMTP server's
greeting since L{smtp.ESMTP} does support the SMTP extensions which
that advertises to the client.
rx  N)	r   r  r   rÅ   rA   r   r/  rs  rë   rz  s      r)   ÚtestESMTPGreetingExtendedÚ)SMTPServerTests.testESMTPGreetingExtended#  sP   € ô �JŠJ‹LˆÜÓˆØ	×Ñ˜ÔØ	×Ñœ×-Ò-Ó/Ô0Ø�‰�h §¡£	Õ*r+   c                 ó  • [         R                  " 5       n[        5       nUR                  U5        UR	                  S5        UR                  [        R                  " 5       5        U R                  SUR                  5       5        g)z>
Sending an unimplemented command is responded to with a 500.
s   DOAGOODTHINGs   500 Command not implementedN)
r   r  r   rÅ   r9   rA   r   r/  rs  rë   rz  s      r)   Útest_SMTPUnknownCommandÚ'SMTPServerTests.test_SMTPUnknownCommand/  s]   € ô �IŠI‹KˆÜÓˆØ	×Ñ˜ÔØ	�‰�Ô'Ø	×Ñœ×-Ò-Ó/Ô0Ø�‰Ð4°a·g±g³iÕ@r+   c                 óâ  •  " S S[         5      n[        [        R                  U" 5       5      n[	        U[        5       /5      n[        R                  " 5       nX4l        [        5       nUR                  U5        UR                  S5        UR                  5         UR                  S5        UR                  [        R                  " 5       5        U R                  UR!                  5       S5        g)zl
Test that a C{MAIL FROM} command with an acceptable address is
responded to with the correct success code.
c                   ó   • \ rS rSrSrS rSrg)ÚDSMTPServerTests.test_acceptSenderAddress.<locals>.AcceptanceDeliveryi@  z5
Delivery object which accepts all senders as valid.
c                 ó   • U$ r%   r&   r  s      r)   r  ÚQSMTPServerTests.test_acceptSenderAddress.<locals>.AcceptanceDelivery.validateFromE  s   € Ø�r+   r&   N©rC   rD   rE   rF   rG   r  rH   r&   r+   r)   ÚAcceptanceDeliveryrˆ  @  s   † ñõr+   rŒ  ó   HELO example.com
ó   MAIL FROM:<alice@example.com>
s   250 Sender address accepted
N©re  rZ  r   ro  r   r   r  rz  r   rÅ   rÝ   r-  rA   r   ÚConnectionLostrË   rë   )r1   rŒ  r€  rz  rÖ  Útranss         r)   Útest_acceptSenderAddressÚ(SMTPServerTests.test_acceptSenderAddress:  s½   € ô	Ô!7ô 	ô œt×4Ñ4Ñ6HÓ6JÓKˆÜ˜Ô 4Ó 6Ð7Ó8ˆÜ—	’	“ˆØŒÜÓ!ˆØ×Ñ˜UÔ#ð 	×ÑÐ2Ô3Ø�‰Œð 	×ÑÐ?Ô@ð 	×ÑœU×1Ò1Ó3Ô4ð 	×Ñ˜Ÿ™›Ð(JÕKr+   c                 óâ  •  " S S[         5      n[        [        R                  U" 5       5      n[	        U[        5       /5      n[        R                  " 5       nX4l        [        5       nUR                  U5        UR                  S5        UR                  5         UR                  S5        UR                  [        R                  " 5       5        U R                  UR!                  5       S5        g)z�
Test that a C{MAIL FROM} command with an address rejected by a
L{smtp.IMessageDelivery} instance is responded to with the correct
error code.
c                   ó   • \ rS rSrSrS rSrg)ÚMSMTPServerTests.test_deliveryRejectedSenderAddress.<locals>.RejectionDeliveryid  z7
Delivery object which rejects all senders as invalid.
c                 ó.   • [         R                  " U5      er%   )r   ÚSMTPBadSenderr  s      r)   r  ÚZSMTPServerTests.test_deliveryRejectedSenderAddress.<locals>.RejectionDelivery.validateFromi  s   € Ü×(Ò(¨Ó0Ð0r+   r&   Nr‹  r&   r+   r)   ÚRejectionDeliveryr–  d  s   † ñõ1r+   rš  r�  rŽ  óV   550 Cannot receive from specified address <alice@example.com>: Sender not acceptable
Nr�  )r1   rš  r€  rz  rÖ  r‘  s         r)   Ú"test_deliveryRejectedSenderAddressÚ2SMTPServerTests.test_deliveryRejectedSenderAddress]  sÂ   € ô	1Ô 6ô 	1ô œt×4Ñ4Ñ6GÓ6IÓJˆÜ˜Ô 4Ó 6Ð7Ó8ˆÜ—	’	“ˆØŒÜÓ!ˆØ×Ñ˜UÔ#ð 	×ÑÐ2Ô3Ø�‰Œð 	×ÑÐ?Ô@ð 	×ÑœU×1Ò1Ó3Ô4ð 	×ÑØ�K‰K‹Mð>õ	
r+   c                 óÖ  •  " S S5      n[        [        R                  [        5       5      n[	        X!" 5       /5      n[        R
                  " 5       nX4l        [        5       nUR                  U5        UR                  S5        UR                  5         UR                  S5        UR                  [        R                  " 5       5        U R                  UR                  5       S5        g)z�
Test that a C{MAIL FROM} command with an address rejected by an
L{smtp.SMTP} instance's portal is responded to with the correct error
code.
c                   ó$   • \ rS rSrSr\4rS rSrg)ÚQSMTPServerTests.test_portalRejectedSenderAddress.<locals>.DisallowAnonymousAccessi�  zB
Checker for L{IAnonymous} which rejects authentication attempts.
c                 ó>   • [         R                  " [        5       5      $ r%   )r   ro   r   rQ  s     r)   rS  ÚaSMTPServerTests.test_portalRejectedSenderAddress.<locals>.DisallowAnonymousAccess.requestAvatarId”  s   € Ü—z’zÔ"3Ó"5Ó6Ð6r+   r&   N)	rC   rD   rE   rF   rG   r   rZ  rS  rH   r&   r+   r)   ÚDisallowAnonymousAccessr   �  s   † ñð %/ =Ð õ7r+   r£  r�  rŽ  r›  N©rZ  r   ro  re  r   r  rz  r   rÅ   rÝ   r-  rA   r   r�  rË   rë   )r1   r£  r€  rz  rÖ  r‘  s         r)   Ú test_portalRejectedSenderAddressÚ0SMTPServerTests.test_portalRejectedSenderAddress…  s¿   € ÷	7ñ 	7ô œt×4Ñ4Ô6LÓ6NÓOˆÜ˜Ð 7Ó 9Ð:Ó;ˆÜ—	’	“ˆØŒÜÓ!ˆØ×Ñ˜UÔ#ð 	×ÑÐ2Ô3Ø�‰Œð 	×ÑÐ?Ô@ð 	×ÑœU×1Ò1Ó3Ô4ð 	×ÑØ�K‰K‹Mð>õ	
r+   c                 ó¸  • [        [        R                  [        5       5      n[	        U/ 5      n[        R
                  " 5       nX#l        [        5       nUR                  U5        UR                  S5        UR                  5         UR                  S5        UR                  [        R                  " 5       5        U R                  UR                  5       S5        g)z²
Test that a C{MAIL FROM} command issued without first authenticating
when a portal has been configured to disallow anonymous logins is
responded to with the correct error code.
r�  rŽ  sd   550 Cannot receive from specified address <alice@example.com>: Unauthenticated senders not allowed
Nr¤  )r1   r€  rz  rÖ  r‘  s        r)   Ú"test_portalRejectedAnonymousSenderÚ2SMTPServerTests.test_portalRejectedAnonymousSender°  s¯   € ô œt×4Ñ4Ô6LÓ6NÓOˆÜ˜˜rÓ"ˆÜ—	’	“ˆØŒÜÓ!ˆØ×Ñ˜UÔ#ð 	×ÑÐ2Ô3Ø�‰Œð 	×ÑÐ?Ô@ð 	×ÑœU×1Ò1Ó3Ô4ð 	×ÑØ�K‰K‹MðLõ	
r+   r&   N)rC   rD   rE   rF   rG   r   r  ru  r{  r~  r�  r„  r’  rœ  r
   r   r¥  r¨  rH   r&   r+   r)   rq  rq  ÿ  sW   † ñð
 04¯y©yô 
1ò
.ò.ò
+ò	Aò!LòF&
ñP Ð$Ó%ñ(
ó &ð(
õT
r+   rq  c                   óh   • \ rS rSrS r SS j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)ÚESMTPAuthenticationTestsiÐ  c                 óÜ   • U R                   R                  5         U R                  R                  U5        U R	                  X R                   R                  5       R                  5       5        g)z¢
Assert that when the given bytes are delivered to the ESMTP server
instance, it responds with the indicated lines.

@type bytes: str
@type response: list of str
N)r½   r-  r«   rÝ   rË   rë   r/  )r1   rÌ   Úresponses      r)   ÚassertServerResponseÚ-ESMTPAuthenticationTests.assertServerResponseÑ  sJ   € ð 	�‰×ÑÔØ�‰× Ñ  Ô'Ø×Ñ˜§>¡>×#7Ñ#7Ó#9×#DÑ#DÓ#FÕGr+   c                 ó‚  • UR                  5       u  pEpgU R                  U/ 5        U R                  [        R                  R
                  R                  R                  U5      5        U R                  UR                  U5        U R                  UR                  U5      5        U R                  [        R                  U5        U R                  [        R                  U5        UR                  [        R                  SS 45        U R                  S/U R                  R!                  5       R#                  5       5        g)a^  
Assert that a login attempt has been made, that the credentials and
interfaces passed to it are correct, and that when the login request
is satisfied, a successful response is sent by the ESMTP server
instance.

@param loginArgs: A C{list} previously passed to L{portalFactory}.
@param username: The login user.
@param password: The login password.
Nc                  ó   • g r%   r&   r&   r+   r)   rl   ÚDESMTPAuthenticationTests.assertServerAuthenticated.<locals>.<lambda>ó  s   € Àr+   s   235 Authentication successful.)r·   rË   rÉ   Útwistedr   rR  rX  Ú
providedByrO  rN  rs  r   ÚIMessageDeliveryFactoryro  r]   r½   rë   r/  )r1   Ú	loginArgsrO  r  r×   rR  rq  r   s           r)   ÚassertServerAuthenticatedÚ2ESMTPAuthenticationTests.assertServerAuthenticatedÝ  sê   € ð ,5¯=©=«?Ñ(ˆ˜Ø×Ñ˜ BÔ'Ø�‰Ü�L‰L×$Ñ$×6Ñ6×AÑAÀ+ÓNô	
ð 	×Ñ˜×-Ñ-¨xÔ8Ø�‰˜×1Ñ1°(Ó;Ô<Ø�‰”d×2Ñ2°JÔ?Ø�‰”d×+Ñ+¨ZÔ8Ø	�
‰
”D×0Ñ0°$¹ÐEÔFà×ÑØ.Ð/°·±×1EÑ1EÓ1G×1RÑ1RÓ1Tõ	
r+   c                 óú   • [         R                  " S[        05      U l        SU R                  l        [        [        R                  " SSS5      S9U l        U R                  R                  U R                  5        g)z9
Create an ESMTP instance attached to a StringTransport.
r†  s	   localhostrÝ  rF  i90  )ÚpeerAddressN)
r   r  r   r«   rP  r   r   rè  r½   rÅ   r=   s    r)   ÚsetUpÚESMTPAuthenticationTests.setUpù  s\   € ô —j’j (Ô,<Ð!=Ó>ˆŒØ'ˆ�‰ÔÜ(Ü×+Ò+¨E°;ÀÓFñ
ˆŒð 	�‰×"Ñ" 4§>¡>Õ2r+   c                 ó`   • U R                   R                  [        R                  " 5       5        g)zD
Disconnect the ESMTP instance to clean up its timeout DelayedCall.
N)r«   rA   r   r/  r=   s    r)   ÚtearDownÚ!ESMTPAuthenticationTests.tearDown  s   € ð 	�‰×"Ñ"¤5×#7Ò#7Ó#9Õ:r+   c                 ó,   ^•  " U4S jS5      nU" 5       $ )Nc                   ó"   >• \ rS rSrU 4S jrSrg)Ú;ESMTPAuthenticationTests.portalFactory.<locals>.DummyPortali  c                 óX   >• [         R                  " 5       nTR                  XAX#45        U$ r%   )r   r\   rS   )r1   rR  rq  r   r×   Ú	loginLists        €r)   ÚloginÚAESMTPAuthenticationTests.portalFactory.<locals>.DummyPortal.login  s'   ø€ Ü—N’NÓ$�Ø× Ñ  !°$Ð!CÔDØ�r+   r&   N)rC   rD   rE   rF   rÅ  rH   )rÄ  s   €r)   ÚDummyPortalrÂ    s   ø† ÷ð r+   rÇ  r&   )r1   rÄ  rÇ  s    ` r)   ÚportalFactoryÚ&ESMTPAuthenticationTests.portalFactory
  s   ø€ ÷	ô 	ñ ‹}Ðr+   c                 óH  • U R                   R                  5         U R                  R                  S5        U R                   R	                  5       R                  5       nU R                  US   S5        U R                  US   S5        U R                  [        U5      S5        g)zF
Test that AUTH is advertised to clients which issue an EHLO command.
ó   EHLO
r   s/   250-localhost Hello 127.0.0.1, nice to meet yourw   s   250 AUTH LOGINrx   N)r½   r-  r«   rÝ   rë   r/  rË   r¯  )r1   ÚresponseLiness     r)   Ú'test_authenticationCapabilityAdvertisedÚ@ESMTPAuthenticationTests.test_authenticationCapabilityAdvertised  s‡   € ð 	�‰×ÑÔØ�‰× Ñ  Ô-ØŸ™×,Ñ,Ó.×9Ñ9Ó;ˆØ×ÑØ˜!ÑÐPô	
ð 	×Ñ˜ qÑ)Ð+<Ô=Ø×Ñœ˜]Ó+¨QÕ/r+   c                 óP  • / nU R                  U5      U R                  l        U R                  R                  S5        U R                  R                  5         U R                  SS[        R                  " S5      R                  5       -   /5        U R                  [        R                  " S5      S-   S[        R                  " S5      R                  5       -   /5        U R                  [        R                  " S5      R                  5       S-   / 5        U R                  U5        g	)
z:
Test that the LOGIN authentication mechanism can be used
rË  ó   AUTH LOGIN
ó   334 ó
   User Name ó   usernamer+  ó	   Password ó   passwordN©rÈ  r«   rz  rÝ   r½   r-  r®  Úbase64Ú	b64encodeÚstripr·  ©r1   r¶  s     r)   Útest_plainAuthenticationÚ1ESMTPAuthenticationTests.test_plainAuthentication   sí   € ð ˆ	Ø!×/Ñ/°	Ó:ˆ�‰Ôà�‰× Ñ  Ô-Ø�‰×ÑÔà×!Ñ!Ø ¬&×*:Ò*:¸>Ó*J×*PÑ*PÓ*RÑ RÐSô	
ð 	×!Ñ!Ü×Ò˜[Ó)¨GÑ3Ø”v×'Ò'¨Ó6×<Ñ<Ó>Ñ>Ð?ô	
ð
 	×!Ñ!¤&×"2Ò"2°;Ó"?×"EÑ"EÓ"GÈ'Ñ"QÐSUÔVà×&Ñ& yÕ1r+   c                 ó  • / nU R                  U5      U R                  l        U R                  R                  S5        U R                  R                  5         U R                  SS[        R                  " S5      R                  5       -   /5        U R                  [        R                  " S5      S-   S[        R                  " S5      R                  5       -   /5        U R                  S/ 5        U R                  USS	9  g
)z=
Test that giving an empty password for plain auth succeeds.
rË  rÐ  rÑ  rÒ  rÓ  r+  rÔ  r+   )r  NrÖ  rÚ  s     r)   Ú%test_plainAuthenticationEmptyPasswordÚ>ESMTPAuthenticationTests.test_plainAuthenticationEmptyPassword7  sØ   € ð ˆ	Ø!×/Ñ/°	Ó:ˆ�‰Ôà�‰× Ñ  Ô-Ø�‰×ÑÔà×!Ñ!Ø ¬&×*:Ò*:¸>Ó*J×*PÑ*PÓ*RÑ RÐSô	
ð 	×!Ñ!Ü×Ò˜[Ó)¨GÑ3Ø”v×'Ò'¨Ó6×<Ñ<Ó>Ñ>Ð?ô	
ð
 	×!Ñ! '¨2Ô.Ø×&Ñ& y¸3Ð&Ò?r+   c                 ó  • / nU R                  U5      U R                  l        U R                  R                  S5        U R                  R                  5         U R                  S[        R                  " S5      R                  5       -   S-   S[        R                  " S5      R                  5       -   /5        U R                  [        R                  " S5      R                  5       S-   / 5        U R                  U5        g)	zr
The response to the first challenge may be included on the AUTH command
line.  Test that this is also supported.
rË  ó   AUTH LOGIN rÓ  r+  rÑ  rÔ  rÕ  NrÖ  rÚ  s     r)   Ú'test_plainAuthenticationInitialResponseÚ@ESMTPAuthenticationTests.test_plainAuthenticationInitialResponseM  sÊ   € ð
 ˆ	Ø!×/Ñ/°	Ó:ˆ�‰Ôà�‰× Ñ  Ô-Ø�‰×ÑÔà×!Ñ!ØœV×-Ò-¨kÓ:×@Ñ@ÓBÑBÀWÑLØ”v×'Ò'¨Ó6×<Ñ<Ó>Ñ>Ð?ô	
ð
 	×!Ñ!¤&×"2Ò"2°;Ó"?×"EÑ"EÓ"GÈ'Ñ"QÐSUÔVà×&Ñ& yÕ1r+   c                 óÚ   • / nU R                  U5      U R                  l        U R                  R                  S5        U R                  R                  S5        U R	                  SS/5        g)zG
Test that a challenge/response sequence can be aborted by the client.
rË  rÐ  s   *
s   501 Authentication abortedN)rÈ  r«   rz  rÝ   r®  rÚ  s     r)   Útest_abortAuthenticationÚ1ESMTPAuthenticationTests.test_abortAuthenticationa  sY   € ð ˆ	Ø!×/Ñ/°	Ó:ˆ�‰Ôà�‰× Ñ  Ô-Ø�‰× Ñ Ð!2Ô3à×!Ñ! (Ð-JÐ,KÕLr+   c                 óþ   • / nU R                  U5      U R                  l        U R                  R                  S5        U R                  R                  S5        U R	                  SS/5        U R                  U/ 5        g)zb
Test that a response which is not properly Base64 encoded results in
the appropriate error code.
rË  rÐ  s   x
ó+   501 Syntax error in parameters or argumentsN©rÈ  r«   rz  rÝ   r®  rË   rÚ  s     r)   Ú!test_invalidBase64EncodedResponseÚ:ESMTPAuthenticationTests.test_invalidBase64EncodedResponsem  sn   € ð
 ˆ	Ø!×/Ñ/°	Ó:ˆ�‰Ôà�‰× Ñ  Ô-Ø�‰× Ñ Ð!2Ô3à×!Ñ!ØÐEÐFô	
ð 	×Ñ˜ BÕ'r+   c                 óÈ   • / nU R                  U5      U R                  l        U R                  R                  S5        U R	                  SS/5        U R                  U/ 5        g)zv
Like L{test_invalidBase64EncodedResponse} but for the case of an
initial response included with the C{AUTH} command.
rË  s   AUTH LOGIN x
rè  Nré  rÚ  s     r)   Ú(test_invalidBase64EncodedInitialResponseÚAESMTPAuthenticationTests.test_invalidBase64EncodedInitialResponse~  s[   € ð
 ˆ	Ø!×/Ñ/°	Ó:ˆ�‰Ôà�‰× Ñ  Ô-Ø×!Ñ!ØÐ"PÐ!Qô	
ð 	×Ñ˜ BÕ'r+   c                 óê  • / nU R                  U5      U R                  l        U R                  R                  S5        U R                  R                  5         U R                  S[        R                  " S5      R                  5       -   S-   S[        R                  " S5      R                  5       -   /5        U R                  [        R                  " S5      R                  5       S-   / 5        UR                  5       u  p#pEUR                  [        S5      5        U R                  S	U R                  R                  5       5        U R                  [        U R!                  [        5      5      S
5        g)zÔ
If the L{Deferred} returned by L{Portal.login} fires with an
exception of any type other than L{UnauthorizedLogin}, the exception
is logged and the client is informed that the authentication attempt
has failed.
rË  rá  rÓ  r+  rÑ  rÔ  rÕ  zSomething wrong with the servers9   451 Requested action aborted: local error in processing
rw   N)rÈ  r«   rz  rÝ   r½   r-  r®  r×  rØ  rÙ  r·   Úerrbackr<   rË   rë   r¯  rI  )r1   r¶  r×   rR  rq  r   s         r)   Útest_unexpectedLoginFailureÚ4ESMTPAuthenticationTests.test_unexpectedLoginFailure�  s!  € ð ˆ	Ø!×/Ñ/°	Ó:ˆ�‰Ôà�‰× Ñ  Ô-Ø�‰×ÑÔà×!Ñ!ØœV×-Ò-¨kÓ:×@Ñ@ÓBÑBÀWÑLØ”v×'Ò'¨Ó6×<Ñ<Ó>Ñ>Ð?ô	
ð 	×!Ñ!¤&×"2Ò"2°;Ó"?×"EÑ"EÓ"GÈ'Ñ"QÐSUÔVà+4¯=©=«?Ñ(ˆ˜Ø	�	‰	”,Ð@ÓAÔBà×ÑØJØ�N‰N× Ñ Ó"ô	
ð
 	×Ñœ˜T×3Ñ3´LÓAÓBÀAÕFr+   )r«   r½   N)rÓ  rÕ  )rC   rD   rE   rF   r®  r·  r»  r¾  rÈ  rÍ  rÛ  rÞ  râ  rå  rê  rí  rñ  rH   r&   r+   r)   r«  r«  Ð  sM   † ò
Hð 9Dô
ò8	3ò;òò0ò2ò.@ò,2ò(
Mò(ò"(õGr+   r«  c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚSMTPClientErrorTestsi«  z$
Tests for L{smtp.SMTPClientError}.
c                 óh   • [         R                  " SS5      nU R                  [        U5      S5        g)zl
The string representation of a L{SMTPClientError} instance includes
the response code and response string.
ru   z	some textz123 some textN©r   rê   rË   r§  ©r1   Úerrs     r)   Útest_strÚSMTPClientErrorTests.test_str°  s*   € ô
 ×"Ò" 3¨Ó4ˆØ×Ñœ˜S› ?Õ3r+   c                 óh   • [         R                  " SS5      nU R                  [        U5      S5        g)zq
If the response code supplied to L{SMTPClientError} is negative, it
is excluded from the string representation.
éÿÿÿÿs   foo barzfoo barNrö  r÷  s     r)   Útest_strWithNegativeCodeÚ-SMTPClientErrorTests.test_strWithNegativeCode¸  s*   € ô
 ×"Ò" 2 zÓ2ˆØ×Ñœ˜S› 9Õ-r+   c                 óÜ   • [        S5      nUR                  S5        UR                  S5        [        R                  " SSUR	                  5       S9nU R                  [	        U5      S5        g)	z„
If a line log is supplied to L{SMTPClientError}, its contents are
included in the string representation of the exception instance.
é
   s   testlogs
   secondlineéd   z
test error)r“   z"100 test error
testlog
secondline
N)r   rS   r   rê   r§  rË   )r1   r“   rø  s      r)   Útest_strWithLogÚ$SMTPClientErrorTests.test_strWithLogÀ  sT   € ô
 �b‹kˆØ�
‰
�:ÔØ�
‰
�=Ô!Ü×"Ò" 3¨¸#¿'¹'»)ÑDˆØ×Ñœ˜S›Ð#PÕQr+   r&   N)	rC   rD   rE   rF   rG   rù  rý  r  rH   r&   r+   r)   rô  rô  «  s   † ñò4ò.õ	Rr+   rô  c                   ó   • \ rS rSrSrS rSrg)ÚSenderMixinSentMailTestsiÌ  zy
Tests for L{smtp.SenderMixin.sentMail}, used in particular by
L{smtp.SMTPSenderFactory} and L{smtp.ESMTPSenderFactory}.
c           	      ón  ^ • T R                  [        R                  " 5       [        R                  5      nUR                  U 4S j5        [        R                  " SS[        S5      USSS9nUR                  [        R                  " SS	S
5      5      nSS/nUR                  SSSXCR                  5        U$ )zƒ
L{smtp.SenderMixin.sentMail} adds only the addresses with failing
SMTP response codes to the log passed to the factory's errback.
c                 ó<   >• TR                  U R                  S5      $ )Ns'   bob@example.com: 199 Error in sending.
)rË   r“   )r¢  r1   s    €r)   rl   ÚFSenderMixinSentMailTests.test_onlyLogFailedAddresses.<locals>.<lambda>Ù  s   ø€ �d×&Ñ&Ø—‘ÐBôr+   rò  rý  ró  r   rá  rô  rÝ  rÞ  rß  )s   alice@example.coméÈ   s   No errors here!)s   bob@example.coméÇ   s   Error in sending.r
  s   Test responserw   )rê  r   r\   r   ÚSMTPDeliveryErrorrÖ   rø  r   rç  r   rè  r”   r“   )r1   rì  rí  r¬   r’   s   `    r)   Útest_onlyLogFailedAddressesÚ4SenderMixinSentMailTests.test_onlyLogFailedAddressesÒ  s±   ø€ ð
 ×#Ñ#¤E§N¢NÓ$4´d×6LÑ6LÓMˆØ×Ñôô	
ô ×.Ò.ØØÜ�OÓ$ØØØñ
ˆð ×,Ñ,Ü×Ò  }°bÓ9ó
ˆð
 <Ø;ð
ˆ	ð 	�‰˜Ð-¨q°)¿Z¹ZÔHàˆr+   r&   N)rC   rD   rE   rF   rG   r  rH   r&   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	)
ÚESMTPDowngradeTestCaseiô  zM
Tests for the ESMTP -> SMTP downgrade functionality in L{smtp.ESMTPClient}.
c                 ó>   • [         R                  " SS S5      U l        g )NrK  rJ  )r   r¢   ÚclientProtocolr=   s    r)   r»  ÚESMTPDowngradeTestCase.setUpù  s   € Ü"×.Ò.¨ÀÀkÓRˆÕr+   c                 ó€  • [        5       nSU R                  l        SU R                  l        SU R                  l        U R                  R                  U5        U R                  R                  S5        UR                  5         U R                  R                  S5        U R                  SUR                  5       5        g)zz
If both authentication and transport security are not required, and it
is asked for, it will fall back to allowing HELO.
FTó   220 localhost
ó   500 not an esmtp server
ó   HELO testuser
N©
r   r  ÚrequireAuthenticationÚrequireTransportSecurityÚheloFallbackrÅ   rÝ   r-  rË   rë   ©r1   r½   s     r)   Ú test_requireHELOFallbackOperatesÚ7ESMTPDowngradeTestCase.test_requireHELOFallbackOperatesü  s–   € ô
 $Ó%ˆ	Ø49ˆ×ÑÔ1Ø7<ˆ×ÑÔ4Ø+/ˆ×ÑÔ(Ø×Ñ×*Ñ*¨9Ô5à×Ñ×(Ñ(Ð)=Ô>Ø�‰ÔØ×Ñ×(Ñ(Ð)GÔHØ×ÑÐ-¨y¯©Ó/@ÕAr+   c                 ó€  • [        5       nSU R                  l        SU R                  l        SU R                  l        U R                  R                  U5        U R                  R                  S5        UR                  5         U R                  R                  S5        U R                  SUR                  5       5        g)z‰
If authentication is required, and HELO fallback is on, HELO fallback
must not be honoured, as authentication requires EHLO to succeed.
TFr  r  rð   Nr  r  s     r)   Ú!test_requireAuthFailsHELOFallbackÚ8ESMTPDowngradeTestCase.test_requireAuthFailsHELOFallback  s•   € ô
 $Ó%ˆ	Ø48ˆ×ÑÔ1Ø7<ˆ×ÑÔ4Ø+/ˆ×ÑÔ(Ø×Ñ×*Ñ*¨9Ô5à×Ñ×(Ñ(Ð)=Ô>Ø�‰ÔØ×Ñ×(Ñ(Ð)GÔHØ×Ñ˜ i§o¡oÓ&7Õ8r+   c                 ó€  • [        5       nSU R                  l        SU R                  l        SU R                  l        U R                  R                  U5        U R                  R                  S5        UR                  5         U R                  R                  S5        U R                  SUR                  5       5        g)z~
If TLS is required and the connection is insecure, HELO fallback must
not be honoured, as STARTTLS requires EHLO to succeed.
FTr  r  rð   Nr  r  s     r)   Ú test_requireTLSFailsHELOFallbackÚ7ESMTPDowngradeTestCase.test_requireTLSFailsHELOFallback  s•   € ô
 $Ó%ˆ	Ø49ˆ×ÑÔ1Ø7;ˆ×ÑÔ4Ø+/ˆ×ÑÔ(Ø×Ñ×*Ñ*¨9Ô5à×Ñ×(Ñ(Ð)=Ô>Ø�‰ÔØ×Ñ×(Ñ(Ð)GÔHØ×Ñ˜ i§o¡oÓ&7Õ8r+   c                 ó´  • [        5       n[        U[        R                  5        SU R                  l        SU R                  l        SU R                  l        U R                  R                  U5        U R                  R                  S5        UR                  5         U R                  R                  S5        U R                  SUR                  5       5        g)zi
If TLS is provided at the transport level, we can honour the HELO
fallback if we're set to require TLS.
FTr  r  r  N)r   r	   r   ÚISSLTransportr  r  r  r  rÅ   rÝ   r-  rË   rë   r  s     r)   Ú/test_requireTLSAndHELOFallbackSucceedsIfOverTLSÚFESMTPDowngradeTestCase.test_requireTLSAndHELOFallbackSucceedsIfOverTLS,  s¦   € ô
 $Ó%ˆ	Ü˜¤J×$<Ñ$<Ô=Ø49ˆ×ÑÔ1Ø7;ˆ×ÑÔ4Ø+/ˆ×ÑÔ(Ø×Ñ×*Ñ*¨9Ô5à×Ñ×(Ñ(Ð)=Ô>Ø�‰ÔØ×Ñ×(Ñ(Ð)GÔHØ×ÑÐ-¨y¯©Ó/@ÕAr+   ©r  N)rC   rD   rE   rF   rG   r»  r  r  r"  r&  rH   r&   r+   r)   r  r  ô  s#   † ñòSòBò 9ò 9õ Br+   r  c                   óZ   • \ rS rSrSr\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)ÚSSLTestCasei>  z<
Tests for the TLS negotiation done by L{smtp.ESMTPClient}.
s3   220 localhost NO UCE NO UBE NO RELAY PROBES ESMTP
s1   250-localhost Hello 127.0.0.1, nice to meet you
c                 ó”   • [         R                  " S[        5       S5      U l        SU R                  l        S U R                  l        g )NrK  rJ  Tc                  ó   • g)Nztest@example.orgr&   r&   r+   r)   rl   Ú#SSLTestCase.setUp.<locals>.<lambda>M  s   € Ð2Dr+   )r   r¢   r"   r  r  r�   r=   s    r)   r»  ÚSSLTestCase.setUpH  s>   € Ü"×.Ò.ØÔ-Ó/°ó
ˆÔð 8<ˆ×ÑÔ4Ù*Dˆ×ÑÕ'r+   c                 ó|  • [        5       n[        U[        R                  5        U R                  R                  U5        U R                  R                  U R                  5        UR                  5         U R                  R                  U R                  U-   5        U R                  SUR                  5       5        g)as  
Verify that when L{smtp.ESMTPClient} connects to a server over a
transport providing L{ISSLTransport}, C{requireTransportSecurity} is
C{True}, and it is presented with the given capabilities, it will try
to send its mail and not first attempt to negotiate TLS using the
I{STARTTLS} protocol action.

@param capabilities: Bytes to include in the test server's capability
    response.  These must be formatted exactly as required by the
    protocol, including a line which ends the capability response.
@type param: L{bytes}

@raise: C{self.failureException} if the behavior of
    C{self.clientProtocol} is not as described.
s   MAIL FROM:<test@example.org>
N)r   r	   r   r%  r  rÅ   rÝ   ÚSERVER_GREETINGr-  ÚEHLO_RESPONSErË   rë   )r1   Úcapabilitiesr½   s      r)   Ú$_requireTransportSecurityOverSSLTestÚ0SSLTestCase._requireTransportSecurityOverSSLTestO  s‘   € ô  $Ó%ˆ	Ü˜¤J×$<Ñ$<Ô=Ø×Ñ×*Ñ*¨9Ô5ð 	×Ñ×(Ñ(¨×)=Ñ)=Ô>Ø�‰Ôð 	×Ñ×(Ñ(¨×);Ñ);¸lÑ)JÔKð 	×ÑÐ<¸i¿o¹oÓ>OÕPr+   c                 ó&   • U R                  S5        g)zw
When C{requireTransportSecurity} is C{True} and the client is connected
over an SSL transport, mail may be delivered.
ó   250 AUTH LOGIN
N©r3  r=   s    r)   Ú$test_requireTransportSecurityOverSSLÚ0SSLTestCase.test_requireTransportSecurityOverSSLn  s   € ð
 	×1Ñ1Ð2GÕHr+   c                 óH  • [        5       nU R                  R                  U5        U R                  R                  U R                  5        UR                  5         U R                  R                  U R                  S-   5        U R                  SUR                  5       5        g)z¸
When C{requireTransportSecurity} is C{True} and the client is connected
over a non-SSL transport, if the server offers the I{STARTTLS}
extension, it is used before mail is delivered.
ó   250-AUTH LOGIN
250 STARTTLS
s
   STARTTLS
N©	r   r  rÅ   rÝ   r0  r-  r1  rË   rë   r  s     r)   Ú'test_requireTransportSecurityTLSOfferedÚ3SSLTestCase.test_requireTransportSecurityTLSOfferedu  s„   € ô $Ó%ˆ	Ø×Ñ×*Ñ*¨9Ô5ð 	×Ñ×(Ñ(¨×)=Ñ)=Ô>Ø�‰Ôð 	×Ñ×(Ñ(Ø×ÑÐ!JÑJô	
ð
 	×Ñ˜¨)¯/©/Ó*;Õ<r+   c                 ó&   • U R                  S5        g)z¹
When C{requireTransportSecurity} is C{True} and the client is connected
over an SSL transport, if the server offers the I{STARTTLS}
extension, it is not used before mail is delivered.
r;  Nr7  r=   s    r)   Ú.test_requireTransportSecurityTLSOfferedOverSSLÚ:SSLTestCase.test_requireTransportSecurityTLSOfferedOverSSLŠ  s   € ð 	×1Ñ1Ø5õ	
r+   c                 óH  • [        5       nU R                  R                  U5        U R                  R                  U R                  5        UR                  5         U R                  R                  U R                  S-   5        U R                  SUR                  5       5        g)z²
When C{requireTransportSecurity} is C{True} and the client is connected
over a non-SSL transport, if the server does not offer the I{STARTTLS}
extension, mail is not delivered.
r6  rð   Nr<  r  s     r)   Ú*test_requireTransportSecurityTLSNotOfferedÚ6SSLTestCase.test_requireTransportSecurityTLSNotOffered”  s�   € ô $Ó%ˆ	Ø×Ñ×*Ñ*¨9Ô5ð 	×Ñ×(Ñ(¨×)=Ñ)=Ô>Ø�‰Ôð 	×Ñ×(Ñ(¨×);Ñ);Ð>SÑ)SÔTð 	×Ñ˜ i§o¡oÓ&7Õ8r+   c                 ó  • U R                   R                  nAU R                  U R                  /S9nU R	                  [        U5      S5        U R                  US   S   [        5        U R	                  US   S   S5        g)ú,
L{smtp.ESMTPClient.tlsMode} is deprecated.
©ÚoffendingFunctionsrw   r   Úcategoryr^   úStlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated since Twisted 13.0N)r  ÚtlsModeÚflushWarningsÚ%test_esmtpClientTlsModeDeprecationGetrË   r¯  ÚassertIdenticalÚDeprecationWarning)r1   ÚvalÚwarningsShowns      r)   rM  Ú1SSLTestCase.test_esmtpClientTlsModeDeprecationGet§  s‹   € ð ×!Ñ!×)Ñ)ˆØØ×*Ñ*Ø $× JÑ JÐKð +ð 
ˆð 	×Ñœ˜]Ó+¨QÔ/Ø×Ñ˜]¨1Ñ-¨jÑ9Ô;MÔNØ×ÑØ˜!Ñ˜YÑ'ð/õ	
r+   c                 ó:   ^ • T R                  [        U 4S j5        g)zi
L{smtp.ESMTPClient.__getattr__} raises an attribute error for other
attribute names which do not exist.
c                  ó0   >• T R                   R                  $ r%   )r  ÚdoesNotExistr=   s   €r)   rl   ÚQSSLTestCase.test_esmtpClientTlsModeDeprecationGetAttributeError.<locals>.<lambda>½  s   ø€ °$×2EÑ2E×2RÒ2Rr+   N)ÚassertRaisesÚAttributeErrorr=   s   `r)   Ú3test_esmtpClientTlsModeDeprecationGetAttributeErrorÚ?SSLTestCase.test_esmtpClientTlsModeDeprecationGetAttributeError¸  s   ø€ ð
 	×Ñœ.Ô*RÕSr+   c                 óø   • SU R                   l        U R                  U R                  /S9nU R	                  [        U5      S5        U R                  US   S   [        5        U R	                  US   S   S5        g)	rF  FrG  rw   r   rI  r^   rJ  N)r  rK  rL  Ú%test_esmtpClientTlsModeDeprecationSetrË   r¯  rN  rO  )r1   rQ  s     r)   r\  Ú1SSLTestCase.test_esmtpClientTlsModeDeprecationSet¿  s…   € ð ',ˆ×ÑÔ#Ø×*Ñ*Ø $× JÑ JÐKð +ð 
ˆð 	×Ñœ˜]Ó+¨QÔ/Ø×Ñ˜]¨1Ñ-¨jÑ9Ô;MÔNØ×ÑØ˜!Ñ˜YÑ'ð/õ	
r+   r(  N)rC   rD   rE   rF   rG   r!   rÑ  r0  r1  r»  r3  r8  r=  r@  rC  rM  rY  r\  rH   r&   r+   r)   r*  r*  >  sI   † ñð €DàN€OØJ€MòEòQò>Iò=ò*
ò9ò&
ò"Tõ
r+   r*  c                   ó"   • \ rS rSrSrSrS rSrg)ÚAbortableStringTransportiÐ  zC
A version of L{StringTransport} that supports C{abortConnection}.
Fc                 ó2   • SU l         U R                  5         g)zŸ
A testable version of the C{ITCPTransport.abortConnection} method.

Since this is a special case of closing the connection,
C{loseConnection} is also called.
TN)Úabortingr¿   r=   s    r)   ÚabortConnectionÚ(AbortableStringTransport.abortConnectionØ  s   € ð ˆŒØ×ÑÕr+   )ra  N)rC   rD   rE   rF   rG   ra  rb  rH   r&   r+   r)   r_  r_  Ð  s   † ñð
 €Hõr+   r_  c                   óN   • \ 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)ÚSendmailTestsiã  z*
Tests for L{twisted.mail.smtp.sendmail}.
c                 óˆ   • [         R                  " [        R                  5      nUS   nU R	                  [
        US   5        g)zc
The default C{reactor} parameter of L{twisted.mail.smtp.sendmail} is
L{twisted.internet.reactor}.
r*  rx   N)ÚinspectÚgetfullargspecr   ÚsendmailrË   r   )r1   ÚfullSpecÚdefaultss      r)   Ú"test_defaultReactorIsGlobalReactorÚ0SendmailTests.test_defaultReactorIsGlobalReactorè  s5   € ô
 ×)Ò)¬$¯-©-Ó8ˆØ˜A‘;ˆØ×Ñœ (¨1¡+Õ.r+   c                 óT  • [        5       n[        R                  " SSSSUUUSSS9	  UR                  S   S   nU R	                  UR
                  S5        U R	                  UR                  S5        U R	                  UR                  S	5        U R	                  UR                  S
5        g)zS
L{twisted.mail.smtp.sendmail} creates the ESMTP factory with the ESMTP
arguments.
r+  rò  rý  r*  T)r   rO  r  r  r  r   rx   rÛ   ó   barN)	r   r   ri  Ú
tcpClientsrË   Ú_requireTransportSecurityÚ_requireAuthenticationrO  r  )r1   rO  r  r   r,  s        r)   Ú_honorsESMTPArgumentsÚ#SendmailTests._honorsESMTPArgumentsñ  s¡   € ô
  “/ˆÜ�ŠØØØØØØØØ%)Ø"&ò
	
ð ×$Ñ$ QÑ'¨Ñ*ˆØ×Ñ˜×:Ñ:¸DÔAØ×Ñ˜×7Ñ7¸Ô>Ø×Ñ˜×)Ñ)¨6Ô2Ø×Ñ˜×)Ñ)¨6Õ2r+   c                 ó"   • U R                  SSS9$ )z_
L{twisted.mail.smtp.sendmail} should accept C{username} and C{password}
which are L{unicode}.
rè   Úbar©rO  r  ©rs  r=   s    r)   Ú&test_honorsESMTPArgumentsUnicodeUserPWÚ4SendmailTests.test_honorsESMTPArgumentsUnicodeUserPW  s   € ð
 ×)Ñ)°5À5Ð)ÐIÐIr+   c                 ó"   • U R                  SSS9$ )z]
L{twisted.mail.smtp.sendmail} should accept C{username} and C{password}
which are L{bytes}.
rÛ   ro  rw  rx  r=   s    r)   Ú$test_honorsESMTPArgumentsBytesUserPWÚ2SendmailTests.test_honorsESMTPArgumentsBytesUserPW  s   € ð
 ×)Ñ)°6ÀFÐ)ÐKÐKr+   c                 óº   • [        5       n[        S5      n[        R                  " SSSUUS9  UR                  S   S   nU R                  UR                  U5        g)	zd
L{twisted.mail.smtp.sendmail} will pass through the message untouched
if it is a file-like object.
s   File!r+  rò  rý  ©r   r   rx   N)r   r   r   ri  rp  ÚassertIsÚfile)r1   r   ÚmessageFiler,  s       r)   Útest_messageFilePassthroughÚ)SendmailTests.test_messageFilePassthrough  sY   € ô
  “/ˆÜ˜hÓ'ˆä�ŠØØØØØò	
ð ×$Ñ$ QÑ'¨Ñ*ˆØ�‰�g—l‘l KÕ0r+   c                 óæ   • [        5       n[        R                  " SSSSUS9  UR                  S   S   nUR                  nUR                  S5        U R                  UR                  5       S5        g)	zt
L{twisted.mail.smtp.sendmail} will turn non-file-like objects
(eg. strings) into file-like objects before sending.
r+  rò  rý  r*  r  r   rx   N)r   r   ri  rp  r�  ÚseekrË   r  )r1   r   r,  r‚  s       r)   Útest_messageStringMadeFileÚ(SendmailTests.test_messageStringMadeFile(  sm   € ô
  “/ˆÜ�ŠØØØØØò	
ð ×$Ñ$ QÑ'¨Ñ*ˆØ—l‘lˆØ×Ñ˜ÔØ×Ñ˜×)Ñ)Ó+¨ZÕ8r+   c           	      ó¦   • [        5       n[        R                  " SSSSUSS9  UR                  S   S   nU R	                  UR
                  S	5        g
)zS
L{twisted.mail.smtp.sendmail} passes through the sender domain name, if
provided.
r+  rò  rý  r*  rè   )r   ÚsenderDomainNamer   rx   rÛ   N)r   r   ri  rp  rË   rM   )r1   r   r,  s      r)   Útest_senderDomainNameÚ#SendmailTests.test_senderDomainName:  sT   € ô
  “/ˆÜ�ŠØØØØØØ"ò	
ð ×$Ñ$ QÑ'¨Ñ*ˆØ×Ñ˜Ÿ™¨Õ0r+   c                 ó  • [        5       n[        R                  " SSSSUS9nUR                  5         U R	                  UR
                  S   R                  S5        U R                  U5      nUR                  [        R                  5        g)	z¤
When a user cancels L{twisted.mail.smtp.sendmail} before the connection
is made, the connection is closed by
L{twisted.internet.interfaces.IConnector.disconnect}.
r+  rò  rý  r*  r  r   TN)r   r   ri  ÚcancelrË   Ú
connectorsÚ_disconnectedÚfailureResultOfÚtrapr   ÚCancelledError)r1   r   r×   Úfailures       r)   Útest_cancelBeforeConnectionMadeÚ-SendmailTests.test_cancelBeforeConnectionMadeK  sv   € ô  “/ˆÜ�MŠMØØØØØñ
ˆð 	
�‰Œ
Ø×Ñ˜×+Ñ+¨AÑ.×<Ñ<¸dÔCØ×&Ñ& qÓ)ˆØ�‰”U×)Ñ)Õ*r+   c                 ó´  • [        5       n[        5       n[        R                  " SSSSUS9nUR                  S   S   nUR                  S5      nUR                  U5        UR                  5         U R                  UR                  S	5        U R                  UR                  S	5        U R                  U5      nUR                  [        R                  5        g)
z¨
When a user cancels L{twisted.mail.smtp.sendmail} after the connection
is made, the connection is closed by
L{twisted.internet.interfaces.ITransport.abortConnection}.
r+  rò  rý  r*  r  r   rx   NT)r   r_  r   ri  rp  rç  rÅ   rŽ  rË   ra  rì   r‘  r’  r   r“  )r1   r   r½   r×   r,  r�  r”  s          r)   Útest_cancelAfterConnectionMadeÚ,SendmailTests.test_cancelAfterConnectionMade^  s¼   € ô  “/ˆÜ,Ó.ˆ	Ü�MŠMØØØØØñ
ˆð ×$Ñ$ QÑ'¨Ñ*ˆØ×!Ñ! $Ó'ˆØ	×Ñ˜Ô#Ø	�‰Œ
Ø×Ñ˜×+Ñ+¨TÔ2Ø×Ñ˜×0Ñ0°$Ô7Ø×&Ñ& qÓ)ˆØ�‰”U×)Ñ)Õ*r+   r&   N)rC   rD   rE   rF   rG   rl  rs  ry  r|  rƒ  r‡  r‹  r•  r˜  rH   r&   r+   r)   re  re  ã  s6   † ñò/ò3ò.JòLò1ò$9ò$1ò"+õ&+r+   re  )krG   r×  rg  rQ   Úior   Útypingr   r   r   r   r   Úzope.interfacer	   r
   Útwisted.cred.checkersr³  Útwisted.cred.credentialsÚtwisted.cred.errorÚtwisted.cred.portalr   r   r   r   r   r   r   Útwisted.internetr   r   r   r   r   r   r   Útwisted.internet.testingr   r   Útwisted.mailr   Útwisted.mail._credr   Útwisted.protocolsr   r   Útwisted.python.utilr   Útwisted.trial.unittestr    r§  r=  Útwisted.test.ssl_helpersr"   r#   r!   ÚImportErrorÚIReactorSSLr´  r*   ÚIMessager-   rJ   rb   ry   rt   r›   r—   r¢   rŸ   r§   ÚLineReceiverr¯   rÂ   r÷   r  r  r  r  r  r   rE  rG  ÚcheckersrI  ro  r  rk  ru  r”  r¿  rÆ  rÓ  rÛ  r$  r  r(  r;  rZ  re  rq  r«  rô  r  r  r*  r_  re  r&   r+   r)   Ú<module>r®     s   ðòó
 Û Û 	Ý ß 3Õ 3ç 8ã Û Û Û Ý ß KÝ /Ý 0ß .ß W× WÑ Wß CÝ Ý /ß -Ý 'Ý +à	�#‰Ó ðßKð €Gð ×Ñ×(Ñ(¨×1Ñ1Ø+€Gòñ ˆT�]‰]Ó÷ð ó ð÷(ñ ÷62ñ 2ð"€÷ñ ô6-�8˜TŸ_™_ô -ô �H˜d×.Ñ.ô  ÷4ñ 4ô
1�U×'Ñ'ô 1ô:r1�h ô r1÷j'ñ '÷&ñ ô �
˜DŸI™Iô ô �˜TŸZ™Zô  ÷jñ jôZ ˜¨ô  ô
�¨ô ñ
 ˆT�]‰]×.Ñ.Ó/÷-ð -ó 0ð-ñ& ˆT×"Ñ"Ó#÷2ð 2ó $ð2÷&Iñ Iô
?�˜-ô ?ôD:Q�hô :Qôz�mô ô@ˆx˜ô @ô";�Xô ;ô$s
�8˜]ô s
ôl¨x×/EÑ/Eô ô"!>˜Xô !>ôH= (ô =ñ@ ˆVÓ÷8ð 8ó ð8÷ Yñ Yô"N
�hô N
ôbXG˜xô XGôvR˜8ô RôB%˜xô %ôPGB˜Xô GBôTO
�(ô O
ôd˜ô ô&Q+�Hõ Q+øð}5 ó $Ø#ƒGð$ús   Â!L ÌLÌL