o
    br                     @   sr   d Z ddlmZ edZerddlmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZ G d	d
 d
ejZdS )z,
Tests for L{twisted.conch.ssh.forwarding}.
    )requireModulecryptography)
forwarding)IPv6Address)deterministicResolvingReactor)MemoryReactorClockStringTransport)unittestc                   @   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)peerAddress)
tcpClients
connectorsbuildProtocolr   getDestinationmakeConnection)selfreactorfactory	connector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  )hostportz::1NTCPr   )r   SSHConnectForwardingChannelr   r   _reactorchannelOpenr   successResultOf_channelOpenDeferredassertIsInstanceclientSSHForwardingClientassertEqualr   r   getPeer)r   sut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.   twisted.python.reflectr   r   twisted.conch.sshr   twisted.internet.addressr   $twisted.internet.test.test_endpointsr   twisted.test.proto_helpersr   r   twisted.trialr	   TestCaser
   r   r   r   r   <module>   s   