%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/cred/test/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/cred/test/__pycache__/test_cramauth.cpython-312.pyc |
� Ϫ�f� � �Z � d Z ddlZddlmZ ddlmZ ddlmZmZ ddl m Z G d� de � Zy) z9 Tests for L{twisted.cred}'s implementation of CRAM-MD5. � N)�hexlify)�HMAC)�CramMD5Credentials�IUsernameHashedPassword)�TestCasec �@ � e Zd ZdZd 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_idempotentChallenge s/ � � � ���~�~�������q�~�~�/�0� c �� � t � }|j � }t t d|t j �� j � � |_ | j |j d� � 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) r r r r �hashlib�md5�digest�response� assertTrue� checkPasswordr s r �test_checkPasswordz*CramMD5CredentialsTests.test_checkPassword sO � � � ���~�~����T�)�T�W�[�[�I�P�P�R�S�� ������� �2�3r c �X � t � }| j |j d� � y)zg When there is no response set, calling C{checkPassword} will return L{False}. r N)r �assertFalser )r r s r �test_noResponsez'CramMD5CredentialsTests.test_noResponse+ s# � � � ���������3�4r c �� � t � }|j � }t t d|t j �� j � � |_ | j |j d� � 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}. s thewrongsecretr r N) r r r r r r r r r r r s r �test_wrongPasswordz*CramMD5CredentialsTests.test_wrongPassword3 sW � � � ���~�~�����"�D�G�K�K�@�G�G�I� �� � �������3�4r c �V � t � }|j � }|j dj dt t d|t j �� j � � f� � | j |j d� � | j |j d� 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}. � s squirrels supersecretr N) r r �setResponse�joinr r r r r r r r �usernamer s r �test_setResponsez(CramMD5CredentialsTests.test_setResponseA s� � � � ���~�~��� � � ��I�I���D������M�T�T�V�W�� � � �������7�8�������[�1r c �T � | j t j t � � y)zd L{CramMD5Credentials} implements the L{IUsernameHashedPassword} interface. N)r r � implementedByr )r s r �test_interfacez&CramMD5CredentialsTests.test_interfaceT s � � ���/�=�=�>P�Q�Rr )�returnN) �__name__� __module__�__qualname__�__doc__r r r! r# r) r, � r r r r s&