File: //lib/python3/dist-packages/twisted/protocols/haproxy/test/__pycache__/test_wrapper.cpython-310.pyc
o
�b�6 � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZm Z ddl
mZ ddlmZ dd l
mZ G d
d� de �ZG dd
� d
ej�ZG dd� dej�ZdS )z>
Test cases for L{twisted.protocols.haproxy.HAProxyProtocol}.
� )�Optional)�mock)�address)�Factory�Protocol)� StringTransportWithDisconnection)�unittest� )�HAProxyWrappingFactoryc @ s, e Zd ZdZd dd�Zdeddfdd�ZdS )
�StaticProtocolz6
Protocol stand-in that maintains test state.
�returnNc C s d | _ d | _d| _d| _d S )N� F)�source�destination�data�disconnected)�self� r �M/usr/lib/python3/dist-packages/twisted/protocols/haproxy/test/test_wrapper.py�__init__ s
zStaticProtocol.__init__r c C s4 | j sJ �| j �� | _| j �� | _| j|7 _d S )N)� transport�getPeerr �getHostr r )r r r r r �dataReceived s
zStaticProtocol.dataReceived�r N)�__name__�
__module__�__qualname__�__doc__r �bytesr r r r r r s
r c @ s` e Zd ZdZddd�Zddd�Zddd �Zdd
d�Zddd
�Zddd�Z ddd�Z
ddd�ZdS )�HAProxyWrappingFactoryV1Testsz]
Test L{twisted.protocols.haproxy.HAProxyWrappingFactory} with v1 PROXY
headers.
r Nc C sR t t�t��}|�t�ddd��}t� }||_|� |� |�
d� | �|j� dS )�J
Test if invalid headers result in connectionLost events.
�TCP� 127.1.1.1� s NOTPROXY anything can go here
N�
r
r �forProtocolr �
buildProtocolr �IPv4Addressr �protocol�makeConnectionr �assertFalse� connected�r �factory�protor r r r �test_invalidHeaderDisconnects) s �
z;HAProxyWrappingFactoryV1Tests.test_invalidHeaderDisconnectsc C s\ t t�t��}|�t�ddd��}t� }||_|� |� |�
d� |�
d� | �|j� dS )r! r"