Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/twisted/protocols/haproxy/test/__pycache__/test_v2parser.cpython-39.pyc
Ðазад
a k�h�. � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ dZ e ddd d dfe e e e e e e d�d d�Ze dddddfe e e e e e e d�dd�Ze ddddfe e e e e e d�dd�Z G dd� dej�ZdS )z7 Test cases for L{twisted.protocols.haproxy.V2Parser}. � )�address)�unittest� )� _v2parser)�InvalidProxyHeaders QUIT � !s $s s �"�)�sig�verCom�famProto� addrLength�addrs�ports�returnc C s | | | | | | S )aV Construct a version 2 IPv6 header with custom bytes. @param sig: The protocol signature; defaults to valid L{V2_SIGNATURE}. @type sig: L{bytes} @param verCom: Protocol version and command. Defaults to V2 PROXY. @type verCom: L{bytes} @param famProto: Address family and protocol. Defaults to AF_INET6/STREAM. @type famProto: L{bytes} @param addrLength: Network-endian byte length of payload. Defaults to description of default addrs/ports. @type addrLength: L{bytes} @param addrs: Address payload. Defaults to C{::1} for source and destination. @type addrs: L{bytes} @param ports: Source and destination ports. Defaults to 8080 for source 8888 for destination. @type ports: L{bytes} @return: A packet with header, addresses, and ports. @rtype: L{bytes} � �r r r r r r r r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/twisted/protocols/haproxy/test/test_v2parser.py�_makeHeaderIPv6 s #r � s s c C s | | | | | | S )aX Construct a version 2 IPv4 header with custom bytes. @param sig: The protocol signature; defaults to valid L{V2_SIGNATURE}. @type sig: L{bytes} @param verCom: Protocol version and command. Defaults to V2 PROXY. @type verCom: L{bytes} @param famProto: Address family and protocol. Defaults to AF_INET/STREAM. @type famProto: L{bytes} @param addrLength: Network-endian byte length of payload. Defaults to description of default addrs/ports. @type addrLength: L{bytes} @param addrs: Address payload. Defaults to 127.0.0.1 for source and destination. @type addrs: L{bytes} @param ports: Source and destination ports. Defaults to 8080 for source 8888 for destination. @type ports: L{bytes} @return: A packet with header, addresses, and ports. @rtype: L{bytes} r r r r r �_makeHeaderIPv46 s #r � 1s �s� /home/tests/mysockets/sock /home/tests/mysockets/sock )r r r r r r c C s | | | | | S )a� Construct a version 2 IPv4 header with custom bytes. @param sig: The protocol signature; defaults to valid L{V2_SIGNATURE}. @type sig: L{bytes} @param verCom: Protocol version and command. Defaults to V2 PROXY. @type verCom: L{bytes} @param famProto: Address family and protocol. Defaults to AF_UNIX/STREAM. @type famProto: L{bytes} @param addrLength: Network-endian byte length of payload. Defaults to 108 bytes for 2 null terminated paths. @type addrLength: L{bytes} @param addrs: Address payload. Defaults to C{/home/tests/mysockets/sock} for source and destination paths. @type addrs: L{bytes} @return: A packet with header, addresses, and8 ports. @rtype: L{bytes} r )r r r r r r r r �_makeHeaderUnix\ s #r c @ s` e Zd ZdZdd�dd�Zdd�dd�Zdd�dd �Zdd�d d�Zdd�dd �Zdd�dd�Z dd�dd�Z dd�dd�Zdd�dd�Zdd�dd�Z dd�dd�Zdd�dd�Zdd�dd�Zdd�dd�Zdd�d d!�Zdd�d"d#�Zdd�d$d%�Zdd�d&d'�Zdd�d(d)�Zdd�d*d+�Zdd�d,d-�Zdd�d.d/�Zdd�d0d1�Zdd�d2d3�ZdS )4� V2ParserTestsz? Test L{twisted.protocols.haproxy.V2Parser} behaviour. N)r c C s t � }| �tj�|�� dS )zL Test if a well formed IPv4 header is parsed without error. N)r � assertTruer �V2Parser�parse��self�headerr r r �test_happyPathIPv4� s z V2ParserTests.test_happyPathIPv4c C s t � }| �tj�|�� dS )zL Test if a well formed IPv6 header is parsed without error. N)r r r r r r r r r �test_happyPathIPv6� s z V2ParserTests.test_happyPathIPv6c C s t � }| �tj�|�� dS )zL Test if a well formed UNIX header is parsed without error. N)r r r r r r r r r �test_happyPathUnix� s z V2ParserTests.test_happyPathUnixc C s t dd�}| �ttjj|� dS )zN Test if an invalid signature block raises InvalidProxyError. s )r N�r �assertRaisesr r r r r r r r �test_invalidSignature� s �z#V2ParserTests.test_invalidSignaturec C s t dd�}| �ttjj|� dS )zF Test if an invalid version raises InvalidProxyError. r �r Nr! r r r r �test_invalidVersion� s �z!V2ParserTests.test_invalidVersionc C s t dd�}| �ttjj|� dS )zF Test if an invalid command raises InvalidProxyError. � #r$ Nr! r r r r �test_invalidCommand� s �z!V2ParserTests.test_invalidCommandc C s t dd�}| �ttjj|� dS )zE Test if an invalid family raises InvalidProxyError. � @�r Nr! r r r r �test_invalidFamily� s �z V2ParserTests.test_invalidFamilyc C s t dd�}| �ttjj|� dS )zG Test if an invalid protocol raises InvalidProxyError. � $r) Nr! r r r r �test_invalidProto� s �zV2ParserTests.test_invalidProtoc C s2 t dd�}tj�|�}| �|j� | �|j� dS )zU Test that local does not return endpoint data for IPv4 connections. � r$ N�r r r r �assertFalse�source�destination�r r �infor r r �test_localCommandIpv4� s z#V2ParserTests.test_localCommandIpv4c C s2 t dd�}tj�|�}| �|j� | �|j� dS )zU Test that local does not return endpoint data for IPv6 connections. r- r$ N�r r r r r/ r0 r1 r2 r r r �test_localCommandIpv6� s z#V2ParserTests.test_localCommandIpv6c C s2 t dd�}tj�|�}| �|j� | �|j� dS )zU Test that local does not return endpoint data for UNIX connections. r- r$ N�r r r r r/ r0 r1 r2 r r r �test_localCommandUnix� s z#V2ParserTests.test_localCommandUnixc C sR t dd�}tj�|�}| �|j� | �|jtj� | �|j � | �|j tj� dS )zM Test that proxy returns endpoint data for IPv4 connections. r r$ N) r r r r r r0 �assertIsInstancer �IPv4Addressr1 r2 r r r �test_proxyCommandIpv4� s z#V2ParserTests.test_proxyCommandIpv4c C sR t dd�}tj�|�}| �|j� | �|jtj� | �|j � | �|j tj� dS )zM Test that proxy returns endpoint data for IPv6 connections. r r$ N) r r r r r r0 r9 r �IPv6Addressr1 r2 r r r �test_proxyCommandIpv6� s z#V2ParserTests.test_proxyCommandIpv6c C sR t dd�}tj�|�}| �|j� | �|jtj� | �|j � | �|j tj� dS )zM Test that proxy returns endpoint data for UNIX connections. r r$ N) r r r r r r0 r9 r ZUNIXAddressr1 r2 r r r �test_proxyCommandUnix s z#V2ParserTests.test_proxyCommandUnixc C s2 t dd�}tj�|�}| �|j� | �|j� dS )�V Test that UNSPEC does not return endpoint data for IPv4 connections. � r) Nr. r2 r r r �test_unspecFamilyIpv4 s z#V2ParserTests.test_unspecFamilyIpv4c C s2 t dd�}tj�|�}| �|j� | �|j� dS )�V Test that UNSPEC does not return endpoint data for IPv6 connections. r@ r) Nr5 r2 r r r �test_unspecFamilyIpv6 s z#V2ParserTests.test_unspecFamilyIpv6c C s2 t dd�}tj�|�}| �|j� | �|j� dS )�V Test that UNSPEC does not return endpoint data for UNIX connections. r@ r) Nr7 r2 r r r �test_unspecFamilyUnix! s z#V2ParserTests.test_unspecFamilyUnixc C s2 t dd�}tj�|�}| �|j� | �|j� dS )r? � r) Nr. r2 r r r �test_unspecProtoIpv4* s z"V2ParserTests.test_unspecProtoIpv4c C s2 t dd�}tj�|�}| �|j� | �|j� dS )rB r- r) Nr5 r2 r r r �test_unspecProtoIpv63 s z"V2ParserTests.test_unspecProtoIpv6c C s2 t dd�}tj�|�}| �|j� | �|j� dS )rD � 0r) Nr7 r2 r r r �test_unspecProtoUnix< s z"V2ParserTests.test_unspecProtoUnixc C s>