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 :  /usr/lib/python3/dist-packages/twisted/names/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


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

Current File : /usr/lib/python3/dist-packages/twisted/names/test/__pycache__/test_srvconnect.cpython-310.pyc
o

�b�$�@s�dZddlZddlmZddlmZmZddlmZm	Z	ddl
mZddlm
Z
mZmZddlmZdd	lmZdd
lmZddlmZGdd
�d
e�ZGdd�dej�ZGdd�dej�ZdS)z-
Test cases for L{twisted.names.srvconnect}.
�N)�verifyObject)�defer�protocol)�DNSLookupError�ServiceNameUnknownError)�
IConnector)�client�dns�
srvconnect)�ResolverBase)�DNSNameError)�
MemoryReactor)�unittestc@s"eZdZdZddd�Zdd�ZdS)�FakeResolvera�
    Resolver that only gives out one given result.

    Either L{results} or L{failure} must be set and will be used for
    the return value of L{_lookup}

    @ivar results: List of L{dns.RRHeader} for the desired result.
    @type results: C{list}
    @ivar failure: Failure with an exception from L{twisted.names.error}.
    @type failure: L{Failure<twisted.python.failure.Failure>}
    NcCs||_||_g|_dS�N)�results�failure�lookups)�selfrr�r�D/usr/lib/python3/dist-packages/twisted/names/test/test_srvconnect.py�__init__$s
zFakeResolver.__init__cCs<|j�||||f�|jdurt�|jggf�St�|j�S)z9
        Return the result or failure on lookup.
        N)r�appendrr�succeed�failr)r�name�cls�qtype�timeoutrrr�_lookup)s
zFakeResolver._lookup)NN)�__name__�
__module__�__qualname__�__doc__rrrrrrrs
rc@s eZdZdZdd�Zdd�ZdS)�DummyFactoryzL
    Dummy client factory that stores the reason of connection failure.
    cCs
d|_dSr��reason�rrrrr9�
zDummyFactory.__init__cCs
||_dSrr%)r�	connectorr&rrr�clientConnectionFailed<r(z#DummyFactory.clientConnectionFailedN)r r!r"r#rr*rrrrr$4sr$c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!�SRVConnectorTestsz/
    Tests for L{srvconnect.SRVConnector}.
    cCsF|�tdt��t�|_t�|_t�|jdd|j�|_	g|_
g|_dS)N�theResolver�xmpp-server�example.org)�patchrrr
�reactorr$�factoryr
�SRVConnectorr)�randIntArgs�randIntResultsr'rrr�setUpEs�
zSRVConnectorTests.setUpcCs|j�||f�|j�d�S)a�
        Fake randint.

        Returns the first element of L{randIntResults} and records the
        arguments passed to it in L{randIntArgs}.

        @param min: Lower bound of the random number.
        @type min: L{int}

        @param max: Higher bound of the random number.
        @type max: L{int}

        @return: Fake random number from L{randIntResults}.
        @rtype: L{int}
        r)r3rr4�pop)r�min�maxrrr�_randintOszSRVConnectorTests._randintcCstt|j�dS)zF
        L{srvconnect.SRVConnector} implements L{IConnector}.
        N)rrr)r'rrr�test_interfacebsz SRVConnectorTests.test_interfacecCsftjdddd�}tjdtjtjd|d�gtj_|j�	�|�
|jj�|�
|jj��dd�d	�dS)
zS
        Test connectTCP gets called with the address from the SRV record.
        �}�host.example.org�<��port�target�ttlr.�r�typerrA�payloadN�)r<r;)r	�
Record_SRV�RRHeader�SRV�INrr,rr)�connect�assertIsNoner1r&�assertEqualr0�
tcpClientsr6�rrDrrr�test_SRVPresenths��
 z!SRVConnectorTests.test_SRVPresentcCsDtd�tj_|j��|�|jj�|�	|j
j��dd�d�dS)zS
        Test connectTCP gets called with fallback parameters on NXDOMAIN.
        sexample.orgNrE�r.r-)
rrr,rr)rJrKr1r&rLr0rMr6r'rrr�test_SRVNotPresentws
�z$SRVConnectorTests.test_SRVNotPresentcCs@gtj_|j��|�|jj�|�|j	j
��dd�d�dS)zW
        Test connectTCP gets called with fallback parameters on empty result.
        NrErP)rr,rr)rJrKr1r&rLr0rMr6r'rrr�test_SRVNoResult�s
�z"SRVConnectorTests.test_SRVNoResultcCs\tj|jdd|jdd�|_t�tj_|j�	�|�
|jj�|�|jj
��dd�d�dS)zY
        connectTCP gets called with default port if the service is not defined.
        �thisbetternotexistr.�f)�defaultPortNrE)r.rT)r
r2r0r1r)rrr,rrJrKr&rLrMr6r'rrr�)test_SRVNoResultUnknownServiceDefaultPort�s�

 z;SRVConnectorTests.test_SRVNoResultUnknownServiceDefaultPortcCsBt�|jdd|j�|_t�tj_|j�	�|�
|jj�t��dS)zR
        Connect fails on no result, unknown service and no default port.
        rSr.N)
r
r2r0r1r)rrr,rrJ�
assertTruer&�checkr'rrr�+test_SRVNoResultUnknownServiceNoDefaultPort�s�

z=SRVConnectorTests.test_SRVNoResultUnknownServiceNoDefaultPortcCsVtjdtjtjddd�gtj_|j��|�	|j
j�|�|j
j��dd�d�dS)zU
        Test connectTCP gets called with fallback parameters on bad result.
        r.r=NrBrErP)r	rG�CNAMErIrr,rr)rJrKr1r&rLr0rMr6r'rrr�test_SRVBadResult�s��
�z#SRVConnectorTests.test_SRVBadResultcCshtjdddd�}tjdtjtjd|d�gtj_|j�	�|�
|jj�|jj�
t�|�|jjg�dS)zH
        Test that connecting fails when no service is present.
        i��.r=r>r.rBN)r	rFrGrHrIrr,rr)rJ�assertIsNotNoner1r&�traprrLr0rMrNrrr�test_SRVNoService�s��
z#SRVConnectorTests.test_SRVNoServicecCs2gtj_|j��tjjdd}|�d|�dS)zW
        The lookup name is a native string from service, protocol and domain.
        ���rs_xmpp-server._tcp.example.orgN)rr,rr)rJrrL)rrrrr�test_SRVLookupName�s
z$SRVConnectorTests.test_SRVLookupNamecCs*t�|jdd|j�|_|�d|jj�dS)zq
        L{srvconnect.SRVConnector} automatically encodes unicode domain using
        C{idna} encoding.
        zxmpp-clientuéchec.example.orgsxn--chec-9oa.example.orgN)r
r2r0r1r)rL�domainr'rrr�test_unicodeDomain�s�z$SRVConnectorTests.test_unicodeDomaincCs�t�dddd�}t�dddd�}||g|j_g|j_|�td|j�ddg|_|j�	�|�
|jdd	�|j�	�|�
|jd
d�ddg|_|j�	�|�
|jdd	�|j�	�|�
|jd
d�dS)a
        pickServer calculates running sum of weights and calls randint.

        This exercises the server selection algorithm specified in RFC 2782 by
        preparing fake L{random.randint} results and checking the values it was
        called with.
        �
rT�host1.example.org��host2.example.org�randint�r)r��)rrdrE�)rrfN)r	rFr)�orderedServers�serversr/�randomr9r4�
pickServerrLr3�r�record1�record2rrr�test_pickServerWeights�s





z(SRVConnectorTests.test_pickServerWeightscCsvt�dddd�}t�dddd�}||g|j_g|j_|�td|j�ddg|_|�	d|j�
��|�	d	|j�
��d
S)zR
        Two records with equal priorities compare on weight (ascending).
        rdrTrerfrgrhr�rerT�rgrTN�r	rFr)rmrnr/ror9r4rLrprqrrr�test_pickServerSamePriorities�
z/SRVConnectorTests.test_pickServerSamePrioritiescCsvt�dddd�}t�dddd�}||g|j_g|j_|�td|j�ddg|_|�	d|j�
��|�	d	|j�
��d
S)zX
        Two records with differing priorities compare on priority (ascending).
        rdrrTrerfrgrhrurvNrwrqrrr�test_srvDifferentPrioritiesryz-SRVConnectorTests.test_srvDifferentPrioritiesN)r r!r"r#r5r9r:rOrQrRrVrYr[r_rarcrtrxrzrrrrr+@s"



!r+)r#ro�zope.interface.verifyr�twisted.internetrr�twisted.internet.errorrr�twisted.internet.interfacesr�
twisted.namesrr	r
�twisted.names.commonr�twisted.names.errorr�twisted.test.proto_helpersr
�
twisted.trialrr�
ClientFactoryr$�TestCaser+rrrr�<module>s

Anon7 - 2022
AnonSec Team