ó
    Ö›‘h4y  ã                   óh  • % S r SSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  \	\
   \S'    SSKrSrSS	KJr  SS
KJr  SSKJrJrJrJr  SSKJrJr  SSKJr  SSKJr  SSKJ r J!r!  SSK"J#r#  SSK$J%r%  SSK&J'r'  SSK(J)r)  \%" S5      (       a  Sr*SSK+J,r,  SSK-J.r.J/r/  SSK0J1r1  SSK2J3r3  OSr*\4" \SS5      b  Sr5OSr5 " S S\)5      r6 " S S\)5      r7 " S  S!\)5      r8 " S" S#\)5      r9 " S$ S%\)5      r: " S& S'\)5      r; " S( S)\)5      r<\" S*S+/5      r= " S, S-\>5      r? " S. S/\)5      r@g! \ a    Sr GNf = f)0z&
Tests for L{twisted.conch.checkers}.
é    N)Úencodebytes)Ú
namedtuple)ÚBytesIO)ÚOptionalÚ	cryptSkipzcannot run without crypt module)ÚverifyObject)Ú'InMemoryUsernamePasswordDatabaseDontUse)ÚISSHPrivateKeyÚIUsernamePasswordÚSSHPrivateKeyÚUsernamePassword)ÚUnauthorizedLoginÚUnhandledCredentials)ÚDeferred)Úutil)ÚShadowDatabaseÚUserDatabase)ÚFilePath)ÚrequireModule)ÚMockOS)ÚTestCaseÚcryptography)Úcheckers)ÚNotEnoughAuthenticationÚValidPublicKey)Úkeys)Úkeydatazcan't run without cryptographyÚgeteuidz0Cannot run without effective UIDs (questionable)c                   ó^   • \ rS rSrSr\=(       d    \rS rS r	S r
S rS rS rS	 rS
 rSrg)ÚHelperTestsé8   z`
Tests for helper functions L{verifyCryptedPassword}, L{_pwdGetByName} and
L{_shadowGetByName}.
c                 ó"   • [        5       U l        g ©N)r   Úmockos©Úselfs    ÚdC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/conch/test/test_checkers.pyÚsetUpÚHelperTests.setUp@   s   € Ü“hˆ�ó    c                 ó¢   • SnSn[         R                   " X5      nU R                  [        R                  " X15      SR	                  X15      5        g)z~
L{verifyCryptedPassword} returns C{True} if the plaintext password
passed to it matches the encrypted password passed to it.
úsecret stringÚsaltyz5{!r} supposed to be valid encrypted password for {!r}N©ÚcryptÚ
assertTruer   ÚverifyCryptedPasswordÚformat©r&   ÚpasswordÚsaltÚcrypteds       r'   Útest_verifyCryptedPasswordÚ&HelperTests.test_verifyCryptedPasswordC   sG   € ð
 #ˆØˆÜ—+’+˜hÓ-ˆØ�‰Ü×*Ò*¨7Ó=ØC×JÑJØóõ	
r*   c                 ó¢   • SnSn[         R                   " X5      nU R                  [        R                  " X15      SR	                  X15      5        g)zr
L{verifyCryptedPassword} returns True if the provided cleartext password
matches the provided MD5 password hash.
r4   z$1$saltz3{!r} supposed to be valid encrypted password for {}Nr.   r3   s       r'   Útest_verifyCryptedPasswordMD5Ú)HelperTests.test_verifyCryptedPasswordMD5R   sG   € ð
 ˆØˆÜ—+’+˜hÓ-ˆØ�‰Ü×*Ò*¨7Ó=ØA×HÑHØóõ	
r*   c                 ó¦   • SnSnSn[         R                   " X5      nU R                  [        R                  " XC5      SR	                  XC5      5        g)z†
L{verifyCryptedPassword} returns C{False} if the plaintext password
passed to it does not match the encrypted password passed to it.
zstring secretÚsomesaltr,   z7{!r} not supposed to be valid encrypted password for {}N)r/   ÚassertFalser   r1   r2   )r&   r4   r5   Úwrongr6   s        r'   Útest_refuteCryptedPasswordÚ&HelperTests.test_refuteCryptedPassworda   sN   € ð
 #ˆØˆØˆÜ—+’+˜hÓ-ˆØ×ÑÜ×*Ò*¨7Ó:ØE×LÑLØóõ	
r*   c           	      óÞ   • [        5       nUR                  SSSSSSS5        U R                  [        SU5        U R	                  [        R
                  " S5      UR                  S5      5        g	)
zo
L{_pwdGetByName} returns a tuple of items from the UNIX /etc/passwd
database if the L{pwd} module is present.
ÚaliceÚsecrité   é   ú
first lastú/fooú/bin/shÚpwdN)r   ÚaddUserÚpatchr   ÚassertEqualÚ_pwdGetByNameÚgetpwnam©r&   Úuserdbs     r'   Útest_pwdGetByNameÚHelperTests.test_pwdGetByNameq   sW   € ô
 “ˆØ�‰�w ¨!¨Q°¸fÀiÔPØ�
‰
”8˜U FÔ+Ø×Ñœ×/Ò/°Ó8¸&¿/¹/È'Ó:RÕSr*   c                 ó|   • U R                  [        SS5        U R                  [        R                  " S5      5        g)zG
If the C{pwd} module isn't present, L{_pwdGetByName} returns L{None}.
rJ   NrC   )rL   r   ÚassertIsNonerN   r%   s    r'   Útest_pwdGetByNameWithoutPwdÚ'HelperTests.test_pwdGetByNameWithoutPwd{   s-   € ð 	�
‰
”8˜U DÔ)Ø×Ñœ(×0Ò0°Ó9Õ:r*   c                 ó  • [        5       nUR                  SSSSSSSSS	5	        U R                  [        S
U5        SU R                  l        SU R                  l        U R                  [        SU R                  5        U R                  [        R                  " S5      UR                  S5      5        U R                  U R                  R                  SS/5        U R                  U R                  R                  SS/5        g)zl
L{_shadowGetByName} returns a tuple of items from the UNIX /etc/shadow
database if the L{spwd} is present.
ÚbobÚ
passphraserE   rF   é   é   é   é   é   Úspwdé)	  éÒ  Úosr   N)r   rK   rL   r   r$   ÚeuidÚegidr   rM   Ú_shadowGetByNameÚgetspnamÚseteuidCallsÚsetegidCallsrP   s     r'   Útest_shadowGetByNameÚ HelperTests.test_shadowGetByName‚   sÄ   € ô
  Ó!ˆØ�‰�u˜l¨A¨q°!°Q¸¸1¸aÔ@Ø�
‰
”8˜V VÔ,àˆ�‰ÔØˆ�‰ÔØ�
‰
”4˜˜tŸ{™{Ô+à×Ñœ×2Ò2°5Ó9¸6¿?¹?È5Ó;QÔRØ×Ñ˜Ÿ™×1Ñ1°A°t°9Ô=Ø×Ñ˜Ÿ™×1Ñ1°A°t°9Õ=r*   c                 ó  • U R                  [        SS5        U R                  [        R                  " S5      5        U R	                  U R
                  R                  / 5        U R	                  U R
                  R                  / 5        g)z@
L{_shadowGetByName} returns L{None} if C{spwd} is not present.
r`   NrY   )rL   r   rU   rf   rM   r$   rh   ri   r%   s    r'   Útest_shadowGetByNameWithoutSpwdÚ+HelperTests.test_shadowGetByNameWithoutSpwd“   sa   € ð 	�
‰
”8˜V TÔ*à×Ñœ(×3Ò3°EÓ:Ô;Ø×Ñ˜Ÿ™×1Ñ1°2Ô6Ø×Ñ˜Ÿ™×1Ñ1°2Õ6r*   )r$   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚdependencySkipÚskipr(   r7   r:   r@   rR   rV   rj   rm   Ú__static_attributes__© r*   r'   r    r    8   s<   † ñð
 ×&˜€Dòò
ò
ò
ò Tò;ò>õ"7r*   r    c                   ót   • \ rS rSrSr\=(       d    \rSS jrS r	S r
S rS rS	 rS
 rS rS rS rS rSrg)ÚSSHPublicKeyDatabaseTestséž   z$
Tests for L{SSHPublicKeyDatabase}.
Nc           	      ó¶  • [         R                  " 5       U l        [        S5      U l        [        S5      U l        SU R                  -   S-   U R
                  -   S-   U l        [        5       U l        U R                  [        SU R                  5        [        U R                  5       5      U l        [        U R                  R                  [        5      (       d   eU R                  R!                  S5      U l        U R"                  R%                  5         ['        5       nUR)                  SS	S
SSU R                  R                  S5        XR                  l        g )Nó   foobaró   eggspams   t1 s    foo
t2 s    egg
rc   ú.sshÚuserr4   rE   rF   rG   ú
/bin/shell)r   ÚSSHPublicKeyDatabaseÚcheckerr   Úkey1Úkey2Úcontentr   r$   rL   r   r   ÚmktempÚpathÚ
isinstanceÚstrÚchildÚsshDirÚmakedirsr   rK   Ú_userdbrP   s     r'   r(   ÚSSHPublicKeyDatabaseTests.setUp¥   s÷   € Ü×4Ò4Ó6ˆŒÜ 	Ó*ˆŒ	Ü 
Ó+ˆŒ	Ø §	¡	Ñ)¨LÑ8¸4¿9¹9ÑDÀyÑPˆŒä“hˆŒØ�
‰
”4˜˜tŸ{™{Ô+ä˜TŸ[™[›]Ó+ˆŒ	Ü˜$Ÿ)™)Ÿ.™.¬#×.Ñ.Ð.Ð.Ø—i‘i—o‘o fÓ-ˆŒØ�‰×ÑÔä“ˆØ�‰ØØØØØØ�I‰I�N‰NØô	
ð  &�‰Õr*   c                 óÖ   • U R                  U R                  /S9nU R                  US   S   [        5        U R                  US   S   S5        U R                  [	        U5      S5        g)z:
L{SSHPublicKeyDatabase} is deprecated as of version 15.0
)ÚoffendingFunctionsr   ÚcategoryÚmessagezÜtwisted.conch.checkers.SSHPublicKeyDatabase was deprecated in Twisted 15.0.0: Please use twisted.conch.checkers.SSHPublicKeyChecker, initialized with an instance of twisted.conch.checkers.UNIXAuthorizedKeysFiles instead.rE   N)ÚflushWarningsr(   rM   ÚDeprecationWarningÚlen)r&   ÚwarningsShowns     r'   Útest_deprecatedÚ)SSHPublicKeyDatabaseTests.test_deprecated¿   sp   € ð ×*Ñ*¸t¿z¹z¸lÐ*ÐKˆØ×Ñ˜ qÑ)¨*Ñ5Ô7IÔJØ×ÑØ˜!Ñ˜YÑ'ðFô	
ð 	×Ñœ˜]Ó+¨QÕ/r*   c                 óª  • U R                   R                  U5      R                  U R                  5        [	        SS5      nSUl        U R                  U R                  R                  U5      5        SUl        U R                  U R                  R                  U5      5        SUl        U R                  U R                  R                  U5      5        g )Nó   useró   passwordr|   r}   s
   notallowed)
r‹   rŠ   Ú
setContentr…   r   Úblobr0   r‚   ÚcheckKeyr>   )r&   Úfilenamer   s      r'   Ú_testCheckKeyÚ'SSHPublicKeyDatabaseTests._testCheckKeyÏ   s—   € Ø�‰×Ñ˜(Ó#×.Ñ.¨t¯|©|Ô<Ü ¨Ó5ˆØˆŒ	Ø�‰˜Ÿ™×-Ñ-¨dÓ3Ô4ØˆŒ	Ø�‰˜Ÿ™×-Ñ-¨dÓ3Ô4Ø!ˆŒ	Ø×Ñ˜Ÿ™×.Ñ.¨tÓ4Õ5r*   c                 ó¾   • U R                  S5        U R                  U R                  R                  / 5        U R                  U R                  R                  / 5        g)z€
L{SSHPublicKeyDatabase.checkKey} should retrieve the content of the
authorized_keys file and check the keys against that file.
Úauthorized_keysN©r    rM   r$   rh   ri   r%   s    r'   Útest_checkKeyÚ'SSHPublicKeyDatabaseTests.test_checkKeyÙ   sG   € ð
 	×ÑÐ,Ô-Ø×Ñ˜Ÿ™×1Ñ1°2Ô6Ø×Ñ˜Ÿ™×1Ñ1°2Õ6r*   c                 ó¾   • U R                  S5        U R                  U R                  R                  / 5        U R                  U R                  R                  / 5        g)z�
L{SSHPublicKeyDatabase.checkKey} should retrieve the content of the
authorized_keys2 file and check the keys against that file.
Úauthorized_keys2Nr¤   r%   s    r'   Útest_checkKey2Ú(SSHPublicKeyDatabaseTests.test_checkKey2â   sG   € ð
 	×ÑÐ-Ô.Ø×Ñ˜Ÿ™×1Ñ1°2Ô6Ø×Ñ˜Ÿ™×1Ñ1°2Õ6r*   c                 óâ  ^^• U R                   R                  S5      mTR                  U R                  5        TR	                  S5        U R                  TR                  S5        U R                  R                  mUU4S jnSU R                  l        SU R                  l	        U R                  U R                  SU5        U R                  [        SU R                  5        [        S	S
5      nSUl        U R                  U R                  R!                  U5      5        U R#                  U R                  R$                  / SQ5        U R#                  U R                  R&                  SS/5        g)z€
If the key file is readable, L{SSHPublicKeyDatabase.checkKey} should
switch its uid/gid to the ones of the authenticated user.
r£   r   éÿ  c                 ó6   >• TR                  S5        T" U 5      $ )Nr¬   )Úchmod)rd   ÚkeyFileÚsavedSeteuids    €€r'   ÚseteuidÚ>SSHPublicKeyDatabaseTests.test_checkKeyAsRoot.<locals>.seteuidø   s   ø€ Ø�M‰M˜%Ô Ù Ó%Ð%r*   ra   rb   r±   rc   rš   r›   r|   )r   rE   r   ra   rF   N)r‹   rŠ   rœ   r…   r®   Ú
addCleanupr$   r±   rd   re   rL   r   r   r�   r0   r‚   rž   rM   rh   ri   )r&   r±   r   r¯   r°   s      @@r'   Útest_checkKeyAsRootÚ-SSHPublicKeyDatabaseTests.test_checkKeyAsRootë   s  ù€ ð
 —+‘+×#Ñ#Ð$5Ó6ˆØ×Ñ˜4Ÿ<™<Ô(à�‰�eÔØ�‰˜Ÿ™ uÔ-à—{‘{×*Ñ*ˆö	&ð  ˆ�‰ÔØˆ�‰ÔØ�
‰
�4—;‘; 	¨7Ô3Ø�
‰
”4˜˜tŸ{™{Ô+Ü ¨Ó5ˆØˆŒ	Ø�‰˜Ÿ™×-Ñ-¨dÓ3Ô4Ø×Ñ˜Ÿ™×1Ñ1²?ÔCØ×Ñ˜Ÿ™×1Ñ1°A°t°9Õ=r*   c           	      óV  ^ • S nT R                  T R                  SU5        [        SS[        R                  S[
        R                  R                  [        R                  5      R                  S5      5      nT R                  R                  U5      nU 4S jnUR                  U5      $ )zx
L{SSHPublicKeyDatabase.requestAvatarId} should return the avatar id
passed in if its C{_checkKey} method returns True.
c                 ó   • g©NTrw   ©Úignoreds    r'   Ú	_checkKeyÚASSHPublicKeyDatabaseTests.test_requestAvatarId.<locals>._checkKey  ó   € Ør*   rž   ó   testó   ssh-rsaó   fooc                 ó*   >• TR                  U S5        g ©Nr¾   ©rM   ©ÚavatarIdr&   s    €r'   Ú_verifyÚ?SSHPublicKeyDatabaseTests.test_requestAvatarId.<locals>._verify  ó   ø€ Ø×Ñ˜X wÕ/r*   )rL   r‚   r   r   ÚpublicRSA_opensshr   ÚKeyÚ
fromStringÚprivateRSA_opensshÚsignÚrequestAvatarIdÚaddCallback)r&   r»   ÚcredentialsÚdrÆ   s   `    r'   Útest_requestAvatarIdÚ.SSHPublicKeyDatabaseTests.test_requestAvatarId  s‰   ø€ ò	ð 	�
‰
�4—<‘< ¨YÔ7Ü#ØØÜ×%Ñ%ØÜ�H‰H×Ñ¤× :Ñ :Ó;×@Ñ@ÀÓHó
ˆð �L‰L×(Ñ(¨Ó5ˆõ	0ð �}‰}˜WÓ%Ð%r*   c                 óÞ   • S nU R                  U R                  SU5        [        SS[        R                  SS5      nU R                  R                  U5      nU R                  U[        5      $ )a   
L{SSHPublicKeyDatabase.requestAvatarId} should raise L{ValidPublicKey}
if the credentials represent a valid key without a signature.  This
tells the user that the key is valid for login, but does not actually
allow that user to do so without a signature.
c                 ó   • gr¸   rw   r¹   s    r'   r»   ÚQSSHPublicKeyDatabaseTests.test_requestAvatarIdWithoutSignature.<locals>._checkKey&  r½   r*   rž   r¾   r¿   N)rL   r‚   r   r   rÉ   rÎ   ÚassertFailurer   ©r&   r»   rÐ   rÑ   s       r'   Ú$test_requestAvatarIdWithoutSignatureÚ>SSHPublicKeyDatabaseTests.test_requestAvatarIdWithoutSignature  sa   € ò	ð 	�
‰
�4—<‘< ¨YÔ7Ü#Ø�Z¤×!:Ñ!:¸DÀ$ó
ˆð �L‰L×(Ñ(¨Ó5ˆØ×!Ñ! !¤^Ó4Ð4r*   c                 ó¤   • S nU R                  U R                  SU5        U R                  R                  S5      nU R                  U[        5      $ )zm
If L{SSHPublicKeyDatabase.checkKey} returns False,
C{_cbRequestAvatarId} should raise L{UnauthorizedLogin}.
c                 ó   • g©NFrw   r¹   s    r'   r»   ÚKSSHPublicKeyDatabaseTests.test_requestAvatarIdInvalidKey.<locals>._checkKey6  ó   € Ør*   rž   N)rL   r‚   rÎ   r×   r   )r&   r»   rÑ   s      r'   Útest_requestAvatarIdInvalidKeyÚ8SSHPublicKeyDatabaseTests.test_requestAvatarIdInvalidKey0  sE   € ò	ð 	�
‰
�4—<‘< ¨YÔ7Ø�L‰L×(Ñ(¨Ó.ˆØ×!Ñ! !Ô%6Ó7Ð7r*   c           	      óR  • S nU R                  U R                  SU5        [        SS[        R                  S[
        R                  R                  [        R                  5      R                  S5      5      nU R                  R                  U5      nU R                  U[        5      $ )z�
Valid keys with invalid signatures should cause
L{SSHPublicKeyDatabase.requestAvatarId} to return a {UnauthorizedLogin}
failure
c                 ó   • gr¸   rw   r¹   s    r'   r»   ÚQSSHPublicKeyDatabaseTests.test_requestAvatarIdInvalidSignature.<locals>._checkKeyD  r½   r*   rž   r¾   r¿   rÀ   )rL   r‚   r   r   rÉ   r   rÊ   rË   ÚprivateDSA_opensshrÍ   rÎ   r×   r   rØ   s       r'   Ú$test_requestAvatarIdInvalidSignatureÚ>SSHPublicKeyDatabaseTests.test_requestAvatarIdInvalidSignature=  s†   € ò	ð 	�
‰
�4—<‘< ¨YÔ7Ü#ØØÜ×%Ñ%ØÜ�H‰H×Ñ¤× :Ñ :Ó;×@Ñ@ÀÓHó
ˆð �L‰L×(Ñ(¨Ó5ˆØ×!Ñ! !Ô%6Ó7Ð7r*   c                 óò   ^ • S nT R                  T R                  SU5        [        SSSSS5      nT R                  R                  U5      nU 4S jnUR	                  U5        T R                  U[        5      $ )	zf
Exceptions raised while verifying the key should be normalized into an
C{UnauthorizedLogin} failure.
c                 ó   • gr¸   rw   r¹   s    r'   r»   ÚSSSHPublicKeyDatabaseTests.test_requestAvatarIdNormalizeException.<locals>._checkKeyX  r½   r*   rž   r¾   Ns   blobs   sigDatas   sigc                 ó|   >• TR                  [        R                  5      nTR                  [	        U5      S5        U $ )NrE   )ÚflushLoggedErrorsr   ÚBadKeyErrorrM   r•   )ÚfailureÚerrorsr&   s     €r'   Ú_verifyLoggedExceptionÚ`SSHPublicKeyDatabaseTests.test_requestAvatarIdNormalizeException.<locals>._verifyLoggedException_  s2   ø€ Ø×+Ñ+¬D×,<Ñ,<Ó=ˆFØ×ÑœS ›[¨!Ô,ØˆNr*   )rL   r‚   r   rÎ   Ú
addErrbackr×   r   )r&   r»   rÐ   rÑ   rð   s   `    r'   Ú&test_requestAvatarIdNormalizeExceptionÚ@SSHPublicKeyDatabaseTests.test_requestAvatarIdNormalizeExceptionR  sl   ø€ ò	ð 	�
‰
�4—<‘< ¨YÔ7Ü# G¨T°7¸JÈÓOˆØ�L‰L×(Ñ(¨Ó5ˆõ	ð
 	
�‰Ð+Ô,Ø×!Ñ! !Ô%6Ó7Ð7r*   )r‚   r…   rƒ   r„   r$   r‡   r‹   ©ÚreturnN)ro   rp   rq   rr   rs   ÚeuidSkiprt   ru   r(   r—   r    r¥   r©   r´   rÒ   rÙ   rà   ræ   ró   rv   rw   r*   r'   ry   ry   ž   sJ   † ñð ×%�~€Dô&ò40ò 6ò7ò7ò>ò6&ò05ò$8ò8õ*8r*   ry   c                   ó@   • \ rS rSrSr\rS rS rS r	S r
S rS rS	rg
)ÚSSHProtocolCheckerTestsih  z"
Tests for L{SSHProtocolChecker}.
c                 óR  • [         R                  " 5       nU R                  UR                  / 5        UR	                  [         R
                  " 5       5        U R                  UR                  [        /5        U R                  UR                   [           [         R
                  5        g)zh
L{SSHProcotolChecker.registerChecker} should add the given checker to
the list of registered checkers.
N)r   ÚSSHProtocolCheckerrM   ÚcredentialInterfacesÚregisterCheckerr�   r
   ÚassertIsInstance©r&   r‚   s     r'   Útest_registerCheckerÚ,SSHProtocolCheckerTests.test_registerCheckero  s�   € ô
 ×-Ò-Ó/ˆØ×Ñ˜×5Ñ5°rÔ:Ø×ÑÜ×)Ò)Ó+ô	
ð 	×Ñ˜×5Ñ5¼Ð7GÔHØ×ÑØ×Ñœ^Ñ,¬h×.KÑ.Kõ	
r*   c                 ó\  • [         R                  " 5       nU R                  UR                  / 5        UR	                  [         R
                  " 5       [        5        U R                  UR                  [        /5        U R                  UR                   [           [         R
                  5        g)z±
If a specific interface is passed into
L{SSHProtocolChecker.registerChecker}, that interface should be
registered instead of what the checker specifies in
credentialIntefaces.
N)r   rû   rM   rü   rý   r�   r   rþ   rÿ   s     r'   Ú!test_registerCheckerWithInterfaceÚ9SSHProtocolCheckerTests.test_registerCheckerWithInterface~  s�   € ô ×-Ò-Ó/ˆØ×Ñ˜×5Ñ5°rÔ:Ø×Ñ¤× =Ò =Ó ?ÔARÔSØ×Ñ˜×5Ñ5Ô8IÐ7JÔKØ×ÑØ×ÑÔ.Ñ/´×1NÑ1Nõ	
r*   c                 óì   ^ • [         R                  " 5       n[        5       nUR                  SS5        UR	                  U5        UR                  [        SS5      5      nU 4S jnUR                  U5      $ )zn
L{SSHProtocolChecker.requestAvatarId} should defer to one if its
registered checkers to authenticate a user.
r¾   c                 ó*   >• TR                  U S5        g rÂ   rÃ   rÄ   s    €r'   Ú	_callbackÚ?SSHProtocolCheckerTests.test_requestAvatarId.<locals>._callback˜  rÈ   r*   )r   rû   r	   rK   rý   rÎ   r   rÏ   )r&   r‚   ÚpasswordDatabaserÑ   r  s   `    r'   rÒ   Ú,SSHProtocolCheckerTests.test_requestAvatarId�  si   ø€ ô
 ×-Ò-Ó/ˆÜBÓDÐØ× Ñ  ¨'Ô2Ø×ÑÐ 0Ô1Ø×#Ñ#Ô$4°W¸gÓ$FÓGˆõ	0ð �}‰}˜YÓ'Ð'r*   c                 ó  • [         R                  " 5       nS nU R                  USU5        [        5       nUR	                  SS5        UR                  U5        UR                  [        SS5      5      nU R                  U[        5      $ )z¢
If the client indicates that it is never satisfied, by always returning
False from _areDone, then L{SSHProtocolChecker} should raise
L{NotEnoughAuthentication}.
c                 ó   • grÝ   rw   )rÅ   s    r'   Ú_areDoneÚYSSHProtocolCheckerTests.test_requestAvatarIdWithNotEnoughAuthentication.<locals>._areDone¥  rß   r*   ÚareDoner¾   )
r   rû   rL   r	   rK   rý   rÎ   r   r×   r   )r&   r‚   r  r	  rÑ   s        r'   Ú/test_requestAvatarIdWithNotEnoughAuthenticationÚGSSHProtocolCheckerTests.test_requestAvatarIdWithNotEnoughAuthentication�  s}   € ô ×-Ò-Ó/ˆò	ð 	�
‰
�7˜I xÔ0äBÓDÐØ× Ñ  ¨'Ô2Ø×ÑÐ 0Ô1Ø×#Ñ#Ô$4°W¸gÓ$FÓGˆØ×!Ñ! !Ô%<Ó=Ð=r*   c                 óŽ   • [         R                  " 5       nUR                  [        SS5      5      nU R	                  U[
        5      $ )z�
If the passed credentials aren't handled by any registered checker,
L{SSHProtocolChecker} should raise L{UnhandledCredentials}.
r¾   )r   rû   rÎ   r   r×   r   )r&   r‚   rÑ   s      r'   Ú%test_requestAvatarIdInvalidCredentialÚ=SSHProtocolCheckerTests.test_requestAvatarIdInvalidCredential°  s>   € ô
 ×-Ò-Ó/ˆØ×#Ñ#Ô$4°W¸gÓ$FÓGˆØ×!Ñ! !Ô%9Ó:Ð:r*   c                 ój   • U R                  [        R                  " 5       R                  S5      5        g)zF
The default L{SSHProcotolChecker.areDone} should simply return True.
N)r0   r   rû   r  r%   s    r'   Útest_areDoneÚ$SSHProtocolCheckerTests.test_areDone¹  s$   € ð 	�‰œ×3Ò3Ó5×=Ñ=¸dÓCÕDr*   rw   N)ro   rp   rq   rr   rs   rt   ru   r   r  rÒ   r  r  r  rv   rw   r*   r'   rù   rù   h  s-   † ñð €Dò
ò
ò(ò >ò&;õEr*   rù   c                   óz   • \ rS rSrSr\=(       d    \rS\\	   S\	SS4S jr
S rS	 rS
 rS rS rS rS rS rSrg)ÚUNIXPasswordDatabaseTestsiÀ  z$
Tests for L{UNIXPasswordDatabase}.
rÑ   Úusernamerö   Nc                 óF   • U R                  U R                  U5      U5        g)zÈ
Assert that the L{Deferred} passed in is called back with the value
'username'.  This represents a valid login for this TestCase.

@param d: a L{Deferred} from an L{IChecker.requestAvatarId} method.
N)rM   ÚsuccessResultOf)r&   rÑ   r  s      r'   ÚassertLoggedInÚ(UNIXPasswordDatabaseTests.assertLoggedInÇ  s   € ð 	×Ñ˜×-Ñ-¨aÓ0°(Õ;r*   c                 ó„  • [         R                  " 5       nS n[        5       nUR                  SU" SS5      SSSSS5        UR                  S	S
SSSSS5        [	        5       nUR                  SSSSSSSSS5	        UR                  S	U" S	S5      SSSSSSS5	        U R                  [         SU5        U R                  [         SU5        [        5       nU R                  [        SU5        SUl        SUl	        [        SS 5      nU R                  UR                  U5      S5        U R                  UR                  / 5        U R                  UR                  / 5        S!Ul        U R                  UR                  U5      S!5        U R                  UR                  S"S/5        U R                  UR                  S"S/5        g#)$zi
L{UNIXPasswordDatabase} with no arguments has checks the C{pwd} database
and then the C{spwd} database.
c                 óf   • [         R                   " X5      n[         R                   " USU-   5      nU$ )Nz$1$)r/   )r  r4   r5   r6   s       r'   r6   Ú?UNIXPasswordDatabaseTests.test_defaultCheckers.<locals>.crypted×  s)   € Ü—;’;˜xÓ2ˆDÜ—k’k (¨E°D©LÓ9ˆGØˆNr*   rC   r4   rE   rF   ÚfoorH   rI   rY   ÚxÚbarú/barr?   r[   r\   r]   r^   r_   é   é	   é
   é   é   é   é   rJ   r`   rc   ra   rb   ó   alicer›   ó   bobr   N)r   ÚUNIXPasswordDatabaser   rK   r   rL   r   r   rd   re   r   r  rÎ   rM   rh   ri   r  )r&   r‚   r6   rJ   r`   r$   Úcreds          r'   Útest_defaultCheckersÚ.UNIXPasswordDatabaseTests.test_defaultCheckersÐ  s‘  € ô
 ×/Ò/Ó1ˆò	ô
 ‹nˆØ�‰Ø‘W˜W jÓ1°1°a¸ÀÈ	ô	
ð 	�‰�E˜3  1 e¨V°YÔ?ÜÓˆØ�‰�W˜g q¨!¨Q°°1°a¸Ô;Ø�‰�U™G E¨:Ó6¸¸1¸bÀ"ÀbÈ"ÈbÔQà�
‰
”8˜U CÔ(Ø�
‰
”8˜V TÔ*ä“ˆØ�
‰
”4˜˜vÔ&àˆŒØˆŒä ¨+Ó6ˆØ×Ñ˜G×3Ñ3°DÓ9¸8ÔDØ×Ñ˜×,Ñ,¨bÔ1Ø×Ñ˜×,Ñ,¨bÔ1ØˆŒØ×Ñ˜G×3Ñ3°DÓ9¸6ÔBØ×Ñ˜×,Ñ,¨q°$¨iÔ8Ø×Ñ˜×,Ñ,¨q°$¨iÕ8r*   c                 óD   • U R                  U[        R                  5        g)a}  
Asserts that the L{Deferred} passed in is erred back with an
L{UnauthorizedLogin} L{Failure}.  This reprsents an invalid login for
this TestCase.

NOTE: To work, this method's return value must be returned from the
test method, or otherwise hooked up to the test machinery.

@param d: a L{Deferred} from an L{IChecker.requestAvatarId} method.
@type d: L{Deferred}
@rtype: L{None}
N)ÚfailureResultOfr   r   ©r&   rÑ   s     r'   ÚassertUnauthorizedLoginÚ1UNIXPasswordDatabaseTests.assertUnauthorizedLoginø  s   € ð 	×Ñ˜Q¤× :Ñ :Õ;r*   c           	      ó  • [         R                   " SS5      n[        5       nUR                  SUSSSSS5        [        R                  " UR
                  /5      nU R                  UR                  [        SS	5      5      S5        g
)zW
L{UNIXPasswordDatabase} takes a list of functions to check for UNIX
user information.
ÚsecretÚanybodyrE   rF   r"  r%  rI   s   anybodys   secretN)	r/   r   rK   r   r/  rO   r  rÎ   r   )r&   r4   rQ   r‚   s       r'   Útest_passInCheckersÚ-UNIXPasswordDatabaseTests.test_passInCheckers  sp   € ô
 —;’;˜x¨Ó2ˆÜ“ˆØ�‰�y (¨A¨q°%¸ÀÔKÜ×/Ò/°·±Ð0AÓBˆØ×ÑØ×#Ñ#Ô$4°ZÀÓ$KÓLÈjõ	
r*   c                 óÆ   • S nS nU R                  [        SU5        [        R                  " U/5      n[        SS5      nU R	                  UR                  U5      S5        g)z½
If the encrypted password provided by the getpwnam function is valid
(verified by the L{verifyCryptedPassword} function), we callback the
C{requestAvatarId} L{Deferred} with the username.
c                 ó
   • X:H  $ r#   rw   ©r6   Úpws     r'   r1   ÚLUNIXPasswordDatabaseTests.test_verifyPassword.<locals>.verifyCryptedPassword  ó
   € Ø‘=Ð r*   c                 ó   • X /$ r#   rw   ©r  s    r'   rO   Ú?UNIXPasswordDatabaseTests.test_verifyPassword.<locals>.getpwnam  s   € ØÐ'Ð'r*   r1   ó   usernameN©rL   r   r/  r   r  rÎ   ©r&   r1   rO   r‚   Ú
credentials        r'   Útest_verifyPasswordÚ-UNIXPasswordDatabaseTests.test_verifyPassword  sY   € ò	!ò	(ð 	�
‰
”8Ð4Ð6KÔLÜ×/Ò/°°
Ó;ˆÜ% k°;Ó?ˆ
Ø×Ñ˜G×3Ñ3°JÓ?ÀÕMr*   c                 ó�   • S n[         R                  " U/5      n[        SS5      nU R                  UR	                  U5      5        g)ze
If the getpwnam function raises a KeyError, the login fails with an
L{UnauthorizedLogin} exception.
c                 ó   • [        U 5      er#   )ÚKeyErrorrD  s    r'   rO   Ú?UNIXPasswordDatabaseTests.test_failOnKeyError.<locals>.getpwnam,  s   € Ü˜8Ó$Ð$r*   rF  r›   N)r   r/  r   r6  rÎ   )r&   rO   r‚   rI  s       r'   Útest_failOnKeyErrorÚ-UNIXPasswordDatabaseTests.test_failOnKeyError&  s@   € ò	%ô ×/Ò/°°
Ó;ˆÜ% k°;Ó?ˆ
Ø×$Ñ$ W×%<Ñ%<¸ZÓ%HÕIr*   c                 óÄ   • S nS nU R                  [        SU5        [        R                  " U/5      n[        SS5      nU R	                  UR                  U5      5        g)z|
If the verifyCryptedPassword function doesn't verify the password, the
login fails with an L{UnauthorizedLogin} exception.
c                 ó   • grÝ   rw   r?  s     r'   r1   ÚOUNIXPasswordDatabaseTests.test_failOnBadPassword.<locals>.verifyCryptedPassword9  rß   r*   c                 ó
   • U S/$ )Nr›   rw   rD  s    r'   rO   ÚBUNIXPasswordDatabaseTests.test_failOnBadPassword.<locals>.getpwnam<  s   € Ø˜kÐ*Ð*r*   r1   rF  r›   N)rL   r   r/  r   r6  rÎ   rH  s        r'   Útest_failOnBadPasswordÚ0UNIXPasswordDatabaseTests.test_failOnBadPassword3  sW   € ò	ò	+ð 	�
‰
”8Ð4Ð6KÔLÜ×/Ò/°°
Ó;ˆÜ% k°;Ó?ˆ
Ø×$Ñ$ W×%<Ñ%<¸ZÓ%HÕIr*   c                 óÌ   • S nS nS nU R                  [        SU5        [        R                  " X#/5      n[        SS5      nU R	                  UR                  U5      S5        g)zí
UNIXPasswordDatabase.requestAvatarId loops through each getpwnam
function associated with it and returns a L{Deferred} which fires with
the result of the first one which returns a value other than None.
ones do not verify the password.
c                 ó
   • X:H  $ r#   rw   r?  s     r'   r1   ÚRUNIXPasswordDatabaseTests.test_loopThroughFunctions.<locals>.verifyCryptedPasswordL  rB  r*   c                 ó
   • U S/$ )Nznot the passwordrw   rD  s    r'   Ú	getpwnam1ÚFUNIXPasswordDatabaseTests.test_loopThroughFunctions.<locals>.getpwnam1O  s   € ØÐ0Ð1Ð1r*   c                 ó
   • U S/$ )Nr4   rw   rD  s    r'   Ú	getpwnam2ÚFUNIXPasswordDatabaseTests.test_loopThroughFunctions.<locals>.getpwnam2R  s   € Ø˜jÐ)Ð)r*   r1   rF  r›   NrG  )r&   r1   r]  r`  r‚   rI  s         r'   Útest_loopThroughFunctionsÚ3UNIXPasswordDatabaseTests.test_loopThroughFunctionsD  s_   € ò	!ò	2ò	*ð 	�
‰
”8Ð4Ð6KÔLÜ×/Ò/°Ð0FÓGˆÜ% k°;Ó?ˆ
Ø×Ñ˜G×3Ñ3°JÓ?ÀÕMr*   c           	      ó"  • [        5       nUR                  SSSSSSS5        UR                  SSSSSSS5        UR                  S	S
SSSSS5        U R                  [        SU5        [        R                  " [        R
                  /5      n[        SS5      nU R                  UR                  U5      5        [        SS5      nU R                  UR                  U5      5        [        SS5      nU R                  UR                  U5      5        g)z�
If the password returned by any function is C{""}, C{"x"}, or C{"*"} it
is not compared against the supplied password.  Instead it is skipped.
rC   Ú rE   rF   r"  r$  rY   r#  ÚcarolÚ*rJ   r-  r*   r.  ó   xs   caroló   *N)	r   rK   rL   r   r/  rN   r   r6  rÎ   )r&   rJ   r‚   r0  s       r'   Útest_failOnSpecialÚ,UNIXPasswordDatabaseTests.test_failOnSpecialZ  së   € ô
 ‹nˆØ�‰�G˜R  A r¨5°%Ô8Ø�‰�E˜3  1 b¨%°Ô7Ø�‰�G˜S ! Q¨¨E°5Ô9Ø�
‰
”8˜U CÔ(ä×/Ò/´×1GÑ1GÐ0HÓIˆÜ ¨#Ó.ˆØ×$Ñ$ W×%<Ñ%<¸TÓ%BÔCä ¨Ó-ˆØ×$Ñ$ W×%<Ñ%<¸TÓ%BÔCä ¨$Ó/ˆØ×$Ñ$ W×%<Ñ%<¸TÓ%BÕCr*   rw   )ro   rp   rq   rr   rs   r   rt   ru   r   Úbytesr  r1  r6  r;  rJ  rP  rW  rb  rj  rv   rw   r*   r'   r  r  À  s_   † ñð ×&˜€Dð< ¨¡ð <¸5ð <ÀTô <ò&9òP<ò
òNò$JòJò"Nõ,Dr*   r  c                   ó.   • \ rS rSrSr\rS rS rS r	Sr
g)ÚAuthorizedKeyFileReaderTestsip  z-
Tests for L{checkers.readAuthorizedKeyFile}
c                 ó„   • [        S5      n[        R                  " US 5      nU R                  SS/[	        U5      5        g)zO
L{checkers.readAuthorizedKeyFile} does not attempt to turn comments
into keys
sE   # this comment is ignored
this is not
# this is again
and this is notc                 ó   • U $ r#   rw   ©r#  s    r'   Ú<lambda>ÚCAuthorizedKeyFileReaderTests.test_ignoresComments.<locals>.<lambda>‚  s   € Á1r*   s   this is nots   and this is notN©r   r   ÚreadAuthorizedKeyFilerM   Úlist©r&   ÚfileobjÚresults      r'   Útest_ignoresCommentsÚ1AuthorizedKeyFileReaderTests.test_ignoresCommentsw  sA   € ô
 ðó
ˆô ×/Ò/°¹ÓEˆØ×Ñ˜.Ð*<Ð=¼tÀF»|ÕLr*   c                 ó~   • [        S5      n[        R                  " US S9nU R                  S/[	        U5      5        g)z_
L{checkers.readAuthorizedKeyFile} ignores leading whitespace in
lines, as well as empty lines
sg   
                           # ignore
                           not ignored
                           c                 ó   • U $ r#   rw   rq  s    r'   rr  ÚYAuthorizedKeyFileReaderTests.test_ignoresLeadingWhitespaceAndEmptyLines.<locals>.<lambda>�  s   € ÉAr*   ©ÚparseKeys   not ignoredNrt  rw  s      r'   Ú*test_ignoresLeadingWhitespaceAndEmptyLinesÚGAuthorizedKeyFileReaderTests.test_ignoresLeadingWhitespaceAndEmptyLines…  s>   € ô
 ðó
ˆô ×/Ò/°Á+ÑNˆØ×Ñ˜.Ð)¬4°«<Õ8r*   c                 ó€   • S n[        S5      n[        R                  " X!S9nU R                  S/[	        U5      5        g)z§
L{checkers.readAuthorizedKeyFile} does not raise an exception
when a key fails to parse (raises a
L{twisted.conch.ssh.keys.BadKeyError}), but rather just keeps going
c                 ó^   • U R                  S5      (       a  [        R                  " S5      eU $ )Nó   fzfailed to parse)Ú
startswithr   rí   )Úlines    r'   Ú
failOnSomeÚKAuthorizedKeyFileReaderTests.test_ignoresUnparsableKeys.<locals>.failOnSomeš  s(   € Ø�‰˜t×$Ñ$Ü×&Ò&Ð'8Ó9Ð9ØˆKr*   s   failed key
good keyr  s   good keyNrt  )r&   rˆ  rx  ry  s       r'   Útest_ignoresUnparsableKeysÚ7AuthorizedKeyFileReaderTests.test_ignoresUnparsableKeys“  s:   € ò	ô
 Ð1Ó2ˆÜ×/Ò/°ÑMˆØ×Ñ˜+˜¬¨V«Õ5r*   rw   N)ro   rp   rq   rr   rs   rt   ru   rz  r�  rŠ  rv   rw   r*   r'   rn  rn  p  s   † ñð €DòMò9õ6r*   rn  c                   ó.   • \ rS rSrSr\rS rS rS r	Sr
g)ÚInMemorySSHKeyDBTestsi¤  z(
Tests for L{checkers.InMemorySSHKeyDB}
c                 ój   • [         R                  " SS/05      n[        [         R                  U5        g)zG
L{checkers.InMemorySSHKeyDB} implements
L{checkers.IAuthorizedKeysDB}
r-  s   keyN)r   ÚInMemorySSHKeyDBr   ÚIAuthorizedKeysDB©r&   Úkeydbs     r'   Útest_implementsInterfaceÚ.InMemorySSHKeyDBTests.test_implementsInterface«  s+   € ô
 ×)Ò)¨8°f°XÐ*>Ó?ˆÜ”X×/Ñ/°Õ7r*   c                 óŠ   • [         R                  " SS/05      nU R                  / [        UR	                  S5      5      5        g)z�
If the user is not in the mapping provided to
L{checkers.InMemorySSHKeyDB}, an empty iterator is returned
by L{checkers.InMemorySSHKeyDB.getAuthorizedKeys}
r-  s   keysr.  N©r   r�  rM   rv  ÚgetAuthorizedKeysr‘  s     r'   Útest_noKeysForUnauthorizedUserÚ4InMemorySSHKeyDBTests.test_noKeysForUnauthorizedUser³  s;   € ô ×)Ò)¨8°g°YÐ*?Ó@ˆØ×Ñ˜œT %×"9Ñ"9¸&Ó"AÓBÕCr*   c                 ó�   • [         R                  " SSS/05      nU R                  SS/[        UR	                  S5      5      5        g)z¥
If the user is in the mapping provided to
L{checkers.InMemorySSHKeyDB}, an iterator with all the keys
is returned by L{checkers.InMemorySSHKeyDB.getAuthorizedKeys}
r-  ó   aó   bNr–  r‘  s     r'   Útest_allKeysForAuthorizedUserÚ3InMemorySSHKeyDBTests.test_allKeysForAuthorizedUser¼  sA   € ô ×)Ò)¨8°d¸D°\Ð*BÓCˆØ×Ñ˜$ ˜¤t¨E×,CÑ,CÀHÓ,MÓ'NÕOr*   rw   N)ro   rp   rq   rr   rs   rt   ru   r“  r˜  r�  rv   rw   r*   r'   r�  r�  ¤  s   † ñð €Dò8òDõPr*   r�  c                   óD   • \ rS rSrSr\rSS jrS rS r	S r
S rS	 rS
rg)ÚUNIXAuthorizedKeysFilesTestsiÆ  z0
Tests for L{checkers.UNIXAuthorizedKeysFiles}.
Nc           	      ó0  • [        U R                  5       5      U l        [        U R                  R                  [        5      (       d   eU R                  R                  5         [        5       U l        U R                  R                  SSSSSU R                  R                  S5        U R                  R                  S5      U l
        U R                  R                  5         U R                  R                  S5      nUR                  S	5        S
S/U l        g )NrC   r4   rE   rF   zalice lastnamer€   r~   r£   s   key 1
key 2s   key 1s   key 2)r   r†   r‡   rˆ   r‰   rŒ   r   rQ   rK   rŠ   r‹   rœ   ÚexpectedKeys)r&   ÚauthorizedKeyss     r'   r(   Ú"UNIXAuthorizedKeysFilesTests.setUpÍ  sÍ   € Ü˜TŸ[™[›]Ó+ˆŒ	Ü˜$Ÿ)™)Ÿ.™.¬#×.Ñ.Ð.Ð.Ø�	‰	×ÑÔä"“nˆŒØ�‰×ÑØØØØØØ�I‰I�N‰NØô	
ð —i‘i—o‘o fÓ-ˆŒØ�‰×ÑÔØŸ™×*Ñ*Ð+<Ó=ˆØ×!Ñ! /Ô2à% xÐ0ˆÕr*   c                 óx   • [         R                  " U R                  5      n[        [         R                  U5        g)zO
L{checkers.UNIXAuthorizedKeysFiles} implements
L{checkers.IAuthorizedKeysDB}.
N)r   ÚUNIXAuthorizedKeysFilesrQ   r   r�  r‘  s     r'   r“  Ú5UNIXAuthorizedKeysFilesTests.test_implementsInterfaceä  s(   € ô
 ×0Ò0°·±Ó=ˆÜ”X×/Ñ/°Õ7r*   c                 ó˜   • [         R                  " U R                  S S9nU R                  / [	        UR                  S5      5      5        g)z²
If the user is not in the user database provided to
L{checkers.UNIXAuthorizedKeysFiles}, an empty iterator is returned
by L{checkers.UNIXAuthorizedKeysFiles.getAuthorizedKeys}.
c                 ó   • U $ r#   rw   rq  s    r'   rr  ÚMUNIXAuthorizedKeysFilesTests.test_noKeysForUnauthorizedUser.<locals>.<lambda>ò  ó   € ÑQRr*   r  r.  N)r   r¦  rQ   rM   rv  r—  r‘  s     r'   r˜  Ú;UNIXAuthorizedKeysFilesTests.test_noKeysForUnauthorizedUserì  s:   € ô ×0Ò0°·±Á{ÑSˆØ×Ñ˜œT %×"9Ñ"9¸&Ó"AÓBÕCr*   c                 ó  • U R                   R                  S5      R                  S5        [        R                  " U R
                  S S9nU R                  U R                  S/-   [        UR                  S5      5      5        g)zö
If the user is in the user database provided to
L{checkers.UNIXAuthorizedKeysFiles}, an iterator with all the keys in
C{~/.ssh/authorized_keys} and C{~/.ssh/authorized_keys2} is returned
by L{checkers.UNIXAuthorizedKeysFiles.getAuthorizedKeys}.
r¨   s   key 3c                 ó   • U $ r#   rw   rq  s    r'   rr  Ú`UNIXAuthorizedKeysFilesTests.test_allKeysInAllAuthorizedFilesForAuthorizedUser.<locals>.<lambda>ý  r«  r*   r  r-  N)
r‹   rŠ   rœ   r   r¦  rQ   rM   r¢  rv  r—  r‘  s     r'   Ú1test_allKeysInAllAuthorizedFilesForAuthorizedUserÚNUNIXAuthorizedKeysFilesTests.test_allKeysInAllAuthorizedFilesForAuthorizedUserõ  sh   € ð 	�‰×ÑÐ,Ó-×8Ñ8¸ÔBÜ×0Ò0°·±Á{ÑSˆØ×ÑØ×Ñ  
Ñ*¬D°×1HÑ1HÈÓ1RÓ,Sõ	
r*   c                 ó¬   • [         R                  " U R                  S S9nU R                  U R                  [        UR                  S5      5      5        g)z˜
L{checkers.UNIXAuthorizedKeysFiles.getAuthorizedKeys} returns only
the keys in C{~/.ssh/authorized_keys} and C{~/.ssh/authorized_keys2}
if they exist.
c                 ó   • U $ r#   rw   rq  s    r'   rr  ÚJUNIXAuthorizedKeysFilesTests.test_ignoresNonexistantFile.<locals>.<lambda>  r«  r*   r  r-  N)r   r¦  rQ   rM   r¢  rv  r—  r‘  s     r'   Útest_ignoresNonexistantFileÚ8UNIXAuthorizedKeysFilesTests.test_ignoresNonexistantFile  s@   € ô ×0Ò0°·±Á{ÑSˆØ×Ñ˜×*Ñ*¬D°×1HÑ1HÈÓ1RÓ,SÕTr*   c                 óþ   • U R                   R                  S5      R                  5         [        R                  " U R
                  S S9nU R                  U R                  [        UR                  S5      5      5        g)zŸ
L{checkers.UNIXAuthorizedKeysFiles.getAuthorizedKeys} returns only
the keys in C{~/.ssh/authorized_keys} and C{~/.ssh/authorized_keys2}
if they are readable.
r¨   c                 ó   • U $ r#   rw   rq  s    r'   rr  ÚIUNIXAuthorizedKeysFilesTests.test_ignoresUnreadableFile.<locals>.<lambda>  r«  r*   r  r-  N)
r‹   rŠ   rŒ   r   r¦  rQ   rM   r¢  rv  r—  r‘  s     r'   Útest_ignoresUnreadableFileÚ7UNIXAuthorizedKeysFilesTests.test_ignoresUnreadableFile  s\   € ð 	�‰×ÑÐ,Ó-×6Ñ6Ô8Ü×0Ò0°·±Á{ÑSˆØ×Ñ˜×*Ñ*¬D°×1HÑ1HÈÓ1RÓ,SÕTr*   )r¢  r‡   r‹   rQ   rõ   )ro   rp   rq   rr   rs   rt   ru   r(   r“  r˜  r°  rµ  rº  rv   rw   r*   r'   r   r   Æ  s/   † ñð €Dô1ò.8òDò
òUõUr*   r   Ú_KeyDBr—  c                   ó   • \ rS rSrSrSrg)Ú_DummyExceptioni  z(
Fake exception to be used for testing.
rw   N)ro   rp   rq   rr   rs   rv   rw   r*   r'   r¾  r¾    s   † ñò 	r*   r¾  c                   óF   • \ rS rSrSr\rS rS rS r	S r
S rS rS	 rS
rg)ÚSSHPublicKeyCheckerTestsi!  z,
Tests for L{checkers.SSHPublicKeyChecker}.
c           	      ó(  • [        SS[        R                  S[        R                  R                  [        R                  5      R                  S5      5      U l        [        S 5      U l
        [        R                  " U R                  5      U l        g )Nr-  r¿   rÀ   c                 ó^   • [         R                  R                  [        R                  5      /$ r#   )r   rÊ   rË   r   rÉ   )Ú_s    r'   rr  Ú0SSHPublicKeyCheckerTests.setUp.<locals>.<lambda>0  s   € ¤t§x¡x×':Ñ':¼7×;TÑ;TÓ'UÑ&Vr*   )r   r   rÉ   r   rÊ   rË   rÌ   rÍ   rÐ   r¼  r’  r   ÚSSHPublicKeyCheckerr‚   r%   s    r'   r(   ÚSSHPublicKeyCheckerTests.setUp(  si   € Ü(ØØÜ×%Ñ%ØÜ�H‰H×Ñ¤× :Ñ :Ó;×@Ñ@ÀÓHó
ˆÔô ÑVÓWˆŒ
Ü×3Ò3°D·J±JÓ?ˆ�r*   c                 ó˜   • SU R                   l        U R                  U R                  R	                  U R                   5      [
        5        g)z…
Calling L{checkers.SSHPublicKeyChecker.requestAvatarId} with
credentials that do not have a signature fails with L{ValidPublicKey}.
N)rÐ   Ú	signaturer4  r‚   rÎ   r   r%   s    r'   Ú test_credentialsWithoutSignatureÚ9SSHPublicKeyCheckerTests.test_credentialsWithoutSignature3  s:   € ð
 &*ˆ×ÑÔ"Ø×ÑØ�L‰L×(Ñ(¨×)9Ñ)9Ó:¼Nõ	
r*   c                 ó¬   • SU R                   l        U R                  U R                  R	                  U R                   5      [
        R                  5        g)z~
Calling L{checkers.SSHPublicKeyChecker.requestAvatarId} with
credentials that have a bad key fails with L{keys.BadKeyError}.
r*   N)rÐ   r�   r4  r‚   rÎ   r   rí   r%   s    r'   Útest_credentialsWithBadKeyÚ3SSHPublicKeyCheckerTests.test_credentialsWithBadKey=  s@   € ð
 !$ˆ×ÑÔØ×ÑØ�L‰L×(Ñ(¨×)9Ñ)9Ó:¼D×<LÑ<Lõ	
r*   c                 ó´   • [         R                  U R                  l        U R	                  U R
                  R                  U R                  5      [        5        g)z±
If L{checkers.IAuthorizedKeysDB.getAuthorizedKeys} returns no keys
that match the credentials,
L{checkers.SSHPublicKeyChecker.requestAvatarId} fails with
L{UnauthorizedLogin}.
N)r   ÚpublicDSA_opensshrÐ   r�   r4  r‚   rÎ   r   r%   s    r'   Útest_credentialsNoMatchingKeyÚ6SSHPublicKeyCheckerTests.test_credentialsNoMatchingKeyG  sA   € ô !(× 9Ñ 9ˆ×ÑÔØ×ÑØ�L‰L×(Ñ(¨×)9Ñ)9Ó:Ô<Mõ	
r*   c                 ó  • [         R                  R                  [        R                  5      R                  S5      U R                  l        U R                  U R                  R                  U R                  5      [        5        g)z‡
Calling L{checkers.SSHPublicKeyChecker.requestAvatarId} with
credentials that are incorrectly signed fails with
L{UnauthorizedLogin}.
rÀ   N)r   rÊ   rË   r   rå   rÍ   rÐ   rÈ  r4  r‚   rÎ   r   r%   s    r'   Ú test_credentialsInvalidSignatureÚ9SSHPublicKeyCheckerTests.test_credentialsInvalidSignatureS  sa   € ô &*§X¡X×%8Ñ%8Ü×&Ñ&ó&
ç
‰$ˆv‹,ð 	×ÑÔ"ð 	×ÑØ�L‰L×(Ñ(¨×)9Ñ)9Ó:Ô<Mõ	
r*   c                 óè   • S nU R                  [        R                  SU5        U R                  U R                  R                  U R                  5      [        5        U R                  [        5        g)z}
If L{keys.Key.verify} raises an exception,
L{checkers.SSHPublicKeyChecker.requestAvatarId} fails with
L{UnauthorizedLogin}.
c                  ó   • [        5       er#   )r¾  )ÚargsÚkwargss     r'   ÚfailÚ?SSHPublicKeyCheckerTests.test_failureVerifyingKey.<locals>.failg  s   € Ü!Ó#Ð#r*   ÚverifyN)
rL   r   rÊ   r4  r‚   rÎ   rÐ   r   rì   r¾  )r&   rÙ  s     r'   Útest_failureVerifyingKeyÚ1SSHPublicKeyCheckerTests.test_failureVerifyingKey`  sV   € ò	$ð 	�
‰
”4—8‘8˜X tÔ,à×ÑØ�L‰L×(Ñ(¨×)9Ñ)9Ó:Ô<Mô	
ð 	×ÑœÕ/r*   c                 ó�   • U R                   R                  U R                  5      nU R                  SU R	                  U5      5        g)z]
L{checker.SSHPublicKeyChecker.requestAvatarId}, if successful,
callbacks with the username.
r-  N)r‚   rÎ   rÐ   rM   r  r5  s     r'   Útest_usernameReturnedOnSuccessÚ7SSHPublicKeyCheckerTests.test_usernameReturnedOnSuccessq  s9   € ð
 �L‰L×(Ñ(¨×)9Ñ)9Ó:ˆØ×Ñ˜ 4×#7Ñ#7¸Ó#:Õ;r*   )r‚   rÐ   r’  N)ro   rp   rq   rr   rs   rt   ru   r(   rÉ  rÌ  rÐ  rÓ  rÜ  rß  rv   rw   r*   r'   rÀ  rÀ  !  s2   † ñð €Dò	@ò
ò
ò

ò
ò0õ"<r*   rÀ  )Ars   rc   Úbase64r   Úcollectionsr   Úior   Útypingr   r‰   Ú__annotations__r/   r   ÚImportErrorÚzope.interface.verifyr   Útwisted.cred.checkersr	   Útwisted.cred.credentialsr
   r   r   r   Útwisted.cred.errorr   r   Útwisted.internet.deferr   Útwisted.pythonr   Útwisted.python.fakepwdr   r   Útwisted.python.filepathr   Útwisted.python.reflectr   Útwisted.test.test_processr   Útwisted.trial.unittestr   rt   Útwisted.conchr   Útwisted.conch.errorr   r   Útwisted.conch.sshr   Útwisted.conch.testr   Úgetattrr÷   r    ry   rù   r  rn  r�  r   r¼  Ú	Exceptionr¾  rÀ  rw   r*   r'   Ú<module>rø     sI  ðòó
 
Ý Ý "Ý Ý à�C‰=Ó ðÛð €Iå .å I÷ó ÷ GÝ +Ý ß ?Ý ,Ý 0Ý ,Ý +á�× Ñ Ø€NÝ&ßKÝ&Þ*à5€Ná
ˆ2ˆy˜$ÓÑ+Ø�HàA€Hôc7�(ô c7ôLG8 ô G8ôTUE˜hô UEôpmD ô mDô`16 8ô 16ôhP˜Hô PôDMU 8ô MUñ` 
�HÐ2Ð3Ó	4€ô	�iô 	ôV<˜xõ V<øð_ ó 2Ø1ƒIð2ús   ©D% Ä%D1Ä0D1