File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_ident.cpython-310.pyc
o
�b> � @ s� d Z ddlZddlZddlmZ ddlmZmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ G d d
� d
ej�ZG dd� de j�ZG d
d� de j�ZG dd� de�ZG dd� dej�Ze�dd�dd� dkrmdZdZndZdZG dd� dej�ZdS )z0
Test cases for twisted.protocols.ident module.
� N)�StringIO)�defer�error)�ident)�failure)�StringTransport)�unittestc @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dS )�ClassParserTestsz*
Test parsing of ident responses.
c C s t �� | _dS )z7
Create an ident client used in tests.
N)r �IdentClient�client��self� r �9/usr/lib/python3/dist-packages/twisted/test/test_ident.py�setUp s zClassParserTests.setUpc C �6 t �� }| jj�|ddf� | j�d� | �|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
�dr r r �test_indentError � z!ClassParserTests.test_indentErrorc C r )zN
'NO-USER' error should map to the L{ident.NoUser} exception.
�� r z234, 456 : ERROR : NO-USER) r r r r r r r r �NoUserr r r r �test_noUSerError( r z!ClassParserTests.test_noUSerErrorc C r )zX
'INVALID-PORT' error should map to the L{ident.InvalidPort} exception.
iY �7 z 345, 567 : ERROR : INVALID-PORT) r r r r r r r r �InvalidPortr r r r �test_invalidPortError1 r z&ClassParserTests.test_invalidPortErrorc C r )zV
'HIDDEN-USER' error should map to the L{ident.HiddenUser} exception.
r! i z567, 789 : ERROR : HIDDEN-USER) r r r r r r r r �
HiddenUserr r r r �test_hiddenUserError: r z%ClassParserTests.test_hiddenUserErrorc C s@ t �� }| jj�|ddf� | j�t�t� � �� | �
|tj�S )zy
A pending query which failed because of a ConnectionLost should
receive an L{ident.IdentError}.
i� i� )
r r r r r �connectionLostr �Failurer �ConnectionLostr r r r r r r �test_lostConnectionC s z$ClassParserTests.test_lostConnectionN)
�__name__�
__module__�__qualname__�__doc__r r r r# r% r) r r r r r s r c @ � e Zd Zdd� ZdS )�TestIdentServerc C s | j S �N)�resultValue�r
�
serverAddress�
clientAddressr r r �lookupO s zTestIdentServer.lookupN�r* r+ r, r5 r r r r r/ N � r/ c @ r. )�TestErrorIdentServerc C s | � � �r0 )�
exceptionTyper2 r r r r5 T s zTestErrorIdentServer.lookupNr6 r r r r r8 S r7 r8 c @ s e Zd ZdS )�NewExceptionN)r* r+ r, r r r r r: X s r: c @ s e Zd Zdd� Zdd� ZdS )�ServerParserTestsc C s4 t � }|�t� � g }|j|_tj|_|�d� | � |d d� tj
|_|�d� | � |d d� tj|_|�d� | � |d d � tj|_|�d
� | � |d d� t
|_|�d
� | � |d d� | �t
�}| � t|�d� dD ]%}|d d �= |�d|f � |�d|f � | � |d|f d|f g� qrd S )Nz123, 345r z 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)���r i i z%d, 5z5, %dz%d, 5 : ERROR : INVALID-PORTz5, %d : ERROR : INVALID-PORT)r8 �makeConnectionr r �sendLiner r r9 r �assertEqualr r"