§
    Ètºfâ‚  ã                   ón  — U d Z 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 ddlmZmZmZ ddlmZ dd	lmZmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ dZee         ed<    ed¦  «        rddl m!Z! ddl"mZm#Z#m$Z$ ddl%m&Z& ddl'm(Z( n G d„ d¦  «        Z# G d„ d¦  «        Z$ G d„ de$j)        ¦  «        Z* G d„ de$j)        ¦  «        Z+ G d„ de$j)        ¦  «        Z, G d„ d e#j-        ¦  «        Z. ee¦  «         G d!„ d"¦  «        ¦   «         Z/ ee¦  «         G d#„ d$¦  «        ¦   «         Z0 ee¦  «         G d%„ d&¦  «        ¦   «         Z1 ee¦  «         G d'„ d(¦  «        ¦   «         Z2 G d)„ d*ej3        ¦  «        Z4 G d+„ d,ej3        ¦  «        Z5 G d-„ d.ej3        ¦  «        Z6 G d/„ d0ej3        ¦  «        Z7dS )1zT
Tests for the implementation of the ssh-userauth service.

Maintainer: Paul Swartz
é    )Ú
ModuleType)ÚOptional)Úimplementer)Ú
ConchErrorÚValidPublicKey)ÚICredentialsChecker)Ú
IAnonymousÚISSHPrivateKeyÚIUsernamePassword)ÚUnauthorizedLogin)ÚIRealmÚPortal)ÚdeferÚtask)Úloopback)ÚrequireModule)ÚunittestNÚkeysÚcryptography)ÚSSHProtocolChecker)r   Ú	transportÚuserauth)ÚNS)Úkeydatac                   ó(   — e Zd Z G d„ d¦  «        ZdS )r   c                   ó   — e Zd ZdZdS )útransport.SSHTransportBaseúQ
            A stub class so that later class definitions won't die.
            N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú_/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/conch/test/test_userauth.pyÚSSHTransportBaser   "   ó   € € € € € ðð ð ð r%   r'   N)r    r!   r"   r'   r$   r%   r&   r   r   !   ó<   € € € € € ð	ð 	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	r%   r   c                   ó(   — e Zd Z G d„ d¦  «        ZdS )r   c                   ó   — e Zd ZdZdS )úuserauth.SSHUserAuthClientr   Nr   r$   r%   r&   ÚSSHUserAuthClientr,   (   r(   r%   r-   N)r    r!   r"   r-   r$   r%   r&   r   r   '   r)   r%   r   c                   ó,   — e Zd ZdZd„ Zd„ Zdd„Zd„ ZdS )ÚClientUserAuthz"
    A mock user auth client.
    c                 óØ   — | j         r)t          j                             t          j        ¦  «        S t          j        t          j                             t          j        ¦  «        ¦  «        S )z˜
        If this is the first time we've been called, return a blob for
        the DSA key.  Otherwise, return a blob
        for the RSA key.
        )	ÚlastPublicKeyr   ÚKeyÚ
fromStringr   ÚpublicRSA_opensshr   ÚsucceedÚpublicDSA_openssh©Úselfs    r&   ÚgetPublicKeyzClientUserAuth.getPublicKey3   sL   € ð Ôð 	QÝ”8×&Ò&¥wÔ'@ÑAÔAÐAå”=¥¤×!4Ò!4µWÔ5NÑ!OÔ!OÑPÔPÐPr%   c                 óx   — t          j        t          j                             t
          j        ¦  «        ¦  «        S )z@
        Return the private key object for the RSA key.
        )r   r5   r   r2   r3   r   ÚprivateRSA_opensshr7   s    r&   ÚgetPrivateKeyzClientUserAuth.getPrivateKey>   s'   € õ Œ}�TœX×0Ò0µÔ1KÑLÔLÑMÔMÐMr%   Nc                 ó*   — t          j        d¦  «        S )z/
        Return 'foo' as the password.
        ó   foo©r   r5   )r8   Úprompts     r&   ÚgetPasswordzClientUserAuth.getPasswordD   s   € õ Œ}˜VÑ$Ô$Ð$r%   c                 ó*   — t          j        d¦  «        S )z>
        Return 'foo' as the answer to two questions.
        )ÚfoorC   r?   )r8   ÚnameÚinformationÚanswerss       r&   ÚgetGenericAnswersz ClientUserAuth.getGenericAnswersJ   s   € õ Œ}˜^Ñ,Ô,Ð,r%   ©N)r    r!   r"   r#   r9   r<   rA   rG   r$   r%   r&   r/   r/   .   se   € € € € € ðð ð	Qð 	Qð 	QðNð Nð Nð%ð %ð %ð %ð-ð -ð -ð -ð -r%   r/   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚOldClientAuthz~
    The old SSHUserAuthClient returned a cryptography key object from
    getPrivateKey() and a string from getPublicKey
    c                 ó‚   — t          j        t          j                             t
          j        ¦  «        j        ¦  «        S rH   )r   r5   r   r2   r3   r   r;   Ú	keyObjectr7   s    r&   r<   zOldClientAuth.getPrivateKeyW   s(   € ÝŒ}�TœX×0Ò0µÔ1KÑLÔLÔVÑWÔWÐWr%   c                 óx   — t           j                             t          j        ¦  «                             ¦   «         S rH   )r   r2   r3   r   r4   Úblobr7   s    r&   r9   zOldClientAuth.getPublicKeyZ   s'   € ÝŒx×"Ò"¥7Ô#<Ñ=Ô=×BÒBÑDÔDÐDr%   N©r    r!   r"   r#   r<   r9   r$   r%   r&   rJ   rJ   Q   sD   € € € € € ðð ð
Xð Xð XðEð Eð Eð Eð Er%   rJ   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚClientAuthWithoutPrivateKeyzP
    This client doesn't have a private key, but it does have a public key.
    c                 ó   — d S rH   r$   r7   s    r&   r<   z)ClientAuthWithoutPrivateKey.getPrivateKeyc   s   € Øˆr%   c                 óT   — t           j                             t          j        ¦  «        S rH   )r   r2   r3   r   r4   r7   s    r&   r9   z(ClientAuthWithoutPrivateKey.getPublicKeyf   s   € ÝŒx×"Ò"¥7Ô#<Ñ=Ô=Ð=r%   NrO   r$   r%   r&   rQ   rQ   ^   s<   € € € € € ðð ðð ð ð>ð >ð >ð >ð >r%   rQ   c                   ó^   — e Zd ZdZ G d„ d¦  «        Z G d„ d¦  «        Zd„ Zd„ Zd„ Zd	„ Z	d
S )ÚFakeTransporta_  
    L{userauth.SSHUserAuthServer} expects an SSH transport which has a factory
    attribute which has a portal attribute. Because the portal is important for
    testing authentication, we need to be able to provide an interesting portal
    object to the L{SSHUserAuthServer}.

    In addition, we want to be able to capture any packets sent over the
    transport.

    @ivar packets: a list of 2-tuples: (messageType, data).  Each 2-tuple is
        a sent packet.
    @type packets: C{list}
    @param lostConnecion: True if loseConnection has been called on us.
    @type lostConnection: L{bool}
    c                   ó   — e Zd ZdZdZd„ ZdS )úFakeTransport.ServicezW
        A mock service, representing the other service offered by the server.
        ó   nancyc                 ó   — d S rH   r$   r7   s    r&   ÚserviceStartedz$FakeTransport.Service.serviceStarted‚   s   € ØˆDr%   N)r    r!   r"   r#   rD   rZ   r$   r%   r&   ÚServicerW   {   s4   € € € € € ð	ð 	ð ˆð	ð 	ð 	ð 	ð 	r%   r[   c                   ó   — e Zd ZdZd„ ZdS )úFakeTransport.Factoryzg
        A mock factory, representing the factory that spawned this user auth
        service.
        c                 ó*   — |dk    rt           j        S dS )z2
            Return our fake service.
            ó   noneN)rU   r[   )r8   r   Úservices      r&   Ú
getServicez FakeTransport.Factory.getService‹   s    € ð ˜'Ò!Ð!Ý$Ô,Ð,ð "Ð!r%   N)r    r!   r"   r#   ra   r$   r%   r&   ÚFactoryr]   …   s-   € € € € € ð	ð 	ð
	-ð 	-ð 	-ð 	-ð 	-r%   rb   c                 óz   — |                       ¦   «         | _        || j        _        d| _        | | _        g | _        d S ©NF)rb   ÚfactoryÚportalÚlostConnectionr   Úpackets)r8   rf   s     r&   Ú__init__zFakeTransport.__init__’   s5   € Ø—|’|‘~”~ˆŒØ$ˆŒÔØ#ˆÔØˆŒØˆŒˆˆr%   c                 ó>   — | j                              ||f¦  «         dS )z8
        Record the packet sent by the service.
        N)rh   Úappend)r8   ÚmessageTypeÚmessages      r&   Ú
sendPacketzFakeTransport.sendPacket™   s%   € ð 	Œ×Ò˜[¨'Ð2Ñ3Ô3Ð3Ð3Ð3r%   c                 ó   — dS )z»
        Pretend that this transport encrypts traffic in both directions. The
        SSHUserAuthServer disables password authentication if the transport
        isn't encrypted.
        Tr$   )r8   Ú	directions     r&   ÚisEncryptedzFakeTransport.isEncryptedŸ   s	   € ð ˆtr%   c                 ó   — d| _         d S ©NT)rg   r7   s    r&   ÚloseConnectionzFakeTransport.loseConnection§   s   € Ø"ˆÔÐÐr%   N)
r    r!   r"   r#   r[   rb   ri   rn   rq   rt   r$   r%   r&   rU   rU   j   sª   € € € € € ðð ð ð ð ð ð ñ ô ð ð-ð -ð -ð -ð -ñ -ô -ð -ðð ð ð4ð 4ð 4ðð ð ð#ð #ð #ð #ð #r%   rU   c                   ó   — e Zd ZdZd„ ZdS )ÚRealmz¿
    A mock realm for testing L{userauth.SSHUserAuthServer}.

    This realm is not actually used in the course of testing, so it returns the
    simplest thing that could possibly work.
    c                 ó>   — t          j        |d         d d„ f¦  «        S )Nr   c                  ó   — d S rH   r$   r$   r%   r&   ú<lambda>z%Realm.requestAvatar.<locals>.<lambda>µ   s   € ¸4€ r%   r?   )r8   ÚavatarIdÚmindÚ
interfacess       r&   ÚrequestAvatarzRealm.requestAvatar´   s   € ÝŒ}˜j¨œm¨T°<°<Ð@ÑAÔAÐAr%   N)r    r!   r"   r#   r}   r$   r%   r&   rv   rv   «   s2   € € € € € ðð ðBð Bð Bð Bð Br%   rv   c                   ó   — e Zd ZdZefZd„ ZdS )ÚPasswordCheckerzŽ
    A very simple username/password checker which authenticates anyone whose
    password matches their username and rejects all others.
    c                 ó–   — |j         |j        k    rt          j        |j         ¦  «        S t          j        t          d¦  «        ¦  «        S )NzInvalid username/password pair)ÚusernameÚpasswordr   r5   Úfailr   )r8   Úcredss     r&   ÚrequestAvatarIdzPasswordChecker.requestAvatarIdÁ   s=   € ØŒ>˜Uœ^Ò+Ð+Ý”= ¤Ñ0Ô0Ð0ÝŒzÕ+Ð,LÑMÔMÑNÔNÐNr%   N)r    r!   r"   r#   r   ÚcredentialInterfacesr…   r$   r%   r&   r   r   ¸   s=   € € € € € ðð ð
 .Ð/ÐðOð Oð Oð Oð Or%   r   c                   ó   — e Zd ZdZefZd„ ZdS )ÚPrivateKeyCheckerz•
    A very simple public key checker which authenticates anyone whose
    public/private keypair is the same keydata.public/privateRSA_openssh.
    c                 óh  — |j         t          j                             t          j        ¦  «                              ¦   «         k    ra|j        �Lt          j                             |j         ¦  «        }|                     |j        |j        ¦  «        r|j	        S nt          ¦   «         ‚t          ¦   «         ‚rH   )rN   r   r2   r3   r   r4   Ú	signatureÚverifyÚsigDatar�   r   r   )r8   r„   Úobjs      r&   r…   z!PrivateKeyChecker.requestAvatarIdÐ   sŽ   € ØŒ:�œ×,Ò,­WÔ-FÑGÔG×LÒLÑNÔNÒNÐNØŒÐ*Ý”h×)Ò)¨%¬*Ñ5Ô5�Ø—:’:˜eœo¨u¬}Ñ=Ô=ð *Ø œ>Ð)ð*õ %Ñ&Ô&Ð&ÝÑ!Ô!Ð!r%   N)r    r!   r"   r#   r
   r†   r…   r$   r%   r&   rˆ   rˆ   Ç   s8   € € € € € ðð ð
 +Ð,Ðð"ð "ð "ð "ð "r%   rˆ   c                   ó   — e Zd ZdZefZd„ ZdS )ÚAnonymousCheckerzI
    A simple checker which isn't supported by L{SSHUserAuthServer}.
    c                 ó   — d S rH   r$   )r8   Úcredentialss     r&   r…   z AnonymousChecker.requestAvatarIdã   s   € àˆr%   N)r    r!   r"   r#   r	   r†   r…   r$   r%   r&   r�   r�   Û   s7   € € € € € ðð ð '˜=Ððð ð ð ð r%   r�   c                   ó’   — e Zd ZdZe€dZd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚSSHUserAuthServerTestsz&
    Tests for SSHUserAuthServer.
    Núcannot run without cryptographyc                 óÐ  — t          ¦   «         | _        t          | j        ¦  «        | _        | j                             t          ¦   «         ¦  «         | j                             t          ¦   «         ¦  «         t          j        ¦   «         | _	        t          | j        ¦  «        | j	        _        | j	                             ¦   «          | j	        j                             ¦   «          d S rH   )rv   Úrealmr   rf   ÚregisterCheckerr   rˆ   r   ÚSSHUserAuthServerÚ
authServerrU   r   rZ   ÚsupportedAuthenticationsÚsortr7   s    r&   ÚsetUpzSSHUserAuthServerTests.setUpð   s¬   € Ý‘W”WˆŒ
Ý˜TœZÑ(Ô(ˆŒØŒ×#Ò#¥OÑ$5Ô$5Ñ6Ô6Ð6ØŒ×#Ò#Õ$5Ñ$7Ô$7Ñ8Ô8Ð8Ý"Ô4Ñ6Ô6ˆŒÝ$1°$´+Ñ$>Ô$>ˆŒÔ!ØŒ×&Ò&Ñ(Ô(Ð(ØŒÔ0×5Ò5Ñ7Ô7Ð7Ð7Ð7r%   c                 óF   — | j                              ¦   «          d | _         d S rH   )r™   ÚserviceStoppedr7   s    r&   ÚtearDownzSSHUserAuthServerTests.tearDownû   ó!   € ØŒ×&Ò&Ñ(Ô(Ð(ØˆŒˆˆr%   c                 ó”   — |                       | j        j        j        d         t          j        t          d¦  «        dz   f¦  «         dS )z;
        Check that the authentication has failed.
        éÿÿÿÿs   password,publickeyó    N)ÚassertEqualr™   r   rh   r   ÚMSG_USERAUTH_FAILUREr   ©r8   Úignoreds     r&   Ú_checkFailedz#SSHUserAuthServerTests._checkFailedÿ   sO   € ð 	×ÒØŒOÔ%Ô-¨bÔ1ÝÔ*­BÐ/DÑ,EÔ,EÈÑ,OÐPñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 óÄ   — | j                              t          d¦  «        t          d¦  «        z   t          d¦  «        z   ¦  «        }|                     | j        ¦  «        S )zÃ
        A client may request a list of authentication 'method name' values
        that may continue by using the "none" authentication 'method name'.

        See RFC 4252 Section 5.2.
        r>   s   servicer_   )r™   Ússh_USERAUTH_REQUESTr   ÚaddCallbackr¨   )r8   Úds     r&   Útest_noneAuthenticationz.SSHUserAuthServerTests.test_noneAuthentication  sQ   € ð ŒO×0Ò0Ýˆv‰JŒJ�˜J™œÑ'­"¨W©+¬+Ñ5ñ
ô 
ˆð �}Š}˜TÔ.Ñ/Ô/Ð/r%   c           	      ó  ‡ — d                      t          d¦  «        t          d¦  «        t          d¦  «        dt          d¦  «        g¦  «        }‰ j                             |¦  «        }ˆ fd„}|                     |¦  «        S )zÝ
        When provided with correct password authentication information, the
        server should respond by sending a MSG_USERAUTH_SUCCESS message with
        no other data.

        See RFC 4252, Section 5.1.
        r%   r>   r_   ó   passwordr£   c                 ól   •— ‰                      ‰j        j        j        t          j        dfg¦  «         d S ©Nr%   ©r¤   r™   r   rh   r   ÚMSG_USERAUTH_SUCCESS©r§   r8   s    €r&   ÚcheckzKSSHUserAuthServerTests.test_successfulPasswordAuthentication.<locals>.check  ó>   ø€ Ø×ÒØ”Ô)Ô1ÝÔ/°Ð5Ð6ñô ð ð ð r%   )Újoinr   r™   rª   r«   )r8   Úpacketr¬   rµ   s   `   r&   Ú%test_successfulPasswordAuthenticationz<SSHUserAuthServerTests.test_successfulPasswordAuthentication  s{   ø€ ð —’�2˜f™:œ:¥r¨'¡{¤{µB°{±O´OÀUÍBÈvÉJÌJÐWÑXÔXˆØŒO×0Ò0°Ñ8Ô8ˆð	ð 	ð 	ð 	ð 	ð �}Š}˜UÑ#Ô#Ð#r%   c           	      óÈ  — d                      t          d¦  «        t          d¦  «        t          d¦  «        dt          d¦  «        g¦  «        }t          j        ¦   «         | j        _        | j                             |¦  «        }|                      | j        j        j	        g ¦  «         | j        j         
                    d¦  «         |                     | j        ¦  «        S )a;  
        When provided with invalid authentication details, the server should
        respond by sending a MSG_USERAUTH_FAILURE message which states whether
        the authentication was partially successful, and provides other, open
        options for authentication.

        See RFC 4252, Section 5.1.
        r%   r>   r_   r¯   r£   ó   baré   )r·   r   r   ÚClockr™   Úclockrª   r¤   r   rh   Úadvancer«   r¨   ©r8   r¸   r¬   s      r&   Ú!test_failedPasswordAuthenticationz8SSHUserAuthServerTests.test_failedPasswordAuthentication'  s©   € ð —’�2˜f™:œ:¥r¨'¡{¤{µB°{±O´OÀUÍBÈvÉJÌJÐWÑXÔXˆÝ $¤
¡¤ˆŒÔØŒO×0Ò0°Ñ8Ô8ˆØ×Ò˜œÔ2Ô:¸BÑ?Ô?Ð?ØŒÔ×%Ò% aÑ(Ô(Ð(Ø�}Š}˜TÔ.Ñ/Ô/Ð/r%   c                 óÂ  ‡ — t           j                             t          j        ¦  «                             ¦   «         }t           j                             t          j        ¦  «        }t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          |                     ¦   «         ¦  «        z   t          |¦  «        z   }d‰ j	        j
        _        |                     t          d¦  «        t          t          j        f¦  «        z   |z   ¦  «        }|t          |¦  «        z  }‰ j	                             |¦  «        }ˆ fd„}|                     |¦  «        S )zN
        Test that private key authentication completes successfully,
        r>   r_   ó	   publickeyó   ÿó   testc                 ól   •— ‰                      ‰j        j        j        t          j        dfg¦  «         d S r±   r²   r´   s    €r&   rµ   zMSSHUserAuthServerTests.test_successfulPrivateKeyAuthentication.<locals>.checkM  r¶   r%   )r   r2   r3   r   r4   rN   r;   r   ÚsshTyper™   r   Ú	sessionIDÚsignÚbytesr   ÚMSG_USERAUTH_REQUESTrª   r«   )r8   rN   r�   r¸   rŠ   r¬   rµ   s   `      r&   Ú'test_successfulPrivateKeyAuthenticationz>SSHUserAuthServerTests.test_successfulPrivateKeyAuthentication8  s8  ø€ õ Œx×"Ò"¥7Ô#<Ñ=Ô=×BÒBÑDÔDˆÝŒh×!Ò!¥'Ô"<Ñ=Ô=ˆåˆv‰JŒJÝ�‰kŒkñå�ÑÔñð ñõ �—’‘”ÑÔñ	 õ
 �‰hŒhñð 	ð /6ˆŒÔ!Ô+Ø—H’HÝˆw‰KŒK�%¥Ô!>Ð @ÑAÔAÑAÀFÑJñ
ô 
ˆ	ð 	•"�Y‘-”-ÑˆØŒO×0Ò0°Ñ8Ô8ˆð	ð 	ð 	ð 	ð 	ð �}Š}˜UÑ#Ô#Ð#r%   c                 óÐ  ‡— t          j        ¦   «         Šd„ }d„ }ˆfd„}|                      | j        d|¦  «         |                      | j        d|¦  «         |                      | j        d|¦  «         t	          d¦  «        t	          d¦  «        z   t	          d	¦  «        z   t	          d
¦  «        z   }| j                             |¦  «         |                      ‰t          ¦  «        S )z‹
        ssh_USERAUTH_REQUEST should raise a ConchError if tryAuth returns
        None. Added to catch a bug noticed by pyflakes.
        c                 ó0   — |                       d¦  «         d S )Nz&request should have raised ConochError)rƒ   r¦   s     r&   ÚmockCbFinishedAuthzOSSHUserAuthServerTests.test_requestRaisesConchError.<locals>.mockCbFinishedAuth\  s   € Ø�IŠIÐ>Ñ?Ô?Ð?Ð?Ð?r%   c                 ó   — d S rH   r$   )ÚkindÚuserÚdatas      r&   ÚmockTryAuthzHSSHUserAuthServerTests.test_requestRaisesConchError.<locals>.mockTryAuth_  ó   € Ø�4r%   c                 ó<   •— ‰                      | j        ¦  «         d S rH   )ÚerrbackÚvalue)Úreasonr¬   s    €r&   ÚmockEbBadAuthzJSSHUserAuthServerTests.test_requestRaisesConchError.<locals>.mockEbBadAuthb  s   ø€ Ø�IŠI�f”lÑ#Ô#Ð#Ð#Ð#r%   ÚtryAuthÚ_cbFinishedAuthÚ
_ebBadAuths   userr_   s
   public-keys   data)r   ÚDeferredÚpatchr™   r   rª   ÚassertFailurer   )r8   rÏ   rÔ   rÚ   r¸   r¬   s        @r&   Útest_requestRaisesConchErrorz3SSHUserAuthServerTests.test_requestRaisesConchErrorU  sô   ø€ õ
 ŒNÑÔˆð	@ð 	@ð 	@ð	ð 	ð 	ð	$ð 	$ð 	$ð 	$ð 	$ð 	�
Š
�4”? I¨{Ñ;Ô;Ð;Ø�
Š
�4”?Ð$5Ð7IÑJÔJÐJØ�
Š
�4”? L°-Ñ@Ô@Ð@å�G‘”�r '™{œ{Ñ*­R°Ñ->Ô->Ñ>ÅÀGÁÄÑLˆð 	Œ×,Ò,¨VÑ4Ô4Ð4Ø×!Ò! !¥ZÑ0Ô0Ð0r%   c                 óŠ  ‡ ‡— t           j                             t          j        ¦  «                             ¦   «         Št          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   t          ‰¦  «        z   }‰ j                             |¦  «        }ˆˆ fd„}| 	                    |¦  «        S )z@
        Test that verifying a valid private key works.
        r>   r_   rÃ   r£   ó   ssh-rsac                 ó¦   •— ‰                      ‰j        j        j        t          j        t          d¦  «        t          ‰¦  «        z   fg¦  «         d S )Nrã   )r¤   r™   r   rh   r   ÚMSG_USERAUTH_PK_OKr   )r§   rN   r8   s    €€r&   rµ   z@SSHUserAuthServerTests.test_verifyValidPrivateKey.<locals>.check~  sO   ø€ Ø×ÒØ”Ô)Ô1ÝÔ-­r°*©~¬~ÅÀ4ÁÄÑ/HÐIÐJñô ð ð ð r%   )
r   r2   r3   r   r4   rN   r   r™   rª   r«   )r8   r¸   r¬   rµ   rN   s   `   @r&   Útest_verifyValidPrivateKeyz1SSHUserAuthServerTests.test_verifyValidPrivateKeyo  sÉ   øø€ õ Œx×"Ò"¥7Ô#<Ñ=Ô=×BÒBÑDÔDˆåˆv‰JŒJÝ�‰kŒkñå�ÑÔñð ñõ �‰nŒnñ	õ
 �‰hŒhñð 	ð ŒO×0Ò0°Ñ8Ô8ˆð	ð 	ð 	ð 	ð 	ð 	ð �}Š}˜UÑ#Ô#Ð#r%   c                 ó„  — t           j                             t          j        ¦  «                             ¦   «         }t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   t          |¦  «        z   }| j                             |¦  «        }| 	                    | j
        ¦  «        S )úd
        Test that private key authentication fails when the public key
        is invalid.
        r>   r_   rÃ   r£   s   ssh-dsa©r   r2   r3   r   r6   rN   r   r™   rª   r«   r¨   ©r8   rN   r¸   r¬   s       r&   Ú3test_failedPrivateKeyAuthenticationWithoutSignaturezJSSHUserAuthServerTests.test_failedPrivateKeyAuthenticationWithoutSignature†  sª   € õ
 Œx×"Ò"¥7Ô#<Ñ=Ô=×BÒBÑDÔDˆåˆv‰JŒJÝ�‰kŒkñå�ÑÔñð ñõ �‰nŒnñ	õ
 �‰hŒhñð 	ð ŒO×0Ò0°Ñ8Ô8ˆØ�}Š}˜TÔ.Ñ/Ô/Ð/r%   c                 ó>  — t           j                             t          j        ¦  «                             ¦   «         }t           j                             t          j        ¦  «        }t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   t          |¦  «        z   t          |                     |¦  «        ¦  «        z   }d| j	        j
        _        | j	                             |¦  «        }|                     | j        ¦  «        S )rè   r>   r_   rÃ   rÄ   rã   rÅ   )r   r2   r3   r   r4   rN   r;   r   rÉ   r™   r   rÈ   rª   r«   r¨   )r8   rN   r�   r¸   r¬   s        r&   Ú0test_failedPrivateKeyAuthenticationWithSignaturezGSSHUserAuthServerTests.test_failedPrivateKeyAuthenticationWithSignature—  së   € õ
 Œx×"Ò"¥7Ô#<Ñ=Ô=×BÒBÑDÔDˆÝŒh×!Ò!¥'Ô"<Ñ=Ô=ˆåˆv‰JŒJÝ�‰kŒkñå�ÑÔñð ñõ �‰nŒnñ	õ
 �‰hŒhñõ �—’˜$‘”Ñ Ô ñ!ð 	ð /6ˆŒÔ!Ô+ØŒO×0Ò0°Ñ8Ô8ˆØ�}Š}˜TÔ.Ñ/Ô/Ð/r%   c                 ó¸  — t           j                             t          j        ¦  «                             ¦   «         }t          d¦  «        |dd…         z   }t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   t          |¦  «        z   }| j                             |¦  «        }| 	                    | j
        ¦  «        S )	z€
        Private key authentication fails when the public key type is
        unsupported or the public key is corrupt.
        s   ssh-bad-typeé   Nr>   r_   rÃ   r£   rã   ré   rê   s       r&   Útest_unsupported_publickeyz1SSHUserAuthServerTests.test_unsupported_publickey«  sÈ   € õ
 Œx×"Ò"¥7Ô#<Ñ=Ô=×BÒBÑDÔDˆõ �/Ñ"Ô" T¨"¨#¨#¤YÑ.ˆõ ˆv‰JŒJÝ�‰kŒkñå�ÑÔñð ñõ �‰nŒnñ	õ
 �‰hŒhñð 	ð ŒO×0Ò0°Ñ8Ô8ˆà�}Š}˜TÔ.Ñ/Ô/Ð/r%   c                 óf  — t          j        ¦   «         }t          | j        ¦  «        |_        | j                             t          ¦   «         ¦  «         |                     ¦   «          |                     ¦   «          |j	         
                    ¦   «          |                      |j	        ddg¦  «         dS )ah  
        L{SSHUserAuthServer} sets up
        C{SSHUserAuthServer.supportedAuthentications} by checking the portal's
        credentials interfaces and mapping them to SSH authentication method
        strings.  If the Portal advertises an interface that
        L{SSHUserAuthServer} can't map, it should be ignored.  This is a white
        box test.
        r¯   rÃ   N)r   r˜   rU   rf   r   r—   r�   rZ   rž   rš   r›   r¤   )r8   Úservers     r&   Ú test_ignoreUnknownCredInterfacesz7SSHUserAuthServerTests.test_ignoreUnknownCredInterfacesÁ  sž   € õ Ô+Ñ-Ô-ˆÝ(¨¬Ñ5Ô5ˆÔØŒ×#Ò#Õ$4Ñ$6Ô$6Ñ7Ô7Ð7Ø×ÒÑÔÐØ×ÒÑÔÐØÔ'×,Ò,Ñ.Ô.Ð.Ø×Ò˜Ô8¸;ÈÐ:UÑVÔVÐVÐVÐVr%   c                 ó6  — |                       d| j        j        ¦  «         t          j        ¦   «         }t          | j        ¦  «        |_        d„ |j        _        | 	                    ¦   «          | 
                    ¦   «          |                      d|j        ¦  «         t          j        ¦   «         }t          | j        ¦  «        |_        d„ |j        _        | 	                    ¦   «          | 
                    ¦   «          |                       d|j        ¦  «         dS )z�
        Test that the userauth service does not advertise password
        authentication if the password would be send in cleartext.
        r¯   c                 ó   — dS rd   r$   ©Úxs    r&   ry   zISSHUserAuthServerTests.test_removePasswordIfUnencrypted.<locals>.<lambda>Û  ó   € ¸%€ r%   c                 ó   — | dk    S ©NÚinr$   rö   s    r&   ry   zISSHUserAuthServerTests.test_removePasswordIfUnencrypted.<locals>.<lambda>â  ó
   € ¸¸dº€ r%   N)ÚassertInr™   rš   r   r˜   rU   rf   r   rq   rZ   rž   ÚassertNotIn)r8   ÚclearAuthServerÚhalfAuthServers      r&   Ú test_removePasswordIfUnencryptedz7SSHUserAuthServerTests.test_removePasswordIfUnencryptedÒ  sö   € ð
 	�Š�k 4¤?Ô#KÑLÔLÐLå"Ô4Ñ6Ô6ˆÝ$1°$´+Ñ$>Ô$>ˆÔ!Ø0?°ˆÔ!Ô-Ø×&Ò&Ñ(Ô(Ð(Ø×&Ò&Ñ(Ô(Ð(Ø×Ò˜ oÔ&NÑOÔOÐOå!Ô3Ñ5Ô5ˆÝ#0°´Ñ#=Ô#=ˆÔ Ø/BÐ/BˆÔ Ô,Ø×%Ò%Ñ'Ô'Ð'Ø×%Ò%Ñ'Ô'Ð'Ø�Š�k >Ô#JÑKÔKÐKÐKÐKr%   c                 óP  — t          | j        ¦  «        }|                     t          ¦   «         ¦  «         t	          j        ¦   «         }t          |¦  «        |_        d„ |j        _        | 	                    ¦   «          | 
                    ¦   «          |                      |j        dg¦  «         t	          j        ¦   «         }t          |¦  «        |_        d„ |j        _        | 	                    ¦   «          | 
                    ¦   «          |                      |j        dg¦  «         dS )zÁ
        If the L{SSHUserAuthServer} is not advertising passwords, then an
        unencrypted connection should not cause any warnings or exceptions.
        This is a white box test.
        c                 ó   — dS rd   r$   rö   s    r&   ry   zSSSHUserAuthServerTests.test_unencryptedConnectionWithoutPasswords.<locals>.<lambda>ô  rø   r%   rÃ   c                 ó   — | dk    S rú   r$   rö   s    r&   ry   zSSSHUserAuthServerTests.test_unencryptedConnectionWithoutPasswords.<locals>.<lambda>ü  rü   r%   N)r   r–   r—   rˆ   r   r˜   rU   r   rq   rZ   rž   r¤   rš   )r8   rf   rÿ   r   s       r&   Ú*test_unencryptedConnectionWithoutPasswordszASSHUserAuthServerTests.test_unencryptedConnectionWithoutPasswordsç  s  € õ ˜œ
Ñ#Ô#ˆØ×ÒÕ0Ñ2Ô2Ñ3Ô3Ð3õ #Ô4Ñ6Ô6ˆÝ$1°&Ñ$9Ô$9ˆÔ!Ø0?°ˆÔ!Ô-Ø×&Ò&Ñ(Ô(Ð(Ø×&Ò&Ñ(Ô(Ð(Ø×Ò˜ÔAÀLÀ>ÑRÔRÐRõ "Ô3Ñ5Ô5ˆÝ#0°Ñ#8Ô#8ˆÔ Ø/BÐ/BˆÔ Ô,Ø×%Ò%Ñ'Ô'Ð'Ø×%Ò%Ñ'Ô'Ð'Ø×Ò˜ÔAÀLÀ>ÑRÔRÐRÐRÐRr%   c                 ó   — t          j        ¦   «         }t          j        ¦   «         |_        t          | j        ¦  «        |_        |                     ¦   «          |j         	                    d¦  «         | 
                    ¦   «          |                      |j        j        t          j        dt          t          j        f¦  «        z   t!          d¦  «        z   t!          d¦  «        z   fg¦  «         |                      |j        j        ¦  «         dS )z0
        Test that the login times out.
        é°š  ó      s   you took too longr%   N)r   r˜   r   r½   r¾   rU   rf   r   rZ   r¿   rž   r¤   rh   ÚMSG_DISCONNECTrÊ   Ú)DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLEr   Ú
assertTruerg   ©r8   ÚtimeoutAuthServers     r&   Útest_loginTimeoutz(SSHUserAuthServerTests.test_loginTimeout  sÿ   € õ %Ô6Ñ8Ô8ÐÝ"&¤*¡,¤,ÐÔÝ&3°D´KÑ&@Ô&@ÐÔ#Ø×(Ò(Ñ*Ô*Ð*ØÔ×'Ò'¨Ñ5Ô5Ð5Ø×(Ò(Ñ*Ô*Ð*Ø×ÒØÔ'Ô/õ Ô,ØÝ�YÔPÐRÑSÔSñTåÐ-Ñ.Ô.ñ/õ ˜‘g”gñððñ	
ô 	
ð 	
ð 	�ŠÐ)Ô3ÔBÑCÔCÐCÐCÐCr%   c                 ó�  — t          j        ¦   «         }t          j        ¦   «         |_        t          | j        ¦  «        |_        |                     ¦   «          | 	                    ¦   «          |j         
                    d¦  «         |                      |j        j        g ¦  «         |                      |j        j        ¦  «         dS )zN
        Test that stopping the service also stops the login timeout.
        r  N)r   r˜   r   r½   r¾   rU   rf   r   rZ   rž   r¿   r¤   rh   ÚassertFalserg   r  s     r&   Útest_cancelLoginTimeoutz.SSHUserAuthServerTests.test_cancelLoginTimeout  s®   € õ %Ô6Ñ8Ô8ÐÝ"&¤*¡,¤,ÐÔÝ&3°D´KÑ&@Ô&@ÐÔ#Ø×(Ò(Ñ*Ô*Ð*Ø×(Ò(Ñ*Ô*Ð*ØÔ×'Ò'¨Ñ5Ô5Ð5Ø×ÒÐ*Ô4Ô<¸bÑAÔAÐAØ×ÒÐ*Ô4ÔCÑDÔDÐDÐDÐDr%   c           	      ó¤  ‡ — d                      t          d¦  «        t          d¦  «        t          d¦  «        dt          d¦  «        g¦  «        }t          j        ¦   «         ‰ j        _        t          d¦  «        D ];}‰ j                             |¦  «        }‰ j        j                             d¦  «         Œ<ˆ fd	„}| 	                    |¦  «        S )
zm
        Test that the server disconnects if the client fails authentication
        too many times.
        r%   r>   r_   r¯   r£   r»   é   r¼   c                 óì   •— ‰                      ‰j        j        j        d         t          j        dt          t          j        f¦  «        z   t          d¦  «        z   t          d¦  «        z   f¦  «         d S )Nr¢   r  s   too many bad authsr%   )r¤   r™   r   rh   r	  rÊ   r
  r   r´   s    €r&   rµ   z:SSHUserAuthServerTests.test_tooManyAttempts.<locals>.check1  s{   ø€ Ø×ÒØ”Ô)Ô1°"Ô5åÔ,ØÝ�YÔPÐRÑSÔSñTåÐ.Ñ/Ô/ñ0õ ˜‘g”gñðñ	ô 	ð 	ð 	ð 	r%   )
r·   r   r   r½   r™   r¾   Úrangerª   r¿   r«   )r8   r¸   Úir¬   rµ   s   `    r&   Útest_tooManyAttemptsz+SSHUserAuthServerTests.test_tooManyAttempts&  s¼   ø€ ð
 —’�2˜f™:œ:¥r¨'¡{¤{µB°{±O´OÀUÍBÈvÉJÌJÐWÑXÔXˆÝ $¤
¡¤ˆŒÔÝ�r‘”ð 	-ð 	-ˆAØ”×4Ò4°VÑ<Ô<ˆAØŒOÔ!×)Ò)¨!Ñ,Ô,Ð,Ð,ð
	ð 
	ð 
	ð 
	ð 
	ð �}Š}˜UÑ#Ô#Ð#r%   c                 ó(  — t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   }t          j        ¦   «         | j        _        | j                             |¦  «        }|                     | j        ¦  «        S )zo
        If the user requests a service that we don't support, the
        authentication should fail.
        r>   r%   r¯   r£   )r   r   r½   r™   r¾   rª   r«   r¨   rÀ   s      r&   Útest_failIfUnknownServicez0SSHUserAuthServerTests.test_failIfUnknownService?  so   € õ
 �F‘”�b ™gœgÑ%­¨;©¬Ñ7¸%Ñ?Å"ÀVÁ*Ä*ÑLˆÝ $¤
¡¤ˆŒÔØŒO×0Ò0°Ñ8Ô8ˆØ�}Š}˜TÔ.Ñ/Ô/Ð/r%   c                 ó  ‡ — d„ }‰                       ‰ j        d|¦  «         ‰                       ‰ j        dd¦  «         ˆ fd„}‰ j                             ddd¦  «        }‰                      |t          ¦  «                             |¦  «        S )aZ  
        tryAuth() has two edge cases that are difficult to reach.

        1) an authentication method auth_* returns None instead of a Deferred.
        2) an authentication type that is defined does not have a matching
           auth_* method.

        Both these cases should return a Deferred which fails with a
        ConchError.
        c                 ó   — d S rH   r$   )r¸   s    r&   ÚmockAuthz>SSHUserAuthServerTests.test_tryAuthEdgeCases.<locals>.mockAuthU  rÕ   r%   Úauth_publickeyÚauth_passwordNc                 ór   •— ‰j                              dd d ¦  «        }‰                     |t          ¦  «        S )Nr¯   )r™   rÛ   rà   r   )r§   Úd2r8   s     €r&   Ú
secondTestz@SSHUserAuthServerTests.test_tryAuthEdgeCases.<locals>.secondTest[  s2   ø€ Ø”×(Ò(¨°d¸DÑAÔAˆBØ×%Ò% b­*Ñ5Ô5Ð5r%   rÃ   )rß   r™   rÛ   rà   r   r«   )r8   r  r!  Úd1s   `   r&   Útest_tryAuthEdgeCasesz,SSHUserAuthServerTests.test_tryAuthEdgeCasesI  s�   ø€ ð	ð 	ð 	ð 	�
Š
�4”?Ð$4°hÑ?Ô?Ð?Ø�
Š
�4”? O°TÑ:Ô:Ð:ð	6ð 	6ð 	6ð 	6ð 	6ð Œ_×$Ò$ \°4¸Ñ>Ô>ˆØ×!Ò! "¥jÑ1Ô1×=Ò=¸jÑIÔIÐIr%   )r    r!   r"   r#   r   Úskiprœ   rŸ   r¨   r­   r¹   rÁ   rÌ   rá   ræ   rë   rí   rð   ró   r  r  r  r  r  r  r#  r$   r%   r&   r“   r“   è   sj  € € € € € ðð ð €|Ø0ˆð8ð 8ð 8ðð ð ð
ð 
ð 
ð
0ð 
0ð 
0ð$ð $ð $ð&0ð 0ð 0ð"$ð $ð $ð:1ð 1ð 1ð4$ð $ð $ð.0ð 0ð 0ð"0ð 0ð 0ð(0ð 0ð 0ð,Wð Wð Wð"Lð Lð Lð*Sð Sð Sð4Dð Dð Dð0Eð Eð Eð$ð $ð $ð20ð 0ð 0ðJð Jð Jð Jð Jr%   r“   c                   ót   — e Zd ZdZe€dZd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚSSHUserAuthClientTestsz&
    Tests for SSHUserAuthClient.
    Nr”   c                 óä   — t          dt                               ¦   «         ¦  «        | _        t          d ¦  «        | j        _        d| j        j        _        | j                             ¦   «          d S )Nr>   rÅ   )r/   rU   r[   Ú
authClientr   rÈ   rZ   r7   s    r&   rœ   zSSHUserAuthClientTests.setUpk  sX   € Ý(¨µ×1FÒ1FÑ1HÔ1HÑIÔIˆŒÝ$1°$Ñ$7Ô$7ˆŒÔ!Ø.5ˆŒÔ!Ô+ØŒ×&Ò&Ñ(Ô(Ð(Ð(Ð(r%   c                 óF   — | j                              ¦   «          d | _         d S rH   )r(  rž   r7   s    r&   rŸ   zSSHUserAuthClientTests.tearDownq  r    r%   c                 óN  — |                       | j        j        d¦  «         |                       | j        j        j        d¦  «         |                       | j        j        j        t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   fg¦  «         dS )z;
        Test that client is initialized properly.
        r>   rX   r_   N)
r¤   r(  rÒ   ÚinstancerD   r   rh   r   rË   r   r7   s    r&   Ú	test_initz SSHUserAuthClientTests.test_initu  s”   € ð 	×Ò˜œÔ-¨vÑ6Ô6Ð6Ø×Ò˜œÔ1Ô6¸ÑAÔAÐAØ×ÒØŒOÔ%Ô-ÝÔ+­R°©Z¬Z½"¸X¹,¼,Ñ-FÍÈGÉÌÑ-TÐUÐVñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 óº   ‡— dgŠˆfd„}|| j         j        _        | j                              d¦  «         |                      ‰d         | j         j        ¦  «         dS )z9
        Test that the client succeeds properly.
        Nc                 ó   •— | ‰d<   d S )Nr   r$   )r`   r+  s    €r&   ÚstubSetServicezDSSHUserAuthClientTests.test_USERAUTH_SUCCESS.<locals>.stubSetService†  s   ø€ Ø!ˆH�Q‰KˆKˆKr%   r%   r   )r(  r   Ú
setServiceÚssh_USERAUTH_SUCCESSr¤   r+  )r8   r/  r+  s     @r&   Útest_USERAUTH_SUCCESSz,SSHUserAuthClientTests.test_USERAUTH_SUCCESS€  so   ø€ ð �6ˆð	"ð 	"ð 	"ð 	"ð 	"ð 0>ˆŒÔ!Ô,ØŒ×,Ò,¨SÑ1Ô1Ð1Ø×Ò˜ !œ d¤oÔ&>Ñ?Ô?Ð?Ð?Ð?r%   c           
      ó  — | j                              t          d¦  «        dz   ¦  «         |                      | j         j        j        d         t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   t          t          j	         
                    t          j        ¦  «                             ¦   «         ¦  «        z   f¦  «         | j                              t          d¦  «        dz   ¦  «         t          t          j	         
                    t          j        ¦  «                             ¦   «         ¦  «        }|                      | j         j        j        d         t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   |z   f¦  «         | j                              t          d¦  «        t          t          j	         
                    t          j        ¦  «                             ¦   «         ¦  «        z   ¦  «         t          | j         j        j        ¦  «        t#          t          j        f¦  «        z   t          d¦  «        z   t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   |z   }t          j	         
                    t          j        ¦  «        }|                      | j         j        j        d         t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   |z   t          |                     |¦  «        ¦  «        z   f¦  «         d	S )
zJ
        Test that the client can authenticate with a public key.
        rÃ   r£   r¢   r>   rX   s   ssh-dssrã   ó   N)r(  Ússh_USERAUTH_FAILUREr   r¤   r   rh   r   rË   r   r2   r3   r   r6   rN   r4   Ússh_USERAUTH_PK_OKrÈ   rÊ   r;   rÉ   )r8   rN   rŒ   r�   s       r&   Útest_publickeyz%SSHUserAuthClientTests.test_publickey�  s1  € ð 	Œ×,Ò,­R°Ñ-=Ô-=ÀÑ-GÑHÔHÐHØ×ÒØŒOÔ%Ô-¨bÔ1åÔ-Ý�6‘
”
Ý�X‘,”,ñå�\Ñ"Ô"ñ#ð ñõ �Z‘.”.ñ	!õ
 •T”X×(Ò(­Ô)BÑCÔC×HÒHÑJÔJÑKÔKñLðñ	
ô 	
ð 	
ð 	Œ×,Ò,­R°Ñ-=Ô-=ÀÑ-GÑHÔHÐHÝ•$”(×%Ò%¥gÔ&?Ñ@Ô@×EÒEÑGÔGÑHÔHˆØ×ÒØŒOÔ%Ô-¨bÔ1åÔ-å�v‘J”JÝ˜‘l”lñ#å˜Ñ&Ô&ñ'ð ñõ ˜‘n”nñ	%ð
 ñð
ñ	
ô 	
ð 	
ð 	Œ×*Ò*Ýˆz‰NŒN�R¥¤× 3Ò 3µGÔ4MÑ NÔ N× SÒ SÑ UÔ UÑVÔVÑVñ	
ô 	
ð 	
õ ˆtŒÔ(Ô2Ñ3Ô3Ý•XÔ2Ð4Ñ5Ô5ñ6å�‰jŒjñõ �‰lŒlñõ �ÑÔñ	ð
 ñõ �‰nŒnñð ñð 	õ Œh×!Ò!¥'Ô"<Ñ=Ô=ˆØ×ÒØŒOÔ%Ô-¨bÔ1åÔ-Ý�6‘
”
Ý�X‘,”,ñå�\Ñ"Ô"ñ#ð ñõ �Z‘.”.ñ	!ð
 ñõ �S—X’X˜gÑ&Ô&Ñ'Ô'ñ(ð	ñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 ó  — t          dt                               ¦   «         ¦  «        }t          d¦  «        |_        d|j        _        |                     ¦   «          |                     d¦  «         g |j        _        |                      | 	                    d¦  «        ¦  «         |  
                    |j        j        t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   fg¦  «         dS )z¼
        If the SSHUserAuthClient doesn't return anything from signData,
        the client should start the authentication over again by requesting
        'none' authentication.
        r>   NrÅ   rÃ   r%   rX   r_   )rQ   rU   r[   r   rÈ   rZ   rÛ   rh   ÚassertIsNoner6  r¤   r   rË   r   )r8   r(  s     r&   Ú!test_publickey_without_privatekeyz8SSHUserAuthClientTests.test_publickey_without_privatekeyË  sâ   € õ 1°½×9NÒ9NÑ9PÔ9PÑQÔQˆ
å,¨TÑ2Ô2ˆ
ÔØ)0ˆ
ÔÔ&Ø×!Ò!Ñ#Ô#Ð#Ø×Ò˜<Ñ(Ô(Ð(Ø')ˆ
ÔÔ$Ø×Ò˜*×7Ò7¸Ñ<Ô<Ñ=Ô=Ð=Ø×ÒØÔ Ô(ÝÔ+­R°©Z¬Z½"¸X¹,¼,Ñ-FÍÈGÉÌÑ-TÐUÐVñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 ó†   ‡ — d„ ‰ j         _        ‰ j                              d¦  «        }ˆ fd„}|                     |¦  «        S )z{
        If there's no public key, auth_publickey should return a Deferred
        called back with a False value.
        c                 ó   — d S rH   r$   rö   s    r&   ry   z:SSHUserAuthClientTests.test_no_publickey.<locals>.<lambda>ã  ó   € °€ r%   rÃ   c                 ó2   •— ‰                      | ¦  «         d S rH   )r  )Úresultr8   s    €r&   rµ   z7SSHUserAuthClientTests.test_no_publickey.<locals>.checkæ  s   ø€ Ø×Ò˜VÑ$Ô$Ð$Ð$Ð$r%   )r(  r9   rÛ   r«   )r8   r¬   rµ   s   `  r&   Útest_no_publickeyz(SSHUserAuthClientTests.test_no_publickeyÞ  sS   ø€ ð
 (6 ~ˆŒÔ$ØŒO×#Ò# LÑ1Ô1ˆð	%ð 	%ð 	%ð 	%ð 	%ð �}Š}˜UÑ#Ô#Ð#r%   c                 óª  — | j                              t          d¦  «        dz   ¦  «         |                      | j         j        j        d         t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   f¦  «         | j                              t          d¦  «        t          d¦  «        z   ¦  «         |                      | j         j        j        d         t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        dz  z   f¦  «         d	S )
zx
        Test that the client can authentication with a password.  This
        includes changing the password.
        r¯   r£   r¢   r>   rX   r%   rÄ   r¼   N)	r(  r5  r   r¤   r   rh   r   rË   r6  r7   s    r&   Útest_passwordz$SSHUserAuthClientTests.test_passwordë  s!  € ð
 	Œ×,Ò,­R°©_¬_¸wÑ-FÑGÔGÐGØ×ÒØŒOÔ%Ô-¨bÔ1åÔ-Ý�6‘
”
�R ™\œ\Ñ)­B¨{©O¬OÑ;¸gÑEÍÈ6É
Ì
ÑRðñ	
ô 	
ð 	
ð 	Œ×*Ò*­2¨c©7¬7µR¸±W´WÑ+<Ñ=Ô=Ð=Ø×ÒØŒOÔ%Ô-¨bÔ1åÔ-Ý�6‘
”
�R ™\œ\Ñ)­B¨{©O¬OÑ;¸gÑEÍÈ6É
Ì
ÐUVÉÑVðñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 óz   — d„ | j         _        |                      | j                              d¦  «        ¦  «         dS )zK
        If getPassword returns None, tryAuth should return False.
        c                  ó   — d S rH   r$   r$   r%   r&   ry   z9SSHUserAuthClientTests.test_no_password.<locals>.<lambda>  s   € ¨d€ r%   r¯   N)r(  rA   r  rÛ   r7   s    r&   Útest_no_passwordz'SSHUserAuthClientTests.test_no_password  s:   € ð '3 lˆŒÔ#Ø×Ò˜œ×0Ò0°Ñ=Ô=Ñ>Ô>Ð>Ð>Ð>r%   c                 ón  — | j                              t          d¦  «        t          d¦  «        z   t          d¦  «        z   dz   t          d¦  «        z   dz   ¦  «         |                      | j         j        j        d         t          j        dt          d¦  «        z   t          d¦  «        z   f¦  «         dS )	zj
        Make sure that the client can authenticate with the keyboard
        interactive method.
        r%   s      s
   Password: r£   r¢   s      r>   N)r(  Ú'ssh_USERAUTH_PK_OK_keyboard_interactiver   r¤   r   rh   r   ÚMSG_USERAUTH_INFO_RESPONSEr7   s    r&   Útest_keyboardInteractivez/SSHUserAuthClientTests.test_keyboardInteractive  sÁ   € ð
 	Œ×?Ò?Ýˆs‰GŒGÝ�‰gŒgñå�‰gŒgñð "ñ"õ �ÑÔñ	 ð
 ññ	
ô 	
ð 	
ð 	×ÒØŒOÔ%Ô-¨bÔ1åÔ3Ø#¥b¨¡j¤jÑ0µ2°f±:´:Ñ=ðñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 ó2  — d| j         _        g | j         j        _        | j                              d¦  «         |                      | j         j        j        t          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   fg¦  «         dS )z¾
        If C{SSHUserAuthClient} gets a MSG_USERAUTH_PK_OK packet when it's not
        expecting it, it should fail the current authentication and move on to
        the next type.
        s   unknownr%   r>   rX   r_   N)	r(  ÚlastAuthr   rh   r6  r¤   r   rË   r   r7   s    r&   Ú"test_USERAUTH_PK_OK_unknown_methodz9SSHUserAuthClientTests.test_USERAUTH_PK_OK_unknown_method  sˆ   € ð $.ˆŒÔ Ø,.ˆŒÔ!Ô)ØŒ×*Ò*¨3Ñ/Ô/Ð/Ø×ÒØŒOÔ%Ô-ÝÔ+­R°©Z¬Z½"¸X¹,¼,Ñ-FÍÈGÉÌÑ-TÐUÐVñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 ó@  ‡ — ˆ fd„}ˆ fd„}|‰ j         _        |‰ j         _        ‰ j                              t	          d¦  «        dz   ¦  «         ‰                      ‰ j         j        j        d         t          j	        t	          d¦  «        t	          d¦  «        z   t	          d¦  «        z   dz   t	          d¦  «        z   f¦  «         ‰ j                              t	          d	¦  «        d
z   ¦  «         ‰                      ‰ j         j        j        dd…         ddg¦  «         dS )z×
        ssh_USERAUTH_FAILURE should sort the methods by their position
        in SSHUserAuthClient.preferredOrder.  Methods that are not in
        preferredOrder should be sorted at the end of that list.
        c                  óH   •— ‰ j         j                             dd¦  «         d S )Néÿ   ó   here is data©r(  r   rn   r7   s   €r&   Úauth_firstmethodzNSSHUserAuthClientTests.test_USERAUTH_FAILURE_sorting.<locals>.auth_firstmethod2  s$   ø€ ØŒOÔ%×0Ò0°°oÑFÔFÐFÐFÐFr%   c                  óH   •— ‰ j         j                             dd¦  «         dS )Néþ   ó
   other dataTrQ  r7   s   €r&   Úauth_anothermethodzPSSHUserAuthClientTests.test_USERAUTH_FAILURE_sorting.<locals>.auth_anothermethod5  s#   ø€ ØŒOÔ%×0Ò0°°mÑDÔDÐDØ�4r%   s   anothermethod,passwordr£   r¢   r>   rX   r¯   s"   firstmethod,anothermethod,passwordrÄ   éþÿÿÿN)rO  rP  )rT  rU  )
r(  rR  rV  r5  r   r¤   r   rh   r   rË   )r8   rR  rV  s   `  r&   Útest_USERAUTH_FAILURE_sortingz4SSHUserAuthClientTests.test_USERAUTH_FAILURE_sorting+  sF  ø€ ð	Gð 	Gð 	Gð 	Gð 	Gð	ð 	ð 	ð 	ð 	ð ,<ˆŒÔ(Ø-?ˆŒÔ*ð 	Œ×,Ò,­RÐ0IÑ-JÔ-JÈWÑ-TÑUÔUÐUà×ÒØŒOÔ%Ô-¨bÔ1åÔ-Ý�6‘
”
�R ™\œ\Ñ)­B¨{©O¬OÑ;¸gÑEÍÈ6É
Ì
ÑRðñ	
ô 	
ð 	
ð 	Œ×,Ò,ÝÐ4Ñ5Ô5¸Ñ?ñ	
ô 	
ð 	
ð 	×ÒØŒOÔ%Ô-¨b¨c¨cÔ2Ø#Ð%9Ð:ñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 óB  — | j                              t          d¦  «        dz   ¦  «         | j                              t          d¦  «        dz   ¦  «         |                      | j         j        j        d         t          j        dt          d¦  «        z   dz   f¦  «         dS )	z»
        If there are no more available user authentication messages,
        the SSHUserAuthClient should disconnect with code
        DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE.
        r¯   r£   rÄ   r¢   s      s(   no more authentication methods availables       N)r(  r5  r   r¤   r   rh   r	  r7   s    r&   Ú%test_disconnectIfNoMoreAuthenticationz<SSHUserAuthClientTests.test_disconnectIfNoMoreAuthenticationO  s    € ð 	Œ×,Ò,­R°©_¬_¸wÑ-FÑGÔGÐGØŒ×,Ò,­R°©_¬_¸wÑ-FÑGÔGÐGØ×ÒØŒOÔ%Ô-¨bÔ1åÔ(Ø#ÝÐ@ÑAÔAñBà%ñ&ðñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 ó  — g | j         j        _        | j                              d¦  «         |                      | j         j        j        t
          j        t          d¦  «        t          d¦  «        z   t          d¦  «        z   fg¦  «         dS )zˆ
        _ebAuth (the generic authentication error handler) should send
        a request for the 'none' authentication method.
        Nr>   rX   r_   )r(  r   rh   Ú_ebAuthr¤   r   rË   r   r7   s    r&   Útest_ebAuthz"SSHUserAuthClientTests.test_ebAutha  s~   € ð
 -/ˆŒÔ!Ô)ØŒ×Ò Ñ%Ô%Ð%Ø×ÒØŒOÔ%Ô-ÝÔ+­R°©Z¬Z½"¸X¹,¼,Ñ-FÍÈGÉÌÑ-TÐUÐVñ	
ô 	
ð 	
ð 	
ð 	
r%   c                 óT  ‡ ‡‡‡— t          j        dt                               ¦   «         ¦  «        Š‰                      ‰                     ¦   «         ¦  «         ˆˆˆ fd„}ˆˆˆ fd„Šd„ Š‰                     ¦   «         }|                     ‰ j        ¦  «         	                    |¦  «        S )zÛ
        getPublicKey() should return None.  getPrivateKey() should return a
        failed Deferred.  getPassword() should return a failed Deferred.
        getGenericAnswers() should return a failed Deferred.
        r>   c                 óº   •— |                       t          ¦  «         ‰                     ¦   «         }|                     ‰j        ¦  «                             ‰¦  «        S rH   )ÚtrapÚNotImplementedErrorrA   r«   rƒ   Ú
addErrback)r?  r¬   r(  Úcheck2r8   s     €€€r&   rµ   z3SSHUserAuthClientTests.test_defaults.<locals>.checkv  sI   ø€ Ø�KŠKÕ+Ñ,Ô,Ð,Ø×&Ò&Ñ(Ô(ˆAØ—=’= ¤Ñ+Ô+×6Ò6°vÑ>Ô>Ð>r%   c                 óÀ   •— |                       t          ¦  «         ‰                     d d d ¦  «        }|                     ‰j        ¦  «                             ‰¦  «        S rH   )r`  ra  rG   r«   rƒ   rb  )r?  r¬   r(  Úcheck3r8   s     €€€r&   rc  z4SSHUserAuthClientTests.test_defaults.<locals>.check2{  sO   ø€ Ø�KŠKÕ+Ñ,Ô,Ð,Ø×,Ò,¨T°4¸Ñ>Ô>ˆAØ—=’= ¤Ñ+Ô+×6Ò6°vÑ>Ô>Ð>r%   c                 ó:   — |                       t          ¦  «         d S rH   )r`  ra  )r?  s    r&   re  z4SSHUserAuthClientTests.test_defaults.<locals>.check3€  s   € Ø�KŠKÕ+Ñ,Ô,Ð,Ð,Ð,r%   )
r   r-   rU   r[   r9  r9   r<   r«   rƒ   rb  )r8   rµ   r¬   r(  rc  re  s   `  @@@r&   Útest_defaultsz$SSHUserAuthClientTests.test_defaultsm  sÐ   øøøø€ õ Ô/°½×8MÒ8MÑ8OÔ8OÑPÔPˆ
Ø×Ò˜*×1Ò1Ñ3Ô3Ñ4Ô4Ð4ð	?ð 	?ð 	?ð 	?ð 	?ð 	?ð 	?ð
	?ð 	?ð 	?ð 	?ð 	?ð 	?ð 	?ð
	-ð 	-ð 	-ð ×$Ò$Ñ&Ô&ˆØ�}Š}˜TœYÑ'Ô'×2Ò2°5Ñ9Ô9Ð9r%   )r    r!   r"   r#   r   r$  rœ   rŸ   r,  r2  r7  r:  r@  rB  rE  rI  rL  rX  rZ  r]  rg  r$   r%   r&   r&  r&  c  s  € € € € € ðð ð €|Ø0ˆð)ð )ð )ðð ð ð	
ð 	
ð 	
ð@ð @ð @ð<
ð <
ð <
ð|
ð 
ð 
ð&$ð $ð $ð
ð 
ð 
ð,?ð ?ð ?ð
ð 
ð 
ð*
ð 
ð 
ð"
ð "
ð "
ðH
ð 
ð 
ð$

ð 

ð 

ð:ð :ð :ð :ð :r%   r&  c                   ó6   — e Zd Ze€dZ G d„ d¦  «        Zd„ ZdS )ÚLoopbackTestsNr”   c                   ó.   — e Zd Z G d„ d¦  «        Zd„ ZdS )úLoopbackTests.Factoryc                   ó   — e Zd ZdZd„ Zd„ ZdS )úLoopbackTests.Factory.Serviceó   TestServicec                 ó8   — | j                              ¦   «          d S rH   )r   rt   r7   s    r&   rZ   z,LoopbackTests.Factory.Service.serviceStarted�  s   € Ø”×-Ò-Ñ/Ô/Ð/Ð/Ð/r%   c                 ó   — d S rH   r$   r7   s    r&   rž   z,LoopbackTests.Factory.Service.serviceStopped’  s   € Ø�r%   N)r    r!   r"   rD   rZ   rž   r$   r%   r&   r[   rm  Œ  s7   € € € € € Ø!ˆDð0ð 0ð 0ðð ð ð ð r%   r[   c                 ó   — | j         S rH   )r[   )r8   ÚavatarrD   s      r&   ra   z LoopbackTests.Factory.getService•  s
   € Ø”<Ðr%   N)r    r!   r"   r[   ra   r$   r%   r&   rb   rk  ‹  sK   € € € € € ð	ð 	ð 	ð 	ð 	ñ 	ô 	ð 	ð	 ð 	 ð 	 ð 	 ð 	 r%   rb   c                 ó  ‡ ‡‡— t          j        ¦   «         Št          d‰ j                             ¦   «         ¦  «        }t          j        ¦   «         ‰_        ‰‰j        _        d„ ‰j        _        t          j        ¦   «         |_        ||j        _        dx‰j        _	        |j        _	        d„ x‰j        _
        |j        _
        ‰                      ¦   «         ‰j        _        d‰_        t          ¦   «         }t          |¦  «        }t          ¦   «         Š‰                     t#          ¦   «         ¦  «         ‰                     t%          ¦   «         ¦  «         ˆfd„‰_        |                     ‰¦  «         |‰j        j        _        t+          j        ‰j        |j        ¦  «        }d„ ‰j        j        _        d„ |j        j        _        ‰                     ¦   «          |                     ¦   «          ˆ ˆfd	„}|                     |¦  «        S )
zW
        Test that the userauth server and client play nicely with each other.
        r>   c                 ó   — dS rs   r$   rö   s    r&   ry   z-LoopbackTests.test_loopback.<locals>.<lambda>¢  r=  r%   r%   c                  ó   — d S rH   r$   r$   r%   r&   ry   z-LoopbackTests.test_loopback.<locals>.<lambda>§  s   € Èd€ r%   r   c                 ó@   •— t          ‰j        |          ¦  «        dk    S )Nr¼   )ÚlenÚsuccessfulCredentials)ÚaIdÚcheckers    €r&   ry   z-LoopbackTests.test_loopback.<locals>.<lambda>±  s   ø€ ¥s¨7Ô+HÈÔ+MÑ'NÔ'NÐRSÒ'S€ r%   c                  ó   — dS )NÚ_ServerLoopbackr$   r$   r%   r&   ry   z-LoopbackTests.test_loopback.<locals>.<lambda>¶  ó   € Ð7H€ r%   c                  ó   — dS )NÚ_ClientLoopbackr$   r$   r%   r&   ry   z-LoopbackTests.test_loopback.<locals>.<lambda>·  r}  r%   c                 óR   •— ‰                      ‰j        j        j        d¦  «         d S )Nrn  )r¤   r   r`   rD   )r§   r8   rò   s    €€r&   rµ   z*LoopbackTests.test_loopback.<locals>.check¼  s(   ø€ Ø×Ò˜VÔ-Ô5Ô:¸NÑKÔKÐKÐKÐKr%   )r   r˜   r/   rb   r[   r   r'   r`   rq   rÈ   ÚsendKexInitre   ÚpasswordDelayrv   r   r   r—   r   rˆ   ÚareDonerf   r   ÚloopbackAsyncÚ	logPrefixrZ   r«   )r8   Úclientr–   rf   r¬   rµ   rz  rò   s   `     @@r&   Útest_loopbackzLoopbackTests.test_loopback˜  sà  øøø€ õ Ô+Ñ-Ô-ˆÝ ¨¬×(<Ò(<Ñ(>Ô(>Ñ?Ô?ˆõ %Ô5Ñ7Ô7ˆÔØ#)ˆÔÔ Ø'5 ~ˆÔÔ$Ý$Ô5Ñ7Ô7ˆÔØ#)ˆÔÔ ØBEÐEˆÔÔ" VÔ%5Ô%?àFRÀlÐRˆÔÔ$ vÔ'7Ô'Cð $(§<¢<¡>¤>ˆÔÔ Ø ˆÔÝ‘”ˆÝ˜‘”ˆÝ$Ñ&Ô&ˆØ×Ò¥Ñ 1Ô 1Ñ2Ô2Ð2Ø×ÒÕ 1Ñ 3Ô 3Ñ4Ô4Ð4ØTÐTÐTÐTˆŒØ×Ò˜wÑ'Ô'Ð'Ø*0ˆÔÔ Ô'åÔ" 6Ô#3°VÔ5EÑFÔFˆØ/HÐ/HˆÔÔ"Ô,Ø/HÐ/HˆÔÔ"Ô,à×ÒÑÔÐØ×ÒÑÔÐð	Lð 	Lð 	Lð 	Lð 	Lð 	Lð �}Š}˜UÑ#Ô#Ð#r%   )r    r!   r"   r   r$  rb   r‡  r$   r%   r&   ri  ri  ‡  sU   € € € € € Ø€|Ø0ˆð ð  ð  ð  ð  ñ  ô  ð  ð'$ð '$ð '$ð '$ð '$r%   ri  c                   ó   — e Zd Ze€dZd„ ZdS )ÚModuleInitializationTestsNr”   c                 ó²   — |                       t          j        j        d         d¦  «         |                       t          j        j        d         d¦  «         d S )Né<   rå   )r¤   r   r˜   ÚprotocolMessagesr-   r7   s    r&   Útest_messagesz'ModuleInitializationTests.test_messagesÆ  sb   € ð 	×ÒÝÔ&Ô7¸Ô;Ð=Qñ	
ô 	
ð 	
ð 	×ÒÝÔ&Ô7¸Ô;Ð=Qñ	
ô 	
ð 	
ð 	
ð 	
r%   )r    r!   r"   r   r$  r�  r$   r%   r&   r‰  r‰  Â  s-   € € € € € Ø€|Ø0ˆð
ð 
ð 
ð 
ð 
r%   r‰  )8r#   Útypesr   Útypingr   Úzope.interfacer   Útwisted.conch.errorr   r   Útwisted.cred.checkersr   Útwisted.cred.credentialsr	   r
   r   Útwisted.cred.errorr   Útwisted.cred.portalr   r   Útwisted.internetr   r   Útwisted.protocolsr   Útwisted.python.reflectr   Útwisted.trialr   r   Ú__annotations__Útwisted.conch.checkersr   Útwisted.conch.sshr   r   Útwisted.conch.ssh.commonr   Útwisted.conch.testr   r-   r/   rJ   rQ   r'   rU   rv   r   rˆ   r�   ÚTestCaser“   r&  ri  r‰  r$   r%   r&   ú<module>r      s€  ððð ð ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &à :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RØ 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø &Ð &Ð &Ð &Ð &Ð &Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø "Ð "Ð "Ð "Ð "Ð "à!€€hˆzÔÐ !Ð !Ñ !Ø€=�Ñ Ô ð Ø9Ð9Ð9Ð9Ð9Ð9Ø;Ð;Ð;Ð;Ð;Ð;Ð;Ð;Ð;Ð;Ø+Ð+Ð+Ð+Ð+Ð+Ø*Ð*Ð*Ð*Ð*Ð*Ð*ðð ð ð ð ñ ô ð ðð ð ð ð ñ ô ð ð -ð  -ð  -ð  -ð  -�XÔ/ñ  -ô  -ð  -ðF
Eð 
Eð 
Eð 
Eð 
E�HÔ.ñ 
Eô 
Eð 
Eð	>ð 	>ð 	>ð 	>ð 	> (Ô"<ñ 	>ô 	>ð 	>ð>#ð >#ð >#ð >#ð >#�IÔ.ñ >#ô >#ð >#ðB €ˆVÑÔð	Bð 	Bð 	Bð 	Bð 	Bñ 	Bô 	Bñ Ôð	Bð €Ð Ñ!Ô!ðOð Oð Oð Oð Oñ Oô Oñ "Ô!ðOð €Ð Ñ!Ô!ð"ð "ð "ð "ð "ñ "ô "ñ "Ô!ð"ð& €Ð Ñ!Ô!ð	ð 	ð 	ð 	ð 	ñ 	ô 	ñ "Ô!ð	ðxJð xJð xJð xJð xJ˜XÔ.ñ xJô xJð xJðva:ð a:ð a:ð a:ð a:˜XÔ.ñ a:ô a:ð a:ðH	8$ð 8$ð 8$ð 8$ð 8$�HÔ%ñ 8$ô 8$ð 8$ðv
ð 
ð 
ð 
ð 
 Ô 1ñ 
ô 
ð 
ð 
ð 
r%   