U
    
W[                     @   s   d Z ddlmZmZ ddlmZ edZer8ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZmZ G d
d dejZdS )z,
Tests for L{twisted.conch.ssh.forwarding}.
    )divisionabsolute_import)requireModulecryptography)
forwarding)IPv6Address)unittest)deterministicResolvingReactor)MemoryReactorClockStringTransportc                   @   s(   e Zd ZdZesdZdd Zdd ZdS )TestSSHConnectForwardingChannelzH
    Unit and integration tests for L{SSHConnectForwardingChannel}.
    zCannot run without cryptographyc                 C   s>   |j d d }|jd }|d}t| d}|| dS )z
        Fake that connection was established for first connectTCP request made
        on C{reactor}.

        @param reactor: Reactor on which to fake the connection.
        @type  reactor: A reactor.
        r      N)ZpeerAddress)Z
tcpClientsZ
connectorsZbuildProtocolr   ZgetDestinationZmakeConnection)selfZreactorfactoryZ	connectorZprotocol	transport r   D/usr/lib/python3/dist-packages/twisted/conch/test/test_forwarding.pymakeTCPConnection   s
    

z1TestSSHConnectForwardingChannel.makeTCPConnectionc                 C   sp   t jdd}t }t|dg|_|d | | | |j | 	|j
t j | tddd|j
j  dS )z
        When a hostname is sent as part of forwarding requests, it
        is resolved using HostnameEndpoint's resolver.
        )zfwd.example.org  )Zhostportz::1NZTCPr   )r   ZSSHConnectForwardingChannelr
   r	   Z_reactorZchannelOpenr   ZsuccessResultOfZ_channelOpenDeferredZassertIsInstanceZclientZSSHForwardingClientZassertEqualr   r   ZgetPeer)r   ZsutZmemoryReactorr   r   r    test_channelOpenHostnameRequests-   s    


 
z@TestSSHConnectForwardingChannel.test_channelOpenHostnameRequestsN)__name__
__module____qualname____doc__r   skipr   r   r   r   r   r   r      s
   r   N)r   Z
__future__r   r   Ztwisted.python.reflectr   r   Ztwisted.conch.sshr   Ztwisted.internet.addressr   Ztwisted.trialr   Z$twisted.internet.test.test_endpointsr	   Ztwisted.test.proto_helpersr
   r   ZTestCaser   r   r   r   r   <module>   s   