HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/cred/test/__pycache__/test_cramauth.cpython-38.pyc
U


W[>�@sddZddlmZmZddlmZddlmZddlm	Z	ddl
mZddl
mZGdd	�d	e	�Z
d
S)z9
Tests for L{twisted.cred}'s implementation of CRAM-MD5.
�)�division�absolute_import)�HMAC)�hexlify)�TestCase)�CramMD5Credentials)�IUsernameHashedPasswordc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�CramMD5CredentialsTestsz*
    Tests for L{CramMD5Credentials}.
    cCs"t�}|��}|�||���dS)z�
        The same L{CramMD5Credentials} will always provide the same challenge,
        no matter how many times it is called.
        N)r�getChallenge�assertEqual��self�cZchal�r�A/usr/lib/python3/dist-packages/twisted/cred/test/test_cramauth.py�test_idempotentChallengesz0CramMD5CredentialsTests.test_idempotentChallengecCs6t�}|��}ttd|����|_|�|�d��dS)a2
        When a valid response (which is a hex digest of the challenge that has
        been encrypted by the user's shared secret) is set on the
        L{CramMD5Credentials} that created the challenge, and C{checkPassword}
        is called with the user's shared secret, it will return L{True}.
        �secretN)rr
rr�digest�response�
assertTrue�
checkPasswordrrrr�test_checkPassword!sz*CramMD5CredentialsTests.test_checkPasswordcCst�}|�|�d��dS)zg
        When there is no response set, calling C{checkPassword} will return
        L{False}.
        rN)r�assertFalser)r
rrrr�test_noResponse.sz'CramMD5CredentialsTests.test_noResponsecCs6t�}|��}ttd|����|_|�|�d��dS)a 
        When an invalid response is set on the L{CramMD5Credentials} (one that
        is not the hex digest of the challenge, encrypted with the user's shared
        secret) and C{checkPassword} is called with the user's correct shared
        secret, it will return L{False}.
        sthewrongsecretrN)rr
rrrrrrrrrr�test_wrongPassword7sz*CramMD5CredentialsTests.test_wrongPasswordc	CsRt�}|��}|�d�dttd|����f��|�|�d��|�	|j
d�dS)z�
        When C{setResponse} is called with a string that is the username and
        the hashed challenge separated with a space, they will be set on the
        L{CramMD5Credentials}.
        � ssquirrelssupersecretN)rr
ZsetResponse�joinrrrrrrZusernamerrrr�test_setResponseDs��z(CramMD5CredentialsTests.test_setResponsecCs|�t�t��dS)zd
        L{CramMD5Credentials} implements the L{IUsernameHashedPassword}
        interface.
        N)rrZ
implementedByr)r
rrr�test_interfaceSs�z&CramMD5CredentialsTests.test_interfaceN)
�__name__�
__module__�__qualname__�__doc__rrrrrrrrrrr	s

	
r	N)r"Z
__future__rrZhmacrZbinasciirZtwisted.trial.unittestrZtwisted.cred.credentialsrrr	rrrr�<module>s