+
    Dfjd                        R t ^ RIt^ RIHt ^ RIHtHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHt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IHt ^ RIHt ]! R4      t ]! R4      t!]! R4      t"R t# ! R R]4      t$ ! R R]4      t% ! R R]4      t& ! R R]4      t']! ]!'       * R4      ]! ] '       * R4      ]! ]"'       * R4       ! R R]4      4       4       4       t(]! ] '       * R4       ! R  R!]4      4       t) ! R" R#]4      t*]! ]!'       * R4      ]! ]! R$4      '       * R%4       ! R& R']4      4       4       t+ ! R( R)]PX                  ]PZ                  4      t. ! R* R+]4      t/ ! R, R-]PX                  ]PZ                  4      t0 ! R. R/]PX                  ]PZ                  4      t1 ! R0 R1]PX                  ]PZ                  4      t2 ! R2 R3]PX                  ]PZ                  4      t3 ! R4 R5]4      t4R# )6z
L{twisted.cred.strcred}.
N)StringIO)SequenceType)skipIf)	Interface)plugin)checkerscredentialserrorstrcred)cred_anonymous	cred_file	cred_unix)usage)UserDatabase)FilePath)requireModule)TestCasecryptpwdspwdc                     Rp T \         P                  ! 4        Uu. uF  qP                  NK  	  up9   d   V R,          p K>  V # u upi )z;
Helper method to produce an auth type that doesn't exist.
ThisPluginDoesNotExist_)r   findCheckerFactoriesauthType)invalidAuthTypefactorys     @/usr/lib/python3/dist-packages/twisted/cred/test/test_strcred.pygetInvalidAuthTyper      sM     /O
(/(D(D(F(FW(F  	3	s   Ac                   ,   a  ] tR t^*t o R tR tRtV tR# )PublicAPITestsc                    \        4       pV P                  \        P                  \        P                  V4       V P                  \        P                  \        P
                  V4       R# )z)
The description string cannot be empty.
Nr   assertRaisesr   InvalidAuthTypemakeCheckerfindCheckerFactoryselfiats   & r   test_emptyDescription$PublicAPITests.test_emptyDescription+   H     !"'1173F3FL'1173M3MsS    c                    \        4       pV P                  \        P                  \        P                  V4       V P                  \        P                  \        P
                  V4       R# )z0
An unrecognized auth type raises an exception.
Nr#   r(   s   & r   test_invalidAuthType#PublicAPITests.test_invalidAuthType3   r-   r.    N)__name__
__module____qualname____firstlineno__r+   r0   __static_attributes____classdictcell____classdict__s   @r   r!   r!   *   s     TT Tr.   r!   c                   ,   a  ] tR t^<t o R tR tRtV tR# )StrcredFunctionsTestsc                    \        \        P                  ! 4       4      p\        P                  ! \        P
                  4       F  pV P                  W!4       K  	  R# )z@
L{strcred.findCheckerFactories} returns all available plugins.
N)listr   r   r   
getPluginsICheckerFactoryassertIn)r)   availablePluginsplgs   &  r   test_findCheckerFactories/StrcredFunctionsTests.test_findCheckerFactories=   s?       < < >?$$W%<%<=CMM#0 >r.   c                n    V P                  \        P                  ! R4      \        P                  4       R# )zc
L{strcred.findCheckerFactory} returns the first plugin
available for a given authentication type.
fileN)assertIdenticalr   r'   r   theFileCheckerFactoryr)   s   &r   test_findCheckerFactory-StrcredFunctionsTests.test_findCheckerFactoryE   s(    
 	&&v.	0O0O	
r.   r2   N)r3   r4   r5   r6   rD   rK   r7   r8   r9   s   @r   r<   r<   <   s     1
 
r.   r<   c                   D   a  ] tR t^Ot o R tR tR tR tR tR t	Rt
V tR# )	MemoryCheckerTestsc                   \         P                  ! R R4      V n        \         P                  ! RR4      V n        \         P                  ! RR4      V n        \         P                  ! RR4      V n        \        P                  ! R4      V n        R# )	adminasdfalicefoofoobarxyzzmemory:admin:asdf:alice:fooN)	r	   UsernamePasswordrP   rR   badPassbadUserr   r&   checkerrJ   s   &r   setUpMemoryCheckerTests.setUpP   se     11'6B
 11'5A
"33GXF"33C>**+HIr.   c                    V P                  \        P                  P                  V P                  4      4       V P                  \        P                  V P                  P                  4       R# zu
Verifies that strcred.makeChecker('memory') returns an object
that implements the L{ICredentialsChecker} interface.
N	
assertTruer   ICredentialsChecker
providedByrZ   rA   r	   IUsernamePasswordcredentialInterfacesrJ   s   &r   test_isChecker!MemoryCheckerTests.test_isCheckerW   C    
 	44??MNk33T\\5V5VWr.   c                d    V P                  \        P                  \        P                  R4       R# )zx
An argument string which does not contain user:pass pairs
(i.e., an odd number of ':' characters) raises an exception.
zmemory:a:b:cN)r$   r   InvalidAuthArgumentStringr&   rJ   s   &r   test_badFormatArgString*MemoryCheckerTests.test_badFormatArgString_   s%    
 	--w/B/BN	
r.   c                x   a  V 3R lpS P                   P                  S P                  4      P                  V4      # )+
The checker works with valid credentials.
c                 T   < SP                  V SP                  P                  4       R # NassertEqualrP   usernamerr   r)   s   &r   
_gotAvatarAMemoryCheckerTests.test_memoryCheckerSucceeds.<locals>._gotAvatarm       Xtzz':':;r.   rZ   requestAvatarIdrP   addCallbackr)   rt   s   f r   test_memoryCheckerSucceeds-MemoryCheckerTests.test_memoryCheckerSucceedsh   .    
	< ||++DJJ7CCJOOr.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # z-
The checker fails with an invalid username.
assertFailurerZ   rx   rY   r
   UnauthorizedLoginrJ   s   &r   test_memoryCheckerFailsUsername2MemoryCheckerTests.test_memoryCheckerFailsUsernamer   5     !!LL((68O8O
 	
r.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # z-
The checker fails with an invalid password.
r   rZ   rx   rX   r
   r   rJ   s   &r   test_memoryCheckerFailsPassword2MemoryCheckerTests.test_memoryCheckerFailsPasswordz   r   r.   )rP   rR   rX   rY   rZ   N)r3   r4   r5   r6   r[   re   rj   r{   r   r   r7   r8   r9   s   @r   rN   rN   O   s+     JX
P

 
r.   rN   c                   ,   a  ] tR t^t o R tR tRtV tR# )AnonymousCheckerTestsc                    \         P                  ! R4      pV P                  \        P                  P                  V4      4       V P                  \        P                  VP                  4       R# )zx
Verifies that strcred.makeChecker('anonymous') returns an object
that implements the L{ICredentialsChecker} interface.
	anonymousN)
r   r&   r`   r   ra   rb   rA   r	   
IAnonymousrd   )r)   rZ   s   & r   re   $AnonymousCheckerTests.test_isChecker   sK    
 %%k244??HIk,,g.J.JKr.   c                   a  \         P                  ! R4      pVP                  \        P                  ! 4       4      pV 3R lpVP                  V4      # )z/
We can log in anonymously using this checker.
r   c                 H   < SP                  \        P                  V 4       R # ro   )rH   r   	ANONYMOUS)avatarr)   s   &r   rt   EAnonymousCheckerTests.testAnonymousAccessSucceeds.<locals>._gotAvatar   s      !3!3V<r.   )r   r&   rx   r	   	Anonymousry   )r)   rZ   requestrt   s   f   r   testAnonymousAccessSucceeds1AnonymousCheckerTests.testAnonymousAccessSucceeds   sF     %%k2))+*?*?*AB	= "":..r.   r2   N)r3   r4   r5   r6   re   r   r7   r8   r9   s   @r   r   r      s     L
/ 
/r.   r   z"Required module not available: pwdz$Required module not available: cryptz#Required module not available: spwdc                   b   a  ] tR t^t o RRRR/tR tR tR tR tR	 t	R
 t
R tR tR tRtV tR# )UnixCheckerTestsrP   rQ   rR   rS   c                    \         P                  V\        P                  V P                  V,          R 4      ^ ^ R^RRR3	4      # )F/i )r   struct_spwdr   users)r)   rr   s   &&r   _spwd_getspnamUnixCheckerTests._spwd_getspnam   sI    DJJx0$7

 	
r.   c           
        \         P                  ! R R4      V n        \         P                  ! RR4      V n        \         P                  ! RR4      V n        \         P                  ! RR4      V n        \        P                  ! R4      V n        \         P                  ! RR	4      V n	        \         P                  ! R
R4      V n
        \         P                  ! R
R4      V n        \         P                  ! RR4      V n        \        P                  ! R4      V n        \        '       d   \        4       pV P                   P#                  4        F7  w  r#VP%                  V\&        P'                  VR4      RRVRV,           R4       K9  	  V P)                  \        RVP*                  4       \,        '       d$   V P)                  \,        RV P.                  4       R# R# )rP   rQ   rR   rS   rT   rU   rV   unix   admin   asdf   alice   foo   foobar   x   yzr   i  z/home/z/bin/shgetpwnamgetspnamN)r	   rW   rP   rR   rX   rY   r   r&   rZ   
adminBytes
aliceBytesbadPassBytesbadUserBytescheckerBytesr   r   r   itemsaddUserr   patchr   r   r   )r)   databaserr   passwords   &   r   r[   UnixCheckerTests.setUp   s\    11'6B
 11'5A
"33GXF"33C>**62%66xI%66xH'889M'88uE#//7 3#~H&*jj&6&6&8"  KK$/x' '9 JJsJ(9(9:4JJtZ)<)<= r.   c                   V P                  \        P                  P                  V P                  4      4       V P                  \        P                  V P                  P                  4       V P                  \        P                  P                  V P                  4      4       V P                  \        P                  V P                  P                  4       R# )zs
Verifies that strcred.makeChecker('unix') returns an object
that implements the L{ICredentialsChecker} interface.
N)
r`   r   ra   rb   rZ   rA   r	   rc   rd   r   rJ   s   &r   re   UnixCheckerTests.test_isChecker   s    
 	44??MNk33T\\5V5VW44??@Q@QRS))4+<+<+Q+Q	
r.   c                x   a  V 3R lpS P                   P                  S P                  4      P                  V4      # )rm   c                 T   < SP                  V SP                  P                  4       R # ro   rp   rs   s   &r   rt   =UnixCheckerTests.test_unixCheckerSucceeds.<locals>._gotAvatar   rv   r.   rw   rz   s   f r   test_unixCheckerSucceeds)UnixCheckerTests.test_unixCheckerSucceeds   r}   r.   c                x   a  V 3R lpS P                   P                  S P                  4      P                  V4      # )z4
The checker works with valid L{bytes} credentials.
c                 r   < SP                  V SP                  P                  P                  R 4      4       R# )utf-8N)rq   r   rr   decoders   s   &r   rt   BUnixCheckerTests.test_unixCheckerSucceedsBytes.<locals>._gotAvatar   s(    Xt'?'?'F'Fw'OPr.   )r   rx   r   ry   rz   s   f r   test_unixCheckerSucceedsBytes.UnixCheckerTests.test_unixCheckerSucceedsBytes   s6    
	Q   00AMM
 	
r.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # r   r   rJ   s   &r   test_unixCheckerFailsUsername.UnixCheckerTests.test_unixCheckerFailsUsername   r   r.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # )z6
The checker fails with an invalid L{bytes} username.
)r   r   rx   r   r
   r   rJ   s   &r   "test_unixCheckerFailsUsernameBytes3UnixCheckerTests.test_unixCheckerFailsUsernameBytes   :     !!--d.?.?@##
 	
r.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # r   r   rJ   s   &r   test_unixCheckerFailsPassword.UnixCheckerTests.test_unixCheckerFailsPassword  r   r.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # )z6
The checker fails with an invalid L{bytes} password.
)r   r   rx   r   r
   r   rJ   s   &r   "test_unixCheckerFailsPasswordBytes3UnixCheckerTests.test_unixCheckerFailsPasswordBytes  r   r.   )
rP   r   rR   r   rX   r   rY   r   rZ   r   N)r3   r4   r5   r6   r   r   r[   re   r   r   r   r   r   r   r7   r8   r9   s   @r   r   r      sK     
 	E

><

P





 
r.   r   z%Required module is unavailable: cryptc                   0   a  ] tR tRt o RtR tR tRtV tR# )
CryptTestsi  z1
L{crypt} has functions for encrypting password.
c                   RpR F  p \         P                  W4      p\        V\        4      '       d   VP                  R4      pRpT P                  \        P                  ! Y14      4       T P                  \        P                  ! YA4      4       K  	  R EF@  p\        \         VR4      pV'       g   K  Rp\         P                  W4      p\        V\        4      '       d   VP                  R4      pVR,           p\        P                  ! Wq4      p	V P                  V	4       \        P                  ! VP                  R4      VP                  R4      4      p	V P                  V	4       \        P                  ! W4      p	V P                  V	4       \        P                  ! VP                  R4      VP                  R4      4      p	V P                  V	4       EKC  	  R#   \         d     EK  i ; i)	z$
L{cred_unix.verifyCryptedPassword}
sample password ^%$Nr   z$1x1234zinteresting password xyzblahfooincorrect)Nab)METHOD_SHA512METHOD_SHA256
METHOD_MD5METHOD_CRYPT)r   
isinstancebytesr   	TypeErrorr`   r   verifyCryptedPasswordassertFalsegetattrencode)
r)   r   saltcryptedCorrectcryptedIncorrectmethodcryptMethodcryptedincorrectCryptedresults
   &         r   test_verifyCryptedPassword%CryptTests.test_verifyCryptedPassword  s    ) D!&X!<ne44%3%:%:7%CN  )OOI;;NUV//0@K !$ WF!%6K1Hkk(8G'5))!..1&);;44WGFOOF#44w')AF OOF#445EPFV$44 ''0(//'2JF V$- W   	s   <GG.-G.c                    R pRp\         P                  VR4      pV P                  \         RV4       V P                  \        P                  ! W24      4       R# )z;
L{cred_unix.verifyCryptedPassword} when OSError is raised
c                     \        R 4      h) )OSError)r   r   s   &&r   	mockCrypt?CryptTests.test_verifyCryptedPasswordOSError.<locals>.mockCryptP  s    "+r.   r   r   r   N)r   r   r   r   r   )r)   r   r   r   s   &   r   !test_verifyCryptedPasswordOSError,CryptTests.test_verifyCryptedPasswordOSErrorK  sG    
	 )Xt4

5'9-88RSr.   r2   N)	r3   r4   r5   r6   __doc__r   r   r7   r8   r9   s   @r   r   r     s     .%`T Tr.   r   c                   T   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tRtV tR# )FileDBCheckerTestsiY  z"
C{--auth=file:...} file checker.
c                   \         P                  ! R R4      V n        \         P                  ! RR4      V n        \         P                  ! RR4      V n        \         P                  ! RR4      V n        V P                  4       V n        \        V P                  4      P                  R4       \        P                  ! RV P                  ,           4      V n        R	# )
r   r   r   r   r   r   r      admin:asdf
alice:foo
file:N)r	   rW   rP   rR   rX   rY   mktempfilenamer   
setContentr   r&   rZ   rJ   s   &r   r[   FileDBCheckerTests.setUp^  s     11(GD
 11(FC
"33HiH"33D%@**+EF**7T]]+BCr.   c                j    R p\         P                  P                  V4      '       d   VR,          pK0  V# )z/DoesNotExistr   )ospathexists)r)   r   s   & r   _fakeFilename FileDBCheckerTests._fakeFilenameg  s(    "ggnnX&&OHr.   c                    V P                  \        P                  P                  V P                  4      4       V P                  \        P                  V P                  P                  4       R# r^   r_   rJ   s   &r   re   !FileDBCheckerTests.test_isCheckerm  rg   r.   c                x   a  V 3R lpS P                   P                  S P                  4      P                  V4      # )rm   c                 T   < SP                  V SP                  P                  4       R # ro   rp   rs   s   &r   rt   ?FileDBCheckerTests.test_fileCheckerSucceeds.<locals>._gotAvatarz  rv   r.   rw   rz   s   f r   test_fileCheckerSucceeds+FileDBCheckerTests.test_fileCheckerSucceedsu  r}   r.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # r   r   rJ   s   &r   test_fileCheckerFailsUsername0FileDBCheckerTests.test_fileCheckerFailsUsername  r   r.   c                    V P                  V P                  P                  V P                  4      \        P
                  4      # r   r   rJ   s   &r   test_fileCheckerFailsPassword0FileDBCheckerTests.test_fileCheckerFailsPassword  r   r.   c                    V P                  \        \        P                  R4       V P                  \        \        P                  R4       R# )z$
An empty filename raises an error.
rG   r   N)r$   
ValueErrorr   r&   rJ   s   &r   test_failsWithEmptyFilename.FileDBCheckerTests.test_failsWithEmptyFilename  s4     	*g&9&96B*g&9&97Cr.   c                T   \         P                  P                  p\        4       pV\         P                  n        \        P
                  ! RV P                  4       ,           4       V\         P                  n        V P                  \         P                  VP                  4       4       R# )z\
When the file auth plugin is given a file that doesn't exist, it
should produce a warning.
r   N)
r   rI   errorOutputr   r   r&   r  rA   invalidFileWarninggetvalue)r)   	oldOutput	newOutputs   &  r   test_warnWithBadFilename+FileDBCheckerTests.test_warnWithBadFilename  sq    
 33??	J	6?	''3Gd&8&8&::;6?	''3i22I4F4F4HIr.   )rP   rR   rX   rY   rZ   r   N)r3   r4   r5   r6   r   r[   r  re   r  r  r  r  r  r7   r8   r9   s   @r   r   r   Y  s=     DXP

D
J 
Jr.   r   cryptographyzcryptography is not availablec                   *   a  ] tR tRt o RtR tRtV tR# )SSHCheckerTestsi  z
Tests for the C{--auth=sshkey:...} checker.  The majority of the
tests for the ssh public key database checker are in
L{twisted.conch.test.test_checkers.SSHPublicKeyCheckerTestCase}.
c                    \         P                  ! R4      pV P                  \        P                  P                  V4      4       V P                  \        P                  VP                  4       R# )zu
Verifies that strcred.makeChecker('sshkey') returns an object
that implements the L{ICredentialsChecker} interface.
sshkeyN)
r   r&   r`   r   ra   rb   rA   r	   ISSHPrivateKeyrd   )r)   
sshCheckers   & r   re   SSHCheckerTests.test_isChecker  sK    
 ((2
44??
KLk00*2Q2QRr.   r2   N)r3   r4   r5   r6   r   re   r7   r8   r9   s   @r   r"  r"    s     S Sr.   r"  c                       ] tR tRtRtRtR# )DummyOptionsi  z8
Simple options for testing L{strcred.AuthOptionMixin}.
r2   N)r3   r4   r5   r6   r   r7   r2   r.   r   r)  r)    s    r.   r)  c                   P   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
tV tR# )CheckerOptionsTestsi  c                   \        4       pVP                  RR.4       V P                  \        VR,          4      ^4       \        4       pVP                  . RO4       V P                  \        VR,          4      ^4       R# )z]
The C{--auth} command line creates a list in the
Options instance and appends values to it.
--authmemorycredCheckersN)r-  r.  r-  r.  )r)  parseOptionsrq   lenr)   optionss   & r   test_createsList$CheckerOptionsTests.test_createsList  sh    
 .h12W^45q9.EFW^45q9r.   c                    \        4       p\        4       pV P                  \        P                  VP
                  RV.4       V P                  \        P                  VP
                  RV.4       R# )z`
The C{--auth} command line raises an exception when it
gets a parameter it doesn't understand.
r-  --help-auth-typeN)r)  r   r$   r   
UsageErrorr0  )r)   r3  invalidParameters   &  r   test_invalidAuthError)CheckerOptionsTests.test_invalidAuthError  sh    
 . ./g22X?O4P	
 	  !12	
r.   c                   \        4       pVP                  . RO4       VR,          pV P                  \        V\        P
                  ,          4      ^4       V P                  \        V\        P                  ,          4      ^4       V\        P
                  ,          ^ ,          pV\        P                  ,          ^ ,          pV P                  \        P                  P                  V4      4       V P                  \        P                  P                  V4      4       V P                  \        P
                  VP                  4       V P                  \        P                  VP                  4       R# )z
The C{--auth} command line creates a dictionary mapping supported
interfaces to the list of credentials checkers that support it.
credInterfacesN)r-  r.  r-  r   )r)  r0  rq   r1  r	   r   rc   r`   r   ra   rb   rA   rd   )r)   r3  chdchdAnonymouschdUserPasss   &    r   test_createsDictionary*CheckerOptionsTests.test_createsDictionary  s    
 .HI&'S!7!7891=S!>!>?@!D;11215+778;44??MN44??LMk,,l.O.OPk33[5U5UVr.   c                    \        4       pVP                  . RO4       V P                  VR,          VR,          \        P                  ,          4       R# )zn
When two C{--auth} arguments are passed along which support the same
interface, a list with both is created.
r/  r=  N)r-  r.  r-  r   )r)  r0  rq   r	   rc   r2  s   & r    test_credInterfacesProvidesLists4CheckerOptionsTests.test_credInterfacesProvidesLists  sD    
 .CDN#$%k&C&CD	
r.   c                    . p\        4       pVP                  4        F:  pV P                  VP                  V4       VP	                  VP                  4       K<  	  R# )z7
The list for C{--help-auth} does not duplicate items.
N)r)  _checkerFactoriesForOptHelpAuthassertNotInr   append)r)   	authTypesr3  cfs   &   r   !test_listDoesNotDisplayDuplicates5CheckerOptionsTests.test_listDoesNotDisplayDuplicates  sI     	.99;BR[[)4R[[) <r.   c                
   \        4       p\        4       pWn        V P                  \        VP
                  R.4       \        P                  ! 4        F-  pV P                  VP                  VP                  4       4       K/  	  R# )zb
The C{--help-auth} argument correctly displays all
available authentication plugins, then exits.
z--help-authN)r   r)  
authOutputr$   
SystemExitr0  r   r   rA   r   r  )r)   	newStdoutr3  checkerFactorys   &   r   test_displaysListCorrectly.CheckerOptionsTests.test_displaysListCorrectly  sb    
 J	.&*g&:&:]OL%::<NMM.1193E3E3GH =r.   c                N   \        4       p\        4       pWn        V P                  \        VP
                  RR.4       \        P                  P                   FI  pVP                  4       '       g   K  V P                  VP                  4       VP                  4       4       KK  	  R# )zn
The C{--help-auth-for} argument will correctly display the help file
for a particular authentication plugin.
r7  rG   N)r   r)  rO  r$   rP  r0  r   rI   authHelpstriprA   r  )r)   rQ  r3  lines   &   r   test_displaysHelpCorrectly.CheckerOptionsTests.test_displaysHelpCorrectly  sy    
 J	.&,,/A6.J	
 33<<Dzz||djjlI,>,>,@A =r.   c                    \        4       pV P                  \        P                  VP                  RR.4      pV P                  \        V4      R4       R# )z
When the checker specified by C{--auth} raises an unexpected error, it
should be caught and re-raised within a L{usage.UsageError}.
r-  rG   z,Unexpected error: 'file' requires a filenameN)r)  r$   r   r8  r0  rq   str)r)   r3  errs   &  r   test_unexpectedException,CheckerOptionsTests.test_unexpectedException  sJ    
 .g22Xv4F
 	S#QRr.   r2   N)r3   r4   r5   r6   r4  r:  rA  rD  rL  rS  rY  r^  r7   r8   r9   s   @r   r+  r+    s7     
:
$W"

*
IB	S 	Sr.   r+  c                   0    ] tR tRt]P
                  3tRtR# )OptionsForUsernamePasswordi)  r2   N)r3   r4   r5   r6   r	   rc   supportedInterfacesr7   r2   r.   r   ra  ra  )  s    &88:r.   ra  c                   0    ] tR tRt]P
                  3tRtR# ) OptionsForUsernameHashedPasswordi-  r2   N)r3   r4   r5   r6   r	   IUsernameHashedPasswordrb  r7   r2   r.   r   rd  rd  -  s    &>>@r.   rd  c                       ] tR tRtRtRtR# )OptionsSupportsAllInterfacesi1  Nr2   )r3   r4   r5   r6   rb  r7   r2   r.   r   rg  rg  1  s    r.   rg  c                   0   a  ] tR tRt o . tV 3R ltRtV tR# )OptionsSupportsNoInterfacesi5  c                F   < V ^8  d   Qh/ S[ S[S[,          ,          ;R&   # )   rb  )r   r   r   )formatr:   s   "r   __annotate__(OptionsSupportsNoInterfaces.__annotate__5  s     !$y/27 r.   r2   N)r3   r4   r5   r6   rb  __annotate_func__r7   r8   r9   s   @r   ri  ri  5  s     57  r.   ri  c                   `   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tRtV tR# )LimitingInterfacesTestsi9  aa  
Tests functionality that allows an application to limit the
credential interfaces it can support. For the purposes of this
test, we use IUsernameHashedPassword, although this will never
really be used by the command line.

(I have, to date, not thought of a half-decent way for a user to
specify a hash algorithm via the command-line. Nor do I think it's
very useful.)

I should note that, at first, this test is counter-intuitive,
because we're using the checker with a pre-defined hash function
as the 'bad' checker. See the documentation for
L{twisted.cred.checkers.FilePasswordDB.hash} for more details.
c                   V P                  4       V n        \        V P                  R 4      ;_uu_ 4       pVP                  R4       RRR4       \        P
                  ! V P                  4      V n        \        P
                  ! V P                  V P                  R7      V n        \        P                  ! 4       V n
        R#   + '       g   i     L; i)wbr   N)hash)r   r   openwriter   FilePasswordDBgoodChecker_hash
badCheckerAllowAnonymousAccessanonChecker)r)   fs   & r   r[   LimitingInterfacesTests.setUpJ  s    $--&&!GG./ '#224==A"11$--djjQ#88:	 '&s   C  C	c                    V# )z.
A dumb hash that doesn't really do anything.
r2   )r)   networkUsernamenetworkPasswordstoredPasswords   &&&&r   ry  LimitingInterfacesTests._hashR  s
     r.   c                <   \        4       pV P                  VP                  \        P                  4      4       V P                  VP                  \        P                  4      4       V P                  \        P                  VP                  V P                  4       R# )z5
The supportsInterface method behaves appropriately.
N)ra  r`   supportsInterfacer	   rc   r   r   r$   r   UnsupportedInterfaces
addCheckerr|  r2  s   & r   test_supportsInterface.LimitingInterfacesTests.test_supportsInterfaceX  so     -.11+2O2OPQ22;3I3IJK))7+=+=t?O?O	
r.   c                    \        4       pV P                  VP                  \        P                  4      4       V P                  VP                  \        P
                  4      4       R# )zd
The supportsInterface method behaves appropriately
when the supportedInterfaces attribute is None.
N)rg  r`   r  r	   rc   r   r2  s   & r   test_supportsAllInterfaces2LimitingInterfacesTests.test_supportsAllInterfacesc  sF    
 /011+2O2OPQ11+2H2HIJr.   c                    \        4       p\        P                  p\        P                  pV P                  VP                  V4      4       V P                  VP                  V4      4       R# )z:
The supportsCheckerFactory method behaves appropriately.
N)ra  r   rI   r   theAnonymousCheckerFactoryr`   supportsCheckerFactoryr   )r)   r3  fileCFanonCFs   &   r   test_supportsCheckerFactory3LimitingInterfacesTests.test_supportsCheckerFactoryl  sR     -.00::66v>?77?@r.   c                   \        4       pVP                  V P                  4       VP                  ^ ,          pV P	                  VR,          V,          ^ ,          V P                  4       V P	                  VR,          ^ ,          V P                  4       V P                  \        VR,          V,          4      ^4       V P                  \        VR,          4      ^4       R# )z
When addChecker is called with a checker that implements at least one
of the interfaces our application supports, it is successful.
r=  r/  N)ra  r  rx  rb  rH   rq   r1  )r)   r3  ifaces   &  r   test_canAddSupportedChecker3LimitingInterfacesTests.test_canAddSupportedCheckerv  s    
 -.4++,++A.W%56u=a@$BRBRSW^4Q79I9IJW%56u=>BW^45q9r.   c                    \        4       pV P                  \        P                  VP                  V P
                  4       R# )zf
When addChecker is called with a checker that does not implement any
supported interfaces, it fails.
N)rd  r$   r   r  r  rz  r2  s   & r   #test_failOnAddingUnsupportedChecker;LimitingInterfacesTests.test_failOnAddingUnsupportedChecker  s1    
 34))7+=+=t	
r.   c                    \        4       p\        P                  P                  pV P	                  \
        P                  VP                  RV.4       R# )zY
The C{--auth} command line raises an exception when it
gets a checker we don't support.
r-  N)ri  r   r  r   r$   r   r8  r0  )r)   r3  r   s   &  r   test_unsupportedInterfaceError6LimitingInterfacesTests.test_unsupportedInterfaceError  s@    
 ./!<<EE%**G,@,@8XBVWr.   c                    \        4       pVP                  4        FP  pRpVP                   F  pVP                  V4      '       g   K  RpK   	  V'       g   K=  \        P
                  ! 4       h	  R# )z
C{--help-auth} will only list checkers that purport to
supply at least one of the credential interfaces our
application can use.
TFN)ra  rG  rd   r  r   r  )r)   r3  r   invalid	interfaces   &    r   test_helpAuthLimitsOutput1LimitingInterfacesTests.test_helpAuthLimitsOutput  sa     -.>>@GG$99	,,Y77#G : w3355 Ar.   c                r   \        4       pRp\        P                  ! 4        F  pVP                  V4      '       d   K  Tp M	  V P	                  VR4       \        4       pWAn        V P                  \        VP                  RR.4       V P                  \        P                  VP                  4       4       R# )z
C{--help-auth-type} will display a warning if you get
help for an authType that does not supply at least one of the
credential interfaces our application can use.
Nr7  r   )ra  r   r   r  assertNotIdenticalr   rO  r$   rP  r0  rA   notSupportedWarningr  )r)   r3  invalidFactoryr   rQ  s   &    r   test_helpAuthTypeLimitsOutput5LimitingInterfacesTests.test_helpAuthTypeLimitsOutput  s     -.335G11'::!( 6 	5J	&,,/A;.O	
 	g1193E3E3GHr.   )r|  rz  r   rx  N)r3   r4   r5   r6   r   r[   ry  r  r  r  r  r  r  r  r  r7   r8   r9   s   @r   rq  rq  9  sF      ;	
KA:
X6I Ir.   rq  )5r   r  ior   typingr   r   unittestr   zope.interfacer   twistedr   twisted.credr   r	   r
   r   twisted.pluginsr   r   r   twisted.pythonr   twisted.python.fakepwdr   twisted.python.filepathr   twisted.python.reflectr   twisted.trial.unittestr   r   r   r   r   r!   r<   rN   r   r   r   r   r"  OptionsAuthOptionMixinr)  r+  ra  rd  rg  ri  rq  r2   r.   r   <module>r     s  
 
  !  $  > > @ @   / , 0 +gEV	TX T$
H 
&1
 1
h/H /. C56E	9:D78u
x u
 9 ; 7u
p E	:;@T @T <@TFGJ GJT C56M.))+JKSh S L 7S"5=='"9"9 jS( jSZ;0G0G ;Au}}g6M6M A5=='2I2I 8%--1H1H 8BIh BIr.   