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   