File: //lib/python3/dist-packages/twisted/protocols/haproxy/test/__pycache__/test_wrapper.cpython-38.pyc
U
W[�2 � @ s| d Z ddlmZ ddlmZ ddlmZmZ ddlm Z ddl
mZ G dd � d e�ZG d
d� dej
�ZG dd
� d
ej
�ZdS )z>
Test cases for L{twisted.protocols.haproxy.HAProxyProtocol}.
� )�unittest)�address)�Protocol�Factory)� StringTransportWithDisconnection� )�HAProxyWrappingFactoryc @ s e Zd ZdZdd� Zdd� ZdS )�StaticProtocolz6
Protocol stand-in that maintains test state.
c C s d | _ d | _d| _d| _d S )N� F)�source�destination�dataZdisconnected)�self� r �M/usr/lib/python3/dist-packages/twisted/protocols/haproxy/test/test_wrapper.py�__init__ s zStaticProtocol.__init__c C s* | j �� | _| j �� | _| j|7 _d S )N)� transport�getPeerr �getHostr r
)r r
r r r �dataReceived s zStaticProtocol.dataReceivedN)�__name__�
__module__�__qualname__�__doc__r r r r r r r s r c @ sH e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dS )�HAProxyWrappingFactoryV1Testsz]
Test L{twisted.protocols.haproxy.HAProxyWrappingFactory} with v1 PROXY
headers.
c 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 r r s PROXY TCP4 1.1.1.1
s 2.2.2.2 8080
Nr r'