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

�b�@�@s8dZddlmZddlmZddlmZddlmZddlm	Z	m
Z
mZmZddl
mZddlmZzdd	lmZWn
eyGd
ZdZYnwdZd
ZdZdZdeZdZdeZGdd�dej�ZGdd�d�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�dej�Z Gdd �d ej�Z!d
S)!z4
Tests for L{twisted.words.protocols.jabber.client}
�)�sha1)�skipIf)�defer)�unittest)�client�error�jid�	xmlstream)�SASLInitiatingInitializer)�utility)�sslN)TzSSL not available)F�z//iq[@type="get"]/query[@xmlns="jabber:iq:auth"]z//iq[@type="set"]/query[@xmlns="jabber:iq:auth"]z urn:ietf:params:xml:ns:xmpp-bindz"/iq[@type="set"]/bind[@xmlns="%s"]z#urn:ietf:params:xml:ns:xmpp-sessionz%/iq[@type="set"]/session[@xmlns="%s"]c@s$eZdZdd�Zdd�Zdd�ZdS)�CheckVersionInitializerTestscCs"t��}t�|�}t�|�|_dS�N)r	�
Authenticator�	XmlStreamr�CheckVersionInitializer�init)�self�a�xs�r�F/usr/lib/python3/dist-packages/twisted/words/test/test_jabberclient.py�setUp#s
z"CheckVersionInitializerTests.setUpcCsd|jj_|j��dS)z3
        Test supported version number 1.0
        )�rN)rr	�version�
initialize�rrrr�
testSupported(s
z*CheckVersionInitializerTests.testSupportedcCs.d|jj_|�tj|jj�}|�d|j�dS)zK
        Test unsupported version number 0.0, and check exception.
        )rrzunsupported-versionN)	rr	r�assertRaisesr�StreamErrorr�assertEqual�	condition)r�excrrr�testNotSupported/s
z-CheckVersionInitializerTests.testNotSupportedN)�__name__�
__module__�__qualname__rrr$rrrrr"src@s eZdZdZdd�Zdd�ZdS)�InitiatingInitializerHarnessa�
    Testing harness for interacting with XML stream initializers.

    This sets up an L{utility.XmlPipe} to create a communication channel between
    the initializer and the stubbed receiving entity. It features a sink and
    source side that both act similarly to a real L{xmlstream.XmlStream}. The
    sink is augmented with an authenticator to which initializers can be added.

    The harness also provides some utility methods to work with event observers
    and deferreds.
    cCs4g|_t��|_|jj|_t�d�|_|j|j_dS)Nzexample.org)�outputr�XmlPipe�pipe�sinkr	�ConnectAuthenticator�
authenticatorrrrrrEs


z"InitiatingInitializerHarness.setUpcCs(t��}|�|�|jj�||j�|S)a�
        Observe an output event, returning a deferred.

        The returned deferred will be fired when the given event has been
        observed on the source end of the L{XmlPipe} tied to the protocol
        under test. The handler is added as the first callback.

        @param event: The event to be observed. See
            L{utility.EventDispatcher.addOnetimeObserver}.
        @param handler: The handler to be called with the observed event object.
        @rtype: L{defer.Deferred}.
        )r�Deferred�addCallbackr+�source�addOnetimeObserver�callback)r�event�handler�drrr�waitForLs
z$InitiatingInitializerHarness.waitForN)r%r&r'�__doc__rr7rrrrr(8sr(cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�IQAuthInitializerTestsz0
    Tests for L{client.IQAuthInitializer}.
    cs2t���t�|j�|_t�d�|j_d|j_	dS)N�user@example.com/resource�secret)
�superrr�IQAuthInitializerr	rr�JIDr.�passwordr��	__class__rrrds
zIQAuthInitializerTests.setUpcs>��fdd�}�fdd����t|�}�j��}t�||g�S)z�
        Test plain-text authentication.

        Act as a server supporting plain-text authentication and expect the
        C{password} field to be filled with the password. Then act as if
        authentication succeeds.
        c�Xt�|d�}|�d�|j�d�|j�d�|j�d���t��}�jj�|�|S�z�
            Called when the initializer sent a query for authentication methods.

            The response informs the client that plain-text authentication
            is supported.
            �result�zjabber:iq:auth�query�usernamer?�resource�	r	�
toResponse�
addElementrFr7�IQ_AUTH_SETr+r1�send��iq�responser6��	onAuthSetrrr�	onAuthGets�	
z7IQAuthInitializerTests.testPlainText.<locals>.onAuthGetcsZ��dt|jj����dt|jj����dt|jj��t�|d�}�jj	�
|�dS)��
            Called when the initializer sent the authentication request.

            The server checks the credentials and responds with an empty result
            signalling success.
            �userr;rHrDN)r!�strrFrGr?rHr	rJr+r1rM�rOrPrrrrR�s
z7IQAuthInitializerTests.testPlainText.<locals>.onAuthSet)r7�IQ_AUTH_GETrrr�
gatherResults�rrS�d1�d2rrQr�
testPlainTextjs
	
z$IQAuthInitializerTests.testPlainTextcsF��fdd�}�fdd��d�j_��t|�}�j��}t�||g�S)a"
        Test digest authentication.

        Act as a server supporting digest authentication and expect the
        C{digest} field to be filled with a sha1 digest of the concatenated
        stream session identifier and password. Then act as if authentication
        succeeds.
        crB)z�
            Called when the initializer sent a query for authentication methods.

            The response informs the client that digest authentication is
            supported.
            rDrErG�digestrHrIrNrQrrrS�rTz4IQAuthInitializerTests.testDigest.<locals>.onAuthGetcsb��dt|jj����td���t|jj����dt|jj��t�	|d�}�j
j�|�dS)rUrVs12345secretrHrDN)
r!rWrFrGr�	hexdigestr_rHr	rJr+r1rMrXrrrrR�s
z4IQAuthInitializerTests.testDigest.<locals>.onAuthSet�12345)r	�sidr7rYrrrrZr[rrQr�
testDigest�s

z!IQAuthInitializerTests.testDigestc�>�fdd�}��t|�}�j��}��|tj�t�||g�S)zT
        Test initializer failure of request for fields for authentication.
        c�"t�d��|�}�jj�|�dS)z�
            Called when the initializer sent a query for authentication methods.

            The server responds that the client is not authorized to authenticate.
            �not-authorizedN�r�StanzaErrorrJr+r1rMrXrrrrS�sz?IQAuthInitializerTests.testFailRequestFields.<locals>.onAuthGet�	r7rYrr�
assertFailurerrhrrZr[rrr�testFailRequestFields�s


z,IQAuthInitializerTests.testFailRequestFieldscsL��fdd�}�fdd����t|�}�j��}��|tj�t�||g�S)z;
        Test initializer failure to authenticate.
        crBrCrIrNrQrrrS�rTz6IQAuthInitializerTests.testFailAuth.<locals>.onAuthGetcre)z�
            Called when the initializer sent the authentication request.

            The server checks the credentials and responds with a not-authorized
            stanza error.
            rfNrgrXrrrrRsz6IQAuthInitializerTests.testFailAuth.<locals>.onAuthSetrir[rrQr�testFailAuth�s
z#IQAuthInitializerTests.testFailAuth)
r%r&r'r8rr^rcrkrl�
__classcell__rrr@rr9_s6;r9c�0eZdZdZ�fdd�Zdd�Zdd�Z�ZS)�BindInitializerTestsz.
    Tests for L{client.BindInitializer}.
    cs*t���t�|j�|_t�d�|j_dS)Nr:)	r<rr�BindInitializerr	rrr>r.rr@rrr+s
zBindInitializerTests.setUpcsF�fdd�}�fdd�}��t|�}�j��}|�|�t�||g�S)zK
        Set up a stream, and act as if resource binding succeeds.
        cs<t�|d�}|�tdf�|jjddd��jj�|�dS)NrD�bindr�user@example.com/other resource)�content)r	rJrK�NS_BINDrqr+r1rMrXrrr�onBind5sz.BindInitializerTests.testBasic.<locals>.onBindcs��t�d��jj�dS)Nrr)r!rr>r.)rDrrr�cb;s�z*BindInitializerTests.testBasic.<locals>.cb)r7�IQ_BIND_SETr�startr0rrZ)rrurvr\r]rrr�	testBasic0s

zBindInitializerTests.testBasiccrd)zH
        Set up a stream, and act as if resource binding fails.
        c�"t�d��|�}�jj�|�dS)N�conflictrgrXrrrruJ�z0BindInitializerTests.testFailure.<locals>.onBind)	r7rwrrxrjrrhrrZ)rrur\r]rrr�testFailureE�

z BindInitializerTests.testFailure)r%r&r'r8rryr}rmrrr@rro&s
rocrn)�SessionInitializerTestsz1
    Tests for L{client.SessionInitializer}.
    cst���t�|j�|_dSr)r<rr�SessionInitializerr	rrr@rrrYs
zSessionInitializerTests.setUpcs0�fdd�}��t|�}�j��}t�||g�S)zP
        Set up a stream, and act as if session establishment succeeds.
        cst�|d�}�jj�|�dS)NrD)r	rJr+r1rMrXrrr�	onSessionbsz6SessionInitializerTests.testSuccess.<locals>.onSession)r7�IQ_SESSION_SETrrxrrZ�rr�r\r]rrr�testSuccess]s
z#SessionInitializerTests.testSuccesscrd)zM
        Set up a stream, and act as if session establishment fails.
        crz)N�	forbiddenrgrXrrrr�or|z6SessionInitializerTests.testFailure.<locals>.onSession)	r7r�rrxrjrrhrrZr�rrrr}jr~z#SessionInitializerTests.testFailure)r%r&r'r8rr�r}rmrrr@rrTs

rc@seZdZdZdd�ZdS)�BasicAuthenticatorTestszB
    Test for both BasicAuthenticator and basicClientFactory.
    cCs�t�d�|_t�|jd��d�}|�d|jj�|�|j|jj�|�d|jj	�|j
\}}|�|tj
�|�|tj�|�|j�dS)a
        Authenticator and stream are properly constructed by the factory.

        The L{xmlstream.XmlStream} protocol created by the factory has the new
        L{client.BasicAuthenticator} instance in its C{authenticator}
        attribute.  It is set up with C{jid} and C{password} as passed to the
        factory, C{otherHost} taken from the client JID. The stream futher has
        two initializers, for TLS and authentication, of which the first has
        its C{required} attribute set to C{True}.
        r:r;N�example.com)rr>�
client_jidr�basicClientFactory�
buildProtocolr!r.�	otherHostr?�initializers�assertIsInstancer	�TLSInitiatingInitializerr=�assertFalse�required)rr�tls�authrrr�
test_basic~s
z"BasicAuthenticatorTests.test_basicN)r%r&r'r8r�rrrrr�ysr�c@s(eZdZdZdd�Zee�dd��ZdS)�XMPPAuthenticatorTestsz@
    Test for both XMPPAuthenticator and XMPPClientFactory.
    cCs�t�d�|_t�|jd��d�}|�d|jj�|�|j|jj�|�d|jj	�|j
\}}}}}|�|tj
�|�|t�|�|tj�|�|tj�|�|j�|�|j�|�|j�|�|j�dS)z�
        Test basic operations.

        Setup an XMPPClientFactory, which sets up an XMPPAuthenticator, and let
        it produce a protocol instance. Then inspect the instance variables of
        the authenticator and XML stream objects.
        r:r;Nr�)rr>r�r�XMPPClientFactoryr�r!r.r�r?r�r�r	r�r
rpr��
assertTruer�r�)rrrr��saslrq�sessionrrrr��sz!XMPPAuthenticatorTests.test_basicc
s�g�d
�fdd�	}t�d�|_t��}tj|jd|d�}|�tj	d|�|�
d�}|j\}}}}}	|�|tj	�|�
|�d	�dS)zG
        A TLS configuration is passed to the TLS initializer.
        TNcs��|�dSr)�append)rrr��configurationForTLS��configsrrr�sz:XMPPAuthenticatorTests.test_tlsConfiguration.<locals>.initr:r;)r��__init__r)TN)rr>r�r�CertificateOptionsrr��patchr	r�r�r�r��assertIs)
rrr��factoryrrr�r�rqr�rr�r�test_tlsConfiguration�s�
z,XMPPAuthenticatorTests.test_tlsConfigurationN)r%r&r'r8r�r�
skipWhenNoSSLr�rrrrr��s
!r�)"r8�hashlibrrr�twisted.internetr�
twisted.trial�twisted.words.protocols.jabberrrrr	�#twisted.words.protocols.jabber.saslr
�twisted.words.xishrr�ImportErrorr�rYrLrtrw�
NS_SESSIONr��TestCaserr(r9rorr�r�rrrr�<module>s:�'H.%%

Anon7 - 2022
AnonSec Team