ó
    Ö›‘h¡  ã                   óæ   • S r SSKJr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JrJr  SSKJr  SSKJr  SS	KJr  \" S
5      r\" S5      r\(       a  \(       a  SSKJr  SSKJr   " S S\5      rg)z!
Tests for L{twisted.conch.tap}.
é    )ÚAnyÚTupleÚUnion)ÚStreamServerEndpointService)Úerror)ÚFilePasswordDBÚICredentialsChecker)ÚISSHPrivateKeyÚIUsernamePasswordÚUsernamePassword)ÚDeferred)ÚrequireModule)ÚTestCaseÚcryptographyztwisted.conch.unix)Útap)ÚOpenSSHFactoryc                   óž   • \ rS rSrSr\(       d  Sr\(       d  SrSrSS jr	SS	 jr
SS
 jrSS jrSS jrS\4S jrS\S   4S jrSS jrSrg)ÚMakeServiceTestsé   z
Tests for L{tap.makeService}.
zcan't run without cryptographyz can't run on non-posix computers)s   iamusers   thisispasswordÚreturnNc                 ó  • U R                  5       U l        [        U R                  S5       nUR                  SR	                  U R
                  5      5        SSS5        [        R                  " 5       U l        g! , (       d  f       N)= f)z
Create a file with two users.
zwb+ó   :N)	ÚmktempÚfilenameÚopenÚwriteÚjoinÚusernamePasswordr   ÚOptionsÚoptions)ÚselfÚfs     Ú_C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/conch/test/test_tap.pyÚsetUpÚMakeServiceTests.setUp(   sW   € ð Ÿ™›ˆŒÜ�$—-‘- Ô'¨1Ø�G‰G�D—I‘I˜d×3Ñ3Ó4Ô5÷ (ä—{’{“}ˆ�÷ (Õ'ús   ¬+A:Á:
Bc                 ó  • [         R                  " 5       n[         R                  " U5      nU R                  U[        5        U R                  UR                  R                  S5        U R                  UR                  [        5        g)z£
L{tap.makeService} returns a L{StreamServerEndpointService} instance
running on TCP port 22, and the linked protocol factory is an instance
of L{OpenSSHFactory}.
é   N)
r   r   ÚmakeServiceÚassertIsInstancer   ÚassertEqualÚendpointÚ_portÚfactoryr   )r!   ÚconfigÚservices      r#   Ú
test_basicÚMakeServiceTests.test_basic1   s^   € ô —’“ˆÜ—/’/ &Ó)ˆØ×Ñ˜gÔ'BÔCØ×Ñ˜×)Ñ)×/Ñ/°Ô4Ø×Ñ˜gŸo™o¬~Õ>ó    c                 óò   • SnU R                  [        U R                  S   S5        U R                  [        U R                  S   S5        U R	                  U[        U R                  S   5      SU4-  5        g)z‰
Make sure that if the C{--auth} command-line option is not passed,
the default checkers are (for backwards compatibility): SSH and UNIX
é   ÚcredInterfacesz)SSH should be one of the default checkersz*UNIX should be one of the default checkersÚcredCheckersz&There should be %d checkers by defaultN)ÚassertInr
   r    r   r*   Úlen)r!   ÚnumCheckerss     r#   Útest_defaultAuthsÚ"MakeServiceTests.test_defaultAuths=   sw   € ð
 ˆà�‰ÜØ�L‰LÐ)Ñ*Ø7ô	
ð
 	�‰ÜØ�L‰LÐ)Ñ*Ø8ô	
ð
 	×ÑØÜ�—‘˜^Ñ,Ó-Ø4¸°~ÑEõ	
r2   c                 ó¨   • U R                   R                  SSU R                  -   /5        U R                  [	        U R                   S   5      S5        g)zv
The C{--auth} command-line option will add a checker to the list of
checkers, and it should be the only auth checker
ú--authúfile:r6   é   N©r    ÚparseOptionsr   r*   r8   ©r!   s    r#   Útest_authAddedÚMakeServiceTests.test_authAddedT   sB   € ð
 	�‰×!Ñ! 8¨W°t·}±}Ñ-DÐ"EÔFØ×Ñœ˜TŸ\™\¨.Ñ9Ó:¸AÕ>r2   c                 ó¬   • U R                   R                  SSU R                  -   SS/5        U R                  [	        U R                   S   5      S5        g)z­
Multiple C{--auth} command-line options will add all checkers specified
to the list ofcheckers, and there should only be the specified auth
checkers (no default checkers).
r=   r>   zmemory:testuser:testpasswordr6   r4   Nr@   rB   s    r#   Útest_multipleAuthAddedÚ'MakeServiceTests.test_multipleAuthAdded\   sP   € ð 	�‰×!Ñ!àØ˜$Ÿ-™-Ñ'ØØ.ð	ô	
ð 	×Ñœ˜TŸ\™\¨.Ñ9Ó:¸AÕ>r2   c                 ó6  • U R                   R                  SSU R                  -   /5        U R                   S   S   nU R                  U[        5        [        U R                  S   S5      nU R                  UR                  U5      [        R                  5      $ )z·
The checker created by the C{--auth} command-line option returns a
L{Deferred} that fails with L{UnauthorizedLogin} when
presented with credentials that are unknown to that checker.
r=   r>   r6   éÿÿÿÿr   s   fake)r    rA   r   r)   r   r   r   ÚassertFailureÚrequestAvatarIdr   ÚUnauthorizedLogin)r!   ÚcheckerÚinvalids      r#   Útest_authFailureÚ!MakeServiceTests.test_authFailurel   s‡   € ð 	�‰×!Ñ! 8¨W°t·}±}Ñ-DÐ"EÔFØ"&§,¡,¨~Ñ">¸rÑ"BˆØ×Ñ˜g¤~Ô6Ü" 4×#8Ñ#8¸Ñ#;¸WÓEˆà×!Ñ!Ø×#Ñ# GÓ,¬e×.EÑ.Eó
ð 	
r2   c                 ó(  ^ ^• T R                   R                  SST R                  -   /5        T R                   S   S   n[        T R                  6 mUR                  T5      nS[        [        [        S   4   SS4UU 4S	 jjnUR                  U5      $ )
z«
The checker created by the C{--auth} command-line option returns a
L{Deferred} that returns the avatar id when presented with credentials
that are known to that checker.
r=   r>   r6   rI   Úusername© r   Nc                 ó>   >• TR                  U TR                  5        g )N)r*   rR   )rR   Úcorrectr!   s    €€r#   ÚcheckSuccessÚ7MakeServiceTests.test_authSuccess.<locals>.checkSuccess†   s   ø€ Ø×Ñ˜X w×'7Ñ'7Õ8r2   )
r    rA   r   r   r   rK   r   Úbytesr   ÚaddCallback)r!   rM   ÚdrV   rU   s   `   @r#   Útest_authSuccessÚ!MakeServiceTests.test_authSuccess{   s�   ù€ ð 	�‰×!Ñ! 8¨W°t·}±}Ñ-DÐ"EÔFØ'+§|¡|°NÑ'CÀBÑ'GˆÜ" D×$9Ñ$9Ð:ˆØ×#Ñ# GÓ,ˆð	9¤5¬´°b±	Ð)9Ñ#:ð 	9¸t÷ 	9ð 	9ð �}‰}˜\Ó*Ð*r2   c                 ó   • [         R                  " 5       n[         R                  " U5      nUR                  R                  nU R                  [        UR                  R                  5       5      [        [        15        g)z“
The L{OpenSSHFactory} built by L{tap.makeService} has a portal with
L{ISSHPrivateKey} and L{IUsernamePassword} interfaces registered as
checkers.
N)r   r   r(   r-   Úportalr*   ÚsetÚcheckersÚkeysr
   r   )r!   r.   r/   r^   s       r#   Útest_checkersÚMakeServiceTests.test_checkers‹   sW   € ô —’“ˆÜ—/’/ &Ó)ˆØ—‘×'Ñ'ˆØ×ÑÜ�—‘×$Ñ$Ó&Ó'¬.Ô:KÐ)Lõ	
r2   )r   r    )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚskipÚunixr   r$   r0   r:   rC   rF   r   rO   r   r[   rb   Ú__static_attributes__rS   r2   r#   r   r      sY   † ñö Ø/ˆæØ1ˆà6Ðô%ô
?ô
ô.?ô?ð 
 #ô 
ð+ (¨4¡.ô +÷ 
r2   r   N)rh   Útypingr   r   r   Útwisted.application.internetr   Útwisted.credr   Útwisted.cred.checkersr   r	   Útwisted.cred.credentialsr
   r   r   Útwisted.internet.deferr   Útwisted.python.reflectr   Útwisted.trial.unittestr   r   rj   Útwisted.conchr   Ú$twisted.conch.openssh_compat.factoryr   r   rS   r2   r#   Ú<module>rv      sZ   ðñ÷ %Ñ $å DÝ ß Eß XÑ XÝ +Ý 0Ý +á˜^Ó,€ÙÐ)Ó*€ö –DÝ!ÝCô{
�xõ {
r2   