Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_smtplib.cpython-312.pyc

�

'Μg���Z�ddlZddlZddlmZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlmZmZddlmZddlmZddlmZddlmZdd	lmZdd
lm Z ejBd��ejDZ"ejFd
k(rd�Z$e$ejJ_$d�Z&Gd�d�Z'Gd�de'ejP�Z)Gd�de'ejP�Z*d�Z+dZ,dZ-Gd�dejP�Z.Gd�dejP�Z/Gd�dejP�Z0Gd�d ejP�Z1Gd!�d"ejP�Z2d#d$d%d&�Z3d'Z4d(Z5d)d*gd+gd,�Z6Gd-�d.e7�Z8Gd/�d0ejJ�Z9Gd1�d2ejt�Z;Gd3�d4ejP�Z<Gd5�d6e;�Z=Gd7�d8ejP�Z>ed9d:�;�Z?Gd<�d=e9�Z@Gd>�d?e;�ZAGd@�dAejP�ZBeCdBk(rej��yy)C�N)�EmailMessage)�body_encode)�support�mock_socket)�hashlib_helper)�
socket_helper)�threading_helper)�asyncore)�smtpd)�MockT)�module�darwinc��y�N���selfs �./usr/local/lib/python3.12/test/test_smtplib.py�handle_exptr$s���c���|j�|j�	|j�\}}d}|rF|dkDrAtjg|gg�\}}}|r|j	|�}	||	d}|dz}|r|dkDr�A|j�|j�|j�y#t$rY�,wxYw#|j�|j�wxYw)Ni�r�)�listen�set�accept�select�send�close�TimeoutError)
�evt�buf�serv�conn�addr�n�r�w�e�sents
          r�serverr*)s����K�K�M��G�G�I���[�[�]�
��d�
���a�!�e��m�m�B����3�G�A�q�!���y�y��~���$�%�j��
��F�A�
�a�!�e�	
�
�
���
�
�����	���
��
��	
�
�
�����	�s/�B0�A	B?�?B?�0	B<�9B?�;B<�<B?�?"C!c�Z�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)�GeneralTestsc�0�tt_d|_y)N�)r�smtplib�socket�portrs r�setUpzGeneralTests.setUpAs��$�����	rc�"�tt_yr)r0r/rs r�tearDownzGeneralTests.tearDownEs	����rc�V�d}d}|j|tj|��y)Nzabc
.jkl
foo
..bluezabc
..jkl
foo
...blue)�assertEqualr/�	quotedata)r�teststr�expecteds   r�
testQuoteDatazGeneralTests.testQuoteDataJs'��-��3������7�#4�#4�W�#=�>rc��tjd�|jt|j�}|j�y)N�220 Hola mundo�r�
reply_with�client�HOSTr1r�rr?s  r�
testBasic1zGeneralTests.testBasic1Os.�����0�1����T�4�9�9�-�����rc���tjd�|jt|jd��}|j|jd�|j�y)Nr<)z	127.0.0.1i�M)�source_address)rr>r?r@r1r6rDrrAs  r�testSourceAddresszGeneralTests.testSourceAddressUsP�����0�1����T�4�9�9�,?��A������.�.�0D�E����rc��tjd�|jt�d|j���}|j�y)Nr<�:r=rAs  r�
testBasic2zGeneralTests.testBasic2]s1�����0�1�����d�i�i�8�9�����rc���tjd�|jt|jd��}|j|jd�|j�y)Nr<�testhost)�local_hostname)rr>r?r@r1r6rKrrAs  r�testLocalHostNamezGeneralTests.testLocalHostNamecsH�����0�1����T�4�9�9�Z��H������.�.�
�;����rc��tjd�|jtj��tjd�|jtj�d�	|j
t|j�}tjd�|j|jj�d�|j�y#tjd�wxYw)Nr<�)rr>�assertIsNone�getdefaulttimeout�setdefaulttimeoutr6r?r@r1�sock�
gettimeoutrrAs  r�testTimeoutDefaultzGeneralTests.testTimeoutDefaultjs������0�1����+�7�7�9�:��%�%�b�)�����6�6�8�"�=�	0��[�[��t�y�y�1�F��)�)�$�/�������/�/�1�2�6������
�)�)�$�/�s�3 C#�#C:c��tjd�|jtj��tj
d�	|j
t|jd��}tj
d�|j|jj��|j�y#tj
d�wxYw�Nr<rN��timeout)rr>rOr0rPrQr?r@r1rRrSrrAs  r�testTimeoutNonezGeneralTests.testTimeoutNonevs������0�1����&�2�2�4�5�� � ��$�	+��[�[��t�y�y�$�[�?�F��$�$�T�*����&�+�+�0�0�2�3������
�$�$�T�*�s�"C�Cc���tjd�|jt�5|j	t
|jd��ddd�y#1swYyxYw)Nr<rrW)rr>�assertRaises�
ValueErrorr?r@r1rs r�testTimeoutZerozGeneralTests.testTimeoutZero�sA�����0�1�
�
�
�z�
*��K�K��d�i�i��K�3�+�
*�
*�s�#A�A c���tjd�|jt|jd��}|j|jj�d�|j�yrV)	rr>r?r@r1r6rRrSrrAs  r�testTimeoutValuezGeneralTests.testTimeoutValue�sO�����0�1����T�4�9�9�b��9��������/�/�1�2�6����rc��tjd�|j�}|jd�t	j
�5}|j
t|j�ddd�|j�tjdtj�}|jj�|�y#1swY�^xYw)N�220 Hello worldrz	^connect:�rr>r?�set_debuglevelr�captured_stderr�connectr@r1r�re�compile�	MULTILINE�assertRegex�getvalue�rr?�stderrr9s    r�test_debuglevelzGeneralTests.test_debuglevel�s������1�2���������a� �
�
$�
$�
&�&��N�N�4����+�'������:�:�l�B�L�L�9��������*�H�5�	'�
&���!C	�	Cc��tjd�|j�}|jd�t	j
�5}|j
t|j�ddd�|j�tjdtj�}|jj�|�y#1swY�^xYw)Nra�z#^\d{2}:\d{2}:\d{2}\.\d{6} connect: rbrks    r�test_debuglevel_2zGeneralTests.test_debuglevel_2�s������1�2���������a� �
�
$�
$�
&�&��N�N�4����+�'������:�:�D� �l�l�,��������*�H�5�'�
&�rnN)�__name__�
__module__�__qualname__r2r4r:rBrErHrLrTrYr]r_rmrqrrrr,r,?sC��� �
?�
����
�	�4�
�6�	6rr,c�$�eZdZejZy)�SMTPGeneralTestsN)rrrsrtr/�SMTPr?rrrrvrv�s��
�\�\�Frrvc�v��eZdZejZejee	d�d�d��Z
�fd�Z�xZS)�LMTPGeneralTests�AF_UNIXz test requires Unix domain socketc�<�d}tjd�	|j||j�}tjd�|j|jj��|j�y#tjd�wxYw)N�!/some/local/lmtp/delivery/programra)	rr>r?r1rQrOrRrSr)r�
local_hostr?s   r�"testUnixDomainSocketTimeoutDefaultz3LMTPGeneralTests.testUnixDomainSocketTimeoutDefault�ss��8�
����1�2�	0��[�[��T�Y�Y�7�F��)�)�$�/����&�+�+�0�0�2�3������
�)�)�$�/�s�B�Bc���t�|��d}|jt�5|j	|d��ddd�y#1swYyxYw)Nr|rrW)�superr]r[r\r?)rr}�	__class__s  �rr]z LMTPGeneralTests.testTimeoutZero�s=���
���!�8�
�
�
�
�z�
*��K�K�
�A�K�.�+�
*�
*�s�A�A
)
rrrsrtr/�LMTPr?�unittest�
skipUnless�hasattrr0r~r]�
__classcell__�r�s@rryry�s@���
�\�\�F��X������3�5W�X��Y��/�/rryc���|j�	ttd�rtj}ntj
}d}tjrX|dkDrS|dtj�|j�r|j�n|dz}tjr|dkDr�S|j�s%tjd�|j�tj�|j�y#t$rY�ewxYw#|j�s%tjd�|j�tj�|j�wxYw)N�polli�r�{�G�z�?rg�?)
rr�rr
�poll2r��
socket_map�is_setrr�time�sleep�	close_all)r"�serv_evt�
client_evt�poll_funr%s     r�debugging_serverr��s���L�L�N���6�6�"��~�~�H��}�}�H����!�!�a�!�e��T�8�.�.�/�� � �"��
�
���
��F�A��!�!�a�!�e�� � �"��J�J�s�O��J�J�L�����������
��
��� � �"��J�J�s�O��J�J�L���������s%�BD�	D�D�D�D�AE1z&---------- MESSAGE FOLLOWS ----------
z&------------ END MESSAGE ------------
c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�DebuggingServerTestsNc��tj�|_tj|_tjt_tj|_	tj�|_|jt_tj�|_tj�|_t"j$|_tj�t"_t#j(t*dfdd��|_|j,jj/�dd\|_|_|j,|j|j f}tj4t6|��|_|j8j;�|jj=�|jj?�y)Nr��nowhere���T��decode_datarp��target�args) r	�threading_setup�
thread_keyr0�getfqdn�real_getfqdnr�sys�stdout�
old_stdout�io�StringIO�output�	threading�Eventr�r�r�DEBUGSTREAM�old_DEBUGSTREAM�DebuggingServerr@r"�getsockname�hostr1�Threadr��thread�start�wait�clear�r�	serv_argss  rr2zDebuggingServerTests.setUp�s,��*�:�:�<���"�N�N���$�,�,����*�*����k�k�m����[�[��
�!���)��
�#�/�/�+���$�0�0����K�K�M����)�)�4��)�_�6:�<��	� $�y�y�/�/�;�;�=�b�q�A���	�4�9��Y�Y��
�
�t���?�	��&�&�.>�Y�O���������	
�
�
�����
�
���rc��|jt_|jj	�|j
j
�tj|j�|jt_tjj�|j t_|`	|j#�tj$|j&�yr)r�r0r�r�rr�r�r	�join_threadr�r�r�r�rr�rr��
doCleanups�threading_cleanupr�rs rr4zDebuggingServerTests.tearDowns����*�*����������
�
�����$�$�T�[�[�1��_�_��
�
�����!� �0�0����K������*�*�D�O�O�<rc��|jj�}tjdd|tjtj
z��S)Nz(.*?)^X-Peer:\s*\S+\n(.*)z\1\2)�flags)r�rjrf�subrh�DOTALL)r�test_outputs  r�get_output_without_xpeerz-DebuggingServerTests.get_output_without_xpeers>���k�k�*�*�,���v�v�2�G�!����b�i�i�)?�A�	Arc��tjt|jdtj
��}|j
�y�N�	localhost�rKrX�r/rwr@r1r�LOOPBACK_TIMEOUT�quit�r�smtps  r�	testBasiczDebuggingServerTests.testBasic�,���|�|�D�$�)�)�K�$+�$<�$<�>���	�	�rc�"�tj�}	tj|j|j
dtj|j|f��}|j|j�|j|j|j|f�|j|jd�|j�y#t$r7}|jtj k(r|j#d|z��d}~wwxYw)Nr�)rKrXrDzcouldn't bind to source port %d)r�find_unused_portr/rwr�r1rr��
addCleanuprr6rDrKr��OSError�errno�
EADDRINUSE�skipTest)r�src_portr�r(s    rrEz&DebuggingServerTests.testSourceAddresss��� �1�1�3��	��<�<��	�	�4�9�9�[�(/�(@�(@�04�	�	�8�/D�F�D�
�O�O�D�J�J�'����T�0�0�4�9�9�h�2G�H����T�0�0�+�>��I�I�K���	��w�w�%�*�*�*��
�
�?�(�J�K���	�s�B7C�	D�2D	�	Dc��tjt|jdtj
��}|j
|j�d}|j|j�|�|j�y�Nr�r���sOK)r/rwr@r1rr�r�rr6�noopr��rr�r9s   r�testNOOPzDebuggingServerTests.testNOOP/�W���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#����������h�/��	�	�rc��tjt|jdtj
��}|j
|j�d}|j|j�|�|j�yr�)r/rwr@r1rr�r�rr6�rsetr�r�s   r�testRSETzDebuggingServerTests.testRSET7r�rc��tjt|jdtj
��}|j
|j�d}|j|j�|�|j�y)Nr�r�)r�s
SIZE 33554432
HELP)r/rwr@r1rr�r�rr6�ehlor�r�s   r�testELHOzDebuggingServerTests.testELHO?sW���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#�2���������h�/��	�	�rc�*�tjt|jdtj
��}|j
|j�d}|jd�|j|j�|�|j�y)Nr�r�)i�sEXPN not implemented�EXPN)r/rwr@r1rr�r�r�putcmdr6�getreplyr�r�s   r�testEXPNNotImplementedz+DebuggingServerTests.testEXPNNotImplementedHsc���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#�1�����F���������(�3��	�	�rc��tjt|jdtj
��}|j
|j�|jt�5}|jd�ddd�|jdtj��|j�y#1swY�?xYw)Nr�r�zhelo
X-INJECTED�prohibited newline characters)r/rwr@r1rr�r�rr[r\r��assertIn�str�	exceptionr�)rr��excs   r�&test_issue43124_putcmd_escapes_newlinez;DebuggingServerTests.test_issue43124_putcmd_escapes_newlineRs���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#�
�
�
�z�
*�c��K�K�*�+�+��
�
�5�s�3�=�=�7I�J��	�	��+�
*�s�&B6�6B?c�L�tjt|jdtj
��}|j
|j�d}|j|jd�|�|j|jd�|�|j�y)Nr�r�)�s>Cannot VRFY user, but will accept message and attempt delivery�nobody@nowhere.com)r/rwr@r1rr�r�rr6�vrfy�verifyr�r�s   r�testVRFYzDebuggingServerTests.testVRFY\sw���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#�2��������#7�8�(�C�������%9�:�H�E��	�	�rc�(�tjt|jdtj
��}|j
|j�|j�d}|j|j�|�|j�y)Nr�r�)i�sDuplicate HELO/EHLO)r/rwr@r1rr�r�r�helor6r�r�s   r�testSecondHELOz#DebuggingServerTests.testSecondHELOfsb���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#��	�	��0���������h�/��	�	�rc��tjt|jdtj
��}|j
|j�|j|j�d�|j�y)Nr�r�s@Supported commands: EHLO HELO MAIL RCPT DATA RSET NOOP QUIT VRFY)r/rwr@r1rr�r�rr6�helpr�r�s  r�testHELPzDebuggingServerTests.testHELPqsY���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#��������'G�	H��	�	�rc�*�d}tjt|jdtj
��}|j
|j�|jdd|�tjd�|j�|jj�|jj�|j j#�t$�|�dt&��}|j)|j j+�|�y)N�A test messager�r��John�Sallyr��
�r/rwr@r1rr�r�r�sendmailr�r�r�r�rr�r�r��flush�	MSG_BEGIN�MSG_ENDr6rj�r�mr��mexpects    r�testSendzDebuggingServerTests.testSendys������|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#��
�
�f�g�q�)�	
�
�
�4���	�	���������
�
���������� )�1�g�6��������-�-�/��9rc�H�d}tjt|jdtj
��}|j
|j�|jdd|�tjd�|j�|jj�|jj�|j j#�t$�|j'd��dt(��}|j+|j j-�|�y)	NsA test messager�r�r�r�r��asciir�)r/rwr@r1rr�r�rrr�r�r�r�rr�r�r�rr�decoderr6rjrs    r�testSendBinaryz#DebuggingServerTests.testSendBinary�s������|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#��
�
�f�g�q�)��
�
�4���	�	���������
�
���������� )�1�8�8�G�+<�g�F��������-�-�/��9rc�*�d}tjt|jdtj
��}|j
|j�|jdd|�tjd�|j�|jj�|jj�|j j#�t$�|�dt&��}|j)|j j+�|�y)Nz.A test
.mes.sage.r�r�r�r�r�r�rrs    r�testSendNeedingDotQuotez,DebuggingServerTests.testSendNeedingDotQuote�s���!���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#��
�
�f�g�q�)��
�
�4���	�	���������
�
���������� )�1�g�6��������-�-�/��9rc��d}tjt|jdtj
��}|j
|j�|jt�5}|jdd|�ddd�|jdtj��tjd�|j!�t"j$j'�}|j)d|�y#1swY��xYw)	N�wazzuuup
linetwoz
hi
X-INJECTEDr��	hi@me.com�
you@me.comz2prohibited newline characters: ehlo hi\nX-INJECTEDr�z
X-INJECTED)r/rwr@r1rr�r�rr[r\rr�r�r�r�r�r�rr�rj�assertNotIn)rrr�r��debugouts     r�$test_issue43124_escape_localhostnamez9DebuggingServerTests.test_issue43124_escape_localhostname�s���
 ���|�|�D�$�)�)�<L�$+�$<�$<�>������
�
�#�
�
�
�z�
*�c��M�M�+�|�Q�7�+��
�
�A���
�
��	
�
	
�
�
�4���	�	���$�$�-�-�/������x�0�+�
*�s�(C?�?Dc���d}tjt|jdtj
��}|j
|j�|jdd|�|jt�5}|jdddg�ddd�tj�}|jd|�|jd	|�tj d
�|j#�t$j&j)�}|j+d|�|j+d|�|j+d
|�|j+d|�y#1swY��xYw)Nrr�r�rrzX-OPTION
X-INJECTED-1zX-OPTION2
X-INJECTED-2r�z.X-OPTION\nX-INJECTED-1 X-OPTION2\nX-INJECTED-2r�zX-OPTIONz	X-OPTION2zX-INJECTED-1zX-INJECTED-2)r/rwr@r1rr�r�rrr[r\�mailr�r�r�r�r�r�rr�rjr)rrr�r��msgrs      r�test_issue43124_escape_optionsz3DebuggingServerTests.test_issue43124_escape_options�s��
 ���|�|��$�)�)�K��,�,�.��	
����
�
�#��
�
�k�<��3�
�
�
�z�
*�c��I�I�k�$<�>W�#X�Y�+��#�-�-� ���
�
�5�s�;��
�
�H�#�N��
�
�4���	�	���$�$�-�-�/������X�.�����h�/������2������2�+�
*�s�;E�E&c���d}tjt|jdtj
��}|j
|j�|jdd|�tjd�|j�|jj�|jj�|j j#�t$�|�dt&��}|j)|j j+�|�t,j.j+�}t1j2dt0j4�}|j7||�y)	Nr�r�r�z<>r�r�r�z^sender: <>$)r/rwr@r1rr�r�rrr�r�r�r�rr�r�r�rrrr6rjrr�rfrgrhri)rrr�rr�senders      r�testSendNullSenderz'DebuggingServerTests.testSendNullSender�s������|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#��
�
�d�G�Q�'��
�
�4���	�	���������
�
���������� )�1�g�6��������-�-�/��9��$�$�-�-�/�����N�B�L�L�9������6�*rc��tjjjd�}t	j
t|jdtj��}|j|j�|j|dd��tjd�|j�|j j#�|j$j'�|j(j+�|j-�}|d=t.�|j1��d	t2��}|j5||�y)
Nr�r�r�r�r���	from_addr�to_addrsr��X-Peerr�)�email�mime�text�MIMETextr/rwr@r1rr�r�r�send_messager�r�r�r�rr�r�r�rr�r�	as_stringrr6)rrr�r�rs     r�testSendMessagez$DebuggingServerTests.testSendMessage�s����J�J�O�O�$�$�%5�6���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#����!�v���@��
�
�4���	�	���������
�
����������
�3�3�5��
�h�K� )�1�;�;�=�'�B������g�.rc��tjjjd�}d|d<d|d<d|d<d|d	<t	j
t|jd
tj��}|j|j�|j|�tjd�|j�|j!|d	d�|j"j%�|j&j)�|j*j-�|j/�}|d
=|d	=t0�|j3��dt4��}|j!||�t6j8j;�}t=j>dt<j@�}|jC||�dD]G}t=j>djE|�t<j@�}|jC||��Iy)Nr��foo@bar.com�Fromr��To�Sally, Fred�CC�?John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>�Bccr�r�r�r!r��^sender: foo@bar.com$)r�r��Fredzroot@localhostzwarped@silly.walks.com�^recips: .*'{}'.*$)#r"r#r$r%r/rwr@r1rr�r�rr&r�r�r�r6r�rr�r�r�rr�rr'rrr�rjrfrgrhri�format�	rrr�r�rrrr$�to_addrs	         r�testSendMessageWithAddressesz1DebuggingServerTests.testSendMessageWithAddressess����J�J�O�O�$�$�%5�6��!��&�	���$����$��T��%���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#����!���
�
�4���	�	������5��$?�	@�	
�������
�
�����������3�3�5��
�h�K�
�e�H� )�1�;�;�=�'�B������g�.��$�$�-�-�/�����3�R�\�\�B������6�*�/�D��j�j�!6�!=�!=�d�!C�!#���/�G����X�w�/�	/rc���tjjjd�}d|d<d|d<t	j
t|jdtj��}|j|j�|j|�tjd�|j�|j j#�|j$j'�|j(j+�|j-�}|d	=t.�|j1��d
t2��}|j5||�t6j8j;�}t=j>dt<j@�}|jC||�dD]G}t=j>d
jE|�t<j@�}|jC||��Iy)Nr�r*r+�John, Dinsdaler,r�r�r�r!r�r1�r��Dinsdaler3�#r"r#r$r%r/rwr@r1rr�r�rr&r�r�r�r�rr�r�r�rr�rr'rr6rr�rjrfrgrhrir4r5s	         r� testSendMessageWithSomeAddressesz5DebuggingServerTests.testSendMessageWithSomeAddresses's^���J�J�O�O�$�$�%5�6��!��&�	�"��$���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#����!���
�
�4���	�	���������
�
�����������3�3�5��
�h�K� )�1�;�;�=�'�B������g�.��$�$�-�-�/�����3�R�\�\�B������6�*�(�D��j�j�!6�!=�!=�d�!C�!#���/�G����X�w�/�)rc�L�tjjjd�}d|d<d|d<t	j
t|jdtj��}|j|j�|j|dd	�
�tjd�|j�|j j#�|j$j'�|j(j+�|j-�}|d=t.�|j1��d
t2��}|j5||�t6j8j;�}t=j>dt<j@�}|jC||�dD]G}t=j>djE|�t<j@�}|jG||��It=j>dt<j@�}	|jC||	�y)Nr�r*r+r9r,r�r�zjoe@example.comzfoo@example.netrr�r!r�z^sender: joe@example.com$r:r3z^recips: .*'foo@example.net'.*$)$r"r#r$r%r/rwr@r1rr�r�rr&r�r�r�r�rr�r�r�rr�rr'rr6rr�rjrfrgrhrir4�assertNotRegex)
rrr�r�rrrr$r6�recips
          r�%testSendMessageWithSpecifiedAddressesz:DebuggingServerTests.testSendMessageWithSpecifiedAddressesDs����J�J�O�O�$�$�%5�6��!��&�	�"��$���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#����!�'8�CT��U��
�
�4���	�	���������
�
�����������3�3�5��
�h�K� )�1�;�;�=�'�B������g�.��$�$�-�-�/�����7����F������6�*�(�D��j�j�!6�!=�!=�d�!C�!#���/�G�����'�2�)��
�
�=�r�|�|�L������5�)rc���tjjjd�}d|d<d|d<d|d<t	j
t|jdtj�	�}|j|j�|j|�tjd
�|j�|j j#�|j$j'�|j(j+�|j-�}|d=t.�|j1��dt2��}|j5||�t6j8j;�}t=j>d
t<j@�}|jC||�dD]G}t=j>djE|�t<j@�}|jC||��Iy)Nr�zBernard, Biancar+z#the_rescuers@Rescue-Aid-Society.com�Senderr9r,r�r�r�r!r�z-^sender: the_rescuers@Rescue-Aid-Society.com$r:r3r<r5s	         r�testSendMessageWithMultipleFromz4DebuggingServerTests.testSendMessageWithMultipleFromcsg���J�J�O�O�$�$�%5�6��%��&�	�;��(��"��$���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#����!���
�
�4���	�	���������
�
�����������3�3�5��
�h�K� )�1�;�;�=�'�B������g�.��$�$�-�-�/�����K�R�\�\�Z������6�*�(�D��j�j�!6�!=�!=�d�!C�!#���/�G����X�w�/�)rc�"�tjjjd�}d|d<d|d<d|d<d|d	<d
|d<d|d
<d|d<d|d<t	j
t|jdtj��}|j|j�|j|�tjd�|j�|j j#�|j$j'�|j(j+�|d	=|d=|j-�}|d=t.�|j1��dt2��}|j5||�t6j8j;�}t=j>dt<j@�}|jC||�dD]G}t=j>djE|�t<j@�}|jC||��Iy)Nr�r*r+r�r,r-r.r/r0�Thu, 1 Jan 1970 17:42:00 +0000�Resent-Date�holy@grail.net�Resent-From�&Martha <my_mom@great.cooker.com>, Jeff�	Resent-To�doe@losthope.net�
Resent-Bccr�r�r�r!r�z^sender: holy@grail.net$)zmy_mom@great.cooker.com�JeffrLr3r<r5s	         r�testSendMessageResentz*DebuggingServerTests.testSendMessageResent�s����J�J�O�O�$�$�%5�6��!��&�	���$����$��T��%��;��-��+��-��A��+��,��,���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#����!���
�
�4���	�	���������
�
����������
�e�H�
�l�O��3�3�5��
�h�K� )�1�;�;�=�'�B������g�.��$�$�-�-�/�����6����E������6�*�K�D��j�j�!6�!=�!=�d�!C�!#���/�G����X�w�/�Lrc��tjjjd�}d|d<d|d<d|d<d|d	<d
|d<d|d
<d|d<d|d<d|d<d|d<d|d
<t	j
t|jdtj��}|j|j�|jt�5|j|�ddd�|j�y#1swY�xYw)Nr�r*r+r�r,r-r.r/r0rFrGrHrIrJrKrLrMzThu, 2 Jan 1970 17:42:00 +0000r�r�)r"r#r$r%r/rwr@r1rr�r�rr[r\r&�rrr�s   r�#testSendMessageMultipleResentRaisesz8DebuggingServerTests.testSendMessageMultipleResentRaises�s����J�J�O�O�$�$�%5�6��!��&�	���$����$��T��%��;��-��+��-��A��+��,��,��;��-��)��+��C��-���|�|�D�$�)�)�K�$+�$<�$<�>������
�
�#�
�
�
�z�
*����a� �+��
�
��+�
*�s�C1�1C:)rrrsrt�maxDiffr2r4r�r�rEr�r�r�r�r�r�r�r�rrrrrrr(r7r=rArDrOrRrrrr�r��s����G��6=� A�
�� ������	��:�&:� :�"1�(3�2+�&/�,"0�H0�:*�>0�<#0�Jrr�c��eZdZd�Zd�Zd�Zy)�NonConnectingTestsc���tj�}|jtj|j�|jtj|j
d�y)Nztest msg)r/rwr[�SMTPServerDisconnectedr�rr�s  r�testNotConnectedz#NonConnectingTests.testNotConnected�sH��
�|�|�~�����'�8�8�$�)�)�D����'�8�8��)�)�Z�	1rc��|jttjdd�|jttjd�y)Nr��boguszlocalhost:bogus)r[r�r/rwrs r�testNonnumericPortz%NonConnectingTests.testNonnumericPort�s6�����'�7�<�<�%�w�	0����'�7�<�<�+�	-rc��tj�5}|j|j�ddd�y#1swYyxYwr)r/rwrOrRr�s  r�testSockAttributeExistsz*NonConnectingTests.testSockAttributeExists�s+���\�\�^�t����d�i�i�(��^�^�s	�:�AN)rrrsrtrXr[r]rrrrUrU�s��1�-�)rrUc��eZdZd�Zd�Zd�Zy)�DefaultArgumentsTestsc��t�|_d|jd<tj�|_td��|j_t�t�c|j_|j_y)N�Páolo <főo@bar.com>r+)���OK)�return_value)	rrr/rwr�rr��has_extnrrs rr2zDefaultArgumentsTests.setUp�sT���>���2�������L�L�N��	��;�7��	�	��15����.��	�	��D�I�I�.rc��d}|jj|j�|jj|j�|j|jjj
ddd|�|j|jjj
ddd|�y)N)�SMTPUTF8�
BODY=8BITMIMEr�r�r�r&rr6r�call_args_list)r�expected_mail_optionss  rr(z%DefaultArgumentsTests.testSendMessage�s��� =���	�	���t�x�x�(��	�	���t�x�x�(�������+�+�:�:�1�=�a�@��C�.�	0�������+�+�:�:�1�=�a�@��C�.�	0rc��dg}d}|jj|jdd|�|j|dg�|j|jjj
ddd|�y)N�STARTTLS)rnrgrhrrirj)r�mail_optionsrls   r�testSendMessageWithMailOptionsz4DefaultArgumentsTests.testSendMessageWithMailOptions�so��"�|�� I���	�	���t�x�x��t�\�B�����
�|�4�������+�+�:�:�1�=�a�@��C�.�	0rN)rrrsrtr2r(rprrrr_r_�s��@�0�0rr_c��eZdZd�Zd�Zd�Zy)�BadHELOServerTestsc���tt_tjd�tj
|_tj�|_	|jt_d|_
y)Ns199 no hello for you!r.)rr/r0r>r�r�r�r�r�r�r1rs rr2zBadHELOServerTests.setUp�sB��$������7�8��*�*����k�k�m����[�[��
���	rc�L�tt_|jt_yr)r0r/r�r�r�rs rr4zBadHELOServerTests.tearDown�s������_�_��
rc��|jtjtjt|j
dd�y�Nr�ri)r[r/�SMTPConnectErrorrwr@r1rs r�testFailingHELOz"BadHELOServerTests.testFailingHELO�s+�����'�2�2�G�L�L� �$�)�)�[�!�	=rN)rrrsrtr2r4rxrrrrrrr�s���%�=rrrc�N�eZdZddejzdzzdzZd�Zd�Zd�Zy)	�TooLongLineTestss250 OK�.rp�
c��tj�|_tj|_t
j�|_|jt_tj�|_tjtjtj�|_|jj!d�t#j$|j�|_|j|j(|jf}tj*t,|��|_|j.j1�|jj3�|jj5�y)N�r�)r	r�r�r�r�r�r�r�r�r�r�r r0�AF_INET�SOCK_STREAMrR�
settimeoutr�	bind_portr1�respdatar�r*r�r�r�r�)r�servargss  rr2zTooLongLineTests.setUps���*�:�:�<����*�*����k�k�m����[�[��
��?�?�$����M�M�&�.�.�&�2D�2D�E��	��	�	���R� �!�+�+�D�I�I�6��	��H�H�d�m�m�T�Y�Y�7���&�&�f�8�D������������
�
�������rc��|jj�|jt_tj|j�|`|j�tj|j�yr)r r�r�r�r�r	r�r�r�r�r�rs rr4zTooLongLineTests.tearDownsM�����
�
���_�_��
��$�$�T�[�[�1��K������*�*�D�O�O�<rc��|jtjtjt|j
dd�yrv)r[r/�SMTPResponseExceptionrwr@r1rs r�testLineTooLongz TooLongLineTests.testLineTooLongs+�����'�7�7������	�	�;��	;rN)	rrrsrtr/�_MAXLINEr�r2r4r�rrrrzrzs0���D�7�#3�#3�3�a�7�8�5�@�H�� =�;rrzzJohn AzSally BzRuth C)�Mr.A@somewhere.com�Ms.B@xn--fo-fka.com�Mrs.C@somewhereesle.com)r��somepasswordz<PENCeUxFREJoU0NnbmhNWitOMjNGNndAZWx3b29kLmlubm9zb2Z0LmNvbT4=r�r�r�)zlist-1zlist-2c��eZdZy)�ResponseExceptionN)rrrsrtrrrr�r�1s�rr�c����eZdZdZdZdZdZdZdZdZ	dZ
dZ�fd�Z�fd�Z
d�Zd�Zd�Zdd	�Zdd
�Zdd�Zdd�Zd
�Zd�Zd�Z�fd�Z�fd�Z�fd�Z�fd�Z�fd�Zd�Z�xZS)�SimSMTPChannelNr�cc���dj|D�cgc]}dj|���c}�|_tt|�|i|��ycc}w)N�z	250-{0}
)�joinr4�_extrafeaturesr�r��__init__)r�extra_featuresr��kw�xr�s     �rr�zSimSMTPChannel.__init__>sL��� �g�g�/=�?�~�!�m�"�"�1�%�~�?�A���
�n�d�,�d�9�b�9��
@s�A	c���|j|jk(rd|jj|j�}tdt
|�tj��g|_	|j|�yt�|�A�y#t$rE}|j|_|j|j�d|j���Yd}~yd}~wwxYw)NzData:)�file� )�
smtp_state�AUTH�_emptystringr��received_lines�print�reprrr��auth_objectr��COMMAND�push�	smtp_code�
smtp_errorr��found_terminator)r�liner(r�s   �rr�zSimSMTPChannel.found_terminatorDs�����?�?�d�i�i�'��$�$�)�)�$�*=�*=�>�D��'�4��:�E�,=�,=�>�"$�D��
A�� � ��&�
�
�� �"��	%�
A�"&�,�,����	�	�Q�[�[�!�,�,�?�@�@���
A�s�-B�	C�;C�Cc�t�|js|jd�y|jrd|jvr|jd�y|j�|jd�y|j�}t
|�dvr|jd�yd|dj�jd	d
�z}	t||�|_
|j|_|jt
|�dk(r
|d
�yd�y#t$r#|jdj|��YywxYw)Nz503 Error: send EHLO firstr�z(500 Error: command "AUTH" not recognizedz3503 Bad sequence of commands: already authenticated)rrpz/501 Syntax: AUTH <mechanism> [initial-response]z_auth_%sr�-�_zQ504 Command parameter not implemented: unsupported  authentication mechanism {!r}rpr)�
seen_greetingr��
extended_smtpr��authenticated_user�split�len�lower�replace�getattrr��AttributeErrorr4r�r�)r�argr��auth_object_names    r�	smtp_AUTHzSimSMTPChannel.smtp_AUTHRs���!�!��I�I�2�3���!�!�V�4�3F�3F�%F��I�I�@�A���"�"�.��I�I�E�
G���y�y�{���t�9�F�"��I�I�G�H��%��Q��
�
��(?�(?��S�(I�I��	�&�t�-=�>�D��
�)�)������C��I��N��a��=��=���	��I�I�7�7=�v�>N�7O�
Q��	�s�?D�)D7�6D7c�~�|r||_|jd�n|jd�|j|_y)Nz235 Authentication Succeededz&535 Authentication credentials invalid)r�r�r�r�)r�user�valids   r�_authenticatedzSimSMTPChannel._authenticatedks2���&*�D�#��I�I�4�5��I�I�>�?��,�,��rc�h�tj|jd��jd�S)Nr
�utf-8)�base64�decodebytes�encoder)r�strings  r�_decode_base64zSimSMTPChannel._decode_base64ss'���!�!�&�-�-��"8�9�@�@��I�Irc� �|�|jd�y|j|�}	|jd��^}}}|j||tdk(�y#t$r+}|jdj	||��Yd}~yd}~wwxYw)Nz334 ��=535 Splitting response {!r} into user and password failed: {}r)r�r�r�r\r4r��sim_auth)rr��logpassr�r��passwordr(s       r�_auth_plainzSimSMTPChannel._auth_plainvs����;��I�I�f���)�)�#�.�G�
�%,�]�]�4�%8�"��D�(�

����h�(�1�+�&=�>��	�
��	�	�(�(.��w��(:�<���
�s�A�	B
�"!B�B
c��|�|jd�yt|d�s(|j|�|_|jd�y|j|�}|j	|j|t
dk(�|`y)Nz334 VXNlcm5hbWU6�_auth_login_userz334 UGFzc3dvcmQ6r)r�r�r�r�r�r�)rr�r�s   r�_auth_loginzSimSMTPChannel._auth_login�st���;��I�I�(�)���1�2�$(�$7�$7��$<�D�!��I�I�(�)��*�*�3�/�H����� 5� 5�x�8�A�;�7N�O��%rc�&�|jd�y)Nz334 QnVHZ1liVWdHeQ==)r��rr�s  r�_auth_buggyzSimSMTPChannel._auth_buggy�s��	
�	�	�(�)rc���|�%|jdjt��y|j|�}	|j	�\}}t
jtdjd�|jt�jd�d�j�}|j|||k(�y#t
$r+}|jdj||��Yd}~yd}~wwxYw)Nz334 {}r�Frr
�md5)r�r4�sim_cram_md5_challenger�r�r\�hmac�HMACr�r��	hexdigestr�)rr�r�r��hashed_passr(�valid_hashed_passs       r�_auth_cram_md5zSimSMTPChannel._auth_cram_md5�s����;��I�I�h�o�o�&<�=�>��)�)�#�.�G�
�$+�M�M�O�!��k�
!%�	�	����"�"�7�+��#�#�$:�;�B�B�7�K��!�!�y�{�
�
����k�5F�&F�G���
��	�	�'�'-�v�g�q�'9�;���
�s�C�	C4�	!C/�/C4c�j�d}||jzdz}|j|�||_d|_y)NzH250-testhost
250-EXPN
250-SIZE 20000000
250-STARTTLS
250-DELIVERBY
z250 HELPT)r�r�r�r�)rr��resps   r�	smtp_EHLOzSimSMTPChannel.smtp_EHLO�s;��$��
�d�)�)�)�J�6���	�	�$�� ���!��rc��|tvr2|jdt|�dtj|����y|jd|z�y)N�250 r�z550 No such user: %s)�	sim_usersr�r/�	quoteaddrr�s  r�	smtp_VRFYzSimSMTPChannel.smtp_VRFY�s<���)���I�I�Y�s�^�W�5F�5F�s�5K�L�M��I�I�,�s�2�3rc�V�|j�}|tvr�t|}t|�D]h\}}tj|�}|t|�dz
kr|j
dt|�d|����K|j
dt|�d|����jy|j
d�y)Nrz250-r�r�z550 No access for you!)r��	sim_lists�	enumerater/r�r�r�r�)rr��	list_name�	user_listr%�
user_email�quoted_addrs       r�	smtp_EXPNzSimSMTPChannel.smtp_EXPN�s����I�I�K�	��	�!�!�)�,�I�!*�9�!5�
��:�%�/�/�
�;���s�9�~��)�)��I�I�Y�z�-B�K�P�Q��I�I�Y�z�-B�K�P�Q�"6�
�I�I�.�/rc���|j�tt|�|�y|j	|j�|j�yr)�
quit_responser�r��	smtp_QUITr��close_when_done�rr�r�s  �rr�zSimSMTPChannel.smtp_QUIT�s<������%��.�$�1�#�6��I�I�d�(�(�)�� � �"rc���|j�t�|�	|�y|j|j�|jr|j�yyr)�
mail_responser��	smtp_MAILr��
disconnectr�r�s  �rr�zSimSMTPChannel.smtp_MAIL�sF������%��G��c�"��I�I�d�(�(�)�����$�$�&�rc���|j�t�|�	|�y|xjdz
c_|j	|j|jdz
�y�Nr)�
rcpt_responser��	smtp_RCPT�
rcpt_countr�r�s  �rr�zSimSMTPChannel.smtp_RCPT�sM������%��G��c�"�����1����	�	�$�$�$�T�_�_�Q�%6�7�8rc�N��|xjdz
c_t�|�	|�yr�)�
rset_countr��	smtp_RSETr�s  �rr�zSimSMTPChannel.smtp_RSET�s������1���
���#�rc�t��|j�t�|�	|�y|j|j�yr)�
data_responser��	smtp_DATAr�r�s  �rr�zSimSMTPChannel.smtp_DATA�s.������%��G��c�"��I�I�d�(�(�)rc���rrrs r�handle_errorzSimSMTPChannel.handle_error����
rr)rrrsrtr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�s@rr�r�2s�����M��M��M��M��J��J��J�
�D���:�#�>�2'�J�?�&�*�
H�$	"�4�0�#�'�9��*�rr�c�.�eZdZeZd�Zd�Zd�Zd�Zd�Z	y)�
SimSMTPServerc�f�g|_i|_tjj|g|��i|��yr)�_extra_features�
_addressesr�
SMTPServerr��rr�r�s   rr�zSimSMTPServer.__init__�s/��!������
���!�!�$�4��4��4rc�b�|j|j||||j��|_y)Nr�)�
channel_classr�_decode_data�_SMTPchannel�rr#r$s   r�handle_acceptedzSimSMTPServer.handle_accepted�s2�� �.�.�� � �$��d��)�)�/�+��rc�@�||jd<||jd<y)N�from�tos)r)r�peer�mailfrom�rcpttos�datas     r�process_messagezSimSMTPServer.process_message�s��"*������!(�����rc�:�|jj|�yr)r�append)r�features  r�add_featurezSimSMTPServer.add_feature�s�����#�#�G�,rc���rrrs rrzSimSMTPServer.handle_error�rrN)
rrrsrtr�r
r�rrrrrrrrr�s ��"�M�5�
+�
)�-�rrc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ejdd
��d��Zejdd
��d��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�SMTPSimTestsc��tj�|_tj|_tjt_tj�|_	tj�|_
ttdfdd��|_
|jjj�d|_|j|j|jf}tj t"|��|_|j$j'�|jj)�|jj+�y�Nrr�Tr�rr�)r	r�r�r0r�r�rr�r�r�r�rr@r"r�r1r�r�r�r�r�r�r�s  rr2zSMTPSimTests.setUps���*�:�:�<���"�N�N���$�,�,���!���)��
�#�/�/�+���!�4��)�_�$�O��	��I�I�$�$�0�0�2�1�5��	��Y�Y��
�
�t���?�	��&�&�.>�Y�O���������	
�
�
�����
�
���rc�0�|jt_|jj	�|j
j
�tj|j�|`	|j�tj|j�yr�
r�r0r�r�rr�r�r	r�r�r�r�r�rs rr4zSMTPSimTests.tearDown�b���*�*����������
�
�����$�$�T�[�[�1��K������*�*�D�O�O�<rc��tjt|jdtj
��}|j
�yr�r�r�s  rr�zSMTPSimTests.testBasic$r�rc��tjt|jdtj
��}|j
|ji�dddddd�}|j�|j
|j|�|D]"}|j|j|���$|j|jd��|j�y)Nr�r�r��20000000)�expn�size�starttls�	deliverbyr�zunsupported-feature)
r/rwr@r1rr�r6�esmtp_featuresr��
assertTruere�assertFalser�)rr��expected_features�ks    r�testEHLOzSMTPSimTests.testEHLO*s����|�|�D�$�)�)�K�$+�$<�$<�>��	
����,�,�b�1�%'�%/�)+�*,�%'�	��	
�	�	������,�,�.?�@�"�A��O�O�D�M�M�!�,�-�#�������'<�=�>��	�	�rc	���tjt|jdtj
��}tj�D]L\}}dt|�dtj|���d�f}|j|j|�|��Nd}dd|zjd�f}|j|j|�|�|j�y)	Nr�r�r�r�r
r��&zNo such user: %s)r/rwr@r1rr�r��items�bytesr�r6r�r�r�)rr��	addr_spec�name�expected_known�u�expected_unknowns       rr�zSMTPSimTests.testVRFY@s����|�|�D�$�)�)�K�$+�$<�$<�>�� )���0�O�I�t�!�5�*.��0A�0A�)�0L�*N�)0�$2�3�N�
���T�Y�Y�y�1�>�B�	 1�
!���"4�q�"8�!@�!@��!I�J��������1��'7�8��	�	�rc	��tjt|jdtj
��}tj�D]|\}}g}|D]2}|jt|�dtj|�����4dtdj|�d�f}|j|j|�|��~d}d}|j|j|�|�|j�y)	Nr�r�r�r�r�r
zPSU-Members-List)r1sNo access for you!)r/rwr@r1rr�r�r2rr�r�r3r�r6r&r�)	rr��listname�members�usersrr6r7r8s	         r�testEXPNzSMTPSimTests.testEXPNOs����|�|�D�$�)�)�K�$+�$<�$<�>��"+���!2��H�g��E������	�!��g�6G�6G��6J�K�L��!�5����5�)9�7�#C�D�N����T�Y�Y�x�0�.�A�"3�
��7��������1��'7�8��	�	�rc�(�|jjd�tjt|j
dtj��}|jtdtd�}|j|d�|j�y)N�
AUTH PLAINr�r�rr���sAuthentication Succeeded�r"rr/rwr@r1rr��loginr�r6r�rr�r�s   r�testAUTH_PLAINzSMTPSimTests.testAUTH_PLAIN_�g���	�	���l�+��|�|�D�$�)�)�K�$+�$<�$<�>���z�z�(�1�+�x��{�3������A�B��
�
�rc�(�|jjd�tjt|j
dtj��}|jtdtd�}|j|d�|j�y)N�
AUTH LOGINr�r�rrr@rBrDs   r�testAUTH_LOGINzSMTPSimTests.testAUTH_LOGINgrFrc�v�|jjd�tjt|j
dtj��5}t\|_	|_
|jd�|jd|jd��}|j|d�ddd�y#1swYyxYw)	NrHr�r��test_auth_login�LOGINT��initial_response_okr@�r"rr/rwr@r1rr�r�r�r�r��auth�
auth_loginr6rDs   r�"testAUTH_LOGIN_initial_response_okz/SMTPSimTests.testAUTH_LOGIN_initial_response_okos����	�	���l�+�
�\�\�$��	�	�+�")�":�":�<�?C�'/�$�D�I�t�}��I�I�'�(��9�9�W�d�o�o�4�9�P�D����T�#E�F�<�<�<��
�AB/�/B8c�v�|jjd�tjt|j
dtj��5}t\|_	|_
|jd�|jd|jd��}|j|d�ddd�y#1swYyxYw)	NrHr�r�rKrLFrMr@rOrDs   r�%testAUTH_LOGIN_initial_response_notokz2SMTPSimTests.testAUTH_LOGIN_initial_response_notokxs����	�	���l�+�
�\�\�$��	�	�+�")�":�":�<�?C�'/�$�D�I�t�}��I�I�'�(��9�9�W�d�o�o�5�9�Q�D����T�#E�F�<�<�<�rSc�����jjd�d
�fd�	}tjt�j
dtj��}	t\|_	|_
|jd�d}�jtj|�5}|jd|d�	�ddd�|j�y#1swY�xYw#|j�wxYw)Nz
AUTH BUGGYc�*���jd|�y)Ns
BuGgYbUgGyr�)r6)�	challengers �r�
auth_buggyz/SMTPSimTests.testAUTH_BUGGY.<locals>.auth_buggy�s������]�I�6�rr�r��test_auth_buggyz&^Server AUTH mechanism infinite loop.*�BUGGYFrMr)r"rr/rwr@r1rr�r�r�r�r��assertRaisesRegex�
SMTPExceptionrPr)rrYr��expect�cms`    r�testAUTH_BUGGYzSMTPSimTests.testAUTH_BUGGY�s�����	�	���l�+�	��|�|��$�)�)�K��,�,�
��	�'/�$�D�I�t�}��I�I�'�(�>�F��'�'��(=�(=�v�F�"��	�	�'�:�5�	�I�G�
�J�J�L�G�F��
�J�J�L�s%�AC�C
�4C�
C�C�C+r�T)�opensslc�(�|jjd�tjt|j
dtj��}|jtdtd�}|j|d�|j�y)Nz
AUTH CRAM-MD5r�r�rrr@rBrDs   r�testAUTH_CRAM_MD5zSMTPSimTests.testAUTH_CRAM_MD5�sg���	�	���o�.��|�|�D�$�)�)�K�$+�$<�$<�>���z�z�(�1�+�x��{�3������A�B��
�
�rc�(�|jjd�tjt|j
dtj��}|jtdtd�}|j|d�|j�y)NzAUTH BOGUS PLAIN LOGIN CRAM-MD5r�r�rrr@rBrDs   r�testAUTH_multiplezSMTPSimTests.testAUTH_multiple�sj��	
�	�	���?�@��|�|�D�$�)�)�K�$+�$<�$<�>���z�z�(�1�+�x��{�3������A�B��
�
�rc	��ddh}	tj�|jd�|D],}|jjdj
|���.|D]�}|j|��5tjt|jdtj��}|jd�td	td
c|_|_d|j%�j'dd
�z}|j)|t+||��}|j-|d�|j/�ddd���y#t$rY��$wxYw#1swY��xYw)N�PLAINrLzCRAM-MD5zAUTH {})�	mechanismr�r��foorr�auth_r�r�r@)�hashlibr��addr\r"rr4�subTestr/rwr@r1rr�r�r�r�r�r�r�rPr�r6r)r�	supportedrhr��methodr�s      r�test_auth_functionzSMTPSimTests.test_auth_function�s$���g�&�	�	&��K�K�M�
�M�M�*�%�"�I��I�I�!�!�)�"2�"2�9�"=�>�#�"�I����	��2��|�|�D�$�)�)�3>�,3�,D�,D�F���	�	�%� �+3�A�;����(��	�4�=� �9�?�?�#4�#<�#<�S�#�#F�F���y�y��G�D�&�,A�B��� � ��'I�J��
�
��3�2�#��
�	��	��3�2�s�E�3CE�	E�E�E	c�8�tjt|jdtj
��}|j
�\}}|j|d�|jd|j�|j�|jd|j�|jt|j�|jd|j�|j�|jd|j�|j�y)Nr�r�r�r')r/rwr@r1rr�r�r6r�r*r�rre�ehlo_or_helo_if_needed�rr��code�messages    r�test_quit_resets_greetingz&SMTPSimTests.test_quit_resets_greeting�s����|�|�D�$�)�)�+6�$+�$<�$<�>���	�	��
��g�����s�#��
�
�f�d�1�1�2��	�	�������!4�!4�5����T�4�9�9�%������!4�!4�5��#�#�%��
�
�f�d�1�1�2��	�	�rc��tjt|j�5}|j	�\}}|j|d�ddd�|j
tjjd�tjt|j�5}|j�ddd�|j
tj|jd�y#1swY��xYw#1swY�AxYw)Nr�sfoo)
r/rwr@r1r�r6r[rWrrrss    r�test_with_statementz SMTPSimTests.test_with_statement�s���
�\�\�$��	�	�
*�d� �I�I�K�M�D�'����T�3�'�+�	
���'�8�8�$�)�)�V�L�
�\�\�$��	�	�
*�d��J�J�L�+����'�8�8�$�)�)�V�L�
+�
*��+�
*�s�&C'�"C3�'C0�3C<c���|jtj�5}tjt|j
�5}|j
�d|jj_	ddd�ddd�|jjjd�|j|jjd�y#1swY�^xYw#1swY�bxYw)Nz421 QUIT FAILED�sQUIT FAILED)r[r/r�rwr@r1r�r"rr�r6r�r�r�)r�errorr�s   r� test_with_statement_QUIT_failurez-SMTPSimTests.test_with_statement_QUIT_failure�s���
�
�
�w�<�<�
=�����d�D�I�I�.�$��	�	��7H��	�	�&�&�4�/�>�	
������2�2�C�8�������3�3�^�D�	/�.��>�
=�s#�%C�,C�1C�C	�C�C#c��tjt|jdtj
��}|j
�d|jj_	d|jj_
|jtj�5|jddd�ddd�|j|j�y#1swY�%xYw)Nr�r�z451 Requested action abortedTr�r��test message)r/rwr@r1rr�r�r"rr�r�r[�SMTPSenderRefusedrrOrRr�s  r�test__rest_from_mail_cmdz%SMTPSimTests.test__rest_from_mail_cmd�s����|�|�D�$�)�)�K�$+�$<�$<�>���	�	��/M��	�	���,�,0��	�	���)�
�
�
�w�8�8�
9��M�M�&�'�>�:�:����$�)�)�$�:�
9�s�C�Cc���tjt|jdtj
��}|j
�d|jj_	|jtj�5|jddd�ddd�|j|j�|j|jjj d�y#1swY�UxYw)Nr�r�z421 closing connectionr�r�r~r)r/rwr@r1rr�r�r"rr�r[rrrOrRr6r�r�s  r�test_421_from_mail_cmdz#SMTPSimTests.test_421_from_mail_cmd�s����|�|�D�$�)�)�K�$+�$<�$<�>���	�	��/G��	�	���,�
�
�
�w�8�8�
9��M�M�&�'�>�:�:����$�)�)�$�������/�/�:�:�A�>�:�
9�s�C(�(C1c�F�tjt|jdtj
��}|j
�ddg|jj_	|jtj�5}|jdgd�d�ddd�|j|j�|j|jjj d�|j#j$j&dd	d
i�y#1swY��xYw)Nr�r�z250 accepted�421 closingr�)r��Frank�Georger~rr�)rzsclosing)r/rwr@r1rr�r�r"rr�r[�SMTPRecipientsRefusedrrOrRr6r��assertDictEqualr�r�)rr�r&s   r�test_421_from_rcpt_cmdz#SMTPSimTests.test_421_from_rcpt_cmd�s����|�|�D�$�)�)�K�$+�$<�$<�>���	�	��0>�
�/N��	�	���,�
�
�
�w�<�<�
=���M�M�&�">��O�>����$�)�)�$�������/�/�:�:�A�>����Q�[�[�-�-�a�0�7�<M�2N�O�	>�
=�s�D�D c���Gd�dt�}||j_tjt
|jdtj��}|j�|jtj�5|jddgd�ddd�|j|j�|j|jj j"d�y#1swY�UxYw)	Nc���eZdZ�fd�Z�xZS)�=SMTPSimTests.test_421_from_data_cmd.<locals>.MySimSMTPChannelc�x��|j|jk(r|jd�yt�|��y)Nr�)r��DATAr�r�r�)rr�s �rr�zNSMTPSimTests.test_421_from_data_cmd.<locals>.MySimSMTPChannel.found_terminators*����?�?�d�i�i�/��I�I�m�,��G�,�.r)rrrsrtr�r�r�s@r�MySimSMTPChannelr�s
���
/�
/rr�r�r�zJohn@foo.orgz
Sally@foo.orgr~r)r�r"r
r/rwr@r1rr�r�r[�
SMTPDataErrorrrOrRr6rr�)rr�r�s   r�test_421_from_data_cmdz#SMTPSimTests.test_421_from_data_cmds���	/�~�	/�#3��	�	���|�|�D�$�)�)�K�$+�$<�$<�>���	�	��
�
�
�w�4�4�
5��M�M�.�?�*;�^�L�6����$�)�)�$�������/�/�:�:�A�>�6�
5�s�C.�.C7c	��tjt|jdtj
��}|j
|j�|j�|j|j�|j|jd��|jtj|jdddddg�	�|jtj|j dddg�
�y)Nr�r��smtputf8r�r�r�rhrg�ro��options)r/rwr@r1rr�r�rr�r+�
does_esmtpr,rer[�SMTPNotSupportedErrorrrr�s  r�4test_smtputf8_NotSupportedError_if_no_server_supportzASMTPSimTests.test_smtputf8_NotSupportedError_if_no_server_supports����|�|��$�)�)�K��,�,�.��	
����
�
�#��	�	��������(�������z�2�3�����)�)��M�M��G�R��
�.K�	�	M�	
����)�)��I�I�v���'D�	�	Frc�,�tjt|jdtj
��}|j
|j�|jt|jddd�|jt|jd�y)Nr�r��AliceuBöbr�uÄlice)r/rwr@r1rr�r�rr[�UnicodeEncodeErrorrrr�s  r�"test_send_unicode_without_SMTPUTF8z/SMTPSimTests.test_send_unicode_without_SMTPUTF8"sh���|�|��$�)�)�K��,�,�.��	
����
�
�#����,�d�m�m�W�f�b�Q����,�d�i�i��Brc�`�t�}d|d<d|d<d|d<tjt|jdt
j��}|j|j�|jtj�5|j|�ddd�y#1swYyxYw)	Nrar+r;r,�Nudge nudge, wink, wink ὠ9�Subjectr�r�)rr/rwr@r1rr�r�rr[r�r&)rrr�s   r�9test_send_message_error_on_non_ascii_addrs_if_no_smtputf8zFSMTPSimTests.test_send_message_error_on_non_ascii_addrs_if_no_smtputf8*s����n��-��F����D�	�:��I���|�|��$�)�)�K��,�,�.��	
����
�
�#�
�
�
�w�<�<�
=����c�"�>�
=�
=�s�	B$�$B-c�(�tjt|jdtj
��}|j
|j�t�}tjjd�|d<tjjd�|d<|j|j|�i�|j|jj dd�|j|jj d	d
g�y)Nr�r�)uMichaël�michael@example.comr+)uRené�rene@example.comr,rr�rr�)r/rwr@r1rr�r�rrr"�utils�
formataddrr�r&r6r"r)rr�rus   r�1test_name_field_not_included_in_envelop_addressesz>SMTPSimTests.test_name_field_not_included_in_envelop_addresses8s����|�|��$�)�)�K��,�,�.��	
����
�
�#��.���+�+�0�0�1T�U�������.�.�/L�M���
����T�.�.�w�7��<�������-�-�f�5�7L�M�������-�-�e�4�7I�6J�KrN)rrrsrtr2r4r�r/r�r=rErIrRrUr`r�requires_hashdigestrcrerprvrxr|r�r�r�r�r�r�r�r�rrrrrs����$	=���,
�� ��G�G��((�^�'�'��t�<��=��(�^�'�'��t�<��=���,
�M�E�%�?�	P�?� F� C�#�
Lrrc�$�eZdZd�Zd�Z		dd�Zy)�SimSMTPUTF8Serverc�\�ddg|_tjj|g|��i|��y)Nrg�8BITMIME)rrrr�rs   rr�zSimSMTPUTF8Server.__init__Js/��!+�J�7���
���!�!�$�4��4��4rc�x�|j|j||||j|j��|_y)N�r��enable_SMTPUTF8)r
rrr�rr
s   rrz!SimSMTPUTF8Server.handle_acceptedQs;�� �.�.�� � �$��d��)�)� �0�0�/�
��rNc�X�||_||_||_||_||_||_yr)�	last_peer�
last_mailfrom�last_rcpttos�last_message�last_mail_options�last_rcpt_options)rrrrrro�rcpt_optionss       rrz!SimSMTPUTF8Server.process_messageXs1�����%���#��� ���!-���!-��r)NN)rrrsrtr�rrrrrr�r�Hs��5�
�KO�JN�.rr�c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)�SMTPUTF8SimTestsNc��tj�|_tj|_tjt_tj�|_	tj�|_
ttdfddd��|_
|jjj�d|_|j|j|jf}tj t"|��|_|j$j'�|jj)�|jj+�y)Nrr�FTr�rr�)r	r�r�r0r�r�rr�r�r�r�r�r@r"r�r1r�r�r�r�r�r�r�s  rr2zSMTPUTF8SimTests.setUpfs���*�:�:�<���"�N�N���$�,�,���!���)��
�#�/�/�+���%�t�Q�i��27�6:�<��	��I�I�$�$�0�0�2�1�5��	��Y�Y��
�
�t���?�	��&�&�.>�Y�O���������	
�
�
�����
�
���rc�0�|jt_|jj	�|j
j
�tj|j�|`	|j�tj|j�yrr!rs rr4zSMTPUTF8SimTests.tearDownzr"rc�:�tjt|jdtj
��}|j
|j�|j�|j|j�|j|jd��y)Nr�r�r�)r/rwr@r1rr�r�rr�r+r�rer�s  r�$test_test_server_supports_extensionsz5SMTPUTF8SimTests.test_test_server_supports_extensions�sd���|�|��$�)�)�K��,�,�.��	
����
�
�#��	�	��������(�����
�
�j�1�2rc��djd�}tjt|jdt
j��}|j|j�|jdd|ddg�	�|j|jjd�|j|jjdg�|j|jj|�|jd|jj �|jd|jj �|j|jj"g�y)
N�$¡a test message containing unicode!r�r�r�uJőhnuSállyrhrgr�)r�r/rwr@r1rr�r�rrr6r"r�r�r�r�r�r�rQs   r�,test_send_unicode_with_SMTPUTF8_via_sendmailz=SMTPUTF8SimTests.test_send_unicode_with_SMTPUTF8_via_sendmail�s��2�9�9�'�B���|�|��$�)�)�K��,�,�.��	
����
�
�#��
�
�g�x��$3�Z�#@�	�	B�������0�0�'�:�������/�/�(��<�������/�/��3��
�
�o�t�y�y�'B�'B�C��
�
�j�$�)�)�"=�"=�>�������4�4�b�9rc�~�djd�}tjt|jdt
j��}|j|j�|j�|j|jdddg��d	�|j|jd
�d	�|j|j|�d	�|j|jjd�|j|jj d
g�|j|jj"|�|j%d|jj&�|j%d|jj&�|j|jj(g�y)Nr�r�r�r�uJőrhrgr�r�uJános)r�r/rwr@r1rr�r�rr�r6r�rcptrr"r�r�r�r�r�r�rQs   r�1test_send_unicode_with_SMTPUTF8_via_low_level_APIzBSMTPUTF8SimTests.test_send_unicode_with_SMTPUTF8_via_low_level_API�sB��2�9�9�'�B���|�|��$�)�)�K��,�,�.��	
����
�
�#��	�	������I�I�e�o�z�%B�I�C��	�	
������8�,�l�;�������1��|�4�������0�0�%�8�������/�/�(��<�������/�/��3��
�
�o�t�y�y�'B�'B�C��
�
�j�$�)�)�"=�"=�>�������4�4�b�9rc�J�t�}d|d<d|d<d|d<|jd�tjd�}t	j
t|jd	tj�
�}|j|j�|j|j|�i�|j|jjd�|j|jj dg�|j|jj"j%�|�|j'd|jj(�|j'd
|jj(�|j|jj*g�y)Nrar+r;r,r�r�u1oh là là, know what I mean, know what I mean?

u<            From: Páolo <főo@bar.com>
            To: Dinsdale
            Subject: Nudge nudge, wink, wink ὠ9
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 8bit
            MIME-Version: 1.0

            oh là là, know what I mean, know what I mean?
            r�r�ufőo@bar.comrhrg)r�set_content�textwrap�dedentr/rwr@r1rr�r�rr6r&r"r�r�r�rr�r�r�)rrr9r�s    r�2test_send_message_uses_smtputf8_if_addrs_non_asciizCSMTPUTF8SimTests.test_send_message_uses_smtputf8_if_addrs_non_ascii�s<���n��-��F����D�	�:��I��	���M�N��?�?�	$�	���|�|��$�)�)�K��,�,�.��	
����
�
�#�����*�*�3�/��4�������0�0�.�A�������/�/�*��>�������/�/�6�6�8�(�C��
�
�o�t�y�y�'B�'B�C��
�
�j�$�)�)�"=�"=�>�������4�4�b�9r)
rrrsrtrSr2r4r�r�r�r�rrrr�r�bs%���G��(	=�3�
:�:�&:rr�spsudoesnotexistr�)�eolc��eZdZd�Zy)�!SimSMTPAUTHInitialResponseChannelc���|j�}|dj�dk(r,t|�dk(r|dtk(r|j	d�y|j	d�y)Nr�plainrprz235 Okz571 Bad authentication)r�r�r��EXPECTED_RESPONSEr�)rr�r�s   rr�z+SimSMTPAUTHInitialResponseChannel.smtp_AUTH�sW���y�y�{����7�=�=�?�g�%��4�y�A�~���7�/�/��I�I�h�'���	�	�*�+rN)rrrsrtr�rrrr�r��s��,rr�c��eZdZeZy)� SimSMTPAUTHInitialResponseServerN)rrrsrtr�r
rrrr�r��s��5�Mrr�c�$�eZdZd�Zd�Zd�Zd�Zy)�SMTPAUTHInitialResponseSimTestsc��tj�|_tj|_tjt_tj�|_	tj�|_
ttdfdd��|_
|jjj�d|_|j|j|jf}tj t"|��|_|j$j'�|jj)�|jj+�yr)r	r�r�r0r�r�rr�r�r�r�r�r@r"r�r1r�r�r�r�r�r�r�s  rr2z%SMTPAUTHInitialResponseSimTests.setUp�s���*�:�:�<���"�N�N���$�,�,���!���)��
�#�/�/�+���4�
�1�I��D�:��	��I�I�$�$�0�0�2�1�5��	��Y�Y��
�
�t���?�	��&�&�.>�Y�O���������	
�
�
�����
�
���rc�0�|jt_|jj	�|j
j
�tj|j�|`	|j�tj|j�yrr!rs rr4z(SMTPAUTHInitialResponseSimTests.tearDown�r"rc���|jjd�tjt|j
dtj��}|jdd�|j�y)Nr?r�r��psu�doesnotexist)
r"rr/rwr@r1rr�rCrr�s  r�%testAUTH_PLAIN_initial_response_loginzESMTPAUTHInitialResponseSimTests.testAUTH_PLAIN_initial_response_loginsL���	�	���l�+��|�|�D�$�)�)�K�$+�$<�$<�>���
�
�5�.�)��
�
�rc�B�|jjd�tjt|j
dtj��}d|_d|_	|jd|j�\}}|j�|j|d�y)Nr?r�r�r�r�r�rA)r"rr/rwr@r1rr�r�r�rP�
auth_plainrr6)rr�rt�responses    r�$testAUTH_PLAIN_initial_response_authzDSMTPAUTHInitialResponseSimTests.testAUTH_PLAIN_initial_response_authst���	�	���l�+��|�|�D�$�)�)�K�$+�$<�$<�>����	�&��
����7�D�O�O�<���h��
�
������s�#rN)rrrsrtr2r4r�r�rrrr�r��s���&	=��$rr��__main__)Er��email.mime.textr"�
email.messager�email.base64mimer�
encode_base64�email.utilsrkr�r0r/r�rfr�r�rr�r�r�r��testrr�test.supportrrr	r
r�
unittest.mockr�requires_working_socketr@�platformr�SMTPChannelr*r,�TestCaservryr�rrr�rUr_rrrzr�r�r�r��	Exceptionr�r�rrrr�r�r�r�r�r�rr�mainrrr�<module>r�s*��
��&�9����
��	�	�
��
�����%�'�&�)�!��� ����t�,������<�<�8��
�$/�E���!��,`6�`6�F�|�X�%6�%6��
/�|�X�%6�%6�/�,�>
6�	�
3��S�8�,�,�S�j)��*�*�)�60�H�-�-�0�8=��*�*�=�&;�x�(�(�;�@#+�#,�'/�
�	�
2��;��+�,E�F�,�.�
�	�
)�	�(�u�U�&�&�u�p�E�$�$��6@L�8�$�$�@L�F
.�
�.�4l:�x�(�(�l:�^"�"8�b�A��
,��
,�6�}�6�.$�h�&7�&7�.$�b�z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists