U
    n5{i”  ã                   @   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                   @   s6   e Zd ZdZesdZeddœdd„Zddœdd	„ZdS )
ÚTestSSHConnectForwardingChannelzH
    Unit and integration tests for L{SSHConnectForwardingChannel}.
    zCannot run without cryptographyN)ÚreactorÚreturnc                 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)Úselfr   ÚfactoryZ	connectorÚprotocolÚ	transport© r   úF/tmp/pip-unpacked-wheel-mnhg7r0q/twisted/conch/test/test_forwarding.pyÚmakeTCPConnection   s
    

z1TestSSHConnectForwardingChannel.makeTCPConnection)r   c                 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::1NZTCPr   )r   ZSSHConnectForwardingChannelr   r   Z_reactorZchannelOpenr   ZsuccessResultOfZ_channelOpenDeferredZassertIsInstanceÚclientZSSHForwardingClientÚassertEqualr   r   ZgetPeer)r   ZsutZmemoryReactorr   r   r   Ú test_channelOpenHostnameRequests+   s    


 
ÿz@TestSSHConnectForwardingChannel.test_channelOpenHostnameRequests)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úskipr   r   r   r   r   r   r   r
      s
   r
   N)r   Ztwisted.python.reflectr   r   Ztwisted.conch.sshr   Ztwisted.internet.addressr   Z$twisted.internet.test.test_endpointsr   Ztwisted.internet.testingr   r   Ztwisted.trialr	   ZTestCaser
   r   r   r   r   Ú<module>   s   