HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/test_email/__pycache__/test_defect_handling.cpython-37.pyc
B

��g�.�@s�ddlZddlZddlZddlmZddlmZddlmZGdd�d�ZGdd�dee�Z	Gd	d
�d
ee�Z
Gdd�dee�Zed
kr�e�
�dS)�N)�policy)�errors)�
TestEmailBasec@s�eZdZejZdZejdd��Zdd�Z	dd�Z
e�d�Z
d	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) �TestDefectsBaseFccs
dVdS)N�)�self�defectrr�@/usr/local/lib/python3.7/test/test_email/test_defect_handling.py�_raise_pointszTestDefectsBase._raise_pointc	Cs�t�d�}|�tj��|�|�}WdQRX|jr6dS|�d�}|�t	|d��|�
t|�|��d�|�
|�|�dtj�dS)Na_            Subject: XX
            From: xx@xx.dk
            To: XX
            Mime-version: 1.0
            Content-type: multipart/mixed;
               boundary="MS_Mac_OE_3071477847_720252_MIME_Part"

            --MS_Mac_OE_3071477847_720252_MIME_Part
            Content-type: multipart/alternative;
               boundary="MS_Mac_OE_3071477847_720252_MIME_Part"

            --MS_Mac_OE_3071477847_720252_MIME_Part
            Content-type: text/plain; charset="ISO-8859-1"
            Content-transfer-encoding: quoted-printable

            text

            --MS_Mac_OE_3071477847_720252_MIME_Part
            Content-type: text/html; charset="ISO-8859-1"
            Content-transfer-encoding: quoted-printable

            <HTML></HTML>

            --MS_Mac_OE_3071477847_720252_MIME_Part--

            --MS_Mac_OE_3071477847_720252_MIME_Part
            Content-type: image/gif; name="xx.gif";
            Content-disposition: attachment
            Content-transfer-encoding: base64

            Some removed base64 encoded chars.

            --MS_Mac_OE_3071477847_720252_MIME_Part--

            r�defects�)�textwrap�dedentr
r�StartBoundaryNotFoundDefect�_str_msg�raise_expected�get_payload�
assertTrue�hasattr�assertEqual�len�get_defects�assertIsInstance)r�source�msg�innerrrr	�test_same_boundary_inner_outers#
z.TestDefectsBase.test_same_boundary_inner_outerc	Cs�t�d�}|�tj��|�|�}WdQRX|jr6dS|�|��t	�|�
t|�|��d�|�|�|�dtj�|�|�|�dtj
�dS)Na�            Date: Fri, 6 Apr 2001 09:23:06 -0800 (GMT-0800)
            From: foobar
            Subject: broken mail
            MIME-Version: 1.0
            Content-Type: multipart/report; report-type=delivery-status;

            --JAB03225.986577786/zinfandel.lacita.com

            One part

            --JAB03225.986577786/zinfandel.lacita.com
            Content-Type: message/delivery-status

            Header: Another part

            --JAB03225.986577786/zinfandel.lacita.com--
            �rr)r
rr
r�NoBoundaryInMultipartDefectrrrr�strrrr�!MultipartInvariantViolationDefect)rrrrrr	�test_multipart_no_boundaryAsz*TestDefectsBase.test_multipart_no_boundarya^        Date: Wed, 14 Nov 2007 12:56:23 GMT
        From: foo@bar.invalid
        To: foo@bar.invalid
        Subject: Content-Transfer-Encoding: base64 and multipart
        MIME-Version: 1.0
        Content-Type: multipart/mixed;
            boundary="===============3344438784458119861=="{}

        --===============3344438784458119861==
        Content-Type: text/plain

        Test message

        --===============3344438784458119861==
        Content-Type: application/octet-stream
        Content-Transfer-Encoding: base64

        YWJj

        --===============3344438784458119861==--
        c	Csf|�tj��|�|j�d��}WdQRX|jr4dS|�t|�	|��d�|�
|�	|�dtj�dS)Nz"
Content-Transfer-Encoding: base64rr)r
rZ-InvalidMultipartContentTransferEncodingDefectr�
multipart_msg�formatrrrrr)rrrrr	�test_multipart_invalid_cteus
z*TestDefectsBase.test_multipart_invalid_ctecCs6|jr
dS|�|j�d��}|�t|�|��d�dS)N�r)rrr"r#rrr)rrrrr	�test_multipart_no_cte_no_defect�sz/TestDefectsBase.test_multipart_no_cte_no_defectcCsN|jr
dSx>dD]6}|�|j�d|��}|�t|�|��dd|�qWdS)N)Z7bitZ8bitZBINaryz
Content-Transfer-Encoding: rzcte=)rrr"r#rrr)rZcterrrr	�"test_multipart_valid_cte_no_defect�s
z2TestDefectsBase.test_multipart_valid_cte_no_defectc	Cs�t�d�}|�tj��|�|�}WdQRX|jr6dS|�t|d��|�	t
|�|��d�|�|�|�dtj�|�|�|�dtj
�dS)Na            From: "Allison Dunlap" <xxx@example.com>
            To: yyy@example.com
            Subject: 64423
            Date: Sun, 11 Jul 2004 16:09:27 -0300
            MIME-Version: 1.0
            Content-Type: multipart/alternative;

            Blah blah blah
            rrrr)r
rr
rrrrrrrrrrr )rrrrrr	�test_lying_multipart�s	z$TestDefectsBase.test_lying_multipartc	Csxt�d�}|�tj��|�|�}WdQRX|jr6dS|�d��d�}|�t	|�
|��d�|�|�
|�dtj�dS)Na�            Content-Type: multipart/mixed; boundary="AAA"
            From: Mail Delivery Subsystem <xxx@example.com>
            To: yyy@example.com

            --AAA

            Stuff

            --AAA
            Content-Type: message/rfc822

            From: webmaster@python.org
            To: zzz@example.com
            Content-Type: multipart/mixed; boundary="BBB"

            --BBB--

            --AAA--

            rr)r
rr
rrrrrrrrr)rrZouterZbadrrr	�test_missing_start_boundary�s	z+TestDefectsBase.test_missing_start_boundaryc	Cs�|�tj��|�d�}WdQRX|jr,dS|�|��dg�|�|��d�|�t|�	|��d�|�
|�	|�tjg�|�|�	|�djd�dS)Nz Line 1
Subject: test

body�SubjectZbodyrrz Line 1
)r
rZ#FirstHeaderLineIsContinuationDefectrrr�keysrrr�assertDefectsEqual�line)rrrrr	�&test_first_line_is_continuation_header�s
z6TestDefectsBase.test_first_line_is_continuation_headerc	Csh|�tj��|�d�}WdQRX|jr,dS|�|��dg�|�|��d�|�|�	|�tjg�dS)Nz&Subject: test
not a header
To: abc

b
r*znot a header
To: abc

b
)
r
rZ MissingHeaderBodySeparatorDefectrrrr+rr,r)rrrrr	�"test_missing_header_body_separator�sz2TestDefectsBase.test_missing_header_body_separatorc	Csht�d�}|�|�}|�tj��|jdd�}WdQRX|jrBdS|�|d�|�	|�
|�tjg�dS)Nz�            Subject: test
            MIME-Version: 1.0
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: base64

            dmk
            T)�decodesvi)r
rrr
rZInvalidBase64PaddingDefectrrrr,r)rrr�payloadrrr	�"test_bad_padding_in_base64_payload�s
z2TestDefectsBase.test_bad_padding_in_base64_payloadc	Csht�d�}|�|�}|�tj��|jdd�}WdQRX|jrBdS|�|d�|�	|�
|�tjg�dS)Nz�            Subject: test
            MIME-Version: 1.0
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: base64

            dmk===
            T)r0svi)r
rrr
rZInvalidBase64CharactersDefectrrrr,r)rrrr1rrr	�$test_invalid_chars_in_base64_payload�s
z4TestDefectsBase.test_invalid_chars_in_base64_payloadc	Csht�d�}|�|�}|�tj��|jdd�}WdQRX|jrBdS|�|d�|�	|�
|�tjg�dS)Nz�            Subject: test
            MIME-Version: 1.0
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: base64

            abcde
            T)r0sabcde)r
rrr
rZInvalidBase64LengthDefectrrrr,r)rrrr1rrr	�%test_invalid_length_of_base64_payloads
z5TestDefectsBase.test_invalid_length_of_base64_payloadc	Cszt�d�}|�tj��|�|�}WdQRX|jr6dS|�t|�	��d�|�|�	d��	�d�|�
|�|�tjg�dS)Na?            To: 1@harrydomain4.com
            Subject: Fwd: 1
            MIME-Version: 1.0
            Content-Type: multipart/alternative;
             boundary="------------000101020201080900040301"

            --------------000101020201080900040301
            Content-Type: text/plain; charset=ISO-8859-1
            Content-Transfer-Encoding: 7bit

            Alternative 1

            --------------000101020201080900040301
            Content-Type: text/html; charset=ISO-8859-1
            Content-Transfer-Encoding: 7bit

            Alternative 2

            rrzAlternative 2
)r
rr
rZCloseBoundaryNotFoundDefectrrrrrr,r)rrrrrr	�test_missing_ending_boundarysz,TestDefectsBase.test_missing_ending_boundaryN)�__name__�
__module__�__qualname__r�defaultr�
contextlib�contextmanagerr
rr!r
rr"r$r&r'r(r)r.r/r2r3r4r5rrrr	r	s$/&
rc@seZdZdd�ZdS)�TestDefectDetectioncCs|jS)N)r)r�objrrr	r2szTestDefectDetection.get_defectsN)r6r7r8rrrrr	r<0sr<c@s.eZdZGdd�dej�Zdd�Zdd�ZdS)�TestDefectCapturec@seZdZdZdd�ZdS)zTestDefectCapture.CapturePolicyNcCs|j�|�dS)N)�captured�append)rr=rrrr	�register_defect:sz/TestDefectCapture.CapturePolicy.register_defect)r6r7r8r?rArrrr	�
CapturePolicy8srBcCs|jt�d�|_dS)N)r?)rB�listr)rrrr	�setUp=szTestDefectCapture.setUpcCs|jjS)N)rr?)rr=rrr	r@szTestDefectCapture.get_defectsN)r6r7r8rZEmailPolicyrBrDrrrrr	r>6sr>c@s0eZdZejZejdd�ZdZejdd��Z	dS)�TestDefectRaisingT)Zraise_on_defectc	cs |�|��dVWdQRXdS)N)ZassertRaises)rrrrr	r
JszTestDefectRaising._raise_pointN)
r6r7r8rrZclonerr:r;r
rrrr	rEDsrE�__main__)r
Zunittestr:ZemailrrZtest.test_emailrrr<r>rEr6�mainrrrr	�<module>s)