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

�b�#�@s�ddlmZddlmZddlmZddlmZmZm	Z	m
Z
ddlmZdZ
ee	j�Gdd�d��ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZdS)�)�implementer)�defer)�unittest)�jid�sasl�sasl_mechanisms�	xmlstream)�domish� urn:ietf:params:xml:ns:xmpp-saslc@s4eZdZdZdZdZdZdd�Zdd�Zd	d
�Z	dS)�DummySASLMechanisma�
    Dummy SASL mechanism.

    This just returns the initialResponse passed on creation, stores any
    challenges and replies with the value of C{response}.

    @ivar challenge: Last received challenge.
    @type challenge: C{unicode}.
    @ivar initialResponse: Initial response to be returned when requested
                           via C{getInitialResponse} or L{None}.
    @type initialResponse: C{unicode}
    N�DUMMY�cCs
||_dS�N��initialResponse)�selfr�r�D/usr/lib/python3/dist-packages/twisted/words/test/test_jabbersasl.py�__init__"s
zDummySASLMechanism.__init__cCs|jSrr�rrrr�getInitialResponse%sz%DummySASLMechanism.getInitialResponsecCs||_|jSr)�	challenge�response)rrrrr�getResponse(szDummySASLMechanism.getResponse)
�__name__�
__module__�__qualname__�__doc__r�namerrrrrrrrrs
rc@seZdZdZdZdd�ZdS)�DummySASLInitiatingInitializerac
    Dummy SASL Initializer for initiating entities.

    This hardwires the SASL mechanism to L{DummySASLMechanism}, that is
    instantiated with the value of C{initialResponse}.

    @ivar initialResponse: The initial response to be returned by the
                           dummy SASL mechanism or L{None}.
    @type initialResponse: C{unicode}.
    NcCst|j�|_dSr)rr�	mechanismrrrr�setMechanism;sz+DummySASLInitiatingInitializer.setMechanism)rrrrrr!rrrrr-src@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�SASLInitiatingInitializerTestsz5
    Tests for L{sasl.SASLInitiatingInitializer}
    cCsPg|_t��|_t�|j�|_|jj|j_|j��|j�d�t	|j�|_
dS)Ns�<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>)�outputr�
Authenticator�
authenticator�	XmlStream�append�send�connectionMade�dataReceivedr�initrrrr�setUpDs

�z$SASLInitiatingInitializerTests.setUpcs\t�d�}|�d�t���j_�j�|����jjt	j
��jj��fdd���jjS)zL
        Test that the SASL error condition is correctly extracted.
        )r
�failure�not-authorizedcs��d|j�S)Nr.)�assertEqual�	condition)�errr�<lambda>\sz?SASLInitiatingInitializerTests.test_onFailure.<locals>.<lambda>)r	�Element�
addElementr�Deferredr+�	_deferred�	onFailure�
assertFailurer�
SASLAuthError�addCallback)rr-rrr�test_onFailureRs


�z-SASLInitiatingInitializerTests.test_onFailurecCs\d|j_|j��|jd}|�t|j�|�d|j�|�d|d�|�dt|��dS)zH
        Test starting authentication with an initial response.
        sdummyr�authrr zZHVtbXk=N)	r+r�startr#r/�NS_XMPP_SASL�urir�str�rr<rrr�test_sendAuthInitialResponse`s

z;SASLInitiatingInitializerTests.test_sendAuthInitialResponsecCs0d|j_|j��|jd}|�dt|��dS)zK
        Test starting authentication without an initial response.
        Nr��r+rr=r#r/r@rArrr�test_sendAuthNoInitialResponsel�

z=SASLInitiatingInitializerTests.test_sendAuthNoInitialResponsecCs0d|j_|j��|jd}|�dt|��dS)zS
        Test starting authentication where the initial response is empty.
        r
r�=NrDrArrr�!test_sendAuthEmptyInitialResponseurFz@SASLInitiatingInitializerTests.test_sendAuthEmptyInitialResponsecCsP|j��}t�tdf�}|�d�|j�|�|�d|jjj	�|j�
d�|S)z5
        Test receiving a challenge message.
        r�bXkgY2hhbGxlbmdlsmy challengeN)r+r=r	r3r>�
addContent�onChallenger/r r�	onSuccess�r�drrrr�test_onChallenge~s

z/SASLInitiatingInitializerTests.test_onChallengecCsb|j��}t�tdf�}|�d�d|jj_|j�|�|j	d}|�
dt|��|j�d�|S)zS
        A non-empty response gets encoded and included as character data.
        rrIsresponse�zcmVzcG9uc2U=N)
r+r=r	r3r>rJr rrKr#r/r@rL)rrNrrrrr�test_onChallengeResponse�s



z7SASLInitiatingInitializerTests.test_onChallengeResponsecCsF|j��}t�tdf�}|j�|�|�d|jjj�|j�	d�|S)z<
        Test receiving an empty challenge message.
        rr
N)
r+r=r	r3r>rKr/r rrLrMrrr�test_onChallengeEmpty�s
z4SASLInitiatingInitializerTests.test_onChallengeEmptycC�@|j��}t�tdf�}|�d�|j�|�|�|tj	�|S)zJ
        Test receiving a challenge message with illegal padding.
        rzbXkg=Y2hhbGxlbmdl�
r+r=r	r3r>rJrKr8r�SASLIncorrectEncodingErrorrMrrr�test_onChallengeIllegalPadding��

z=SASLInitiatingInitializerTests.test_onChallengeIllegalPaddingcCrS)zM
        Test receiving a challenge message with illegal characters.
        rzbXkg*Y2hhbGxlbmdlrTrMrrr�!test_onChallengeIllegalCharacters�rWz@SASLInitiatingInitializerTests.test_onChallengeIllegalCharacterscCrS)z?
        Test receiving a malformed challenge message.
        r�arTrMrrr�test_onChallengeMalformed�rWz8SASLInitiatingInitializerTests.test_onChallengeMalformedN)rrrrr,r;rBrErHrOrQrRrVrXrZrrrrr"?s		r"c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�*SASLInitiatingInitializerSetMechanismTestszB
    Test for L{sasl.SASLInitiatingInitializer.setMechanism}.
    cCsRg|_t��|_t�|j�|_|jj|j_|j��|j�d�t	�
|j�|_dS)Nz�<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>)r#rr$r%r&r'r(r)r*r�SASLInitiatingInitializerr+rrrrr,�s

�z0SASLInitiatingInitializerSetMechanismTests.setUpcCsDt�tdf�}|jd|d�||jj|j|jf<|j�	�|jj
jS)zX
        Set up the XML Stream to have a SASL feature with the given mechanism.
        �
mechanismsr )�content)r	r3r>r4r�featuresr?rr+r!r )rr�featurerrr�
_setMechanism�s


z8SASLInitiatingInitializerSetMechanismTests._setMechanismcCs0t�d�|j_d|j_d}|�||�|��dS)zI
        Test setting ANONYMOUS as the authentication mechanism.
        �example.comN�	ANONYMOUS�r�JIDr%�passwordr/ra�rrrrr�test_anonymous��z9SASLInitiatingInitializerSetMechanismTests.test_anonymouscC�0t�d�|j_d|j_d}|�||�|��dS)zE
        Test setting PLAIN as the authentication mechanism.
        �test@example.com�secret�PLAINNrdrgrrr�
test_plain�riz5SASLInitiatingInitializerSetMechanismTests.test_plaincCrj)zJ
        Test setting DIGEST-MD5 as the authentication mechanism.
        rkrlz
DIGEST-MD5Nrdrgrrr�test_digest�riz6SASLInitiatingInitializerSetMechanismTests.test_digestcC�,t�d�|j_d|j_|�tj|jd�dS)zK
        Test using an unacceptable SASL authentication mechanism.
        rkrl�SOMETHING_UNACCEPTABLEN�rrer%rf�assertRaisesr�SASLNoAcceptableMechanismrarrrr�test_notAcceptables

�z=SASLInitiatingInitializerSetMechanismTests.test_notAcceptablecCrp)zW
        Test using an unacceptable SASL authentication mechanism with no JID.
        rbrlrqNrrrrrr�test_notAcceptableWithoutUsers

�zHSASLInitiatingInitializerSetMechanismTests.test_notAcceptableWithoutUserN)rrrrr,rarhrnrorurvrrrrr[�s


r[N)�zope.interfacer�twisted.internetr�
twisted.trialr�twisted.words.protocols.jabberrrrr�twisted.words.xishr	r>�ISASLMechanismrr\r�TestCaser"r[rrrr�<module>s

Anon7 - 2022
AnonSec Team