+
    ibr                     @   R t ^ RIHt ^ RIHt ^ RIt^ RIt ^ RIHt ^ RI
Ht ^ RIHtHtHt ^ RIHtHt ^ RIHu Ht ^ RIHtHt ^ R	IHtHtHt ]! ] 4      t! ! R
 R]4      t" ! R R]4      t# ! R R]PH                  4      t% ! R R]4      t&R#   ]	 d    Rt L~i ; i)a  tests for passlib.context

this file is a clone of the 1.5 test_context.py,
containing the tests using the legacy CryptPolicy api.
it's being preserved here to ensure the old api doesn't break
(until Passlib 1.8, when this and the legacy api will be removed).
)with_statement)	getLoggerN)resource_filename)hash)CryptContextCryptPolicyLazyCryptContext)to_bytes
to_unicode)TestCaseset_file)register_crypt_handler_path_has_crypt_handler_unload_handler_namec                     a  ] tR t^%t o RtRtRt]P                  P                  ]P                  P                  ]P                  P                  ]4      R4      4      t]P                  P                  ]4      '       g   ]'       d
   ]! RR4      t]P!                  R4      '       g   Q h]! . R?ORRRRRRR7      tRRRRRRRRRRRRRR/t]! ]P*                  ]P,                  ]P.                  ]P0                  .RRRRRRR7      tRt]! RRRRR7      t]! . R?ORRRRRRRR7      t]! R
R 7      t]! . R?OR
RRRRRRR7      tR!t]! R
.RR"R#RR$7      t ]R%,           t!]PE                  4       t#]#PI                  R.RR	.R&7       ]PE                  4       t%]%PI                  R'RR(R)/4       ]PE                  4       t&]&PI                  R'R.R*RR	./4       R+ t'R, t(R- t)R. t*R/ t+R0 t,R1 t-R2 t.R3 t/R4 t0R5 t1R6 t2R7 t3R8 t4R9 t5R: t6R; t7R< t8R=t9V t:R># )@CryptPolicyTestztest CryptPolicy objectr   z[passlib]
schemes = des_crypt, md5_crypt, bsdi_crypt, sha512_crypt
default = md5_crypt
all.vary_rounds = 10%%
bsdi_crypt.max_rounds = 30000
bsdi_crypt.default_rounds = 25000
sha512_crypt.max_rounds = 50000
sha512_crypt.min_rounds = 40000
zsample_config_1s.cfgzpasslib.testsz[passlib]
schemes	des_crypt	md5_crypt
bsdi_cryptsha512_crypt皙?0u  ia  P  @  )schemesdefaultall__vary_roundsbsdi_crypt__max_roundsbsdi_crypt__default_roundssha512_crypt__max_roundssha512_crypt__min_roundsr   z.des_crypt, md5_crypt, bsdi_crypt, sha512_cryptr   zall.vary_roundszbsdi_crypt.max_roundszbsdi_crypt.default_roundszsha512_crypt.max_roundszsha512_crypt.min_roundsz[passlib]
bsdi_crypt.min_rounds = 29000
bsdi_crypt.max_rounds = 35000
bsdi_crypt.default_rounds = 31000
sha512_crypt.min_rounds = 45000
Hq  鸈  y  ȯ  )bsdi_crypt__min_roundsr   r   r    )r   r   r   r%   r   r   r   r    r   z
[passlib]
schemes = sha512_crypt
all.vary_rounds = 10%%
default.sha512_crypt.max_rounds = 20000
admin.all.vary_rounds = 5%%
admin.sha512_crypt.max_rounds = 40000
 N  皙?)r   r   r   admin__all__vary_roundsadmin__sha512_crypt__max_roundszJdeprecated = des_crypt
admin__context__deprecated = des_crypt, bsdi_crypt
)
deprecatedadmin__context__deprecatedr+   zadmin.context.deprecatedzdes_crypt, bsdi_cryptr,   c                    \         P                  ! V 4       \        P                  ! R R4       \        P                  ! R R4       \        P                  ! R R4       \        P                  ! R R4       R# )ignorez)The CryptPolicy class has been deprecated,the method.*hash_needs_update.*is deprecatedz The 'all' scheme is deprecated.*zbsdi_crypt rounds should be oddNr   setUpwarningsfilterwarningsselfs   &c/var/www/html/photoedit/myenv/lib/python3.14/site-packages/passlib/tests/test_context_deprecated.pyr1   CryptPolicyTest.setUp   sX    t L	N O	Q*LM*KL    c                Z   \        R/ V P                  B pV P                  VP                  4       V P                  4       \        V P                  4      pV P                  VP                  4       V P                  4       V P	                  \
        \         / / 4       V P	                  \
        \         / ^R7       V P	                  \
        \         . RORR7        ! R R\        P                  4      pV P	                  \        \         V.R7       V P	                  \
        \         \        P                  .R7        ! R	 R
\        P                  4      pV P	                  \        \         W3.R7       V P	                  \        \         R.R.R7       V P	                  \        \         R.RR7       R# )ztest CryptPolicy() constructor)dummyr   r   r   )r    bad__key__bsdi_crypt__max_roundsc                       ] tR t^tRtRtR# )5CryptPolicyTest.test_00_constructor.<locals>.namelessN __name__
__module____qualname____firstlineno__name__static_attributes__r>   r8   r6   namelessr=      s    Dr8   rF   r   c                       ] tR t^tRtRtR# )4CryptPolicyTest.test_00_constructor.<locals>.dummy_1dummy_1r>   Nr?   r>   r8   r6   rJ   rI      s    Dr8   rJ   r   r+   r   r   Nr>   r   r   r   r   )
r   sample_config_1pdassertEqualto_dictassertRaises	TypeErroruhStaticHandler
ValueErrorKeyError)r5   policyrF   rJ   s   &   r6   test_00_constructor#CryptPolicyTest.test_00_constructor   s`   6t556)4+A+ABT334)4+A+AB)["b9)["A> 	)[O/4 	 		r'' 	*kH:F 	)[2;K;K:LM	b&& 	(K'9KL 	(K#.-&1] 	 	4
 	(K#.-"- 	 	/r8   c                    V P                   p\        P                  ! V4      pV P                  VP	                  4       V P
                  4       V P                  \        \        P                  VR,           4       R# )z(test CryptPolicy.from_path() constructorxxxN)sample_config_1s_pathr   	from_pathrO   rP   rN   rQ   EnvironmentError)r5   pathrW   s   &  r6   test_01_from_path_simple(CryptPolicyTest.test_01_from_path_simple  s[    
 ))&&t,)4+A+AB 	*K,A,A4%<Pr8   c                d   V P                  4       p\        WP                  4       \        P                  ! V4      pV P                  VP                  4       V P                  4       \        WP                  P                  RR4      4       \        P                  ! V4      pV P                  VP                  4       V P                  4       \        V P                  RRR7      p\        W4       \        P                  ! VRR7      pV P                  VP                  4       V P                  4       R# )z7test CryptPolicy.from_path() constructor with encodings

utf-16utf-8source_encodingencodingN)
mktempr   sample_config_1sr   r]   rO   rP   rN   replacer	   )r5   r_   rW   uc2s   &   r6   test_01_from_path!CryptPolicyTest.test_01_from_path  s    {{} 	,,-&&t,)4+A+AB 	,,44T&AB&&t,)4+A+AB t,,hP&&th?)4+A+ABr8   c                @   \         P                  ! V P                  4      pV P                  VP	                  4       V P
                  4       \         P                  ! V P                  P                  RR4      4      pV P                  VP	                  4       V P
                  4       \        V P                  4      p\         P                  ! V4      pV P                  VP	                  4       V P
                  4       \        V P                  RRR7      p\         P                  ! VRR7      pV P                  VP	                  4       V P
                  4       \         P                  ! V P                  4      pV P                  VP	                  4       V P                  4       R# )z*test CryptPolicy.from_string() constructorrc   rd   re   rf   rg   ri   N)r   from_stringrl   rO   rP   rN   rm   r
   r	   sample_config_4ssample_config_4pd)r5   rW   datarn   s   &   r6   test_02_from_string#CryptPolicyTest.test_02_from_string"  s5    (()>)>?)4+A+AB ((!!))$v68)4+A+AB $//0((.)4+A+AB t,,hP((x@)4+A+AB (()>)>?)4+A+ABr8   c                   \         P                  ! V P                  4      pV P                  VP	                  4       V P
                  4       \         P                  ! V P                  4      pV P                  VP	                  4       V P
                  4       \         P                  ! V P
                  P                  4       4      pV P                  VP	                  4       V P
                  4       \         P                  ! V4      pV P                  W4       V P                  \        \         P                  ^4       V P                  \        \         P                  . 4       R# )z*test CryptPolicy.from_source() constructorN)r   from_sourcer\   rO   rP   rN   rl   copyassertIsrQ   rR   )r5   rW   p2s   &  r6   test_03_from_source#CryptPolicyTest.test_03_from_source;  s     (()C)CD)4+A+AB (()>)>?)4+A+AB (()?)?)D)D)FG)4+A+AB $$V,f! 	)[%<%<a@)[%<%<bAr8   c                   V P                  \        \        P                  . 4       \        P                  ! V P                  .4      pV P                  VP                  4       V P                  4       \        P                  ! V P                  V P                  V P                  .4      pV P                  VP                  4       V P                  4       R# )z+test CryptPolicy.from_sources() constructorN)rQ   rU   r   from_sourcesrl   rO   rP   rN   r\   sample_config_2ssample_config_3pdsample_config_123pd)r5   rW   s   & r6   test_04_from_sources$CryptPolicyTest.test_04_from_sourcesQ  s     	*k&>&>C ))4+@+@*AB)4+A+AB ))&&!!"" 	)4+C+CDr8   c                   \        R/ V P                  B pVP                  ! R/ V P                  B pV P	                  VP                  4       V P                  4       VP                  ! R/ V P                  B pV P	                  VP                  4       V P                  4       VP                  V P                  4      pV P	                  VP                  4       V P                  4       R# )z&test CryptPolicy.replace() constructorNr>   )	r   rN   rm   sample_config_2pdrO   rP   sample_config_12pdr   r   )r5   p1r|   p2bp3s   &    r6   test_05_replaceCryptPolicyTest.test_05_replaced  s     24112 ZZ1$001t'>'>? jj24112(?(?@ ZZ../t'?'?@r8   c                    V P                  \        \        R.RR7       V P                  \        \        R.RR7       V P                  \        \        R.R.R7       R# )z!test CryptPolicy() forbidden kwdsr   xx)r   des_crypt__salt)r   	all__saltr   )r   user__context__schemesN)rQ   rV   r   r4   s   &r6   test_06_forbidden!CryptPolicyTest.test_06_forbiddenu  sg     	(K M  	 	
 	(K M 	 	
 	(K M$/= 	 	
r8   c                    \        R/ V P                  B pV P                  VP                  4       4       \        R/ V P                  B pV P                  VP                  4       '       * 4       R# )ztest has_schemes() methodNr>   )r   rN   
assertTruehas_schemesr   )r5   r   r   s   &  r6   test_10_has_schemes#CryptPolicyTest.test_10_has_schemes  sS     24112()24112BNN,,-r8   c                $   \        R/ V P                  B pV P                  R,          pV P                  \	        VP                  4       4      V4       \        R/ V P                  B pV P                  \	        VP                  4       4      . 4       R# )ztest iter_handlers() methodr   Nr>   )r   rN   sample_config_1prdrO   listiter_handlersr   )r5   r   sr   s   &   r6   test_11_iter_handlers%CryptPolicyTest.test_11_iter_handlers  sv     24112##I.b..011524112b..0126r8   c                r   \        R/ V P                  B pV P                  VP                  R4      \        P
                  4       V P                  VP                  R4      R4       V P                  \        VP                  RRR7       V P                  VP                  4       \        P                  4       R# )ztest get_handler() methodr   sha256_cryptNTrequiredr>   )	r   rN   r{   get_handlerr   r   rQ   rV   r   )r5   r   s   & r6   test_12_get_handler#CryptPolicyTest.test_12_get_handler  s     24112 	bnn\2DOOD 	bnn^4d;(BNNNTR 	bnn&7r8   c           
     2   \        R/ V P                  B pV P                  VP                  R4      \	        RRRRR7      4       V P                  VP                  R4      \	        RRR	R
7      4       \         P
                  ! V P                  4      pV P                  VP                  R4      \	        RRR7      4       V P                  VP                  RR4      \	        RRR7      4       V P                  VP                  RR4      \	        RRR7      4       R# )ztest get_options() methodr   r   r!   r"   r#   )vary_rounds
min_rounds
max_roundsdefault_roundsr   r$   r   )r   r   r   r'   )r   r   useradminr(   r   Nr>   )r   r   rO   get_optionsdictrr   rs   )r5   p12p4s   &  r6   test_13_get_options#CryptPolicyTest.test_13_get_options  s    4D3346t"8
 	 	8	:
 	 $$T%:%:;7:
 	 	?B
 	 	@$C
 	r8   c                B   \        R	/ V P                  B p\        R	/ V P                  B pV P                  VP	                  R4      4       V P                  VP	                  \
        P                  4      4       V P                  VP	                  R4      4       V P                  VP	                  R4      4       V P                  VP	                  \
        P                  4      4       V P                  VP	                  R4      4       V P                  VP	                  RR4      4       V P                  VP	                  RR4      4       V P                  VP	                  RR4      4       V P                  VP	                  RR4      4       \        RR.R.R.R7      pV P                  VP	                  R4      4       V P                  VP	                  R4      4       V P                  VP	                  RR4      4       V P                  VP	                  RR4      4       R# )
z#test handler_is_deprecated() methodr   r   r   r   r   r   )r   r+   user__context__deprecatedNr>   )r   rN   sample_config_5pdassertFalsehandler_is_deprecatedr   r   r   )r5   papbpcs   &   r6   test_14_handler_is_deprecated-CryptPolicyTest.test_14_handler_is_deprecated  s   241122411211+>?11$//BC11.AB00=>11$//BC11.AB 	00fEF11,GH00gFG00wGH  +.#}'2m

 	00=>11+>?11+vFG00fEFr8   c                z   \         P                  ! R\        R7       \        4       pV P	                  VP                  4       ^ 4       V P	                  VP                  R4      ^ 4       VP                  RR7      pV P	                  VP                  4       ^ 4       V P	                  VP                  R4      ^ 4       R# )z!test get_min_verify_time() methodr.   )categoryr   r   )min_verify_timeN)r2   r3   DeprecationWarningr   rO   get_min_verify_timerm   )r5   r   r   s   &  r6   test_15_min_verify_time'CryptPolicyTest.test_15_min_verify_time  s     	3EF]//115//8!<ZZZ+//115//8!<r8   c                j   \        R/ V P                  B pV P                  \        VP	                  4       4      V P                  4       V P                  \        VP	                  RR7      4      V P
                  4       V P                  \        VP	                  RR7      4      V P                  4       R# )ztest iter_config() methodTresolve)iniNr>   )r   r   rO   r   iter_configsample_config_5prdsample_config_5pidr5   p5s   & r6   test_20_iter_config#CryptPolicyTest.test_20_iter_config  s    24112bnn./1G1GHbnnTn:;T=T=TUbnnn679P9PQr8   c                    \        R/ V P                  B pV P                  VP                  4       V P                  4       V P                  VP                  RR7      V P                  4       R# )ztest to_dict() methodTr   Nr>   )r   r   rO   rP   r   r   s   & r6   test_21_to_dictCryptPolicyTest.test_21_to_dict	  sR    24112t'='=>D143J3JKr8   c                    \        R/ V P                  B pVP                  4       p\         P                  ! V4      pV P	                  VP                  4       V P                  4       VP                  RR7      pV P                  V\        4       R# )ztest to_string() methodzlatin-1ri   Nr>   )r   r   	to_stringrr   rO   rP   assertIsInstancebytes)r5   r   r   r   s   &   r6   test_22_to_string!CryptPolicyTest.test_22_to_string  sl    24112LLN$$Q't'='=>LL)L,a'r8   r>   NrM   );r@   rA   rB   rC   __doc__descriptionPrefixrl   osr_   abspathjoindirname__file__r\   existsr   
startswithr   rN   sample_config_1pidr   r   r   r   r   r   r   r   r   r   r   rs   rt   sample_config_5srz   r   updater   r   r1   rX   r`   ro   rv   r}   r   r   r   r   r   r   r   r   r   r   r   r   rE   __classdictcell____classdict__s   @r6   r   r   %   s    ! &	 GGOOBGGLL
!#9-; <77>>/005F 1/2H!J &&';<<<<K!&%*#(#(	 	C;3#U!5!5	 NNDNNDOOTEVEVW!&%*#(#(	 !&!&%*!& K!&!&%*#(!&
  K !&!&%*#(!&
 "$#("&*/
 ( + 
 *..0"_'2L%B  
 ,002k"$; 
 ,002 	{m${L&A	 M&/P
QC(C2B,E&A"
,.78%NG<= RL( (r8   r   c                   x   a  ] tR tRt o RtRtR tR tR tR t	]
! . ROR.R	^^^ R
RR
R^R7      tR tR tRtV tR# )CryptContextTesti   ztest CryptContext classr   c                    \         P                  ! V 4       \        P                  ! R R4       \        P                  ! R R4       \        P                  ! R R4       \        P                  ! R R4       R# )r.   z3CryptContext\(\)\.replace\(\) has been deprecated.*z9The CryptContext ``policy`` keyword has been deprecated.*=.*(CryptPolicy|context\.policy).*(has|have) been deprecated.*r/   Nr0   r4   s   &r6   r1   CryptContextTest.setUp$  s[    t V	X \	^*ij O	Qr8   c                R   \        \        P                  \        P                  \        P                  .4      pVP
                  P                  4       w  r#pV P                  V\        P                  4       V P                  V\        P                  4       V P                  V\        P                  4       \        . RO4      pVP
                  P                  4       w  r#pV P                  V\        P                  4       V P                  V\        P                  4       V P                  V\        P                  4       VP
                  p\        VR7      pV P                  VP                  4       VP                  4       4       \        VRR7      pV P                  VP                  4       VP                  4       4       V P                  VP                  4       \        . RORR7      4       V P                  \        \        VRR4       V P                  \        \         RR7       R# )	ztest constructorr   )rW   )rW   r   rL   rW   Nxr   r   r   )r   r   r   r   r   rW   r   r{   rO   rP   assertNotEqualr   rQ   rR   setattr)r5   cccbarW   s   &     r6   rX   $CryptContextTest.test_00_constructor1  ss    4>>4??DNNKL		'')Aa(a)a( BC		'')Aa(a)a( (v~~'78>BJJL&..*:;t4Z4@(B 	C 	)Wb(DA)\#>r8   c                   \        . RO4      pV P                  VP                  P                  4       \        P
                  4       VP                  4       pV P                  W!4       VP                  RR7      pV P                  W14       V P                  VP                  P                  4       \        P                  4       R# )ztest replace()r   r&   Nr   )	r   r{   rW   r   r   r   rm   assertIsNotr   )r5   r   cc2cc3s   &   r6   test_01_replace CryptContextTest.test_01_replaceN  s     BCbii++-t~~>jjl! jjj.! 	cjj,,.@r8   c                   \        4       pV P                  \        VP                  RRR7       V P                  \        VP                  R4       V P                  \        VP
                  RR4       \        R.4      p\        . R7      pW!n        V P                  \        VP                  RRR7       V P                  \        VP                  R4       V P                  \        VP
                  RR4       R# )ztest no handlersr   Tr   secretr   rG   N)r   rQ   rV   identifyr   verifyr   rW   )r5   r   ps   &  r6   test_02_no_handlers$CryptContextTest.test_02_no_handlers_  s     ^(BKK$G(BGGX6(BIIx@ ;-(#	(BKK$G(BGGX6(BIIx@r8   r   r   i  i  H)r   r+   r   r   r   bsdi_crypt__vary_roundssha256_crypt__max_roundssha256_crypt__min_roundssha256_crypt__default_roundsphpass__identphpass__default_roundsc                   \        R/ V P                  B pV P                  VP                  R4      4       V P	                  VP                  R4      4       V P                  VP                  R4      4       V P	                  VP                  R4      4       V P	                  VP                  R4      4       V P                  VP                  R4      4       R# )	ztest hash_needs_update() method9XXD4trGYeGJAz"$1$J8HC2RCr$HcmM.7NxB2weSvlw2FgzU0zK$5$rounds=1999$jD81UCoo.zI.UETs$Y7qSTQ6mTiU9qZB4fRr43wRgQq4V.5AAf7F97Pzxey/zK$5$rounds=2000$228SSRje04cnNCaQ$YGV4RYu.5sNiBvorQDlO0WWQjyJVGKBcJXz3OtyQ2u8zK$5$rounds=3000$fS9iazEwTKi7QPW4$VasgBC8FqlOvD7x2HhABaMXCTh9jwHclPA9j5YQdns.zK$5$rounds=3001$QlFHHifXvpFX4PLs$/0ekt7lSs/lOikSerQ0M/1porEHxYq7W/2hdFpxA3fANr>   )r   sample_policy_1r   hash_needs_updater   r5   r   s   & r6   test_12_hash_needs_update*CryptContextTest.test_12_hash_needs_update  s    1D001 	,,_=>--.RST 	,,-z{|--.{|} 	--.{|},,-z{|r8   c                   \         P                  ! RR4       \        R.4      pR/ 3RRR/3^/ 3R/ 33 F(  w  r#V P                  ! \        VP
                  V3/ VB  K*  	  \        R.4      pV P                  \        VP
                  R4       R# )z'test non-string hash values cause errorr.   z0.*needs_update.*'scheme' keyword is deprecated.*r   Nschememysql323r>   )r2   r3   r   rQ   rR   r  )r5   r   r   kwdsr   s   &    r6   test_30_nonstring_hash'CryptContextTest.test_30_nonstring_hash  s    *\] ;-(r
+./BRJD i)=)=tLtL J<()S%:%:DAr8   r>   N)r   r   phpassr   r   )r@   rA   rB   rC   r   r   r1   rX   r   r  r   r  r  r  rE   r   r   s   @r6   r   r      si     !&Q?:A"A* '&)$%')+&''+'++/%&O}&B Br8   r   c                       ] tR tRtR tRtR# )dummy_2i  r>   Nr?   r>   r8   r6   r  r    s    Dr8   r  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )LazyCryptContextTesti  r   c                    \         P                  ! V 4       \        R 4       V P                  \        R 4       \        P
                  ! RR4       \        P
                  ! RR4       R# )r  r.   z1CryptContext\(\)\.replace\(\) has been deprecatedr   N)r   r1   unload_handler_name
addCleanupr2   r3   r4   s   &r6   r1   LazyCryptContextTest.setUp  sN    t 	I&+Y7 	 T	V*ijr8   c                   V P                  \        R4      4       \        RR4       \        \	        RR.4      R.R7      pV P                  \        RR4      4       V P                  VP                  P                  R4      4       V P                  VP                  P                  4       RR.4       V P                  \        RR4      4       R# )ztest plain kwdsr  passlib.tests.test_contextr   )r+   TN)
r   has_crypt_handlerr   r   iterr   rW   r   rO   r   r  s   & r6   test_kwd_constructor)LazyCryptContextTest.test_kwd_constructor  s    *956#I/KLdI{#;<+W*9d;<		77DE**,y+.FG))T:;r8   c                  a  S P                  \        R4      4       \        RR4       RV 3R llp\        VRR7      pS P                  \        RR4      4       S P	                  VP
                  P                  R4      4       S P                  VP
                  P                  4       RR.4       S P	                  \        RR4      4       R# )	z0test create_policy() hook, returning CryptPolicyr  r#  c                 X   < SP                  V 4       \        \        R R.4      R.R7      # )r  r   rK   )r   r   r%  )flagr5   s   &r6   create_policyELazyCryptContextTest.test_callable_constructor.<locals>.create_policy  s*    OOD!tY,D'ES^R_``r8   T)r+  r*  r   N)F)	r   r$  r   r   r   rW   r   rO   r   )r5   r+  r   s   f  r6   test_callable_constructor.LazyCryptContextTest.test_callable_constructor  s    *956#I/KL	a ME*9d;<		77DE**,y+.FG))T:;r8   r>   N)
r@   rA   rB   rC   r   r1   r&  r-  rE   r   r   s   @r6   r  r    s      *
k<< <r8   r  )'r   
__future__r   loggingr   r   r2   pkg_resourcesr   ImportErrorpasslibr   passlib.contextr   r   r   passlib.utilsr	   r
   passlib.utils.handlersutilshandlersrS   passlib.tests.utilsr   r   passlib.registryr   r   r$  r   r  r@   logr   r   rT   r  r  r>   r8   r6   <module>r<     s    &  	 /  G G . # # 2 
 
r(h r(vJBx JBfb -<8 -<G  s   B 	BB