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

�b[;�@s
dZzddlZWneydZYnweZzddlZWney'dZYnweZddlZddlmZddl	m
Z
ddlmZm
Z
ddlmZdZdd	�Ze�ZGd
d�d�ZGdd
�d
ee�ZGdd�dee�ZGdd�d�ZGdd�dee�ZGdd�dee�ZdS)z&
Tests for L{twisted.python.fakepwd}.
�N)�getitem)�_PYPY)�ShadowDatabase�UserDatabase)�TestCasei�cCs@t}tdur	zt�|�Wn
tyY|Sw|d8}q|S)a�
    By convention, UIDs less than 1000 are reserved for the system.  A system
    which allocated every single one of those UIDs would likely have practical
    problems with allocating new ones, so let's assume that we'll be able to
    find one.  (If we don't, this will wrap around to negative values and
    I{eventually} find something.)

    @return: a user ID which does not exist on the local system.  Or, on
        systems without a L{pwd} module, return C{SYSTEM_UID_MAX}.
    NT�)�SYSTEM_UID_MAX�pwd�getpwuid�KeyError)�guess�r
�B/usr/lib/python3/dist-packages/twisted/python/test/test_fakepwd.py�findInvalidUID s��rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�UserDatabaseTestsMixina^
    L{UserDatabaseTestsMixin} defines tests which apply to any user database
    implementation.  Subclasses should mix it in, implement C{setUp} to create
    C{self.database} bound to a user database instance, and implement
    C{getExistingUserInfo} to return information about a user (such information
    should be unique per test method).
    c
Cs�td�D]D}|��\}}}}}}}|j�|�}	|�|	j|�|�|	j|�|�|	j|�|�|	j|�|�|	j	|�|�|	j
|�|�|	j|�qdS)zc
        I{getpwuid} accepts a uid and returns the user record associated with
        it.
        �N)�range�getExistingUserInfo�databaser
�assertEqual�pw_name�	pw_passwd�pw_uid�pw_gid�pw_gecos�pw_dir�pw_shell�
�self�i�username�password�uid�gid�gecos�dir�shell�entryr
r
r�
test_getpwuidC��z$UserDatabaseTestsMixin.test_getpwuidcCs|�t|jjt�dS)zu
        I{getpwuid} raises L{KeyError} when passed a uid which does not exist
        in the user database.
        N)�assertRaisesrrr
�INVALID_UID�rr
r
r�test_noSuchUIDV�z%UserDatabaseTestsMixin.test_noSuchUIDc
Cs�td�D]D}|��\}}}}}}}|j�|�}	|�|	j|�|�|	j|�|�|	j|�|�|	j|�|�|	j	|�|�|	j
|�|�|	j|�qdS)zh
        I{getpwnam} accepts a username and returns the user record associated
        with it.
        rN)rrr�getpwnamrrrrrrrrrr
r
r�
test_getpwnam]r)z$UserDatabaseTestsMixin.test_getpwnamcCs"t}trt}|�||jjd�dS)zN
        L{getpwnam} rejects a non-L{str} username with an exception.
        �
i-am-bytesN)�	TypeErrorr�	Exceptionr*rr/)r�exc_typer
r
r�test_getpwnamRejectsBytespsz0UserDatabaseTestsMixin.test_getpwnamRejectsBytescC�|�t|jjd�dS)zz
        I{getpwnam} raises L{KeyError} when passed a username which does not
        exist in the user database.
        z.nosuchuserexiststhenameistoolongandhasinittooN)r*rrr/r,r
r
r�test_noSuchName{s
�z&UserDatabaseTestsMixin.test_noSuchNamec
Csd|j}|��\}}}}}}}|�|�|�|�|��dfD]}	|�t|	�t�|�t|	�d�qdS)zm
        The user record returned by I{getpwuid}, I{getpwnam}, and I{getpwall}
        has a length.
        r�N)	rrr
r/�getpwall�assertIsInstance�len�intr�
r�dbr r!r"r#r$r%r&r'r
r
r�test_recordLength�s"�z(UserDatabaseTestsMixin.test_recordLengthc
Cs�|j}|��\}}}}}}}|�|�|�|�|��dfD]N}	|�|	d|�|�|	d|�|�|	d|�|�|	d|�|�|	d|�|�|	d|�|�|	d|�|�t|	�tt|	���|�t	t
|	d�qd	S)
a:
        The user record returned by I{getpwuid}, I{getpwnam}, and I{getpwall}
        is indexable, with successive indexes starting from 0 corresponding to
        the values of the C{pw_name}, C{pw_passwd}, C{pw_uid}, C{pw_gid},
        C{pw_gecos}, C{pw_dir}, and C{pw_shell} attributes, respectively.
        rrr����r8N)rrr
r/r9rr;�listr*�
IndexErrorrr=r
r
r�test_recordIndexable�s"�z+UserDatabaseTestsMixin.test_recordIndexableN)�__name__�
__module__�__qualname__�__doc__r(r-r0r5r7r?rFr
r
r
rr:src@�(eZdZdZdd�Zdd�Zdd�ZdS)	�UserDatabaseTestsz$
    Tests for L{UserDatabase}.
    cCst�|_td|_dS)zC
        Create a L{UserDatabase} with no user data in it.
        rN)rrr�_counterr,r
r
r�setUp�szUserDatabaseTests.setUpc		Cs~|jd7_dt|j�}d|}d|}|j}|jd}d|}d|}d|}|j�|||||||�|||||||fS)	�P
        Add a new user to C{self.database} and return its information.
        r�_r r!i�r$r%r&�rM�strr�addUser)	r�suffixr r!r"r#r$r%r&r
r
rr�s
z%UserDatabaseTests.getExistingUserInfoc
	Cs�d}d}d}d}d}d}d}|j}|�|||||||�|�|�g|�|�g|��fD]4\}	|�|	j|�|�|	j|�|�|	j|�|�|	j	|�|�|	j
|�|�|	j|�|�|	j|�q+dS)	�
        L{UserDatabase.addUser} accepts seven arguments, one for each field of
        a L{pwd.struct_passwd}, and makes the new record available via
        L{UserDatabase.getpwuid}, L{UserDatabase.getpwnam}, and
        L{UserDatabase.getpwall}.
        �alice�secr3t�{i�zAlice,,,z/users/alicez/usr/bin/fooshN)
rrSr
r/r9rrrrrrrr)
rr r!r"r#r$�homer&r>r'r
r
r�test_addUser�s$$�zUserDatabaseTests.test_addUserN�rGrHrIrJrNrrZr
r
r
rrL�s
rLc@s2eZdZdZedur
dZneZdd�Zdd�ZdS)�PwdModuleTestsz�
    L{PwdModuleTests} runs the tests defined by L{UserDatabaseTestsMixin}
    against the built-in C{pwd} module.  This serves to verify that
    L{UserDatabase} is really a fake of that API.
    Nz2Cannot verify UserDatabase against pwd without pwdcCst|j���|_t�|_dS�N)�iterrr9�_users�set�_uidsr,r
r
rrN�szPwdModuleTests.setUpcCs.	t|j�}|j}||jvr|j�|�|Sq)z�
        Read and return the next record from C{self._users}, filtering out
        any records with previously seen uid values (as these cannot be
        found with C{getpwuid} and only cause trouble).
        )�nextr_rra�add)rr'r"r
r
rr�s

�z"PwdModuleTests.getExistingUserInfo)	rGrHrIrJr	�skiprrNrr
r
r
rr\�sr\c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ShadowDatabaseTestsMixinan
    L{ShadowDatabaseTestsMixin} defines tests which apply to any shadow user
    database implementation.  Subclasses should mix it in, implement C{setUp} to
    create C{self.database} bound to a shadow user database instance, and
    implement C{getExistingUserInfo} to return information about a user (such
    information should be unique per test method).
    c
Cs�td�D]T}|��\	}}}}}}}}	}
|j�|�}|�|j|�|�|j|�|�|j|�|�|j|�|�|j	|�|�|j
|�|�|j|�|�|j|	�|�|j
|
�qdS)zh
        L{getspnam} accepts a username and returns the user record associated
        with it.
        rN)rrr�getspnamr�sp_nam�sp_pwd�	sp_lstchg�sp_min�sp_max�sp_warn�sp_inact�	sp_expire�sp_flag)rrr r!�
lastChange�min�max�warn�inact�expire�flagr'r
r
r�
test_getspnams.��z&ShadowDatabaseTestsMixin.test_getspnamcCr6)zz
        I{getspnam} raises L{KeyError} when passed a username which does not
        exist in the user database.
        rVN)r*rrrfr,r
r
rr73r.z(ShadowDatabaseTestsMixin.test_noSuchNamecCr6)zm
        I{getspnam} raises L{TypeError} when passed a L{bytes}, just like
        L{spwd.getspnam}.
        r1N)r*r2rrfr,r
r
r�test_getspnamBytes:r.z+ShadowDatabaseTestsMixin.test_getspnamBytescCsR|j}|��d}|�|�|��dfD]}|�t|�t�|�t|�d�qdS)zf
        The shadow user record returned by I{getspnam} and I{getspall} has a
        length.
        r�	N)rrrf�getspallr:r;r<r)rr>r r'r
r
rr?As�z*ShadowDatabaseTestsMixin.test_recordLengthc	Cs�|j}|��\	}}}}}}}}	}
|�|�|��dfD]^}|�|d|�|�|d|�|�|d|�|�|d|�|�|d|�|�|d|�|�|d|�|�|d|	�|�|d	|
�|�t|�tt|���|�tt	|d
�qdS)aS
        The shadow user record returned by I{getpwnam} and I{getspall} is
        indexable, with successive indexes starting from 0 corresponding to the
        values of the C{sp_nam}, C{sp_pwd}, C{sp_lstchg}, C{sp_min}, C{sp_max},
        C{sp_warn}, C{sp_inact}, C{sp_expire}, and C{sp_flag} attributes,
        respectively.
        rrrr@rArBrCr8�ryN)
rrrfrzrr;rDr*rEr)rr>r r!rprqrrrsrtrurvr'r
r
rrFLs2��z-ShadowDatabaseTestsMixin.test_recordIndexableN)	rGrHrIrJrwr7rxr?rFr
r
r
rresrec@rK)	�ShadowDatabaseTestsz&
    Tests for L{ShadowDatabase}.
    cCst�|_d|_dS)zE
        Create a L{ShadowDatabase} with no user data in it.
        rN)rrrMr,r
r
rrNts
zShadowDatabaseTests.setUpcCs�|jd7_dt|j�}d|}d|}|jd}|jd}|jd}|jd}|jd}|jd	}	|jd
}
|j�||||||||	|
�	||||||||	|
f	S)rOrrPr r!rr@rArBrCr8rQ)rrTr r!rprqrrrsrtrurvr
r
rr{s






�z'ShadowDatabaseTests.getExistingUserInfocCs�d}d}d}d}d}d}d}d}d}	|j}
|
�|||||||||	�	|
�|�g|
��fD]B\}|�|j|�|�|j|�|�|j|�|�|j|�|�|j	|�|�|j
|�|�|j|�|�|j|�|�|j
|	�q,d	S)
rUrVrW��*�i�r@i�N)rrSrfrzrrgrhrirjrkrlrmrnro)rr r!rprqrrrsrtrurvr>r'r
r
rrZ�s,�z ShadowDatabaseTests.test_addUserNr[r
r
r
rr|os
r|c@sDeZdZdZedur
dZne��dkrdZneZdd�Z	dd	�Z
dS)
�SPwdModuleTestsz�
    L{SPwdModuleTests} runs the tests defined by L{ShadowDatabaseTestsMixin}
    against the built-in C{spwd} module.  This serves to verify that
    L{ShadowDatabase} is really a fake of that API.
    Nz6Cannot verify ShadowDatabase against spwd without spwdrz1Cannot access shadow user database except as rootcCst|j���|_dSr])r^rrzr_r,r
r
rrN�szSPwdModuleTests.setUpcCs
t|j�S)zF
        Read and return the next record from C{self._users}.
        )rbr_r,r
r
rr�s
z#SPwdModuleTests.getExistingUserInfo)rGrHrIrJ�spwdrd�os�getuidrrNrr
r
r
rr��sr�)rJr	�_pwd�ImportErrorr��_spwdr��operatorr�twisted.python.compatr�twisted.python.fakepwdrr�twisted.trial.unittestrrrr+rrLr\rer|r�r
r
r
r�<module>s6��{9cA

Anon7 - 2022
AnonSec Team