+
    Dfj                         R t ^ RIHtHtHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHtHtHt ^ RIHt ^ RIHt ^ RIHt ]! R	4      t]! R
4      t]'       d   ]'       d   ^ RIHt ^ RIHt  ! R R]4      tR# )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                      a  ] tR t^t o Rt]'       g   Rt]'       g   RtRtV 3R lR lt	V 3R lR lt
V 3R lR	 ltV 3R
 lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )MakeServiceTestsz
Tests for L{tap.makeService}.
zcan't run without cryptographyz can't run on non-posix computersc                   < V ^8  d   QhRR/#    returnN )format__classdict__s   "=/usr/lib/python3/dist-packages/twisted/conch/test/test_tap.py__annotate__MakeServiceTests.__annotate__(   s     % %t %    c                ,   V P                  4       V n        \        V P                  R4      ;_uu_ 4       pVP                  RP	                  V P
                  4      4       RRR4       \        P                  ! 4       V n        R#   + '       g   i     L,; i)z
Create a file with two users.
zwb+   :N)	mktempfilenameopenwritejoinusernamePasswordr   Optionsoptions)selffs   & r   setUpMakeServiceTests.setUp(   sZ     $--''1GGDIId3345 ({{} ('s   +BB	c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   1   s     
? 
?D 
?r   c                   \         P                  ! 4       p\         P                  ! V4      pV P                  V\        4       V P                  VP                  P                  ^4       V P                  VP                  \        4       R# )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goo~>r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   =   s     
 
4 
r   c                   ^pV P                  \        V P                  R,          R4       V P                  \        V P                  R,          R4       V P	                  V\        V P                  R,          4      RV3,          4       R# )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
   r2   len)r*   numCheckerss   & r   test_defaultAuths"MakeServiceTests.test_defaultAuths=   sw    
 LL)*7	

 	LL)*8	

 	^,-4~E	
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   T   s     ? ? ?r   c                    V P                   P                  RRV P                  ,           .4       V P                  \	        V P                   R,          4      ^4       R# )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:r=   Nr)   parseOptionsr#   r2   r?   r*   s   &r   test_authAddedMakeServiceTests.test_authAddedT   sB    
 	!!8Wt}}-D"EFT\\.9:A>r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   \   s     ? ? ?r   c                    V P                   P                  RRV P                  ,           RR.4       V P                  \	        V P                   R,          4      ^4       R# )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).
rE   rF   zmemory:testuser:testpasswordr=   NrG   rI   s   &r   test_multipleAuthAdded'MakeServiceTests.test_multipleAuthAdded\   sP     	!!$--'.		
 	T\\.9:A>r   c                    < V ^8  d   QhRS[ /# )r   r   )r   )r   r   s   "r   r   r   l   s     
 
# 
r   c                V   V P                   P                  RRV P                  ,           .4       V P                   R,          R,          pV P                  V\        4       \        V P                  ^ ,          R4      pV P                  VP                  V4      \        P                  4      # )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.
rE   rF   r=   s   fake)r)   rH   r#   r1   r   r   r'   assertFailurerequestAvatarIdr   UnauthorizedLogin)r*   checkerinvalids   &  r   test_authFailure!MakeServiceTests.test_authFailurel   s     	!!8Wt}}-D"EF"&,,~">r"Bg~6"4#8#8#;WE!!##G,e.E.E
 	
r   c                .   < V ^8  d   QhRS[ R,          /# r   r   )r   r   s   "r   r   r   {   s     + +(4. +r   c                  a a S P                   P                  RRS P                  ,           .4       S P                   R,          R,          p\        S P                  !  oVP                  S4      pR VV 3R llpVP                  V4      # )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.
rE   rF   r=   c                X    V ^8  d   QhR\         \        \        R,          3,          RR/# )r   usernamer   Nr   )r   bytesr   )r   s   "r   r   7MakeServiceTests.test_authSuccess.<locals>.__annotate__   s(     	9 	95b	)9#: 	9t 	9r   c                 @   < SP                  V SP                  4       R # )N)r2   r]   )r]   correctr*   s   &r   checkSuccess7MakeServiceTests.test_authSuccess.<locals>.checkSuccess   s    Xw'7'78r   rR   )r)   rH   r#   r   r'   rT   addCallback)r*   rV   drb   ra   s   f   @r   test_authSuccess!MakeServiceTests.test_authSuccess{   ss     	!!8Wt}}-D"EF'+||N'CB'G"D$9$9:##G,	9 	9 }}\**r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     
 
t 
r   c                   \         P                  ! 4       p\         P                  ! V4      pVP                  P                  pV P                  \        VP                  P                  4       4      \        \        04       R# )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(   r0   r5   portalr2   setcheckerskeysr	   r
   )r*   r6   r7   rj   s   &   r   test_checkersMakeServiceTests.test_checkers   sW     //&)''$$&'.:K)L	
r   )r#   r)   N)s   iamusers   thisispassword)__name__
__module____qualname____firstlineno____doc__r   skipunixr'   r,   r8   rA   rJ   rN   rX   rf   rn   __static_attributes____classdictcell__)r   s   @r   r   r      sr      /16% %
? 
?
 
.? ?? ? 
 
+ + 
 
r   r   N)rt   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   rv   twisted.conchr   $twisted.conch.openssh_compat.factoryr   r   r   r   r   <module>r      sZ    % $ D  E X X + 0 +^,)* D!C{
x {
r   