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/words/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/words/test/__pycache__/test_jabbercomponent.cpython-310.pyc
o

�bR6�@sdZddlmZddlmZddlmZddlmZddl	m
Z
mZmZddl
mZddlmZdd	lmZGd
d�d�ZGdd
�d
ej�ZGdd�dej�ZGdd�dej�ZGdd�de
j�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZdS)z7
Tests for L{twisted.words.protocols.jabber.component}
�)�sha1)�verifyObject)�failure)�unittest)�	component�ijabber�	xmlstream)�JID)�domish)�XmlPipec@�eZdZdd�Zdd�ZdS)�DummyTransportcCs
||_dS�N)�list)�selfr�r�I/usr/lib/python3/dist-packages/twisted/words/test/test_jabbercomponent.py�__init__�
zDummyTransport.__init__cCs|j�|�dSr)r�append)r�bytesrrr�writeszDummyTransport.writeN)�__name__�
__module__�__qualname__rrrrrrr
�r
c@r)�#ComponentInitiatingInitializerTestscCsjg|_t��|_d|j_t�|j�|_d|j_|jj|j_|j�	�|j�
d�d|j_t�
|j�|_dS)N�secret�test:componentz�<stream:stream xmlns='test:component' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>�12345)�outputr�
Authenticator�
authenticator�password�	XmlStream�	namespacer�send�connectionMade�dataReceived�sidr�ComponentInitiatingInitializer�init�rrrr�setUps

�z)ComponentInitiatingInitializerTests.setUpcCsb|j��}|jd}|�d|j�|�d|j�|�td���t|��g|_	|j
�|���|S)z?
        Test basic operations of component handshake.
        ����	handshaker�12345secret)
r+�
initializer �assertEqual�name�urir�	hexdigest�str�childrenrr(�toXml)r�dr/rrr�
testHandshake-s

z1ComponentInitiatingInitializerTests.testHandshakeN)rrrr-r:rrrrrsrc@r)�ComponentAuthTestscC�
d|_dS�NT)�authComplete)r�streamrrr�
authPassedDrzComponentAuthTests.authPassedcCs�d|_g}t�dd�}t�|�}t|�|_|�tj|j	�|�
�|�d�td��
��d�}|�|dd|d	�|�d
�|�|jd�dS)NF�cjidrsv<stream:stream xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams' from='cjid' id='12345'>r0�ascii�s<handshake>s</handshake>�<handshake/>T)r>r�ConnectComponentAuthenticatorrr$r
�	transport�addObserver�STREAM_AUTHD_EVENTr@r'r(rr5�encoder2)r�outlist�ca�xs�hvrrr�testAuthGs

�
zComponentAuthTests.testAuthN)rrrr@rNrrrrr;Crr;c@seZdZdZdd�ZdS)�ServiceTestsz)
    Tests for L{component.Service}.
    cCst��}ttj|�dS)zF
        L{component.Service} implements L{ijabber.IService}.
        N)r�Servicerr�IService)r�servicerrr�test_interfacefszServiceTests.test_interfaceN)rrr�__doc__rSrrrrrOasrOc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�JabberServiceHarnesscCsd|_d|_d|_dS)NF)�componentConnectedFlag�componentDisconnectedFlag�transportConnectedFlagr,rrrros
zJabberServiceHarness.__init__cCr<r=)rV�rrrrr�componentConnectedtrz'JabberServiceHarness.componentConnectedcCr<r=)rWr,rrr�componentDisconnectedwrz*JabberServiceHarness.componentDisconnectedcCr<r=)rXrYrrr�transportConnectedzrz'JabberServiceHarness.transportConnectedN)rrrrrZr[r\rrrrrUns
rUc@seZdZdd�ZdS)�JabberServiceManagerTestscCs�t�dd�}t�}|�|�g}|���d�}||_|j|j_|�	�|�
d|j�|�|t
j�|�
d|j�|�d�|�
d|j�dS)N�foor#T)r�ServiceManagerrU�setServiceParent�
getFactory�
buildProtocolrFrrr'r2rX�dispatchrrHrV�connectionLostrW)r�sm�svc�wlistrLrrr�testSMs


z JabberServiceManagerTests.testSMN)rrrrhrrrrr]~sr]c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�RouterTestsz(
    Tests for L{component.Router}.
    cs|t��}g��fdd�|_t�}|�d|j�|�dt|j��|�|j|jd�t	�
d�}|j�|�|�|g��dS)zJ
        Test route registration and routing on incoming stanzas.
        c�
��|�Sr�r��element��routedrr�<lambda>��
z+RouterTests.test_addRoute.<locals>.<lambda>zexample.orgrC)�testns�testN)
r�Router�router�addRoute�sinkr2�len�routesr
�Element�sourcer&)r�router�pipermrrnr�
test_addRoute�s
zRouterTests.test_addRoutecs�t�}t�}t��}|�d|j�|�d|j�g�|j�d�fdd��t�d�}d|d<d|d<|j�	|�|�
|g��d	S)
z,
        Test routing of a message.
        �component1.example.orgzcomponent2.example.org�/*crjrrkrl��outgoingrrrp�rqz(RouterTests.test_route.<locals>.<lambda>�N�presence�from�toN�rrrtrvrwr{rGr
rzr&r2)r�
component1�
component2r|�stanzarr�r�
test_route�s
zRouterTests.test_routecs�t�}t�}t��}|�d|j�|�d|j�g�|j�d�fdd��t�d�}d|d<d|d	<|j�	|�|�
|g��dS)
a
        Test routing of a message using the default route.

        The default route is the one with L{None} as its key in the
        routing table. It is taken when there is no more specific route
        in the routing table that matches the stanza's destination.
        rNr�crjrrkrlr�rrrp�rqz/RouterTests.test_routeDefault.<locals>.<lambda>r�r�zexample.comr�r�)rr��s2sr|r�rr�r�test_routeDefault�s
zRouterTests.test_routeDefaultN)rrrrTr~r�r�rrrrri�s
ric@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�!ListenComponentAuthenticatorTestsz>
    Tests for L{component.ListenComponentAuthenticator}.
    cCs,g|_t�d�}t�|�|_|jj|j_dS)Nr)r r�ListenComponentAuthenticatorrr$rr&)rr"rrrr-�s
z'ListenComponentAuthenticatorTests.setUpcCs|j�d�dS)zA
        Stub loseConnection because we are a transport.
        z	no reasonN)rrdr,rrr�loseConnection�sz0ListenComponentAuthenticatorTests.loseConnectioncs�g��fdd�}|j}||_|�|�|�d|j�|�|j�|�d�|�d|j	�|�
d|j�|�|j�|�d|jj
f�d�dS)zK
        The received stream header should set several attributes.
        cs��||f�dSrrk)�event�
observerfn��	observersrr�addOnetimeObserver�szPListenComponentAuthenticatorTests.test_streamStarted.<locals>.addOnetimeObserverNzz<stream:stream xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams' to='component.example.org'>)rrr�r.)rr��makeConnection�assertIdenticalr)�assertFalse�_headerSentr(r2�version�assertNotIdentical�
assertTruer"�	onElement)rr�rLrr�r�test_streamStarted�s
�z4ListenComponentAuthenticatorTests.test_streamStartedcC�Lg}|j}|j|_|�|�|�d�|�dt|��|�d|dj�dS)zM
        The received stream header should have a correct namespace.
        zp<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='component.example.org'>rCzinvalid-namespacer.N�rr�sendStreamErrorr�r(r2rx�	condition�r�streamErrorsrLrrr� test_streamStartedWrongNamespace
s
�zBListenComponentAuthenticatorTests.test_streamStartedWrongNamespacecCr�)zJ
        The received stream header should have a 'to' attribute.
        z_<stream:stream xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>rCzimproper-addressingr.Nr�r�rrr�test_streamStartedNoTos
�z8ListenComponentAuthenticatorTests.test_streamStartedNoTocCsHg}|j}|j|j_t�d�}|�d�|j�|�|�d|d�dS)z<
        We expect a handshake element with a hash.
        )�jabber:component:acceptr/�1234r.N)	rrr"�onHandshaker
rz�
addContentr�r2)r�
handshakesrLr/rrr�test_onElement+s


z0ListenComponentAuthenticatorTests.test_onElementcCsVg}g}|j}|j|j_|j|_t�d�}|j�|�|�|�|�	d|dj
�dS)z9
        Reject elements that are not handshakes
        )r��message�not-authorizedr.N)rrr"r�r�r
rzr�r�r2r�)rr�r�rLrmrrr�test_onElementNotHandshake9s


z<ListenComponentAuthenticatorTests.test_onElementNotHandshakecs`g��fdd�}|j}|�tj|�d|_d}|j�|�|�d|jd�|�dt���dS)	zU
        Receiving a handshake matching the secret authenticates the stream.
        c���|�dSrrk�rL��authdrr�
authenticatedO�zIListenComponentAuthenticatorTests.test_onHandshake.<locals>.authenticatedr��(32532c0f7dbf1253c095b18b18e36d38d94c1256rDr.rCN)	rr�rHr)r"r�r2r rx)rr�rL�theHashrr�r�test_onHandshakeIsz2ListenComponentAuthenticatorTests.test_onHandshakecslg}g��fdd�}|j}|�tj|�|j|_d|_d}|j�|�|�d|dj	�|�dt
���dS)zH
        Receiving a bad handshake should yield a stream error.
        cr�rrkr�r�rrr�ar�zRListenComponentAuthenticatorTests.test_onHandshakeWrongHash.<locals>.authenticatedr�r�r.rN)rr�rHrr�r)r"r�r2r�rx)rr�r�rLr�rr�r�test_onHandshakeWrongHashZsz;ListenComponentAuthenticatorTests.test_onHandshakeWrongHashN)
rrrrTr-r�r�r�r�r�r�r�r�rrrrr��sr�c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�XMPPComponentServerFactoryTestsz<
    Tests for L{component.XMPPComponentServerFactory}.
    cCs8t��|_t�|jd�|_|j�d�|_td�|j_dS)Nr�component.example.org)	rrtr|�XMPPComponentServerFactory�factoryrbrr	�
thisEntityr,rrrr-ts
z%XMPPComponentServerFactoryTests.setUpcCsV|j�|jtj�|�d|jj�|�d|jj�|�d|jj�|�d|jj�dS)zY
        A new connection increases the stream serial count. No logs by default.
        rrCN)	rrc�STREAM_CONNECTED_EVENTr2�serialr�r��rawDataInFn�rawDataOutFnr,rrr�test_makeConnectionzs
z3XMPPComponentServerFactoryTests.test_makeConnectioncCs>d|j_|j�|jtj�|�d|jj�|�d|jj�dS)zD
        Setting logTraffic should set up raw data loggers.
        TN)r��
logTrafficrrcr�r�r�r�r,rrr�test_makeConnectionLogTraffic�sz=XMPPComponentServerFactoryTests.test_makeConnectionLogTrafficcCsX|j�|jtj�Gdd�dt�}t�|��}|j�|tj�|�dt|�	|���dS)zQ
        An observer for stream errors should trigger onError to log it.
        c@seZdZdS)z?XMPPComponentServerFactoryTests.test_onError.<locals>.TestErrorN)rrrrrrr�	TestError�sr�rCN)
rrcr��	Exceptionr�Failure�STREAM_ERROR_EVENTr2rx�flushLoggedErrors)rr��reasonrrr�test_onError�s
z,XMPPComponentServerFactoryTests.test_onErrorcCs<|j�|jtj�|�d|jj�|�|j|jjd�dS)zG
        Make sure a new stream is added to the routing table.
        r�N)rrcrH�assertInr|ryr�r,rrr�test_connectionInitialized�s
�z:XMPPComponentServerFactoryTests.test_connectionInitializedcCs6|j�|jtj�|j�dtj�|�d|jj�dS)zU
        Make sure a stream is removed from the routing table on disconnect.
        Nr�)rrcrH�STREAM_END_EVENT�assertNotInr|ryr,rrr�test_connectionLost�sz3XMPPComponentServerFactoryTests.test_connectionLostN)
rrrrTr-r�r�r�r�r�rrrrr�os
	

r�N)rT�hashlibr�zope.interface.verifyr�twisted.pythonr�
twisted.trialr�twisted.words.protocols.jabberrrr�"twisted.words.protocols.jabber.jidr	�twisted.words.xishr
�twisted.words.xish.utilityrr
�TestCaserr;rOrPrUr]rir�r�rrrr�<module>s&(
"?

Anon7 - 2022
AnonSec Team