Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_smtpd.cpython-39.pyc

a

XC?hK��@sxddlZddlZddlmZmZddlmZddlZddlZddl	Z	ddl
Z
Gdd�de	j�ZGdd�de
�ZGdd	�d	e�ZGd
d�dej�ZGdd
�d
ej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Ze�ejd�Gdd�de��ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd �d ej�ZGd!d"�d"ej�Zed#k�rte� �dS)$�N)�support�mock_socket)�
socket_helperc@seZdZdd�Zdd�ZdS)�DummyServercOs8tjj|g|�Ri|��g|_|jr.d|_nd|_dS)Nz
return statuss
return status)�smtpd�
SMTPServer�__init__�messagesZ_decode_data�
return_status)�self�args�kwargs�r�4/opt/alt/python39/lib64/python3.9/test/test_smtpd.pyrs
zDummyServer.__init__cKs>|j�||||f�||jkr"dSd|vr:d|dvr:dSdS)Nz	250 OkishZmail_optionsZSMTPUTF8z250 SMTPUTF8 message okish)r	�appendr
)rZpeer�mailfromZrcpttos�data�kwrrr�process_messages

zDummyServer.process_messageN)�__name__�
__module__�__qualname__rrrrrrrsrc@seZdZdS)�DummyDispatcherBrokenN)rrrrrrrrsrc@seZdZdd�ZdS)�BrokenDummyServercCs
t��dS�N)r)rZnumrrr�listen!szBrokenDummyServer.listenN)rrrrrrrrr src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�SMTPDServerTestcCstt_t_dSr�rr�socket�asyncore�rrrr�setUp&szSMTPDServerTest.setUpcsrtjtjdfddd�}|��\}}tj|||dd���fdd�}|d�|d�|d	�|d
�|�t|d�dS)Nr��brT��decode_datacs�j�|����dSr�r�
queue_recv�handle_read��line��channelrr�
write_line/szFSMTPDServerTest.test_process_message_unimplemented.<locals>.write_line�HELO example�MAIL From:eggs@example�RCPT To:spam@example�DATAs	spam
.
)rrr�HOST�accept�SMTPChannel�assertRaises�NotImplementedError)r�server�conn�addrr-rr+r�"test_process_message_unimplemented)s�z2SMTPDServerTest.test_process_message_unimplementedcCs"|jttjtjdfdddd�dS)Nrr"T��enable_SMTPUTF8r%)r5�
ValueErrorrrrr2r rrr�+test_decode_data_and_enable_SMTPUTF8_raises9s�z;SMTPDServerTest.test_decode_data_and_enable_SMTPUTF8_raisescCst��tt_t_dSr�r�	close_allrrr rrr�tearDownBszSMTPDServerTest.tearDownN)rrrr!r:r>rArrrrr%s	rc@sFeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�DebuggingServerTestcCstt_t_dSrrr rrrr!IszDebuggingServerTest.setUpFcsN�fdd�}|d�|r"|d�n|d�|d�|d�||�|d�dS)	Ncs�j�|����dSrr&r)r+rrr-Msz1DebuggingServerTest.send_data.<locals>.write_line�EHLO examples-MAIL From:eggs@example BODY=8BITMIME SMTPUTF8r/r0r1�.r)rr,rr<r-rr+r�	send_dataLs
zDebuggingServerTest.send_datacCs�tjtjdfddd�}|��\}}tj|||dd�}t���}|�|d�Wd�n1s^0Y|�	�}|�
|t�d��dS)Nrr"Tr$sFrom: test

hello
z�             ---------- MESSAGE FOLLOWS ----------
             From: test
             X-Peer: peer-address

             hello
             ------------ END MESSAGE ------------
             �
rZDebuggingServerrr2r3r4rZcaptured_stdoutrE�getvalue�assertEqual�textwrap�dedent�rr7r8r9r,�s�stdoutrrr�*test_process_message_with_decode_data_trueZs�
*z>DebuggingServerTest.test_process_message_with_decode_data_truecCs~t�tjdfd�}|��\}}t�|||�}t���}|�|d�Wd�n1sV0Y|�	�}|�
|t�d��dS)Nrr"�From: test

héllo�
��             ---------- MESSAGE FOLLOWS ----------
             b'From: test'
             b'X-Peer: peer-address'
             b''
             b'h\xc3\xa9llo\xff'
             ------------ END MESSAGE ------------
             rFrKrrr�+test_process_message_with_decode_data_falseks
*z?DebuggingServerTest.test_process_message_with_decode_data_falsecCs�tjtjdfddd�}|��\}}tj|||dd�}t���}|�|d�Wd�n1s^0Y|�	�}|�
|t�d��dS)Nrr"T�r<rOrPrFrKrrr�.test_process_message_with_enable_SMTPUTF8_true{s�
*zBDebuggingServerTest.test_process_message_with_enable_SMTPUTF8_truecCs�tjtjdfddd�}|��\}}tj|||dd�}t��� }|j|ddd�Wd�n1sb0Y|�	�}|�
|t�d��dS)Nrr"TrRrOa             ---------- MESSAGE FOLLOWS ----------
             mail options: ['BODY=8BITMIME', 'SMTPUTF8']
             b'From: test'
             b'X-Peer: peer-address'
             b''
             b'h\xc3\xa9llo\xff'
             ------------ END MESSAGE ------------
             rFrKrrr�7test_process_SMTPUTF8_message_with_enable_SMTPUTF8_true�s�
�$zKDebuggingServerTest.test_process_SMTPUTF8_message_with_enable_SMTPUTF8_truecCst��tt_t_dSrr?r rrrrA�szDebuggingServerTest.tearDownN)F)
rrrr!rErNrQrSrTrArrrrrBGs
rBc@s:eZdZdd�Zdd�Ze�ejd�dd��Z	dd	�Z
d
S)�TestFamilyDetectioncCstt_t_dSrrr rrrr!�szTestFamilyDetection.setUpcCst��tt_t_dSrr?r rrrrA�szTestFamilyDetection.tearDown�IPv6 not enabledcCs.t�tjdftjdf�}|�|jjtj�dS�Nr)	rrr�HOSTv6�HOSTv4rHr�familyZAF_INET6�rr7rrr�test_socket_uses_IPv6�sz)TestFamilyDetection.test_socket_uses_IPv6cCs.t�tjdftjdf�}|�|jjtj�dSrW)	rrrrYrXrHrrZZAF_INETr[rrr�test_socket_uses_IPv4�sz)TestFamilyDetection.test_socket_uses_IPv4N)rrrr!rA�unittest�
skipUnlessr�IPV6_ENABLEDr\r]rrrrrU�s

rUc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�TestRcptOptionParsing�:555 RCPT TO parameters not recognized or not implemented
cCs(tt_t_tj|_t��|_t_dSr�	rrrr�DEBUGSTREAM�old_debugstream�io�StringIO�debugr rrrr!�szTestRcptOptionParsing.setUpcCs t��tt_t_|jt_dSr�rr@rrrerdr rrrrA�szTestRcptOptionParsing.tearDowncCs|j�|�|��dSrr&�rr,r*rrrr-�sz TestRcptOptionParsing.write_linecCsdttjdfd�}|��\}}t�|||�}|�|d�|�|d�|�|d�|�|jj	|j
�dS)Nrr"rC�$MAIL from: <foo@example.com> size=20s"RCPT to: <foo@example.com> foo=bar�rrr2r3rr4r-rHr�last�error_response�rr7r8r9r,rrr�test_params_rejected�sz*TestRcptOptionParsing.test_params_rejectedcCsbttjdfd�}|��\}}t�|||�}|�|d�|�|d�|�|d�|�|jj	d�dS)Nrr"rCrksRCPT to: <foo@example.com>�250 OK
�
rrr2r3rr4r-rHrrmrorrr�test_nothing_accepted�sz+TestRcptOptionParsing.test_nothing_acceptedN)	rrrrnr!rAr-rprsrrrrra�s	rac@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�TestMailOptionParsing�<555 MAIL FROM parameters not recognized or not implemented
cCs(tt_t_tj|_t��|_t_dSrrcr rrrr!�szTestMailOptionParsing.setUpcCs t��tt_t_|jt_dSrrir rrrrA�szTestMailOptionParsing.tearDowncCs|j�|�|��dSrr&rjrrrr-�sz TestMailOptionParsing.write_linecCs�ttjdfddd�}|��\}}tj|||dd�}|�|d�dD]"}|�||�|�|jj	|j
�qB|�|d�|�|jj	d�dS)	Nrr"Tr$rC)�-MAIL from: <foo@example.com> size=20 SMTPUTF8�;MAIL from: <foo@example.com> size=20 SMTPUTF8 BODY=8BITMIMEs1MAIL from: <foo@example.com> size=20 BODY=UNKNOWN�2MAIL from: <foo@example.com> size=20 body=8bitmimerkrqrl�rr7r8r9r,r*rrr�test_with_decode_data_true�sz0TestMailOptionParsing.test_with_decode_data_truecCs�ttjdfd�}|��\}}t�|||�}|�|d�dD]"}|�||�|�|jj	|j
�q:|�|d�|�|jj	d�|�|d�|�|jj	d�dS)	Nrr"rC)rvrws:MAIL from: <foo@example.com> size=20 SMTPUTF8 BODY=UNKNOWNs3501 Error: BODY can only be one of 7BIT, 8BITMIME
rxrqrlryrrr�test_with_decode_data_false�s&���z1TestMailOptionParsing.test_with_decode_data_falsecCs^ttjdfddd�}|��\}}tj|||dd�}|�|d�|�|d�|�|jj	d�dS)Nrr"TrRrCs;MAIL from: <foo@example.com> size=20 body=8bitmime smtputf8rqrrrorrr�test_with_enable_smtputf8_trues�z4TestMailOptionParsing.test_with_enable_smtputf8_trueN)
rrrrnr!rAr-rzr{r|rrrrrt�srtc@s$eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:dqdr�Z;dsdt�Z<dudv�Z=dwdx�Z>dydz�Z?d{d|�Z@d}d~�ZAdd��ZBd�d��ZCd�d��ZDd�d��ZEd�S)��SMTPDChannelTestcCsbtt_t_tj|_t��|_t_t	t
jdfddd�|_|j�
�\}}tj|j||dd�|_dS�Nrr"Tr$�rrrrrdrerfrgrhrrr2r7r3r4r,�rr8r9rrrr!s��zSMTPDChannelTest.setUpcCs t��tt_t_|jt_dSrrir rrrrA(szSMTPDChannelTest.tearDowncCs|jj�|�|j��dSr�r,rr'r(�rr*rrrr--szSMTPDChannelTest.write_linecCs|jtttjdfddd�dSr~)r5rrrr2r rrr�test_broken_connect1s�z$SMTPDChannelTest.test_broken_connectc	Cs(|jttj|j|jj|jjddd�dS)NTr;)r5r=rr4r7r,r8r9r rrrr>6s
�z<SMTPDChannelTest.test_decode_data_and_enable_SMTPUTF8_raisescCs|j��dSr)r7Z
handle_acceptr rrr�test_server_accept<sz#SMTPDChannelTest.test_server_acceptcCs |�d�|�|jjjd�dS)N�s500 Error: bad syntax
�r-rHr,rrmr rrr�test_missing_data?s
�z"SMTPDChannelTest.test_missing_datacCs |�d�|�|jjjd�dS)NrCs
250 HELP
r�r rrr�	test_EHLODs
zSMTPDChannelTest.test_EHLOcCs |�d�|�|jjjd�dS)NsEHLOs501 Syntax: EHLO hostname
r�r rrr�test_EHLO_bad_syntaxHs
�z%SMTPDChannelTest.test_EHLO_bad_syntaxcCs*|�d�|�d�|�|jjjd�dS)NrC�503 Duplicate HELO/EHLO
r�r rrr�test_EHLO_duplicateMs


�z$SMTPDChannelTest.test_EHLO_duplicatecCs*|�d�|�d�|�|jjjd�dS)NrCr.r�r�r rrr�test_EHLO_HELO_duplicateSs


�z)SMTPDChannelTest.test_EHLO_HELO_duplicatecCs6tj��}|�d�|�|jjjd�|��d��dS)Nr.z250 {}
�ascii)	rrZgetfqdnr-rHr,rm�format�encode)r�namerrr�	test_HELOYs


�zSMTPDChannelTest.test_HELOcCs*|�d�|�d�|�|jjjd�dS)Nr.rCr�r�r rrr�test_HELO_EHLO_duplicate_s


�z)SMTPDChannelTest.test_HELO_EHLO_duplicatecCs |�d�|�|jjjd�dS)NsHELPsF250 Supported commands: EHLO HELO MAIL RCPT DATA RSET NOOP QUIT VRFY
r�r rrr�	test_HELPes
�zSMTPDChannelTest.test_HELPcCs |�d�|�|jjjd�dS)Ns	HELP MAILs"250 Syntax: MAIL FROM: <address>
r�r rrr�test_HELP_commandks
�z"SMTPDChannelTest.test_HELP_commandcCs |�d�|�|jjjd�dS)Ns	HELP SPAMsF501 Supported commands: EHLO HELO MAIL RCPT DATA RSET NOOP QUIT VRFY
r�r rrr�test_HELP_command_unknownps
�z*SMTPDChannelTest.test_HELP_command_unknowncCs |�d�|�|jjjd�dS)NsHELOs501 Syntax: HELO hostname
r�r rrr�test_HELO_bad_syntaxvs
�z%SMTPDChannelTest.test_HELO_bad_syntaxcCs*|�d�|�d�|�|jjjd�dS)Nr.r�r�r rrr�test_HELO_duplicate{s


�z$SMTPDChannelTest.test_HELO_duplicatecCs0d|_|�d�|�d�|�|jjjd�dS)NFr.s%MAIL from:<foo@example.com> SIZE=1234�"501 Syntax: MAIL FROM: <address>
)Z
extended_smtpr-rHr,rrmr rrr�8test_HELO_parameter_rejected_when_extensions_not_enabled�s

�zISMTPDChannelTest.test_HELO_parameter_rejected_when_extensions_not_enabledcCs*|�d�|�d�|�|jjjd�dS)Nr.sMAIL from:   <foo@example.com>rqr�r rrr�"test_MAIL_allows_space_after_colon�s


�z3SMTPDChannelTest.test_MAIL_allows_space_after_coloncCs*|�d�|�d�|�|jjjd�dS)NrCs&MAIL from:   <foo@example.com> size=20rqr�r rrr�+test_extended_MAIL_allows_space_after_colon�s


�z<SMTPDChannelTest.test_extended_MAIL_allows_space_after_coloncCs |�d�|�|jjjd�dS)N�NOOPrqr�r rrr�	test_NOOP�s
zSMTPDChannelTest.test_NOOPcCs*|�d�|�d�|�|jjjd�dS)Nr.r�rqr�r rrr�test_HELO_NOOP�s

zSMTPDChannelTest.test_HELO_NOOPcCs |�d�|�|jjjd�dS)NsNOOP his501 Syntax: NOOP
r�r rrr�test_NOOP_bad_syntax�s
�z%SMTPDChannelTest.test_NOOP_bad_syntaxcCs |�d�|�|jjjd�dS)N�QUIT�	221 Bye
r�r rrr�	test_QUIT�s
zSMTPDChannelTest.test_QUITcCs*|�d�|�d�|�|jjjd�dS)Nr.r�r�r�r rrr�test_HELO_QUIT�s

zSMTPDChannelTest.test_HELO_QUITcCs |�d�|�|jjjd�dS)NsQUIT bye byer�r�r rrr�test_QUIT_arg_ignored�s
z&SMTPDChannelTest.test_QUIT_arg_ignoredcCs(d|j_|�d�|�|jjjd�dS)Nz	BAD STATEr.s451 Internal confusion
)r,Z
smtp_stater-rHrrmr rrr�test_bad_state�s

�zSMTPDChannelTest.test_bad_statecCs:|�d�|�dd|jjd�|�|jjjd�dS)Nr.sMAIL from: �as@example�500 Error: line too long
)r-r,�command_size_limitrHrrmr rrr�test_command_too_long�s

���z&SMTPDChannelTest.test_command_too_longcCsr|�d�|jjtd�}|�dd|d�|�|jjjd�|�dd|dd�|�|jjjd�dS)	NrCzMAIL from:<@example>�MAIL from:<r�s@example> SIZE=1234rq�r�)r-r,r��lenrHrrm�r�fill_lenrrr�*test_MAIL_command_limit_extended_with_SIZE�s 
��
���z;SMTPDChannelTest.test_MAIL_command_limit_extended_with_SIZEcCs2|�d�|�d�|�|jjjdd�d�dS)NrCs5MAIL from: <naive@example.com> BODY=8BITMIME SMTPUTF8r��5r�r rrr�-test_MAIL_command_rejects_SMTPUTF8_by_default�s

�z>SMTPDChannelTest.test_MAIL_command_rejects_SMTPUTF8_by_defaultcCs\d|j_|�d�|�d�|�d�|�d�|�d|jjd�|�|jjjd�dS)	N�r.r/r0r1�AsA
.�552 Error: Too much mail data
�r,Zdata_size_limitr-rHrrmr rrr�-test_data_longer_than_default_data_size_limit�s



��z>SMTPDChannelTest.test_data_longer_than_default_data_size_limitcCs*|�d�|�d�|�|jjjd�dS)NrCs!MAIL FROM:<eggs@example> SIZE=512rqr�r rrr�test_MAIL_size_parameter�s


�z)SMTPDChannelTest.test_MAIL_size_parametercCs*|�d�|�d�|�|jjjd�dS)NrCs%MAIL FROM:<eggs@example> SIZE=invalid�9501 Syntax: MAIL FROM: <address> [SP <mail-parameters>]
r�r rrr� test_MAIL_invalid_size_parameter�s


�z1SMTPDChannelTest.test_MAIL_invalid_size_parametercCsP|�d�|�d�|�|jjjd�|�d�|�d�|�|jjjd�dS)NrCs"MAIL FROM:<eggs@example> ham=greenrusMAIL FROM:<eggs@example>s RCPT TO:<eggs@example> ham=greenrbr�r rrr�!test_MAIL_RCPT_unknown_parameters�s

�

�z2SMTPDChannelTest.test_MAIL_RCPT_unknown_parameterscCs2d|j_|�d�|�d�|�|jjjd�dS)Nr�rCs"MAIL FROM:<eggs@example> SIZE=2096s<552 Error: message size exceeds fixed maximum message size
r�r rrr�<test_MAIL_size_parameter_larger_than_default_data_size_limit�s

�zMSMTPDChannelTest.test_MAIL_size_parameter_larger_than_default_data_size_limitcCs*|�d�|�d�|�|jjjd�dS)Nr.sRCPT to:spam@examples503 Error: need MAIL command
r�r rrr�test_need_MAIL�s


�zSMTPDChannelTest.test_need_MAILcCs*|�d�|�d�|�|jjjd�dS)Nr.�MAIL from eggs@exampler�r�r rrr�test_MAIL_syntax_HELOs


�z&SMTPDChannelTest.test_MAIL_syntax_HELOcCs*|�d�|�d�|�|jjjd�dS)NrCr�r�r�r rrr�test_MAIL_syntax_EHLOs


�z&SMTPDChannelTest.test_MAIL_syntax_EHLOcCs*|�d�|�d�|�|jjjd�dS)Nr.s
MAIL from:r�r�r rrr�test_MAIL_missing_address
s


�z*SMTPDChannelTest.test_MAIL_missing_addresscCs*|�d�|�d�|�|jjjd�dS)Nr.sMAIL from:<eggs@example>rqr�r rrr�test_MAIL_chevronss

z#SMTPDChannelTest.test_MAIL_chevronscCs*|�d�|�d�|�|jjjd�dS)NrCsMAIL from:<>rqr�r rrr�test_MAIL_empty_chevronss

z)SMTPDChannelTest.test_MAIL_empty_chevronscCs:|�d�|�d�|�|jjjd�|�|jjd�dS)NrCs%MAIL from: <"Fred Blogs"@example.com>rq�"Fred Blogs"@example.com�r-rHr,rrmrr rrr�test_MAIL_quoted_localparts

z+SMTPDChannelTest.test_MAIL_quoted_localpartcCs:|�d�|�d�|�|jjjd�|�|jjd�dS)NrCs#MAIL from: "Fred Blogs"@example.comrqr�r�r rrr�$test_MAIL_quoted_localpart_no_angles#s

z5SMTPDChannelTest.test_MAIL_quoted_localpart_no_anglescCs:|�d�|�d�|�|jjjd�|�|jjd�dS)NrCs/MAIL from: <"Fred Blogs"@example.com> SIZE=1000rqr�r�r rrr�$test_MAIL_quoted_localpart_with_size)s

z5SMTPDChannelTest.test_MAIL_quoted_localpart_with_sizecCs:|�d�|�d�|�|jjjd�|�|jjd�dS)NrCs-MAIL from: "Fred Blogs"@example.com SIZE=1000rqr�r�r rrr�.test_MAIL_quoted_localpart_with_size_no_angles/s

z?SMTPDChannelTest.test_MAIL_quoted_localpart_with_size_no_anglescCs4|�d�|�d�|�d�|�|jjjd�dS)Nr.sMAIL from:eggs@examplesMAIL from:spam@examples 503 Error: nested MAIL command
r�r rrr�test_nested_MAIL5s


�z!SMTPDChannelTest.test_nested_MAILcCs |�d�|�|jjjd�dS)NsVRFY eggs@examplesD252 Cannot VRFY user, but will accept message and attempt delivery
r�r rrr�	test_VRFY<s
�zSMTPDChannelTest.test_VRFYcCs |�d�|�|jjjd�dS)NsVRFYs501 Syntax: VRFY <address>
r�r rrr�test_VRFY_syntaxBs
�z!SMTPDChannelTest.test_VRFY_syntaxcCs |�d�|�|jjjd�dS)NsEXPNs502 EXPN not implemented
r�r rrr�test_EXPN_not_implementedGs
�z*SMTPDChannelTest.test_EXPN_not_implementedcCs |�d�|�|jjjd�dS)NsMAIL from:<foo@example.com>�503 Error: send HELO first
r�r rrr�test_no_HELO_MAILLs
�z"SMTPDChannelTest.test_no_HELO_MAILcCs4|�d�|�d�|�d�|�|jjjd�dS)Nr.r/r1s503 Error: need RCPT command
r�r rrr�test_need_RCPTQs


�zSMTPDChannelTest.test_need_RCPTcCs4|�d�|�d�|�d�|�|jjjd�dS)Nr.�MAIL From: eggs@example�RCPT to eggs@examples 501 Syntax: RCPT TO: <address>
r�r rrr�test_RCPT_syntax_HELOXs


�z&SMTPDChannelTest.test_RCPT_syntax_HELOcCs4|�d�|�d�|�d�|�|jjjd�dS)NrCr�r�s7501 Syntax: RCPT TO: <address> [SP <mail-parameters>]
r�r rrr�test_RCPT_syntax_EHLO_s


�z&SMTPDChannelTest.test_RCPT_syntax_EHLOcCs4|�d�|�d�|�d�|�|jjjd�dS)Nr.r�sRCPT to: <eggs@example>rqr�r rrr�test_RCPT_lowercase_to_OKfs


z*SMTPDChannelTest.test_RCPT_lowercase_to_OKcCs |�d�|�|jjjd�dS)Nr�r�r�r rrr�test_no_HELO_RCPTls
�z"SMTPDChannelTest.test_no_HELO_RCPTcCs�|�d�|�d�|�|jjjd�|�d�|�|jjjd�|�d�|�|jjjd�|�d�|�|jjjd�|�|jjdd	d
gdfg�dS�Nr.r/rqr0r1�%354 End data with <CR><LF>.<CR><LF>
s
data
more
.�zpeer-addressz	peer-port�eggs@example�spam@examplez	data
more�r-rHr,rrmr7r	r rrr�test_data_dialogqs$



�

��z!SMTPDChannelTest.test_data_dialogcCs>|�d�|�d�|�d�|�d�|�|jjjd�dS)Nr.r/r0�	DATA spams501 Syntax: DATA
r�r rrr�test_DATA_syntax�s




z!SMTPDChannelTest.test_DATA_syntaxcCs |�d�|�|jjjd�dS)Nr�r�r�r rrr�test_no_HELO_DATA�s
�z"SMTPDChannelTest.test_no_HELO_DATAcCsF|�d�|�d�|�d�|�d�|�d�|�|jjd�dS)Nr.r/r0r1s..
.
�.�r-rHr,�
received_datar rrr�$test_data_transparency_section_4_5_2�s




z5SMTPDChannelTest.test_data_transparency_section_4_5_2cCs^|�d�|�d�|�d�|�d�|�d�|�d�|�|jjddd	d
gdfg�dS)Nr.r/r0sRCPT To:ham@exampler1�data
.r�r�r�zham@exampler)r-rHr7r	r rrr�test_multiple_RCPT�s






��z#SMTPDChannelTest.test_multiple_RCPTcCsH|�d�|�d�|�d�|�d�|�d�|�|jjjd�dS)Nr.r/r0r1sreturn status
.s250 Okish
r�r rrr�test_manual_status�s




z#SMTPDChannelTest.test_manual_statuscCs�|�d�|�d�|�d�|�d�|�|jjjd�|�d�|�d�|�d�|�d	�|�|jjd
ddgd
fg�dS)Nr.r/r0�RSETrqsMAIL From:foo@examplesRCPT To:eggs@exampler1r�r�zfoo@exampler�rr�r rrr�	test_RSET�s 








��zSMTPDChannelTest.test_RSETcCs*|�d�|�d�|�|jjjd�dS)Nr.r�rqr�r rrr�test_HELO_RSET�s

zSMTPDChannelTest.test_HELO_RSETcCs |�d�|�|jjjd�dS)NsRSET his501 Syntax: RSET
r�r rrr�test_RSET_syntax�s
z!SMTPDChannelTest.test_RSET_syntaxcCs |�d�|�|jjjd�dS)NsUNKNOWN_CMDs1500 Error: command "UNKNOWN_CMD" not recognized
r�r rrr�test_unknown_command�s
�z%SMTPDChannelTest.test_unknown_commandcCs�t�dtf��|jj}Wd�n1s,0Yt�dtf��d|j_Wd�n1sb0Yt�dtf��|jj}Wd�n1s�0Yt�dtf��d|j_Wd�n1s�0Yt�dtf��|jj}Wd�n1�s0Yt�dtf��d|j_Wd�n1�s>0Yt�dtf��|jj}Wd�n1�sv0Yt�dtf��d|j_Wd�n1�s�0Yt�dtf��|jj}Wd�n1�s�0Yt�dtf��d|j_Wd�n1�s0Yt�dtf��|jj	}Wd�n1�sV0Yt�dtf��d|j_	Wd�n1�s�0Yt�dtf��|jj
}Wd�n1�s�0Yt�dtf��d|j_
Wd�n1�s�0Yt�dtf��|jj}Wd�n1�s60Yt�dtf��d|j_Wd�n1�sn0Yt�dtf��|jj}Wd�n1�s�0Yt�dtf��d|j_Wd�n1�s�0Yt�dtf��|jj
}Wd�n1�s0Yt�dtf��d|j_
Wd�n1�sN0Yt�dtf��|jj}Wd�n1�s�0Yt�dtf��d|j_Wd�n1�s�0YdS)N��spam)rZcheck_warnings�DeprecationWarningr,Z_SMTPChannel__serverZ_SMTPChannel__lineZ_SMTPChannel__stateZ_SMTPChannel__greetingZ_SMTPChannel__mailfromZ_SMTPChannel__rcpttosZ_SMTPChannel__dataZ_SMTPChannel__fqdnZ_SMTPChannel__peerZ_SMTPChannel__connZ_SMTPChannel__addr)rr�rrr�test_attribute_deprecations�sX&&&&(((((((((((((((((z,SMTPDChannelTest.test_attribute_deprecationsN)Frrrr!rAr-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�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�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr}s�

	r}rVc@seZdZdd�ZdS)�SMTPDChannelIPv6TestcCsbtt_t_tj|_t��|_t_t	t
jdfddd�|_|j�
�\}}tj|j||dd�|_dSr~)rrrrrdrerfrgrhrrrXr7r3r4r,r�rrrr!�s��zSMTPDChannelIPv6Test.setUpN)rrrr!rrrrr��sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�!SMTPDChannelWithDataSizeLimitTestcCsdtt_t_tj|_t��|_t_t	t
jdfddd�|_|j�
�\}}tj|j||ddd�|_dS)Nrr"Tr$� rr�rrrr!s��z'SMTPDChannelWithDataSizeLimitTest.setUpcCs t��tt_t_|jt_dSrrir rrrrAsz*SMTPDChannelWithDataSizeLimitTest.tearDowncCs|jj�|�|j��dSrr�r�rrrr-sz,SMTPDChannelWithDataSizeLimitTest.write_linecCs�|�d�|�d�|�|jjjd�|�d�|�|jjjd�|�d�|�|jjjd�|�d�|�|jjjd�|�|jjdd	d
gdfg�dSr�r�r rrr�test_data_limit_dialogs$



�

��z8SMTPDChannelWithDataSizeLimitTest.test_data_limit_dialogcCs~|�d�|�d�|�|jjjd�|�d�|�|jjjd�|�d�|�|jjjd�|�d�|�|jjjd�dS)	Nr.r/rqr0r1r�s'This message is longer than 32 bytes
.r�r�r rrr�$test_data_limit_dialog_too_much_data.s



�
�zFSMTPDChannelWithDataSizeLimitTest.test_data_limit_dialog_too_much_dataN)rrrr!rAr-r�r�rrrrr�s
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SMTPDChannelWithDecodeDataFalsecCsZtt_t_tj|_t��|_t_t	t
jdfd�|_|j�
�\}}t�|j||�|_dS)Nrr"rr�rrrr!?sz%SMTPDChannelWithDecodeDataFalse.setUpcCs t��tt_t_|jt_dSrrir rrrrAGsz(SMTPDChannelWithDecodeDataFalse.tearDowncCs|jj�|�|j��dSrr�r�rrrr-Lsz*SMTPDChannelWithDecodeDataFalse.write_linecCsP|�d�|�d�|�d�|�d�|�d�|�d�|�|jjd�dS)Nr.r/r0r1�plain ascii textrDr�r rrr�test_ascii_dataPs





z/SMTPDChannelWithDecodeDataFalse.test_ascii_datacCsZ|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�|jjd�dS)	Nr.r/r0r1�utf8 enriched text: żźć�and some plain asciirDs/utf8 enriched text: żźć
and some plain asciir�r rrr�test_utf8_dataYs






�z.SMTPDChannelWithDecodeDataFalse.test_utf8_dataN�rrrr!rAr-r�r�rrrrr�=s
	r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SMTPDChannelWithDecodeDataTruecCsbtt_t_tj|_t��|_t_t	t
jdfddd�|_|j�
�\}}tj|j||dd�|_dSr~rr�rrrr!is��z$SMTPDChannelWithDecodeDataTrue.setUpcCs t��tt_t_|jt_dSrrir rrrrAtsz'SMTPDChannelWithDecodeDataTrue.tearDowncCs|jj�|�|j��dSrr�r�rrrr-ysz)SMTPDChannelWithDecodeDataTrue.write_linecCsP|�d�|�d�|�d�|�d�|�d�|�d�|�|jjd�dS)Nr.r/r0r1r�rDzplain ascii textr�r rrrr�}s





z.SMTPDChannelWithDecodeDataTrue.test_ascii_datacCsZ|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�|jjd�dS)	Nr.r/r0r1r�r�rDu/utf8 enriched text: żźć
and some plain asciir�r rrrr��s






�z-SMTPDChannelWithDecodeDataTrue.test_utf8_dataNr�rrrrr�gs
	r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�&SMTPDChannelTestWithEnableSMTPUTF8TruecCsbtt_t_tj|_t��|_t_t	t
jdfddd�|_|j�
�\}}tj|j||dd�|_dS)Nrr"TrRrr�rrrr!�s��z,SMTPDChannelTestWithEnableSMTPUTF8True.setUpcCs t��tt_t_|jt_dSrrir rrrrA�sz/SMTPDChannelTestWithEnableSMTPUTF8True.tearDowncCs|jj�|�|j��dSrr�r�rrrr-�sz1SMTPDChannelTestWithEnableSMTPUTF8True.write_linecCs0|�d�|�d�d��|�|jjjd�dS)NrCu7MAIL from: <naïve@example.com> BODY=8BITMIME SMTPUTF8�utf-8rq)r-r�rHr,rrmr rrr�1test_MAIL_command_accepts_SMTPUTF8_when_announced�s
��zXSMTPDChannelTestWithEnableSMTPUTF8True.test_MAIL_command_accepts_SMTPUTF8_when_announcedcCs�|�d�dD]�}|�d|�|�|jjjdd�d�|�d�|�|jjjdd�d�|�d�|�|jjjdd�d	�|�d
�|dkr�|�|jjjd�q|�|jjjd
�qdS)NrC)r�sBODY=8BITMIME SMTPUTF8sMAIL from: <a@example> r��250srcpt to:<b@example.com>�data�354sc
.r�rqs250 SMTPUTF8 message okish
r�)rZmail_parametersrrr�test_process_smtputf8_message�s



�zDSMTPDChannelTestWithEnableSMTPUTF8True.test_process_smtputf8_messagecCs�|�d�|�d�d��|�|jjjdd�d�|�d�d��|�|jjjdd�d�|�d�|�|jjjdd�d	�|�d
�|�d�|�|jjd
�dS)NrCu2MAIL From: naïve@examplé BODY=8BITMIME SMTPUTF8r�rrruRCPT To:späm@examplér1rr�rD)r-r�rHr,rrmr�r rrrr��s
�


�z5SMTPDChannelTestWithEnableSMTPUTF8True.test_utf8_datacCsn|�d�dtd�}|�dd|dd�|�|jjjd�|�dd|d�|�|jjjd	�dS)
N�ehlo example�$�mail from:<@example>r�r�r��	@example>r�rq�r-r�rHr,rrmr�rrr�7test_MAIL_command_limit_extended_with_SIZE_and_SMTPUTF8�s 

�����z^SMTPDChannelTestWithEnableSMTPUTF8True.test_MAIL_command_limit_extended_with_SIZE_and_SMTPUTF8cCs�|�d�dtd�}dD]�}|�d||d�|�|jjjdd�d	�|�d||d
�|�|jjjdd�d�|�d�|�|jjjdd�d�|�d
�|�|jjjdd�d�|�d�|�|jjjdd�d�qdS)Nrrr)r��b�cr�s
a@example>rrs500r	rsrcpt to:<hans@example.com>rrstest
.r
)rr��charrrr�1test_multiple_emails_with_extended_command_length�s



zXSMTPDChannelTestWithEnableSMTPUTF8True.test_multiple_emails_with_extended_command_lengthN)rrrr!rAr-rrr�rrrrrrr��s

r�c@seZdZdd�ZdS)�MiscTestCasecCshd�}tj|t|d�dS)N>	ZDATA_SIZE_DEFAULTZDevnullZOptionsZ
COMMASPACE�NEWLINEZprogramZusageZ	parseargsrd)�	blacklist)rZcheck__all__r)rrrrr�test__all__�szMiscTestCase.test__all__N)rrrrrrrrr�sr�__main__)!r^rI�testrrZtest.supportrrrfrrrr�	ExceptionrrZTestCaserrBrUrartr}r_r`r�r�r�r�r�rr�mainrrrr�<module>s8"]%B`7*,X