%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f<���dZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZGd	�d
ej �ZGd�dej$�ZGd
�dej$�ZGd�de�ZGd�dej �Zej0dd�dddk(rdZdZndZdZGd�dej �Zy)z0
Test cases for twisted.protocols.ident module.
�N)�StringIO)�defer�error)�StringTransport)�ident)�failure)�unittestc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�ClassParserTestsz*
    Test parsing of ident responses.
    c�6�tj�|_y)z7
        Create an ident client used in tests.
        N)r�IdentClient�client��selfs �9/usr/lib/python3/dist-packages/twisted/test/test_ident.py�setUpzClassParserTests.setUps���'�'�)���c���tj�}|jjj	|ddf�|jjd�|j
|tj�S)zX
        'UNKNOWN-ERROR' error should map to the L{ident.IdentError} exception.
        �{��z 123, 456 : ERROR : UNKNOWN-ERROR)	r�Deferredr�queries�append�lineReceived�
assertFailurer�
IdentError�r�ds  r�test_indentErrorz!ClassParserTests.test_indentErrorsZ��
�N�N��������"�"�A�s�C�=�1���� � �!C�D��!�!�!�U�%5�%5�6�6rc���tj�}|jjj	|ddf�|jjd�|j
|tj�S)zN
        'NO-USER' error should map to the L{ident.NoUser} exception.
        ��rz234, 456 : ERROR : NO-USER)	rrrrrrrr�NoUserrs  r�test_noUSerErrorz!ClassParserTests.test_noUSerError(sX��
�N�N��������"�"�A�s�C�=�1���� � �!=�>��!�!�!�U�\�\�2�2rc���tj�}|jjj	|ddf�|jjd�|j
|tj�S)zX
        'INVALID-PORT' error should map to the L{ident.InvalidPort} exception.
        iY�7z 345, 567 :  ERROR : INVALID-PORT)	rrrrrrrr�InvalidPortrs  r�test_invalidPortErrorz&ClassParserTests.test_invalidPortError1sZ��
�N�N��������"�"�A�s�C�=�1���� � �!C�D��!�!�!�U�%6�%6�7�7rc���tj�}|jjj	|ddf�|jjd�|j
|tj�S)zV
        'HIDDEN-USER' error should map to the L{ident.HiddenUser} exception.
        r%iz567, 789 : ERROR : HIDDEN-USER)	rrrrrrrr�
HiddenUserrs  r�test_hiddenUserErrorz%ClassParserTests.test_hiddenUserError:sZ��
�N�N��������"�"�A�s�C�=�1���� � �!A�B��!�!�!�U�%5�%5�6�6rc�:�tj�}|jjj	|ddf�|jjt
jtj���|j|tj�S)zy
        A pending query which failed because of a ConnectionLost should
        receive an L{ident.IdentError}.
        i�i�)
rrrrr�connectionLostr�Failurer�ConnectionLostrrrrs  r�test_lostConnectionz$ClassParserTests.test_lostConnectionCsk��

�N�N��������"�"�A�s�C�=�1����"�"�7�?�?�5�3G�3G�3I�#J�K��!�!�!�U�%5�%5�6�6rN)
�__name__�
__module__�__qualname__�__doc__rrr#r'r*r/�rrrrs%���*�7�3�8�7�7rrc��eZdZd�Zy)�TestIdentServerc��|jS�N)�resultValue�r�
serverAddress�
clientAddresss   r�lookupzTestIdentServer.lookupOs�����rN�r0r1r2r=r4rrr6r6Ns�� rr6c��eZdZd�Zy)�TestErrorIdentServerc�"�|j��r8)�
exceptionTyper:s   rr=zTestErrorIdentServer.lookupTs��� � �"�"rNr>r4rrr@r@Ss��#rr@c��eZdZy)�NewExceptionN)r0r1r2r4rrrDrDXs��rrDc��eZdZd�Zd�Zy)�ServerParserTestsc��t�}|jt��g}|j|_t
j|_|jd�|j|dd�t
j|_|jd�|j|dd�t
j|_|jd�|j|dd	�t
j|_|jd
�|j|dd�t|_|jd
�|j|dd�|jt�}|jt|�d�dD]M}|dd�=|jd|fz�|jd|fz�|j|d|fzd|fzg��Oy)Nz123, 345rz 123, 345 : ERROR : UNKNOWN-ERRORz432, 210�z432, 210 : ERROR : NO-USERz987, 654�z987, 654 : ERROR : INVALID-PORTz756, 827�z756, 827 : ERROR : HIDDEN-USERz987, 789�z 987, 789 : ERROR : UNKNOWN-ERROR)���riiz%d, 5z5, %dz%d, 5 : ERROR : INVALID-PORTz5, %d : ERROR : INVALID-PORT)r@�makeConnectionrr�sendLinerrrBr�assertEqualr"r&r)rD�flushLoggedErrors�len)r�p�L�errs�ports     r�
testErrorszServerParserTests.testErrors]s��� �"��	����*�+����X�X��
��*�*���	���z�"�����1��A�B��,�,���	���z�"�����1��;�<��+�+���	���z�"�����1��@�A��*�*���	���z�"�����1��?�@�&���	���z�"�����1��A�B��%�%�l�3������T��A�&�'�
	�D��!��
�N�N�7�d�W�,�-�
�N�N�7�d�W�,�-�����2�d�W�<�2�d�W�<��
�	
	rc���t�}|jt��g}|j|_d|_|j
d�|j|dd�y)N)�SYS�USERz123, 456rz123, 456 : USERID : SYS : USER)r6rMrrrNr9rrO)rrRrSs   r�testSuccesszServerParserTests.testSuccess�sS�����	����*�+����X�X��
�'��
�	���z�"�����1��?�@rN)r0r1r2rVrZr4rrrFrF\s��&�PArrFz=LrH��0100007F�04030201�7F000001�01020304c�L�eZdZde�de�d�ZdezZd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�ProcMixinTestsz4: z:0019 z]:02FA 0A 00000000:00000000 00:00000000 00000000     0        0 10927 1 f72a5b80 3000 0 0 2 -1zd  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
   c�v�tj�}|j|jt�d�y)N�	127.0.0.1)r�ProcServerMixinrO�dottedQuadFromHexString�_addr1�rrRs  r�testDottedQuadFromHexStringz*ProcMixinTests.testDottedQuadFromHexString�s+���!�!�#������2�2�6�:�K�Hrc�|�tj�}|j|jtdz�d�y)Nz:0277)rciw)rrdrO�
unpackAddressrfrgs  r�testUnpackAddressz ProcMixinTests.testUnpackAddress�s/���!�!�#���������'�)9�:�<N�Orc��tj�}|j|j|j�d�y)N)�rc���1.2.3.4�r)rrdrO�	parseLine�linergs  r�testLineParserzProcMixinTests.testLineParser�s1���!�!�#�����
�K�K��	�	�"�$L�	
rc�����g�tj�}�fd�|_�fd�|_�j	|jdd�|jdf��j	�dg�y)Nc�0��t�jg�Sr8��iterrsrs�r�<lambda>z4ProcMixinTests.testExistingAddress.<locals>.<lambda>�����D�$�)�)��-�rc�0���j|�dfdS)N�rootrH)r)�uid�usernames �rryz4ProcMixinTests.testExistingAddress.<locals>.<lambda>�s���X�_�_�S�%9�6�$B�1�$E�rrmror|r)rrd�entries�getUsernamerOr=�SYSTEM_NAME)rrRr~s` @r�testExistingAddressz"ProcMixinTests.testExistingAddress�sa������!�!�#��-��	�E��
����
�H�H�&�(8�9�A�M�M�6�;R�	
�	
����A�3�'rc�J��tj�}�fd�|_�jtj|j
dd��jtj|j
dd��jtj|j
dd�y)Nc�0��t�jg�Sr8rwrs�rryz7ProcMixinTests.testNonExistingAddress.<locals>.<lambda>�rzr�rc�rorm)z1.2.3.5rq)rpi�)rrdr�assertRaisesr"r=rgs` r�testNonExistingAddressz%ProcMixinTests.testNonExistingAddress�sr����!�!�#��-��	����%�,�,����2C�EU�V����%�,�,����2C�EU�V����%�,�,����2C�EU�Vrc�����g���fd�}�jtd|�tj�}�j	tj
|jdd��jdifg��y)zS
        L{ident.ProcServerMixin.lookup} uses the Linux TCP process table.
        c�T���j||f�t�j�S)z[
            Mock for the open call to prevent actually opening /proc/net/tcp.
            )rr�
sampleFile)�args�kwargs�
open_callsrs  ��r�mocked_openz8ProcMixinTests.testLookupProcNetTcp.<locals>.mocked_open�s&���
���t�V�n�-��D�O�O�,�,r�openr�ro)z
/proc/net/tcpN)�patch�builtinsrrdr�r"r=rO)rr�rRr�s`  @r�testLookupProcNetTcpz#ProcMixinTests.testLookupProcNetTcp�sf����
�	-�	
�
�
�8�V�[�1��!�!�#�����%�,�,����2C�EU�V����-�r�2�3�Z�@rN)
r0r1r2rf�_addr2rsr�rhrkrtr�r�r�r4rrrara�sD��

��	�D�	6�8<�	=��
I�P�
�(�W�Arra)r3r��struct�ior�twisted.internetrr�twisted.internet.testingr�twisted.protocolsr�twisted.pythonr�
twisted.trialr	�TestCaser�IdentServerr6r@�RuntimeErrorrDrF�packrfr�rar4rr�<module>r�s���
��
��)�4�#�"�"�77�x�(�(�77�t �e�'�'� �
#�5�,�,�#�
	�<�	�1A��)�)�1A�h�6�;�;�t�Q���!���'�
�F�
�F�
�F�
�F�;A�X�&�&�;Ar

Zerion Mini Shell 1.0