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

�b9�@s�dZddlmZmZddlmZmZddlmZm	Z	m
Z
mZddlm
Z
ddlmZddlmZddlmZzdd	lmZWneyId
ZYnweZeddd
d�ZGdd�de�ZGdd�d�Zee�Gdd�dej��Ze�eee�Gdd�de	j�Zeee�Gdd�d��Zeej �Gdd�d��Z!Gdd�dej"�Z#Gdd�dej"�Z$Gdd�dej"�Z%Gd d!�d!�Z&Gd"d#�d#�Z'Gd$d%�d%e'�Z(Gd&d'�d'e'�Z)Gd(d)�d)e'e&ej"�Z*Gd*d+�d+e(e&ej"�Z+Gd,d-�d-e)e&ej"�Z,Gd.d/�d/ej"�Z-d
S)0z6
Tests for L{twisted.cred}, now with 30% more starch.
�)�hexlify�	unhexlify)�	Interface�implementer)�checkers�credentials�error�portal)�defer)�
components)�Version)�unittest)�cryptN�Twisted��c@�eZdZdZdS)�	ITestablez2
    An interface for a theoretical protocol.
    N��__name__�
__module__�__qualname__�__doc__�rr�=/usr/lib/python3/dist-packages/twisted/cred/test/test_cred.pyrsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
TestAvatarz
    A test avatar.
    cCs||_d|_d|_dS)NF)�name�loggedIn�	loggedOut)�selfrrrr�__init__,s
zTestAvatar.__init__cCs|jrJ�d|_dS�NT)r�rrrr�login1s

zTestAvatar.logincCs
d|_dSr!)rr"rrr�logout5�
zTestAvatar.logoutN)rrrrr r#r$rrrrr's
rc@r)�Testablez-
    A theoretical protocol for testing.
    Nrrrrrr&9sr&c@�eZdZdS)�IDerivedCredentialsN�rrrrrrrr(Esr(c@seZdZdd�Zdd�ZdS)�DerivedCredentialscCs||_||_dS�N)�username�password)rr,r-rrrr Ks
zDerivedCredentials.__init__cCs
||jkSr+)r-�rr-rrr�
checkPasswordOr%z DerivedCredentials.checkPasswordN)rrrr r/rrrrr*Isr*c@s eZdZdZdd�Zdd�ZdS)�	TestRealmz
    A basic test realm.
    cCs
i|_dSr+)�avatarsr"rrrr Yr%zTestRealm.__init__cGsH||jvr|j|}n	t|�}||j|<|��|d|d|�|jfS)Nr)r1rr#r$)r�avatarId�mind�
interfaces�avatarrrr�
requestAvatar\s

zTestRealm.requestAvatarN)rrrrr r6rrrrr0Ssr0c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�	CredTestsz^
    Tests for the meat of L{twisted.cred} -- realms, portals, avatars, and
    checkers.
    cCs@t�|_t�|j�|_t��|_|j�dd�|j�|j�dS)N�bob�hello)	r0�realmr	�Portalr�'InMemoryUsernamePasswordDatabaseDontUse�checker�addUser�registerCheckerr"rrr�setUpls

zCredTests.setUpcCs.tjtjg}|j��}|�t|�t|��dS)z�
        The checkers in a portal can check only certain types of credentials.
        Since this portal has
        L{checkers.InMemoryUsernamePasswordDatabaseDontUse} registered, it
        N)r�IUsernamePassword�IUsernameHashedPasswordr	�listCredentialsInterfaces�assertEqual�sorted)r�expected�gotrrr�test_listCheckersss
zCredTests.test_listCheckerscCs�|�|j�t�dd�|t��}|\}}}|�|t�|�|�|�|�d|���|�|j	j
�|�|j	j�|�|�|j	j�dS)z�
        Calling C{login} on a portal with correct credentials and an interface
        that the portal's realm supports works.
        r8r9� does not implement N)�successResultOfr	r#r�UsernamePasswordrrD�
assertTrue�
providedBy�originalrr�rr#�iface�implr$rrr�test_basicLogin}s��
zCredTests.test_basicLogincCs�|�|j�tdd�|t��}|\}}}|�|t�|�|�|�|�d|���|�|jj	�|�|jj
�|�|�|jj
�dS)z~
        Logging in with correct derived credentials and an interface
        that the portal's realm supports works.
        r8r9rIN)rJr	r#r*rrDrLrMrNrrrOrrr�test_derivedInterface�s�
zCredTests.test_derivedInterfacecC�<|�|j�t�dd�|t��}|�|�|�tj	|j
�dS)z�
        Calling C{login} with incorrect credentials (in this case a wrong
        password) causes L{error.UnauthorizedLogin} to be raised.
        r8sh3lloN��failureResultOfr	r#rrKrrLrDr�UnauthorizedLogin�type�rr#rrr�test_failedLoginPassword����
z"CredTests.test_failedLoginPasswordcCrT)z�
        Calling C{login} with incorrect credentials (in this case no known
        user) causes L{error.UnauthorizedLogin} to be raised.
        sjayr9NrUrYrrr�test_failedLoginName�r[zCredTests.test_failedLoginNameN)
rrrrr@rHrRrSrZr\rrrrr7fs

r7c@sDeZdZgd�Zdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�OnDiskDatabaseTests�)�user1spass1)�user2spass2)�user3spass3cCsb|��|_t|jd��}|jD]\}}|�|d|d�qWd�dS1s*wYdS)N�wb�:�
)�mktemp�dbfile�open�users�write)r�f�u�prrrr@�s
�"�zOnDiskDatabaseTests.setUpcCs$t�d�|_|�tj|jjd�dS)zg
        A missing db file will cause a permanent rejection of authorization
        attempts.
        ztest_thisbetternoteverexist.db�userN)r�FilePasswordDB�db�assertRaisesrrW�getUserr"rrr�test_getUserNonexistentDatabase�sz3OnDiskDatabaseTests.test_getUserNonexistentDatabasecCsPt�|j�|_|jD]\}}|�t|jj|���|�	|j�|�||f�q
dSr+)
rrnrfrorhrp�KeyErrorrq�upperrD�rrkrlrrr�testUserLookup�s
�z"OnDiskDatabaseTests.testUserLookupcCsBtj|jdd�|_|jD]\}}|�|j�|���||f�qdS)NF)�
caseSensitive)rrnrfrorhrDrqrtrurrr�testCaseInSensitivity�s�z)OnDiskDatabaseTests.testCaseInSensitivitycsTt��j��_dd��jD�}t��fdd�|D��}|��jdd��jD��|S)NcS�g|]
\}}t�||��qSr�rrK��.0rkrlrrr�
<listcomp>��z;OnDiskDatabaseTests.testRequestAvatarId.<locals>.<listcomp>c�g|]
}t��jj|��qSr�r
�
maybeDeferredro�requestAvatarId�r|�cr"rrr}�r~cS�g|]\}}|�qSrrr{rrrr}��)	rrnrfrorhr
�
gatherResults�addCallbackrD�r�creds�drr"r�testRequestAvatarId�s�z'OnDiskDatabaseTests.testRequestAvatarIdcsft��j��_��ddt���fdd��jD�}t��fdd�|D��}|�	�j
dd��jD��|S)N�twisted.cred.credentials�UsernameHashedPasswordcsg|]	\}}�||��qSrrr{)r�rrr}��zBOnDiskDatabaseTests.testRequestAvatarId_hashed.<locals>.<listcomp>crrr�r�r"rrr}�r~cSr�rrr{rrrr}�r�)rrnrfro�getDeprecatedModuleAttribute�_uhpVersionrhr
r�r�rDr�r�r�rr�testRequestAvatarId_hashed�s��z.OnDiskDatabaseTests.testRequestAvatarId_hashedN)
rrrrhr@rrrvrxr�r�rrrrr]�s		r]c@sneZdZgd�Zdd�Zdedededefdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zedur5dZ
dSdS)�!HashedPasswordOnDiskDatabaseTestsr^cCs�|��}tj||jd�|_t|d��$}|jD]\}}|�|d|�|||dd��d�qWd�n1s9wYt�}t	�
|�|_|j�|j�dS)N��hashrbrcrrd)
rerrnr�rorgrhrir0r	r;�portr?)rrfrjrkrl�rrrrr@s*��z'HashedPasswordOnDiskDatabaseTests.setUprkrl�s�returncCs.t|�d�|�d��}t|t�r|S|�d�S)N�ascii)r�decode�
isinstance�bytes�encode)rrkrlr��hashed_passwordrrrr�s

z&HashedPasswordOnDiskDatabaseTests.hashcsFdd��jD�}t��fdd�|D��}|��jdd��jD��|S)NcSryrrzr{rrrr}r~zIHashedPasswordOnDiskDatabaseTests.testGoodCredentials.<locals>.<listcomp>csg|]}�j�|��qSr)ror�r�r"rrr}scSr�rrr{rrrr}r��rhr
r�r�rD�r�	goodCredsr�rr"r�testGoodCredentialssz5HashedPasswordOnDiskDatabaseTests.testGoodCredentialscsTdd��jD�}t��fdd�|D��}|�dd��|��jdd��jD��|S)NcSryrrzr{rrrr}r~zOHashedPasswordOnDiskDatabaseTests.testGoodCredentials_login.<locals>.<listcomp>c�g|]
}�j�|dt��qSr+�r�r#rr�r"rrr}r~cSsdd�|D�S)NcSsg|]	\}}}|jj�qSr)rNr)r|�i�a�lrrrr}r�zaHashedPasswordOnDiskDatabaseTests.testGoodCredentials_login.<locals>.<lambda>.<locals>.<listcomp>r��xrrr�<lambda>szMHashedPasswordOnDiskDatabaseTests.testGoodCredentials_login.<locals>.<lambda>cSr�rrr{rrrr} r�r�r�rr"r�testGoodCredentials_logins�z;HashedPasswordOnDiskDatabaseTests.testGoodCredentials_logincs@dd��jD�}tj�fdd�|D�dd�}|��jtj�|S)NcSsg|]
\}}t�|d��qS)swrong passwordrzr{rrrr}$s�zHHashedPasswordOnDiskDatabaseTests.testBadCredentials.<locals>.<listcomp>cr�r+r�r�r"rrr}(r~T��
consumeErrors)rhr
�DeferredListr��_assertFailuresrrW)r�badCredsr�rr"r�testBadCredentials#s��z4HashedPasswordOnDiskDatabaseTests.testBadCredentialscsT��ddt����fdd��jD�}tj�fdd�|D�dd�}|��jtj�|S)Nr�r�cs,g|]\}}�|��d||dd����qS)Nrr�r{r�rrr}1s �zKHashedPasswordOnDiskDatabaseTests.testHashedCredentials.<locals>.<listcomp>cr�r+r�r�r"rrr}5r~Tr�)	r�r�rhr
r�r�r�r�UnhandledCredentials)r�hashedCredsr�rr�r�testHashedCredentials-s���z7HashedPasswordOnDiskDatabaseTests.testHashedCredentialscGs*|D]\}}|�|tj�|j|�qdSr+)rDr
�FAILURE�trap)r�failures�expectedFailures�flag�failurerrrr�;sz1HashedPasswordOnDiskDatabaseTests._assertFailuresNzcrypt module not available)rrrrhr@r�r�r�r�r�r�r�r�skiprrrrr��s		
�r�c@s,eZdZdZejdd��Zejdd��ZdS)�
CheckersMixina�
    L{unittest.TestCase} mixin for testing that some checkers accept
    and deny specified credentials.

    Subclasses must provide
      - C{getCheckers} which returns a sequence of
        L{checkers.ICredentialChecker}
      - C{getGoodCredentials} which returns a list of 2-tuples of
        credential to check and avaterId to expect.
      - C{getBadCredentials} which returns a list of credentials
        which are expected to be unauthorized.
    ccs>�|��D]}|��D]\}}|�|�V}|�||�qqdS)zt
        The given credentials are accepted by all the checkers, and give
        the expected C{avatarID}s
        N)�getCheckers�getGoodCredentialsr�rD)r�chk�credr2r�rrr�
test_positiveSs���zCheckersMixin.test_positiveccs<�|��D]}|��D]}|�|�}|�|tj�VqqdS)zI
        The given credentials are rejected by all the checkers.
        N)r��getBadCredentialsr��
assertFailurerrW)rr�r�r�rrr�
test_negative^s�
��zCheckersMixin.test_negativeN)rrrrr
�inlineCallbacksr�r�rrrrr�Es

r�c@sLeZdZejZdZededefdd��Z	gd�Z
dd�Zd	d
�Zdd�Z
dS)
�HashlessFilePasswordDBMixinNr�r�cC�|Sr+rr�rrr�networkHashmsz'HashlessFilePasswordDBMixin.networkHash))r_�	password1)r`s	password2)ra�	password3ccs.�|jD]\}}|�||�|��|fVqdSr+)�_validCredentials�	credClassr�rurrrr�ws��z.HashlessFilePasswordDBMixin.getGoodCredentialsccs(�dD]\}}|�||�|��VqdS)N))r_r�)r`r�)sbloofsblarf)r�r�rurrrr�{s��z-HashlessFilePasswordDBMixin.getBadCredentialsc
#s���jpdd�}�jo�fdd�}dD]�}���}t|d��}�jD]\}}|�|d||�d�q"Wd�n1s>wYtj|||d�V���}t|d��}�jD]\}}|�||�d	|d�qYWd�n1suwYtj|d
dd||d�V���}t|d��!}�jD]\}}|�d
|��d||�d�q�Wd�n1s�wYtj|dddd||d�VqdS)NcSr�r+rr�rrrr��sz9HashlessFilePasswordDBMixin.getCheckers.<locals>.<lambda>cs
��|�Sr+)�diskHash)r,r-�storedr"rrr��s
)TFrbrcrd)�cacher�s dingle dongle � �rszip,zap,s,zup,�,r�F)r�rergr�rirrn�title)rr��	hashCheckr��fn�fObjrkrlrr"rr��s@�
��������
��z'HashlessFilePasswordDBMixin.getCheckers)rrrrrKr�r��staticmethodr�r�r�r�r�r�rrrrr�isr�c@seZdZedd��ZdS)� LocallyHashedFilePasswordDBMixincC�t|�Sr+�rr�rrrr���z)LocallyHashedFilePasswordDBMixin.diskHashN)rrrr�r�rrrrr��sr�c@s4eZdZededefdd��ZGdd�dej�ZdS)� NetworkHashedFilePasswordDBMixinr�r�cCr�r+r�r�rrrr��r�z,NetworkHashedFilePasswordDBMixin.networkHashc@seZdZdd�ZdS)z*NetworkHashedFilePasswordDBMixin.credClasscCst|j�|kSr+)rr-r.rrrr/�sz8NetworkHashedFilePasswordDBMixin.credClass.checkPasswordN)rrrr/rrrrr��sr�N)	rrrr�r�r�rrKr�rrrrr��sr�c@r')�"HashlessFilePasswordDBCheckerTestsNr)rrrrr���r�c@r')�'LocallyHashedFilePasswordDBCheckerTestsNr)rrrrr��r�r�c@r')�'NetworkHashedFilePasswordDBCheckerTestsNr)rrrrr��r�r�c@seZdZdZdd�ZdS)�UsernameHashedPasswordTestszo
    UsernameHashedPassword is a deprecated class that is functionally
    equivalent to UsernamePassword.
    cCs|�ddtd�dS)zB
        Tests that UsernameHashedPassword is deprecated.
        r�r�z6Use twisted.cred.credentials.UsernamePassword instead.N)r�r�r"rrr�test_deprecation�s�z,UsernameHashedPasswordTests.test_deprecationN)rrrrr�rrrrr��sr�).r�binasciirr�zope.interfacerr�twisted.credrrrr	�twisted.internetr
�twisted.pythonr�twisted.python.versionsr�
twisted.trialr
r�_crypt�ImportErrorr�rr�Adapterr&�registerAdapterrAr(r*�IRealmr0�TestCaser7r]r�r�r�r�r�r�r�r�r�rrrr�<module>sT�	\7L$8

�
�
�

Anon7 - 2022
AnonSec Team