File: //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_proxy.cpython-310.pyc
o
�bNN � @ s� d Z ddlmZmZ ddlmZ ddlmZmZm Z m
Z
mZ ddlm
Z
ddlmZ ddlmZ G dd � d e�ZG d
d� d�ZG dd
� d
e�ZG dd� de�ZG dd� de�ZG dd� d�ZG dd� de�ZdS )z
Test for L{twisted.web.proxy}.
� )�
MemoryReactor� StringTransportWithDisconnection)�TestCase)�ProxyClient�ProxyClientFactory�ProxyRequest�ReverseProxyRequest�ReverseProxyResource)�Resource)�Site��DummyRequestc @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dS )�ReverseProxyResourceTestsz,
Tests for L{ReverseProxyResource}.
c C s� t � }t� }tddd|�}|�d|� t|�}t� }|�d�}|�|� | �|j d� |�
d| d � |j\\} }
}}}
| �| d� | �|
d� | �
|t� | �|j|� | �|jd d � dS )
z�
Check that a request pointing at C{uri} produce a new proxy connection,
with the path of this request pointing at C{expectedURI}.
� 127.0.0.1�� � /paths indexNs GET s HTTP/1.1
Accept: text/html
� hosts 127.0.0.1:1234)r
r r �putChildr r �
buildProtocol�makeConnection�
addCleanup�connectionLost�dataReceived�
tcpClients�assertEqual�assertIsInstancer �rest�headers)�self�uri�expectedURI�root�reactor�resource�site� transport�channel�host�port�factory�_timeout�
_bind_addr� r, �=/usr/lib/python3/dist-packages/twisted/web/test/test_proxy.py�_testRender s
z%ReverseProxyResourceTests._testRenderc C � | � dd�S )z�
Test that L{ReverseProxyResource.render} initiates a connection to the
given server with a L{ProxyClientFactory} as parameter.
s /indexr �r. �r r, r, r- �test_render8 � z%ReverseProxyResourceTests.test_renderc C r/ )z�
Test that L{ReverseProxyResource.render} will instantiate a child
resource that will initiate a connection to the given server
requesting the apropiate url subpath.
s /index/page1s /path/page1r0 r1 r, r, r- �test_render_subpage? � z-ReverseProxyResourceTests.test_render_subpagec C r/ )zr
Test that L{ReverseProxyResource.render} passes query parameters to the
created factory.
s /index?foo=bars
/path?foo=barr0 r1 r, r, r- �test_renderWithQueryG r3 z.ReverseProxyResourceTests.test_renderWithQueryc C sj t � }tddd|�}|�dd�}| �|t� | �|jd� | �|jd� | �|jd� | �|j |j � dS )a
The L{ReverseProxyResource.getChild} method should return a resource
instance with the same class as the originating resource, forward
port, host, and reactor values, and update the path value with the
value passed.
r r r � fooNs /path/foo)
r r �getChildr r �pathr( r'