AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/mail/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/mail/test/__pycache__/test_mailmail.cpython-310.pyc
o

�bk2�@s�dZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZdd
lmZddlmZddlmZdd
lmZGdd�de�ZdS)zi
Tests for L{twisted.mail.scripts.mailmail}, the implementation of the
command line program I{mailmail}.
�N)�StringIO)�skipIf)�version)�Deferred)�smtp)�mailmail)�parseOptions)�Failure)�platformType)�
MemoryReactor)�TestCasec@s�eZdZdZe�Zdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zeedkd�dd��Zeedkd�dd��Zd d!�Zd"d#�Zd$d%�Zd&S)'�OptionsTestsz�
    Tests for L{parseOptions} which parses command line arguments and reads
    message text from stdin to produce an L{Options} instance which can be
    used to send a message.
    csft��_ddlm}m}|�j�}��td||d��d�_d�_d�_	�fdd�}��td|�dS)	zz
        Override some things in mailmail, so that we capture C{stdout},
        and do not call L{reactor.stop}.
        r)�Logger�textFileLogObserver�_log)�observerNcs.|�_|�_|�_tj||j|j|j�jd�S)N)�reactor)	�host�options�identr�sendmail�sender�to�body�
memoryReactor)rrr��self��A/usr/lib/python3/dist-packages/twisted/mail/test/test_mailmail.pyr3s�z$OptionsTests.setUp.<locals>.sendmailr)
r�out�twisted.loggerrr�patchrrrr)rrr�logObserverrrrr�setUp#s
zOptionsTests.setUpcCs2|�tdtd��|�ttg�}|�|jd�dS)z�
        If no recipients are given in the argument list and there is no
        recipient header in the message text, L{parseOptions} raises
        L{SystemExit} with a string describing the problem.
        �stdinzSubject: foo

Hello, goodbye.
)zNo recipients specified.N)r!�sysr�assertRaises�
SystemExitr�assertEqual�args�r�excrrr�test_unspecifiedRecipientsAsz'OptionsTests.test_unspecifiedRecipientscC�"|�ttdg�}|�|jd�dS)z�
        The I{-bp} option for listing queue information is unsupported and
        if it is passed to L{parseOptions}, L{SystemExit} is raised.
        z-bp�zUnsupported option.N�r&r'rr(r)r*rrr�test_listQueueInformationKsz&OptionsTests.test_listQueueInformationcCr-)z�
        The I{-bs} option for using stdin and stdout as the SMTP transport
        is unsupported and if it is passed to L{parseOptions}, L{SystemExit}
        is raised.
        z-bsr.Nr/r*rrr�test_stdioTransportS�z OptionsTests.test_stdioTransportcCs@|�ttdg�}|�|jd�|�ttdg�}|�|jd�dS)z�
        The I{-i} and I{-oi} options for ignoring C{"."} by itself on a line
        are unsupported and if either is passed to L{parseOptions},
        L{SystemExit} is raised.
        z-ir.z-oiNr/r*rrr�test_ignoreFullStop\sz OptionsTests.test_ignoreFullStopcCr-)z�
        The I{-om} option for copying the sender if they appear in an alias
        expansion is unsupported and if it is passed to L{parseOptions},
        L{SystemExit} is raised.
        z-omr.Nr/r*rrr�test_copyAliasedSendergr2z#OptionsTests.test_copyAliasedSendercCsPt�}|�td|�|�ttd�}|�|jd�|��}|�|dt	�d��dS)z~
        The I{--version} option displays the version and raises
        L{SystemExit} with L{None} as the exit code.
        �stdoutz	--versionNzmailmail version: �
)
rr!r%r&r'rr(�code�getvaluer)rr�systemExitCode�datarrr�test_versionpszOptionsTests.test_versioncC�.td�}|�td|�td�}|�|j�dS)zA
        The I{-odb} flag specifies background delivery.
        r6r$z-odbN)rr!r%r�
assertTrue�
background�rr$�orrr�test_backgroundDelivery}�z$OptionsTests.test_backgroundDeliverycCr<)zB
        The I{-odf} flags specifies foreground delivery.
        r6r$z-odfN)rr!r%r�assertFalser>r?rrr�test_foregroundDelivery�rBz$OptionsTests.test_foregroundDeliverycCs4td�}|�td|�td�}|�t|j�d�dS)zd
        The I{-t} flags specifies that recipients should be obtained
        from headers.
        zTo: Curly <invaliduser2@example.com>
Cc: Larry <invaliduser1@example.com>
Bcc: Moe <invaliduser3@example.com>

Oh, a wise guy?
r$�-t�N)rr!r%rr(�lenrr?rrr�test_recipientsFromHeaders�s�z'OptionsTests.test_recipientsFromHeaderscC�4td�}|�td|�tgd��}|�|jd�dS)zw
        When a message has no I{From:} header, a I{From:} value can be
        specified with the I{-F} flag.
        z3To: invaliduser2@example.com
Subject: A wise guy?

r$)�-F� Larry <invaliduser1@example.com>rErKN�rr!r%rr(rr?rrr�test_setFrom�szOptionsTests.test_setFromcCrI)z�
        The I{-F} flag specifies the From: value.  However, I{-F} flag is
        overriden by the value of From: in the e-mail header.
        zLTo: Curly <invaliduser4@example.com>
From: Shemp <invaliduser4@example.com>
r$)rJz"Groucho <invaliduser5@example.com>rEzinvaliduser4@example.comNrLr?rrr�!test_overrideFromFlagByFromHeader�s�z.OptionsTests.test_overrideFromFlagByFromHeader�win32zImailmail.run() does not work on win32 due to lack of support for getuid()cCstd}td�}|�td|�|�td|�t��|�|jjt���|�|jj	dg�|�
|jj�|�tj
�dS)z�
        Call L{mailmail.run}, and specify I{-oep} to print errors
        to stderr.  The sender, to, and printErrors options should be
        set and there should be no failure.
        �ztest_mailmail.py�invaliduser2@example.comz-oepr6�argvr$rQN)rr!r%r�runr(rr�getloginrr=�printErrors�assertIsNone�failed)rrRr$rrr�test_runErrorsToStderr�s
z#OptionsTests.test_runErrorsToStderrcCs�td�}|�td|�|��}t��}t��}t|d��}|�d�	||��Wd�n1s0wY|�t
d|�d}|�td|�t
��|�|j
��d	�|�|j
��d
�|�|j
��d�dS)z�
        Error messages for illegal UID value, illegal GID value, and illegal
        identity entry will be sent to stderr.
        r6r$�wa[useraccess]
allow=invaliduser2,invaliduser1
deny=invaliduser3,invaliduser4,{}
order=allow,deny
[groupaccess]
allow=invalidgid1,invalidgid2
deny=invalidgid1,invalidgid2,{}
order=deny,allow
[identity]
localhost=funny
[addresses]
smarthost=localhost
default_domain=example.com
N�	LOCAL_CFGrPrRz3Illegal UID in \[useraccess\] section: invaliduser1z3Illegal GID in \[groupaccess\] section: invalidgid1z,Illegal entry in \[identity\] section: funny)rr!r%�mktemp�os�getuid�getgid�open�write�formatrrS�assertRegexrr8)rr$�filename�myUid�myGid�frRrrr�test_readInvalidConfig�s4	����
�z#OptionsTests.test_readInvalidConfigcCsVddlm}|��}t|d��}|�|�Wd�||�S1s"wY||�S)a�
        Read a mailmail configuration file.

        The mailmail script checks the twisted.mail.scripts.mailmail.GLOBAL_CFG
        variable and then the twisted.mail.scripts.mailmail.LOCAL_CFG
        variable for the path to its  config file.

        @param config: path to config file
        @type config: L{str}

        @return: A parsed config.
        @rtype: L{twisted.mail.scripts.mailmail.Configuration}
        r)�
loadConfigrYN)�twisted.mail.scripts.mailmailrhr[r_r`)r�configrhrcrfrrr�getConfigFromFiles
��zOptionsTests.getConfigFromFilecCsN|�d�}|�|jd�|�d�}|�|jd�|�d�}|�|jd�|�|jd�|�d�}|�d|j�|�|jdd	d
g�|�d�}|�|jdg�|�d
�}|�|jddg�|�d�}|�|jddg�|�|jddg�|�d�}|�|jdg�|�d�}|�|j	dg�|�d�}|�|jddg�|�|j	ddg�dS)zj
        L{twisted.mail.scripts.mailmail.loadConfig}
        parses the config file for mailmail.
        z 
[addresses]
smarthost=localhost�	localhostz'
[addresses]
default_domain=example.comzexample.comz;
[addresses]
smarthost=localhost
default_domain=example.comz1
[identity]
host1=invalid
host2=username:password�host1�host2�username�passwordz+
[useraccess]
allow=invalid1,35
order=allow�#z#
[useraccess]
deny=35,36
order=deny�$z/
[useraccess]
allow=35,36
deny=37,38
order=deny�%�&z(
[groupaccess]
allow=gid1,41
order=allow�)z!
[groupaccess]
deny=41
order=denyz6
[groupaccess]
allow=41,42
deny=43,44
order=allow,deny�*�+�,N)
rkr(�	smarthost�domain�assertNotIn�
identities�	allowUIDs�denyUIDs�	allowGIDs�denyGIDs)rrjrrr�test_loadConfigsX����������zOptionsTests.test_loadConfigcsB�fdd�}��td|�t��}d|_tt��}t�||�dS)z�
        L{twisted.mail.scripts.mailmail.senderror} sends mail back to the
        sender if an error occurs while sending mail to the recipient.
        cs0��|d���|dg���|��d�t�S)Nzpostmaster@�
testsender�
ValueError)rbr(r8r)rr�	recipientrrrrr}sz-OptionsTests.test_senderror.<locals>.sendmailrr�N)r!rr�Optionsrr	r��	senderror)rr�opts�failrrr�test_senderrorws
zOptionsTests.test_senderrorN)�__name__�
__module__�__qualname__�__doc__rrr#r,r0r1r3r4r;rArDrHrMrNrr
rXrgrkr�r�rrrrr
s8
		
		

�
�
6Yr
)r�r\r%�ior�unittestr�twisted.copyrightr�twisted.internet.deferr�twisted.mailr�twisted.mail.scriptsrrir�twisted.python.failurer	�twisted.python.runtimer
�twisted.test.proto_helpersr�twisted.trial.unittestrr
rrrr�<module>s

Anon7 - 2022
AnonSec Team