%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/cred/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/cred/test/__pycache__/test_cramauth.cpython-312.pyc

�

Ϫ�f���Z�dZddlZddlmZddlmZddlmZmZddl	m
Z
Gd�de
�Zy)	z9
Tests for L{twisted.cred}'s implementation of CRAM-MD5.
�N)�hexlify)�HMAC)�CramMD5Credentials�IUsernameHashedPassword)�TestCasec�@�eZdZdZd	d�Zd	d�Zd	d�Zd	d�Zd	d�Zd	d�Z	y)
�CramMD5CredentialsTestsz*
    Tests for L{CramMD5Credentials}.
    Nc�x�t�}|j�}|j||j��y)z�
        The same L{CramMD5Credentials} will always provide the same challenge,
        no matter how many times it is called.
        N)r�getChallenge�assertEqual��self�c�chals   �A/usr/lib/python3/dist-packages/twisted/cred/test/test_cramauth.py�test_idempotentChallengez0CramMD5CredentialsTests.test_idempotentChallenges/��

� ���~�~�������q�~�~�/�0�c���t�}|j�}ttd|tj
��j
��|_|j|jd��y)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}.
        �secret��	digestmodN)
rrrr�hashlib�md5�digest�response�
assertTrue�
checkPasswordr
s   r�test_checkPasswordz*CramMD5CredentialsTests.test_checkPasswordsO��
� ���~�~����T�)�T�W�[�[�I�P�P�R�S��
�������	�2�3rc�X�t�}|j|jd��y)zg
        When there is no response set, calling C{checkPassword} will return
        L{False}.
        rN)r�assertFalser)rrs  r�test_noResponsez'CramMD5CredentialsTests.test_noResponse+s#��

� ���������3�4rc���t�}|j�}ttd|tj
��j
��|_|j|jd��y)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}.
        sthewrongsecretrrN)
rrrrrrrrr rr
s   r�test_wrongPasswordz*CramMD5CredentialsTests.test_wrongPassword3sW��
� ���~�~�����"�D�G�K�K�@�G�G�I�
��
�	
�������3�4rc�V�t�}|j�}|jdjdt	td|tj��j��f��|j|jd��|j|jd�y)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}.
        � ssquirrelssupersecretrN)
rr�setResponse�joinrrrrrrrr�usernamer
s   r�test_setResponsez(CramMD5CredentialsTests.test_setResponseAs���
� ���~�~���	�
�
��I�I���D������M�T�T�V�W��
�	
�	
�������7�8�������[�1rc�T�|jtjt��y)zd
        L{CramMD5Credentials} implements the L{IUsernameHashedPassword}
        interface.
        N)rr�
implementedByr)rs r�test_interfacez&CramMD5CredentialsTests.test_interfaceTs��
	
���/�=�=�>P�Q�Rr)�returnN)
�__name__�
__module__�__qualname__�__doc__rrr!r#r)r,�rrr	r	s&���1�
4�5�5�2�&Srr	)r1r�binasciir�hmacr�twisted.cred.credentialsrr�twisted.trial.unittestrr	r2rr�<module>r7s+���
���P�+�HS�h�HSr

Zerion Mini Shell 1.0