o
    Òó·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                   @   s4   e Zd ZdZes
dZdeddfdd„Zd
dd	„ZdS )ÚTestSSHConnectForwardingChannelzH
    Unit and integration tests for L{SSHConnectForwardingChannel}.
    zCannot run without cryptographyÚreactorÚreturnNc                 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   úhC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-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::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)r   N)	Ú__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   