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_pop3client.cpython-310.pyc
o

�bTU�@s�ddlZddlZddlmZddlmZddlmZddlZ	ddl
mZmZm
Z
mZmZddlmZmZmZddlmZddlmZmZdd	lmZdd
lmZddlmZz
ddl m!Z!m"Z"Wn
e#ymdZ!dZ"YnwGd
d�de�Z$ddddddd�Z%d0dd�Z&dd�Z'Gdd�de�Z(Gdd�d�Z)Gdd�d�Z*Gdd�de�Z+Gdd �d e�Z,Gd!d"�d"e�Z-Gd#d$�d$e�Z.Gd%d&�d&�Z/Gd'd(�d(ej0�Z1ee!d)�ee
�2ed�d)�Gd*d+�d+e���Z3Gd,d-�d-e/e�Z4Gd.d/�d/e�Z5dS)1�N)�List)�skipIf)�directlyProvides)�defer�error�
interfaces�protocol�reactor)�AdvancedPOP3Client� InsecureAuthenticationDisallowed�ServerErrorResponse)�pop3testserver)�basic�loopback)�log)�StringTransport)�TestCase)�ClientTLSContext�ServerTLSContextc@�eZdZdd�ZdS)�#StringTransportWithConnectionLosingcCs|j�t���dS�N)r�connectionLostr�ConnectionDone��self�r�C/usr/lib/python3/dist-packages/twisted/mail/test/test_pop3client.py�loseConnection!�z2StringTransportWithConnectionLosing.loseConnectionN)�__name__�
__module__�__qualname__rrrrrr �rs180sLOGIN)sTOPsLOGIN-DELAYsUIDL�STLSsUSERsSASLTcCs8t�}t|_t�}||_|�|�|r|�d�||fS)Ns+OK Hello!
)�
POP3Client�capCache�	_capCacherr�makeConnection�dataReceived)�greet�p�trrr�setUp/s

r-cCs|fdd�S)NcSs|�Srr)�result�frrr�<lambda>Aszstrip.<locals>.<lambda>r)r/rrr�strip@sr1c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�POP3ClientLoginTestscsDtdd�\}}d|_|�dd�}|�d���|t���fdd��S)	NF�r*T�username�passwords-ERR Offline for maintenance
c���|jdd�S)NrsOffline for maintenance��assertEqual�args��excrrrr0K�z;POP3ClientLoginTests.testNegativeGreeting.<locals>.<lambda>)r-�allowInsecureLogin�loginr)�
assertFailurer�addCallback�rr+r,�drrr�testNegativeGreetingEs

�z)POP3ClientLoginTests.testNegativeGreetingcC�<t�\}}|�d�}|�|��d�|�d�|�|jd�S)Nr4�USER username
s+OK send password
s
send password)r-�userr8�valuer)r@rArrr�
testOkUserN�



zPOP3ClientLoginTests.testOkUserc�Ht�\}}|�d�}��|��d�|�d���|t���fdd��S)Nr4rEs-ERR account suspended
cr6)Nrsaccount suspendedr7r:rrrr0[r<z2POP3ClientLoginTests.testBadUser.<locals>.<lambda>)r-rFr8rGr)r?rr@rArrr�testBadUserU�



�z POP3ClientLoginTests.testBadUsercCrD)Nr5�PASS password
s+OK you're in!
s
you're in!)r-�passwordr8rGr)r@rArrr�
testOkPass^rIzPOP3ClientLoginTests.testOkPasscrJ)Nr5rMs-ERR go away
cr6)Nrsgo awayr7r:rrrr0kr<z2POP3ClientLoginTests.testBadPass.<locals>.<lambda>)r-rNr8rGr)r?rr@rArrr�testBadPasserLz POP3ClientLoginTests.testBadPasscCs^t�\}}d|_|�dd�}|�|��d�|�d�|�|��d�|�d�|�|jd�S)	NTr4r5rEs+OK go ahead
�USER username
PASS password
s+OK password accepted
spassword accepted)r-r=r>r8rGr)r@rArrr�testOkLoginns


z POP3ClientLoginTests.testOkLogincsjt�\}}d|_|�dd�}��|��d�|�d���|��d�|�d���|t���fdd	��S)
NTr4r5rEs+OK waiting on you
rQ�-ERR bogus login
cr6�Nrsbogus loginr7r:rrrr0�r<z;POP3ClientLoginTests.testBadPasswordLogin.<locals>.<lambda>�	r-r=r>r8rGr)r?rr@rArrr�testBadPasswordLoginxs



�z)POP3ClientLoginTests.testBadPasswordLogincsPt�\}}d|_|�dd�}��|��d�|�d���|t���fdd��S)NTr4r5rErScr6rTr7r:rrrr0�r<z;POP3ClientLoginTests.testBadUsernameLogin.<locals>.<lambda>rUrArrr�testBadUsernameLogin�s


�z)POP3ClientLoginTests.testBadUsernameLogincCs*tdd�\}}|�d�|�|jd�dS)NFr3s"+OK lalala this has no challenge
�r-r)r8�serverChallenge�rr+r,rrr�testServerGreeting��
z'POP3ClientLoginTests.testServerGreetingcCs*tdd�\}}|�d�|�|jd�dS)NFr3s+OK <here is the challenge>
s<here is the challenge>rXrZrrr�testServerGreetingWithChallenge�r\z4POP3ClientLoginTests.testServerGreetingWithChallengecCsLtdd�\}}|�d�|�dd�}|�|��d�|�d�|�|jd�S)	NFr3s"+OK <challenge string goes here>
r4r5s0APOP username f34f1e464d0d7927607753129cabe39a
s+OK Welcome!
sWelcome!)r-r)r>r8rGr@rArrr�testAPOP�s
�
zPOP3ClientLoginTests.testAPOPcCs>tdd�\}}|�d�|�dd�}|�|���|�|t�S)NFr3�+OK Howdy
r4r5)r-r)r>�assertFalserGr?rrArrr� testInsecureLoginRaisesException�s

z5POP3ClientLoginTests.testInsecureLoginRaisesExceptioncCsptdd�\}}t|tj�|�d�|�dd�}|�|��d�|��|�d�|�|��d�|�d�|S)	z�
        If a server doesn't offer APOP but the transport is secured using
        SSL or TLS, a plaintext login should be allowed, not rejected with
        an InsecureAuthenticationDisallowed exception.
        Fr3r_r4r5rEs+OK
rM)	r-rr�
ISSLTransportr)r>r8rG�clearrArrr� testSSLTransportConsideredSecure�s


z5POP3ClientLoginTests.testSSLTransportConsideredSecureN)r r!r"rCrHrKrOrPrRrVrWr[r]r^rardrrrrr2Ds			


r2c@�eZdZdd�Zdd�ZdS)�ListConsumercCs
i|_dSr��datarrrr�__init__��
zListConsumer.__init__cCs |\}}|j�|g��|�dSr)rh�
setdefault�append)rr.�itemrGrrr�consume�szListConsumer.consumeN�r r!r"rirnrrrrrf��rfc@re)�MessageConsumercCs
g|_dSrrgrrrrri�rjzMessageConsumer.__init__cCs|j�|�dSr)rhrl�r�linerrrrn��zMessageConsumer.consumeNrorrrrrq�rprqc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�POP3ClientListTestscC�Ht�\}}|��}|�|��d�|�d�|�d�|�|jgd��S)N�LIST
�+OK Here it comes
s1 3
2 2
3 1
.
)���)r-�listSizer8rGr)r@rArrr�testListSize��


z POP3ClientListTests.testListSizec
Cs�t�\}}t�}|j}|�|�}|�|��d�|�d�|�d�|�|jdgdgdgd��|�d�|�|jdgdgdgdgdgdgd	��|�d
�|�|j	|�S)Nrwrxs1 3
2 2
3 1
ryrzr{)rr{rzs5 3
6 2
7 1
)rr{rz����.
)
r-rfrnr|r8rGr)rhr@�assertIdentical�rr+r,�cr/rBrrr�testListSizeWithConsumer�s




(
z,POP3ClientListTests.testListSizeWithConsumerc�Ft�\}}|��}��|��d�|�d���|t���fdd��S)Nrw�!-ERR Fatal doom server exploded
cr6�NrsFatal doom server explodedr7r:rrrr0�r<z8POP3ClientListTests.testFailedListSize.<locals>.<lambda>)r-r|r8rGr)r?rr@rArrr�testFailedListSize��


�z&POP3ClientListTests.testFailedListSizecCrv)N�UIDL
rxs1 abc
2 def
3 ghi
.
)�abcsdefsghi)r-�listUIDr8rGr)r@rArrr�testListUID�r~zPOP3ClientListTests.testListUIDcCsxt�\}}t�}|j}|�|�}|�|��d�|�d�|�d�|�|jdgdgdgd��|�d�|�|j	|�S)	Nr�rxs1 xyz
2 abc
5 mno
sxyzr�smno)rr{rr�)
r-rfrnr�r8rGr)rhr@r�r�rrr�testListUIDWithConsumer�s




z+POP3ClientListTests.testListUIDWithConsumercr�)Nr�r�cr6r�r7r:rrrr0r<z7POP3ClientListTests.testFailedListUID.<locals>.<lambda>)r-r�r8rGr)r?rr@rArrr�testFailedListUIDr�z%POP3ClientListTests.testFailedListUIDN)	r r!r"r}r�r�r�r�r�rrrrru�s	ruc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�POP3ClientMessageTestscCs^t�\}}|�d�}|�|��d�|�d�|�d�|�d�|�d�|�|jddg�S)	N��RETR 8
�+OK Message incoming
�La la la here is message text
s"..Further message text tra la la
r��La la la here is message texts.Further message text tra la la�r-�retriever8rGr)r@rArrr�testRetrieves





�z#POP3ClientMessageTests.testRetrievecCs`t�\}}t�}|j}|�d|�}|�|��d�|�d�|�d�|�d�|�|j||�S)Nr�r�r�r�s..Further message text
.
)	r-rqrnr�r8rGr)r@�_cbTestRetrieveWithConsumerr�rrr�testRetrieveWithConsumers



z/POP3ClientMessageTests.testRetrieveWithConsumercC�"|�||�|�|jddg�dS)Nr�s.Further message text�r�r8rh�rr.r/r�rrrr�#s
�z2POP3ClientMessageTests._cbTestRetrieveWithConsumercCsbt�\}}|jddd�}|�|��d�|�d�|�d�|�d�|�d�|�|jd	d
g�S)Nr�rz��lines�	TOP 8 2
�+OK 2 lines on the way
�Line the first!  Woop
�Line the last!  Bye
r��Line the first!  Woop�Line the last!  Byer�rArrr�testPartialRetrieve)s





�z*POP3ClientMessageTests.testPartialRetrievecCsnt�\}}t�}|j}|jd|dd�}|�|��d�|�d�|�d�|�d�|�d�|�|j||�S)	Nr�rzr�r�r�r�r�r�)	r-rqrnr�r8rGr)r@�"_cbTestPartialRetrieveWithConsumerr�rrr�testPartialRetrieveWithConsumer5s




z6POP3ClientMessageTests.testPartialRetrieveWithConsumercCr�)Nr�r�r�r�rrrr�Asz9POP3ClientMessageTests._cbTestPartialRetrieveWithConsumercrJ)NrsRETR 1
r�cr6r�r7r:rrrr0Kr<z;POP3ClientMessageTests.testFailedRetrieve.<locals>.<lambda>)r-r�r8rGr)r?rr@rArrr�testFailedRetrieveErLz)POP3ClientMessageTests.testFailedRetrievecs�t�\�}��fdd�td�D�}tdd�D]3}��|��d|f�|����d���d|f���d	|f���|��d
���d�qtj|dd
�S)z�
        Issue three retrieve calls immediately without waiting for any to
        succeed and make sure they all do succeed eventually.
        c	s8g|]}��|���jd|dfd|dfg��qS)sFirst line of %d.r{sSecond line of %d.)r�r@r8)�.0�i�r+rrr�
<listcomp>Ts
���zCPOP3ClientMessageTests.test_concurrentRetrieves.<locals>.<listcomp>ryr{rs	RETR %d
r�sFirst line of %d.
sSecond line of %d.
�r�T)�fireOnOneErrback)r-�ranger8rGrcr)r�DeferredList)rr,�messagesr�rr�r�test_concurrentRetrievesNs
�
z/POP3ClientMessageTests.test_concurrentRetrievesN)r r!r"r�r�r�r�r�r�r�r�rrrrr�
s
	r�c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�POP3ClientMiscTestsc
Cs`t�\}}|jdd�}|�|��d�|�d�|�d�|�|jdddgd�ddgdgd	��S)
Nr��useCache�CAPA
s+OK Capabilities on the way
s!X
Y
Z
A 1 2 3
B 1 2
C 1
.
)�1�2�3r�r�)�X�Y�Z�A�B�C�r-�capabilitiesr8rGr)r@rArrr�testCapabilityis


��z"POP3ClientMiscTests.testCapabilitycCs>t�\}}|jdd�}|�|��d�|�d�|�|ji�S)Nrr�r��-ERR This server is lame!
r�rArrr�testCapabilityError{s


z'POP3ClientMiscTests.testCapabilityErrorcC�:t�\}}|��}|�|��d�|�d�|�|jd�S)N�STAT
s+OK 1 1212
)r{i�)r-�statr8rGr)r@rArrr�testStat��


zPOP3ClientMiscTests.testStatcr�)Nr�r�cr6�NrsThis server is lame!r7r:rrrr0�r<z3POP3ClientMiscTests.testStatError.<locals>.<lambda>)r-r�r8rGr)r?rr@rArrr�
testStatError�r�z!POP3ClientMiscTests.testStatErrorcCr�)N�NOOP
s+OK No-op to you too!
sNo-op to you too!)r-�noopr8rGr)r@rArrr�testNoop�r�zPOP3ClientMiscTests.testNoopcr�)Nr�r�cr6r�r7r:rrrr0�r<z3POP3ClientMiscTests.testNoopError.<locals>.<lambda>)r-r�r8rGr)r?rr@rArrr�
testNoopError�r�z!POP3ClientMiscTests.testNoopErrorcCr�)N�RSET
s+OK Reset state
sReset state)r-�resetr8rGr)r@rArrr�testRset�r�zPOP3ClientMiscTests.testRsetcr�)Nr�r�cr6r�r7r:rrrr0�r<z3POP3ClientMiscTests.testRsetError.<locals>.<lambda>)r-r�r8rGr)r?rr@rArrr�
testRsetError�r�z!POP3ClientMiscTests.testRsetErrorcCrD)Nry�DELE 4
s+OK Hasta la vista
sHasta la vista)r-�deleter8rGr)r@rArrr�
testDelete�rIzPOP3ClientMiscTests.testDeletecrJ)Nryr�s-ERR Winner is not you.
cr6)NrsWinner is not you.r7r:rrrr0�r<z5POP3ClientMiscTests.testDeleteError.<locals>.<lambda>)r-r�r8rGr)r?rr@rArrr�testDeleteError�rLz#POP3ClientMiscTests.testDeleteErrorN)
r r!r"r�r�r�r�r�r�r�r�r�r�rrrrr�hs			r�c@seZdZddd�Zdd�ZdS)�SimpleClientNcCs||_d|_dS)NT)�deferredr=)rr��contextFactoryrrrri�s
zSimpleClient.__init__cCs|j�d�dSr)r��callback)r�	challengerrr�serverGreeting�rtzSimpleClient.serverGreetingr)r r!r"rir�rrrrr��s
r�c@s<eZdZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dS)�POP3HelperMixinNcCs:t��}tj|jd�|_t||jd�|_d|j_	||_
dS)N)r��)r�Deferredr
�POP3TestServer�	serverCTX�serverr��	clientCTX�client�timeout�	connected)rrBrrrr-�s

zPOP3HelperMixin.setUpcCs|`|`|`dSr)r�r�r�rrrr�tearDown�szPOP3HelperMixin.tearDowncCs|jj��dSr)r��	transportr)r�ignorerrr�
_cbStopClient�rtzPOP3HelperMixin._cbStopClientcCs|jj��|jj��|Sr)r�r�rr�)r�failurerrr�
_ebGeneral�szPOP3HelperMixin._ebGeneralcCstj|j|jdd�S)NF)�noisy)r�loopbackTCPr�r�rrrrr�rzPOP3HelperMixin.loopback)
r r!r"r�r�r-r�r�r�rrrrrr��sr�c@seZdZGdd�dej�ZdS)�TLSServerFactoryc@s2eZdZUdZgZeeed<dd�Zdd�Z	dS)zTLSServerFactory.protocolN�outputcCs8g|j_|jdd�|_|j�d�D]}|�|�qdS)Nr)�factory�inputr��pop�sendLinerrrrr�connectionMade�s
�z(TLSServerFactory.protocol.connectionMadecsF�jj�|��fdd��j�d�D�|dkr!�j��j�dSdS)Ncsg|]}��|��qSr)r�)r��lrrrr��sz:TLSServerFactory.protocol.lineReceived.<locals>.<listcomp>rr$)r�r�rlr�r�r��startTLS�contextrrrrr�lineReceived�s
�z&TLSServerFactory.protocol.lineReceived)
r r!r"r�r�r�bytes�__annotations__r�r�rrrrr�s

rN)r r!r"r�LineReceiverrrrrrr��sr�zOpenSSL not presentc@seZdZdZdd�ZdS)�POP3TLSTestsz=
    Tests for POP3Client's support for TLS connections.
    c
st��dggd�dgddgdgg�j_t��j_tjd�dd�}��|j�|�	�j
}|�	�j}t�
��tt�
�t�����fdd�}|�_t��}�fd	d
�|_t�|||���fdd�}�fd
d�}��fdd�}��fdd�}	�j�|��j�|��j�|��j�|	��jS)zd
        POP3Client.startTLS starts a TLS session over its existing TCP
        connection.
        �+OK)rr$�.rrz	127.0.0.1)�	interfacecst��|���d�dSr)r�rr�)�reason)�connLostDeferred�cprrr�z2POP3TLSTests.test_startTLS.<locals>.connectionLostcs�Srrr�rrrr0sz,POP3TLSTests.test_startTLS.<locals>.<lambda>c�t�d����S)Nz!Connected to server; starting TLS)r�msgr���ignoredr	rr�cbConnected!�
z/POP3TLSTests.test_startTLS.<locals>.cbConnectedcr
)NzStarted TLS; disconnecting)rr�quitrr	rr�cbStartedTLS%rz0POP3TLSTests.test_startTLS.<locals>.cbStartedTLScs t�d����jgd��dS)Nz.Disconnected; asserting correct input received)�CAPAr$rsQUIT)rrr8r�)�ign)r�sfrr�cbDisconnected)s
z2POP3TLSTests.test_startTLS.<locals>.cbDisconnectedcst�d�����S)NzEAsserted correct input; disconnecting client and shutting down server)rr�
disconnect�r.)�connrrr�cleanup-s
�z+POP3TLSTests.test_startTLS.<locals>.cleanup)r�rr�rr�r	�	listenTCP�
addCleanup�
stopListening�getHost�host�portrr�r�rr�
ClientFactory�
connectTCPr�r@�addBoth)
rr�H�Pr�cfrrrrr)rrrrrr�
test_startTLSs8�


zPOP3TLSTests.test_startTLSN)r r!r"�__doc__r&rrrrr�src@r)�POP3TimeoutTestscs����fdd�}�fdd���fdd���fdd�}d	�j_d
t_||g}t�jjtt|���j��j��j�	�j
����S)Ncs&�j�dd�}|���|���|S)N�test�twisted)r�r>r@�
addErrback)rB��loggedInr�timedOutrrr>?s

z+POP3TimeoutTests.testTimeout.<locals>.logincs��d�dS)Nz%Successfully logged in!?  Impossible!)�failrrrrr-Esz.POP3TimeoutTests.testTimeout.<locals>.loggedIncs|�tj���d�dSr)�trapr�TimeoutErrorr�)r�rrrr.Hrz.POP3TimeoutTests.testTimeout.<locals>.timedOutcs
�j��Sr)r�rrrrrrLrjz*POP3TimeoutTests.testTimeout.<locals>.quitg{�G�z�?T)r�r�r
�TIMEOUT_RESPONSE�mapr�r@r1r�r+r�r)rr>r�methodsrr,r�testTimeout>szPOP3TimeoutTests.testTimeoutN)r r!r"r5rrrrr(=r#r(c@s eZdZdZdd�Zdd�ZdS)�POP3ClientModuleStructureTestszt
    Miscellaneous tests more to do with module/package structure than
    anything to do with the POP3 client.
    cCs|�tjjjg�dS)z�
        twisted.mail._pop3client.__all__ should be empty because all classes
        should be imported through twisted.mail.pop3.
        N)r8r*�mail�_pop3client�__all__rrrr�test_allbsz'POP3ClientModuleStructureTests.test_allcCs�dd�t�tjdtj�D�}|D]-}tjdkr|dkrq|dks4|�ttj	j
|�|�dtj	j
���q|�ttj	j
d��qd	S)
a
        Every public class in twisted.mail._pop3client should be available as
        a member of twisted.mail.pop3 with the exception of
        twisted.mail._pop3client.POP3Client which should be available as
        twisted.mail.pop3.AdvancedClient.
        cSs$g|]}|dddks|d�qS)r�_r)r�r�rrrr�ps
�z>POP3ClientModuleStructureTests.test_import.<locals>.<listcomp>ztwisted.mail._pop3client)ryr�rr%z not in r
N)�inspect�
getmembers�sys�modules�isclass�version_info�
assertTrue�hasattrr*r7�pop3)r�
publicClasses�pcrrr�test_importis����z*POP3ClientModuleStructureTests.test_importN)r r!r"r'r:rGrrrrr6\sr6)T)6r<r>�typingr�unittestr�zope.interfacer�twisted.mail._pop3clientr*�twisted.internetrrrrr	�twisted.mail.pop3r
r%rr�twisted.mail.testr
�twisted.protocolsrr�twisted.pythonr�twisted.test.proto_helpersr�twisted.trial.unittestr�twisted.test.ssl_helpersrr�ImportErrorrr&r-r1r2rfrqrur�r�r�r��
ServerFactoryr��IReactorSSLrr(r6rrrr�<module>sV��

w	>^[	
A

Anon7 - 2022
AnonSec Team