
    K}bg2#                    0   d Z ddlmZ ddlmZ erddlmZ nddlmZ ddlZddl	m
Z
 ddlZ ej        e          ZddlZddlZddlmZ ddlmZmZ dd	lmZmZ dd
lmZmZ ddlmZmZmZmZm Z m!Z! ddl"m#c m$Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z.m/Z0m1Z2m3Z3 ej4        5                    ej4        6                    e7                    Z8d Z9 G d de'          Z:ddl;Z;ddl<Z< G d de%j=                  Z> G d de%j=                  Z? G d de'          Z@dS )ztests for passlib.context    )with_statement)PY3)NoSectionErrorN)partial)hash)CryptContextLazyCryptContext)PasslibConfigWarningPasslibHashWarning)tick
to_unicode)irangeuunicodestr_to_uasciiPY2PY26)TestCaseset_fileTICK_RESOLUTION
quicksleep	time_callhandler_derived_from)register_crypt_handler_path_has_crypt_handler_unload_handler_nameget_crypt_handlerc                     |                                  }|D ]}|                    |           |r|                    |           |S N)copyupdate)firstargskwdstargetargs        m/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/passlib/tests/test_context.pymerge_dictsr(   &   sR    ZZ\\F  c dM    c                       e Zd ZdZg dZd eD             Z eedddddd	
          Z eee          Z	 e
d          Z e
d          Zej                            ed          Ze                     e
d           e
d                    Zej                            ed          Ze                     e
d           e
d                                        d          Zej                            ed          Z	  edddd          ZdZ eee          Z ed          Z eee          Z eg dd gd!d"d#d$d%d&d%d'd()          Z fd*Zd+ Z d, Z!d- Z"d. Z#d/ Z$d0 Z%d1 Z&d2 Z'd3 Z(d4 Z)d5 Z*d6 Z+d7 Z,dUd9Z-d: Z.d; Z/d< Z0d= Z1d> Z2d? Z3d8i fd8d@d ifdAi fdBi fgZ4dC Z5dD Z6dE Z7dF Z8dVdGZ9dH Z:dI Z;dJ Z<dK Z=dL Z>dM Z?dN Z@dO ZAdP ZBdQ ZCdR ZDdS ZEdT ZF xZGS )WCryptContextTestr   )	des_crypt	md5_crypt
bsdi_cryptsha512_cryptc                 ,    g | ]}t          |          S  )r   ).0names     r'   
<listcomp>zCryptContextTest.<listcomp>?   s!    NNNT*400NNNr)   r-   皙?i1u  ia  iP  @  )schemesdefaultall__vary_roundsbsdi_crypt__max_roundsbsdi_crypt__default_roundssha512_crypt__max_roundssha512_crypt__min_roundsr7   a  [passlib]
schemes = des_crypt, md5_crypt, bsdi_crypt, sha512_crypt
default = md5_crypt
; this is using %...
all__vary_rounds = 10%%
bsdi_crypt__default_rounds = 25001
bsdi_crypt__max_rounds = 30001
sha512_crypt__max_rounds = 50000
sha512_crypt__min_rounds = 40000
z[passlib]
schemes = des_crypt, md5_crypt, bsdi_crypt, sha512_crypt
default = md5_crypt
all__vary_rounds = 0.1
bsdi_crypt__default_rounds = 25001
bsdi_crypt__max_rounds = 30001
sha512_crypt__max_rounds = 50000
sha512_crypt__min_rounds = 40000

zsample1.cfg
z
zsample1b.cfg	[passlib]z
[mypolicy]utf-16zsample1c.cfgFiIq  i  iy  iȯ  )bsdi_crypt__min_roundsr:   r;   r=   z[passlib]
bsdi_crypt__min_rounds = 29001
bsdi_crypt__max_rounds = 35001
bsdi_crypt__default_rounds = 31001
sha512_crypt__min_rounds = 45000
r/   r8   )r,   r-   phpassr.   sha256_cryptr,   rE         r       H   )r7   
deprecatedr8   r:   r;   bsdi_crypt__vary_roundssha256_crypt__max_roundssha256_crypt__min_roundssha256_crypt__default_roundsphpass__identphpass__default_roundsc                     t          t          |                                            t          j        dd           t          j        dd           d S )Nignorez The 'all' scheme is deprecated.*z4.*'scheme' keyword is deprecated as of Passlib 1.7.*)superr+   setUpwarningsfilterwarnings)self	__class__s    r'   rV   zCryptContextTest.setUp   sN    %%++---*LMMM*`aaaaar)   c                    t                      }|                     |                                i            t          di | j        }|                     |                                | j                   t          di | j        }|                     |                                | j                   t          di | j        }|                     |                                | j                   t          di | j        }|                     |                                | j                   t          t          d          g          }|                     |                                d           dS )ztest class constructorrE   r>   )rE   Nr1   )	r   assertEqualto_dictsample_1_dictsample_1_resolved_dictsample_2_dictsample_3_dictr   r7   rY   ctxs     r'   test_01_constructorz$CryptContextTest.test_01_constructor   sQ    nn+++ 00T/00(:;;; 99T899(:;;; 00T/00(:;;; 00T/00(:;;; An$5$5#6777(9:::::r)   c                    t          j        | j                  }|                     |                                | j                   t          j        | j                  }|                     |                                | j                   t          j        | j                            d                    }|                     |                                | j                   t          j        | j                  }|                     |                                | j                   t          j        | j	        dd          }|                     |                                | j                   | 
                    t          t           j        d           | 
                    t          t           j        | j        d           dS )ztest from_string() constructorutf-8mypolicyrA   sectionencodingNfakesectionri   )r   from_stringsample_1_unicoder\   r]   r^   sample_1_unnormalizedencodesample_1b_unicodesample_1c_bytesassertRaises	TypeErrorr   rb   s     r'   test_02_from_stringz$CryptContextTest.test_02_from_string   s    &t'<==(:;;; &t'ABB(:;;; &t'<'C'CG'L'LMM(:;;; &t'=>>(:;;; &t';Z.68 8 8(:;;; 	)\%=tDDD 	.,*B/ 	 	H 	H 	H 	H 	Hr)   c                    t           j                            | j                  st	          d| j        z            t          j        | j                  }|                     |                                | j	                   t          j        | j
                  }|                     |                                | j	                   t          j        | j        dd          }|                     |                                | j	                   |                     t          t
          j        t           j                            t          d                     |                     t           t
          j        | j        d           dS )	ztest from_path() constructorzcan't find data file: %rrg   rA   rh   zsample1xxx.cfgrk   rl   N)ospathexistssample_1_pathRuntimeErrorr   	from_pathr\   r]   r^   sample_1b_pathsample_1c_pathrs   EnvironmentErrorjoinherer   rb   s     r'   test_03_from_pathz"CryptContextTest.test_03_from_path   s[    w~~d011 	P9D<NNOOO $T%788(:;;; $T%899(:;;; $T%8*.68 8 8(:;;; 	*L,B',,t-=>>	@ 	@ 	@ 	.,*@,m 	 	E 	E 	E 	E 	Er)   c                 6   t          di | j        } |j        di | j        }|                     |                                | j                   |                     |                                | j                    |j        di | j        }|                     |                                | j                   |                     |                                | j                    |j        di | j        }|                     |                                | j                   |                                }| 	                    ||           |                     |                                | j                   |                     |                                | j                    |j
        di | j         |                     |                                | j                   |                     |                                | j                   dS )ztest copy() methodNr1   )r   r^   r    r`   r\   r]   sample_12_dictra   sample_123_dictassertIsNotr!   )rY   cc1cc2cc2bcc3cc4s         r'   test_04_copyzCryptContextTest.test_04_copy  s   00T/00 ch,,+,,(:;;;(;<<< sx--$,--(:;;;)<=== ch,,+,,(<=== hhjjc"""(:;;;(:;;; 	
((T'((((:;;;(;<<<<<r)   c                 n    t          di | j        }|                     t          |          d           dS )ztest repr()z!^<CryptContext at 0x-?[0-9a-f]+>$Nr1   )r   r^   assertRegexrepr)rY   r   s     r'   test_09_reprzCryptContextTest.test_09_repr+  s;    00T/00c$GHHHHHr)   c                    t                      }|                    | j                   |                     |                                | j                   |                    | j                   |                     |                                | j                   |                    | j                            d                     |                     |                                | j                   |                     t          |j        d           t          di | j        }|                    i d           |                     |                                | j                   t                      }|                    | j                   |                    | j	                   |                     |                                | j	                   dS )z test load() / load_path() methodrf   NT)r!   r1   )
r   loadr^   r\   r]   rn   rp   rs   rt   r`   rb   s     r'   test_10_loadzCryptContextTest.test_10_load4  s    nn 	#$$$(:;;; 	&'''(:;;; 	&--g66777(:;;; 	)SXt444 00T/00D!!!(:;;; nn#$$$#$$$(:;;;;;r)   c                    t          ddgdd          }|                                }|                     t          |j        d           |                     |                                |           |                     t          |j        d           |                     |                                |           |                     t          |j        d	
           |                     |                                |           dS )z$test load() errors restore old stater,   rE   i  r5   )rP   r9   T)too__many__key__parts)fake_context_optioni'  rO   N)r   	to_stringrs   rt   r!   r\   KeyError
ValueError)rY   ccresults      r'   test_11_load_rollbackz&CryptContextTest.test_11_load_rollback_  s     ;7)-     	)RYdKKK000
 	(BI4HHH000 	*bi%PPP00000r)   c                    t          di | j        }|                                 |                     |                                | j                   t          di | j        } |j        di | j         |                     |                                | j                    |j        di | j         |                     |                                | j                   t          di | j        }|                    | j                   |                     |                                | j                   t          di | j        }|                    | j	                   |                     |                                | j                   | 
                    t          |j        i i            | 
                    t          |j        i dg           | 
                    t          |j        d           dS )ztest update() methodr,   r>   Nr1   )r   r^   r!   r\   r]   r`   r   ra   r   sample_2_unicoders   rt   rb   s     r'   test_12_updatezCryptContextTest.test_12_updatew  s    00T/00

(:;;; 00T/00
((T'((((;<<< 	
((T'((((<=== 00T/00

4%&&&(;<<< 00T/00

4()))(;<<< 	)SZR888)SZk]KKK 	)SZ66666r)   c                    d }|                      t          t          d           |                      t          t          d           |                      t          t          d           |                      t          t          d           |                      t          t          d           |                      t          t          d	
            | j         t          |fi ddi t          d&i ddd}|                     |                    d          d           t          d          }|                      |d          |           |                      |d          |           |                      |d          |           |                      |d&i ddi|           |                      |d&i ddi|           t          d          }|                      |d          |           |                      |d&i ddi|           t          d          }|                      |d          |           |                      |d          |           |                      |d&i ddi|           |                      |d&i ddi|           t          d          }|                      |d          |           |                      |d&i ddi|           t          ddgd           }|                      t          |j        d!           |                      t          t          dgd"#           |                      t          t          dgd"$           d%S )'ztest basic option parsingc                  >    t          di |                                 S )Nr1   r   r]   )r$   s    r'   parsez/CryptContextTest.test_20_options.<locals>.parse  s"    ''$''//111r)   r5   )__x)default__scheme__)__option)default____option)__scheme__optioni0u  )!category__scheme__option__invalidzadmin.context__schemesr-   md5_crypt,des_cryptr,   )r7   zadmin.context__defaultadminrC   )context__default)default__context__defaultzcontext.defaultzdefault.context.defaultadmin__context__defaultzadmin.context.defaultr9   )default__all__vary_roundszall.vary_roundszdefault.all.vary_rounds)admin__all__vary_roundszadmin.all.vary_roundsrD   P)rQ   )md5_crypt__identxx)r7   des_crypt__salt)r7   	all__saltNr1   )rs   rt   r   r   r\   default_schemedictr    )rY   r   rc   r   s       r'   test_20_optionsz CryptContextTest.test_20_options  s-   	2 	2 	2 	)\c:::)\SIII 	)\C@@@)\SIII 	)\CHHH 	)\>C 	 	E 	E 	E
 	(E 	D 	D5kB	D 	D 	D E E(=7BD D E E++G44kBBB k***{333V<<<<<<fEEEEEEvNNNAA"3K!@AA6JJJII";K!HII6RRR k:::{CCCVLLLGG"9+!FGGPPP s+++444f======vFFF99"3C!8996BBBAA";C!@AA6JJJ c222s;;;VDDD??"9#!>??HHH Hk2#FFF(CHsCCC 	(L;-BF 	 	H 	H 	H(L;-<@ 	 	B 	B 	B 	B 	Br)   c                    t          d          }|                     |                                d           t          ddg          }|                     |                                d           t          d          }|                     |                                d           t          t          j        t          j        g          }|                     |                                d           |                     t          t           t          j	        g            G d d	t          j	                  }|                     t          t           |g            G d
 dt          j	                  }|                     t          t           ||g           |                     t          t           dg           dS )z%test 'schemes' context option parsingNr>   r1   r,   r-   )r,   r-   z des_crypt, md5_crypt, c                       e Zd ZdZdS )2CryptContextTest.test_21_schemes.<locals>.namelessN__name__
__module____qualname__r3   r1   r)   r'   namelessr     s        DDDr)   r   c                       e Zd ZdZdS )1CryptContextTest.test_21_schemes.<locals>.dummy_1dummy_1Nr   r1   r)   r'   r   r     s        DDDr)   r   )admin__context__schemes)r   r\   r7   r   r,   r-   rs   rt   uhStaticHandlerr   r   )rY   r   r   r   s       r'   test_21_schemesz CryptContextTest.test_21_schemes  s    $'''r*** ;"<==='ABBB ";<<<'ABBB 4>4>"BCCC'ABBB 	)\B<L;MNNN	 	 	 	 	r' 	 	 	*lXJGGG	 	 	 	 	b& 	 	 	(L7G:LMMM 	(L3>- 	 	A 	A 	A 	A 	Ar)   c                 ,   dd}t          dg          }|                    ddg           |                      ||          dg           t          dgddg          }|                      ||          dg           |                     t          t           t
          j        gddg           t          dg d	          }|                      ||          ddg           |                     t          t           dgdg
           |                     t          t           dgdg
           |                     t          t           ddgddg           |                     t          t           ddgdd           |                     t          t           ddgdd           |                     t          t           ddgdd           |                     t          t           ddgdd           t          ddgddg            |                     t          t           d           t          dgddgdg          }|                      ||          dg           |                      ||d          dg           |                      ||d          dg           t          dgddgg           }|                      ||          dg           |                      ||d          dg           |                      ||d          g            dS )z(test 'deprecated' context option parsingNc                 H      fd                                  D             S )Nc                 J    g | ]}                     |          j        | S r1   handlerrL   )r2   r3   categoryrc   s     r'   r4   zGCryptContextTest.test_22_deprecated.<locals>.getdep.<locals>.<listcomp>  s>     ? ? ?T{{422=?D ? ? ?r)   r>   rc   r   s   ``r'   getdepz3CryptContextTest.test_22_deprecated.<locals>.getdep  s;    ? ? ? ? ?S[[]] ? ? ? ?r)   r-   rL   r,   r>   )rL   r7   r   )r-   r,   rE   r7   rL   )r7   admin__context__deprecated)r7   r8   rL   )r7   r8   r   )r7   r   rL   )r7   r   r   )r7   rL   r   r   {   )rL   r7   r   userr   r   )	r   r!   r\   rs   rt   r   r-   r   r   )rY   r   r   s      r'   test_22_deprecatedz#CryptContextTest.test_22_deprecated  s   	? 	? 	? 	?
 k]333
		;4	555[M222 k][+<VWWWk]333 	)\t~>N#."< 	 	> 	> 	> %:DnDnDnoook;%?@@@ 	(L;->I] 	 	L 	L 	L 	*l#.-&1] 	 	4 	4 	4 	*l#."<6A;5O 	 	Q 	Q 	Q 	*l#."<"-%0 	 	2 	2 	2 	*l#."<"-5@ 	 	B 	B 	B 	*l#."<2=%0 	 	2 	2 	2 	*l#."<2=5@ 	 	B 	B 	B 	#."<%02=57		9 	9 	9 	9 	)\cBBB k]#."<6A]   	k]333F++k];;;G,,{m<<< k]#."<57   	k]333F++k];;;G,,b11111r)   c                 &   |                      t          d                                          t          d                     t          dddg          }|                      |                                d           t          t
          j        ddg          }|                      |                                d           t          ddg          }|                      |                                d           |                    d           |                      |                                d           |                     t          t          dgd           |                     t          t          d           t          dddgd	          }|                      |                                d           |                      |                    d
          d           |                      |                    d          d           dS )z%test 'default' context option parsingr-   rC   r,   )r8   r7   r>   r   )r7   r8      )r8   r7   r   r   r   N)r\   r   r]   r   r   r   r-   r!   rs   r   rt   rb   s     r'   test_23_defaultz CryptContextTest.test_23_defaulth  s    	k:::BBDDk222	4 	4 	4 ;k8RSSS++--{;;; 4>K;UVVV++--{;;; K#=>>>++--{;;;

k
***++--{;;; 	(L;-:E 	 	G 	G 	G 	)\1=== ;$/#=3>@ @ @ 	++--{;;;++F33[AAA++G44kBBBBBr)   c                 B   d }|                       |d          d           |                       |d          d           |                       |d          d           |                       |d          d           |                       |d          d           dS )z&test 'vary_rounds' hash option parsingc                 R    t          |                                           d         S )Nr   r9   r   )vs    r'   r   z3CryptContextTest.test_24_vary_rounds.<locals>.parse  s%    333;;==>PQQr)   r5   z0.1z10%i  1000N)r\   )rY   r   s     r'   test_24_vary_roundsz$CryptContextTest.test_24_vary_rounds  s    	R 	R 	R 	sS)))us+++ 	us+++ 	td+++v-----r)   Nc                 P    |                      t          ||          |           d S )N)msg)
assertTruer   )rY   r   baser   s       r'   assertHandlerDerivedFromz)CryptContextTest.assertHandlerDerivedFrom  s)    ,Wd;;EEEEEr)   c                    t                      }|                     |                                d           |                     |                    d          d           t          di | j        }|                     |                                t	          | j                             |                     |                    dd          t	          | j                             t          |                    d          | j                  D ](\  }}|                     t          ||                     )t          di | j
        }|                     |                                d           dS )ztest schemes() methodr1   Tresolver   unconfiguredN)r   r\   r7   r^   tuplesample_1_schemessample_1_handlerszipr   r   r`   )rY   rc   r   corrects       r'   test_30_schemesz CryptContextTest.test_30_schemes  sM   
 nn+++T22B777 00T/00d.C(D(DEEETEEuTMcGdGdeee"3;;t;#<#<d>TUU 	C 	COFGOO0AABBBB 00T/00+++++r)   c                    t                      }|                     t          |j                   t          di | j        }|                     |                                d           |                     |                    dd          t          j                   |                     |                    d          t          j                   t          di | j	        }|                     t          |j                   t          | j
                  }|                     |                                d           dS )	ztest default_scheme() methodr-   Tr   r   r>   r,   Nr1   )r   rs   r   r   r^   r\   r   r-   r   r`   r   rb   s     r'   test_31_default_schemez'CryptContextTest.test_31_default_scheme  s"   
 nn(C$6777 00T/00++--{;;;++Dt+LLdn]]]%%c&8&8&8&F&FWWW 00T/00(C$6777 4#8999++--{;;;;;r)   c                 P   t                      }|                     t          |j                   |                     t          |j        d           t          di | j        }|                     |                    d          t          j                   |                     |                                t          j                   |                     |                    dd          t          j	                   |                     |                    d          t          j	                   |                     t          |j        d           t          dd          }|                     |                    d          t          j
                   |                     |                                t          j
                   |                     |                    dd	          t          j
                   |                     |                    d
          t          j
                   |                     |                    dd	          t          j                   |                     |                    d
          t          j
                   t          r|                     |                    t          d          d	          t          j
                   |                     |                    t          d          d	          t          j                   dS dS )ztest handler() methodr-   T)r   r,   mysql323sha256_crypt,md5_cryptr   staff)r   r   r   r   Nr1   )r   rs   r   r   r^   r\   r   r-   r   r,   rE   r   r   rb   s     r'   test_32_handlerz CryptContextTest.test_32_handler  s    nn(CK000(CK=== 00T/00$77HHH%%ckkmmT^DDD 	[tDDdnUUU%%ckk+&>&>OOO 	(CK<<< 3[YYY$779JKKK%%ckkmmT5FGGGgDII4K\]]]%%ckk7k&C&CTEVWWWgDII4>ZZZ%%ckk7k&C&CTEVWWW  	bS[[!G**4[PPRVRcdddS[[!G**4[PPRVR`aaaaa	b 	br)   c                    dd}t          dg dddgddd	dd
gddd
  
        }|                     |j        j        d           |                      ||d          t	          ddd	                     |                      ||dd          t	          ddd	                     |                      ||dd          t	          dd                     |                      ||d          t	          dd                     |                      ||dd          t	          dd                     |                      ||dd          t	          dd                     |                      ||d
          t	          d                     |                      ||d
d          t	          d                     |                      ||d
d          t	          dd                     dS )z*test internal _get_record_options() methodNc                 D    | j                             ||          d         S )Nr   )_config_get_record_options_with_flag)rc   schemer   s      r'   optionsz1CryptContextTest.test_33_options.<locals>.options  s    ;<<VXNNqQQr)   T)r/   r,   r.   r/   r,   r5   皙?i N  r.   皙?g333333?r6   )
truncate_errorr7   rL   r9   rM   r<   r   r   admin__bsdi_crypt__vary_roundsadmin__sha512_crypt__max_rounds)r   )rL   vary_rounds
max_roundsr   r   )r  r  )rL   r  )r  )r  rL   r   )r   r\   r   
categoriesr   )rY   r   r   s      r'   test_33_optionsz CryptContextTest.test_33_options  s   	R 	R 	R 	R
 BBB(+6"$'',+6)F&*+..3
 
 
 	/<<< 	n55t8
 8
 8
 	 	 	 	nf==t@
 @
 @
 	 	 	 	ng>>A
 A
 A
 	 	 	 	k22D5
 5
 5
 	 	 	
 	k6::D=
 =
 =
 	 	 	
 	k7;;T>
 >
 >
 	 	 	 	l33T6
 6
 6
 	 	 	 	lF;;T>
 >
 >
 	 	 	 	lG<<d?
 ?
 ?
 	 	 	 	 	r)   c                     t          di | j        }|                     |                                | j                   |                     |                    d          | j                   dS )ztest to_dict() methodTr   Nr1   )r   r^   r\   r]   r_   rb   s     r'   test_34_to_dictz CryptContextTest.test_34_to_dictC  sh     00T/00(:;;;T22D4OPPPPPr)   c                    t          d
i | j        }|                                }t          s|                     || j                   t          j        |          }|                     |                                | j                   |                    d          }|                     ||                    dd                     ddl	m
} t          |dg          }|                                }|                     |d           d	S )ztest to_string() methodzpassword-securityrl   r@   z[password-security]r   )UnsaltedHashr-   zM# NOTE: the 'unsalted_test_hash' handler\(s\) are not registered with PasslibNr1   )r   r^   r   r   r\   rn   rm   r]   replace!passlib.tests.test_utils_handlersr  r   )rY   rc   dumpctx2otherr  ctx3s          r'   test_35_to_stringz"CryptContextTest.test_35_to_stringJ  s    00T/00}}  	:T4#8999 '--);<<< &9::[9N O OPPP 	CBBBBB\;788~~  C 	D 	D 	D 	D 	Dr)   r   r   r1   c                    t           j        t           j        t           j        g}t	          |d          }|D ]}|                     d|j                  }|                     |                    |          |j                   |                     |                    |dd          |           |                     |                    |d          |           | 	                    |
                    d|                     |                     |
                    d|                     |                     d          }|                     |                    |          d	           |                    d
|                                          }|                     |                    |          d	           |                    d
|                                d	          }|                     |                    |          d	           |                     t          |j        d
|                                d           dS )z-test basic hash/identify/verify functionality   r;   testr   Tr   r   notestr-   secretr,   N)r   r-   r,   r.   r   r3   r\   identifyr   r   verifyassertFalsegenhash	genconfigrs   r   )rY   handlersr   crypths        r'   test_40_basiczCryptContextTest.test_40_basicq  s   NDNDOD(qAAA  	5 	5Euz22AR[[^^UZ888R[[Dt[LLeTTT))"++a+*F*FNNNOOBIIfa00111RYYx334444 GGFOOQ555 JJx00Q555JJxJDDQ555*bj(BLLNNS^_____r)   c                    t          ddgddd          }|                     |                                                    d                     |                     |                    d                              d	                     |                     |                    dd
                              d                     |                     |                    dd                              d	                     |                     |                    dddd          d           t
          r|                    d          }|                     |                    t          d
                                        d                     |                     |                    t          d                                        d	                     |                     t          t                      j                   |                     t          t                      j        d           |                     t          |j        d           |                     t          |j        dd           |                     t          |j        d           |                     t          |j        d           dS )ztest genconfig() methodr-   rD   rJ   rK   r   )r7   rQ   rR   admin__phpass__identz$1$r  z$H$5r   )r   r   z$P$5r   ........   )r   saltroundsidentz"$P$6........22zGEuacuPOqEpYPDeR0R/rC   r   faker   N)r   r   r  
startswithr\   r   r    r   rs   r   rt   rY   r   c2s      r'   test_41_genconfigz"CryptContextTest.test_41_genconfig  s_   ;"9(+12/2   	11%88999 	H55@@HHIII 	HwGGRRSYZZ[[[HwGGRRSYZZ[[[ 	LLuQcLJJ0	 	 	  	R**BOOBLL!G**L==HHPPQQQOOBLL!G**L==HHPPQQQ 	(LNN$<===(LNN$<[QQQ 	(BL@@@)R\!gNNN)R\!<<< 	)R\A>>>>>r)   c                    t          dg          }|                    d          }| j        D ] \  }} | j        t          |j        ||fi | !t          dg          }| j        D ]#\  }}| | j        t          |j        d|fi | $t          dg          }|                     t          |j        dd           |                     t          t                      j        dd           |                     t          |j        d|d           |                     t          |j        d|d	           |                     t          |j        d|d	
           dS )ztest genhash() methodr,   stubNr  r   r   r+  r  r   r   )r   r   nonstring_vectorsrs   rt   r  r   r  )rY   r   r   r  r$   configs         r'   test_42_genhashz CryptContextTest.test_42_genhash  sv    ;-((wwv 2 	K 	KLFDDiVTJJTJJJJ ;-(( 2 	O 	OLFD| DiXvNNNNNN :,'')RZ>>> 	(LNN$:HfMMM 	(BJ$vNNN)RZ4JJJ 	)R\8TANNNNNr)   c                    t          di | j        }|                    d          }|                      |j        d                     |                     |                    d|                     |                     |                    d|                     |                     t          |j	        d           t          dg          }| j
        D ]\  }} | j        t          |j        |fi |  |                     t          t                      j        d           |                     t          |j        dd	           d
S )ztest hash() methodpasswordz$5$rounds=3000$	passwordxi  rP   r,   r  r   r   Nr1   )r   sample_4_dictr   r   r,  r  r  rs   r   r    r2  rt   r   )rY   r   r   r  r$   s        r'   test_43_hashzCryptContextTest.test_43_hash  sI    //D.//wwz""(9::;;;		*d33444;55666 	*bg7; 	 	= 	= 	= ;-(( 2 	B 	BLFDDi&AADAAAA 	(LNN$7BBB 	)RWhCCCCCr)   c           	         t          di | j        }|                     dg          5  |                     |                    ddd          d           ddd           n# 1 swxY w Y   |                     dg          5  |                     |                    dddd	          d
           ddd           n# 1 swxY w Y   |                     dg          5  |                     |                    ddd          d           ddd           n# 1 swxY w Y   |                     dg          5  |                     |                    ddd          d           ddd           n# 1 swxY w Y   |                     t          |j        dd           |                     t          |j        dd           dS )z;test hash() method -- legacy 'scheme' and settings keywords"passing settings to.*is deprecatedr6  rD   r&  )r   r(  z"$H$5........De04R5Egz0aq8Tf.1eVhY/Nr   )r   r(  r*  z"$P$5........De04R5Egz0aq8Tf.1eVhY/  naclr)  r(  z?$5$rounds=1999$nacl$nmfwJIxqj0csloAAvSER0B8LU0ERCAbhmMug4Twl609  z?$5$rounds=2001$nacl$8PdeoPL4aXQnJ0woHhqgIw/efyfCKC2WHneOpnvF.31r  r+  r  r   r1   )r   r9  assertWarningListr\   r   rs   r   rt   )rY   use_16_legacyr   s      r'   test_43_hash_legacyz$CryptContextTest.test_43_hash_legacy  s   //D.//  ##%I$JKK 	 	
8%@@4  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 ##%I$JKK 	 	
8%sKK4  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ##%I$JKK 	 	
4f==Q  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ##%I$JKK 	 	
4f==Q  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	(BGXfEEE)RWhqAAAAAsG   -A!!A%(A%.B<<C C -DDD7-E00E47E4c                 0   g d}t          |d          }|                     |                    d          d           |                     t          |j        dd           t          dg          }| j        D ]\  }} | j        t          |j        |fi |  t                      }|                     |                    d	          d           |                     t          |j        d	d           |                     t          |j        dd
           dS )ztest identify() border casesr-   r,   r.   r  r  z$9$232323123$1287319827NT)requiredr,   r   r   r   )	r   r\   r  rs   r   r2  rt   assertIsr   )rY   r   r   r   r$   s        r'   test_44_identifyz!CryptContextTest.test_44_identify.  s#   ;;;(qAAA 	%>??FFF*bk3LW[\\\ ;-((0 	D 	DJD$DidCCdCCCC ^^bkk&))4000(BK$GGG 	)R[$CCCCCr)   c                    g d}t          |d          }t          j                            d          }|                     |                    d|                     |                     |                    d|                      |                     |                    d|d                     |                     |                    d|d                      |                     t          |j        d|d           |                     t          |j        d	d
           t          dg          }|                    d	          x}}| j        D ] \  }} | j        t          |j        ||fi | !| 	                    |                    |d                     t          dg          }| j        D ]#\  }}| | j        t          |j        d|fi | $|                     t          t                      j        dd           |                     t          |j        d|d           |                     t          |j        d|d           |                     t          |j        d|d           dS )ztest verify() scheme kwdrE  r  r  r  r  r-   r  r.   r1  z$6$232323123$1287319827r,   Nr  r   r+  r   r   )r   r   r-   r   r  rs   r   r2  rt   r  r   )rY   r   r   r"  refhashr  r$   s          r'   test_45_verifyzCryptContextTest.test_45_verifyH  sv   ;;;(qAAAN'' 			&!,,---BIIh222333 			&!K	@@AAABIIh+IFFFGGG 	*bi<PPP 	*bi9RSSS ;-((ggfoo%G 2 	G 	GLFDDiFAFFFFFF 	6400111 ;-((- 	I 	IGAtyDiHaHH4HHHH 	(LNN$98VLLL 	(BIxPPP)RY'!LLL 	)RY'ANNNNNr)   c                    t          di | j        }|                     |                    d                     |                     |                    d                     |                     |                    d                     |                     |                    d                     |                     |                    d                     |                     |                    d                     g  G fddt
          j                  }t          |g          }|                    d	          x}}|                     |                    |                     |                     |d
fg           d
d
= |                     |                    |d                     |                     |dfg           d
d
= |                     |                    |d                     |                     |dfg           d
d
= t          dg          }| j	        D ]\  }} | j
        t          |j        |fi |  | 
                    t          t                      j        d           | 
                    t          |j        |d           | 
                    t          |j        |d           | 
                    t          |j        |d           d
S )ztest 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/2hdFpxA3fAc                   :    e Zd ZdZdZed fd	            Zd ZdS )4CryptContextTest.test_46_needs_update.<locals>.dummydummy@Nc                 >                         ||f           |dk    S )Nnu)append)clsr   r  check_states      r'   needs_updatezACryptContextTest.test_46_needs_update.<locals>.dummy.needs_update  s%    ""D&>222~%r)   c                     ddl m} t          |t                    r|                    d          }t           ||                                                    S )Nr   )md5rf   )hashlibrY  
isinstancer   rp   r   	hexdigest)rY   r  rY  s      r'   _calc_checksumzCCryptContextTest.test_46_needs_update.<locals>.dummy._calc_checksum  sY    ''''''fg.. 4#]]733F$SS[[%:%:%<%<===r)   r   )r   r   r   r3   _hash_prefixclassmethodrW  r]  )rV  s   r'   rP  rO    sV        DL& & & & & [&> > > > >r)   rP  r  Nbob)r  rS  r,   r   r+  r  r   r   r1   )r   r9  r   rW  r  r   r   r   r\   r2  rs   rt   r   )rY   r   rP  rc   r   rJ  r$   rV  s          @r'   test_46_needs_updatez%CryptContextTest.test_46_needs_update{  s   //D.// 	88999)MNNOOO 	(uvvwww)vwwxxx 	)vwwxxx(uvvwww
 	> 	> 	> 	> 	> 	> 	>B$ 	> 	> 	>  E7##F+++w))$//000T{m444N 	))$u)==>>>U|n555N 	((d(;;<<<T{m444N ;-((0 	H 	HJD$Di$GG$GGGG 	(LNN$?HHH 	(BOWVLLL)R_gaHHH 	)R_gJJJJJr)   c                    t          di | j        }|                    d                              d          }|                    d                              d          }|                    d|          \  }}|                     |           |                     |d           |                    d|          \  }}|                     |           |                     |d           |                    d|          \  }}|                     |           |                     |                    |          d           |                    d|          \  }}|                     |           |                     |d           t          dg          }|                    d          x}}| j	        D ] \  }}	 | j
        t          |j        ||fi |	 !|                     |                    |d          d           t          dg          }| j	        D ]#\  }}	| | j
        t          |j        d|fi |	 $| 
                    t          t                      j        dd	           | 
                    t          |j        d|d
           | 
                    t          |j        d|d           | 
                    t          |j        d|d           dS )ztest verify_and_update()r,   r6  rE   	wrongpassNr1  FNr  r   r+  r  r   r   r1   )r   r9  r   r   verify_and_updater  rG  r   r  r2  rs   rt   r\   r   )
rY   r   h1h2oknew_hashr   rJ  r  r$   s
             r'   test_47_verify_and_updatez*CryptContextTest.test_47_verify_and_update  s   //D.// ZZ$$))*55ZZ'',,Z88 ++K<<Hh%%% ++K<<Hh%%% ++J;;HH--~>>> ++J;;Hh%%% ;-(((w 2 	U 	ULFDDi)=vtTTtTTTT 	--fd;;]KKK ;-((0 	W 	WJD$|Di)=xVVQUVVVV 	(LNN$DhPVWWW 	(B$8(GTZ[[[)R%98WUVWWW 	)R%98WWXYYYYYr)   c                 H
   ddl m}m}m} |                    d          }|                    dd          }|                    dd          }t          ||g          }|                     |j        t                                 | 	                    |
                    |                    d                    d           | 	                    |                    d|                     |                     |                    d|          d           |                     d	g          5  |                     t          |j        dd           d
d
d
           n# 1 swxY w Y   |                     t          |j        d|d           |                     t          |j        d|d           t          ||g          }|                     |j        t          dg                     | 	                    |
                    |                    d                    d           | 	                    |                    d|                     |                     |                    d|          d           | 	                    |
                    |                    dd                    d           | 	                    |                    d|d                     |                     |                    d|d          d           |                     d	g          5  |                     t          |j        dd           d
d
d
           n# 1 swxY w Y   |                     t          |j        d|d           |                     t          |j        d|d           t          ||gd          }	|                     |	j        t          dg                     |                     t          |	j        d           |                     t          |	j        d|           |                     t          |	j        d|           |                     |	                    dd          |           | 	                    |	                    d|d                     |                     |	                    d|d          d           |                     |	                    d|d          d           |                     |	                    d|d          d|f           d
S )zLhash(), verify(), and verify_and_update() -- discard unused context keywordsr   )r,   r-   postgres_md5r1  root)r   r   r,   )TNr<  Nr   )badkwdautor   rd  T)passlib.hashr,   r-   rl  r   r   r\   context_kwdssetr   r  r  re  rA  rs   rt   )
rY   r,   r-   rl  des_hashpg_root_hashpg_admin_hashr   r   r   s
             r'   test_48_context_kwdsz%CryptContextTest.test_48_context_kwds  sw   
 	DCCCCCCCCC>>&))#((f(==$))&w)??
 Iy122)355111 		**388F+;+;<<kJJJ

6844555..vx@@,OOO ##%I$JKK 	H 	Hi6GGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H)SZOOO)S%:FHSYZZZ
 I|455)3x==999 		**388F+;+;<<kJJJ

6844555..vx@@,OOO 		**388F8+H+HII;WWW

68&
AABBB..vxf.MM|\\\ ##%I$JKK 	J 	Ji6&III	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J)SZ&QQQ)S%:FHU[\\\
 L)4HHH)3x==999 	)SXv666)SZFFF)S%:FLQQQ 	&v66EEE

6<f
EEFFF..v|&.QQS_``` 	..v|'.RRTabbb 	..vxf.MM-	/ 	/ 	/ 	/ 	/s$   +$EE"E"$MMMc                 J   t          dgddd          }d}|                    dd          }|                     |j        d           |                     |j        d           |                     |j        d           |                     t          gdz            5  |                    d	dd	
          }ddd           n# 1 swxY w Y   |                     |	                    d          d|z              |                     g           5  |                     |	                    dd          d|z              ddd           n# 1 swxY w Y   |                     |	                    dd          d|z              |                     |	                    dd          d|z              |                     t          gdz            5  |                    t          d          d	z   dt          d          d	z             }ddd           n# 1 swxY w Y   |                     |	                    d          d|z              |                     g           5  |                     |	                    dd          d|z              ddd           n# 1 swxY w Y   |                     |	                    dd          d|z              |                     |	                    dd          d|z              |                     |	                    d          d|z              t          j        j        }|                    d|dz            }|                     |	                    d          d||fz             |                    dd          }|                     |	                    d          d|z              |                     t          |j        d            |                    d            |                    d            |                     t          |j        d            t          dg!          }|                     t          |j        dd"           |                     t          t           d#$           |                     t          t           d#%           |                     t          t           d#&           |                     t          t           d#            t          j                                        }|                     t"          t           d|$           |                     t"          t           d|%           |                     t"          t           d|&           |                     t"          t           d|            dS )'ztest rounds limitsrE   rI   rH   i	  r7   rO   rN   rP   z+...........................................N   i  )rO   rN   rP   r>  r(  z$5$rounds=1000$nacl$r=  r?  z$5$rounds=1999$nacl$z$5$rounds=2000$nacl$r@  z$5$rounds=2001$nacl$g    eA)rN   rO   rP   z$5$rounds=999999999$nacl$i  z$5$rounds=3001$nacl$z$5$rounds=3000$nacl$i  z$5$rounds=2999$nacl$z$5$rounds=2500$nacl$r   )rP   rN   z$5$rounds=%d$nacl$%sr8  r>   )rO   rN   r   r   )rN   r   )r   _get_recordr\   min_desired_roundsmax_desired_roundsdefault_roundsrA  r   r    r  intr   rE   rs   r   datetimenowrt   )rY   r   STUBcustom_handlerr.  dfbads          r'   test_50_rounds_limitsz&CryptContextTest.test_50_rounds_limitsQ  s   >"237377;   = ==:DAAA:DAAA6=== ##%7$8$:;; 	> 	>#PT9<  > >B	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	6224JT4QRRR ##B'' 	W 	WDv668NQU8UW W W	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W
 	LL6L224JT4Q	S 	S 	S 	LL6L224JT4Q	S 	S 	S ##%7$8$:;; 	G 	G#c((3,Y]9<S#  G GB	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	6224ORV4VWWW ##B'' 	W 	WDv668NQU8UW W W	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W
 	LL6L224JT4Q	S 	S 	S 	LL6L224JT4Q	S 	S 	S 	6224JT4QRRR -WW$QSUVQVWWW6224JbRVZ4WXXX WW$QUWVV6224JT4QRRR
 	*bgDQQQ
T222
T222*bgDQQQ >"2333 	*bg37 	 	9 	9 	9 	*lSQQQ*lSQQQ*lSIII*lQTUUU ##%%)\>\_```)\>\_```)\>TWXXX)\>`cdddddsH   CCC/E		EE9HHH /JJ"Jc                 V   t          dgddd          }|                     t          |j        d           |                     t          |j        d           |                     t          |j        d	           |                    d
          }|                     |                    dd          j        d
           |                     |ddd           |                    d          }|                     |                    dd          j        d
           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           dS )ztest linear vary roundsrE   i  i  rI   rx  r   -1%101%r   N0%r   r=  r@  d   z0.1%gMbP?i  i  100%      ?r   rs   r   r    r\   r{  r  assert_rounds_ranger-  s      r'   test_51_linear_vary_roundsz+CryptContextTest.test_51_linear_vary_rounds  s   >"237377;   	*bgCCC*bgFFF*bgGGG WWaW((==I1MMM  ^T4@@@WWdW++==I1MMM  ^T4@@@ WWaW((==I1MMM  ^T4@@@WWcW**==I3OOO  ^T4@@@ WWfW--==I5QQQ  ^T4@@@WWfW--==I3OOO  ^T4@@@@@r)   c                    t          dgddd          }|                     t          |j        d           |                     t          |j        d           |                     t          |j        d	           |                    d
          }|                     |                    dd          j        d
           |                     |ddd           |                    d          }|                     |                    dd          j        d
           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           |                    d          }|                     |                    dd          j        d           |                     |ddd           dS )ztest log2 vary roundsbcrypt   rG      )r7   bcrypt__min_roundsbcrypt__max_roundsbcrypt__default_roundsr  r   r  r  r   Nr  r         r  z1%g{Gz?z49%g\(\?z50%g      ?r  r  r  r-  s      r'   test_52_log2_vary_roundsz)CryptContextTest.test_52_log2_vary_rounds  s(   8*-/-/13   	*bgCCC*bgFFF*bgGGG WWaW(($77CQGGG  Xr2666WWdW++$77CQGGG  Xr2666 WWaW(($77CQGGG  Xr2666WWcW**$77CSIII  Xr2666 WWdW++$77CTJJJ  Xr2666WWeW,,$77CTJJJ  Xr2666WWeW,,$77CSIII  Xr2666WWfW--$77CSIII  Xr266666r)   c                    |                     |          }|j        dd         |j        z  }t                      }t	          d          D ]H}|                    ||          }	|                    |	          j        }
|                    |
           I| 	                    t          |          |d           | 	                    t          |          |d           dS )z2helper to check vary_rounds covers specified ranger   r   i,  rz  z"vary_rounds had wrong lower limit:z"vary_rounds had wrong upper limit:N)r   default_salt_charsmax_salt_sizerr  r   r  rm   r)  addr\   minmax)rY   contextr   lowerupperr   r(  seenir"  rs              r'   r  z$CryptContextTest.assert_rounds_range  s     //&)))!A#.1FFuu 	 	A!!&t!44A##A&&-AHHQKKKKTE+OPPPTE+OPPPPPr)   c                    t          j        ddt                     t          dg          }|                     |j        d           |                     |                    d          j        d           |                     |                    d	          j        d           |                     |                    d
          j        d           dS )zharden_verify -- parsingrT   z.*harden_verify.*r   rE   r>   N )harden_verifytruefalse)rW   rX   DeprecationWarningr   r\   r  usingrb   s     r'   test_harden_verify_parsingz+CryptContextTest.test_harden_verify_parsing-  s    *=);	= 	= 	= 	= N#3444*D11144BDIII88FMMM99GNNNNNr)   c                     d}d}t                                           }||_        t          |g          }|                                 t          |j                  \  }}|                     ||||z             dS )z'
        dummy_verify() method
        r  r   r>   )deltaN)	DelayHashr  delayr   dummy_verifyr   assertAlmostEqual)rY   expectedaccuracyr   rc   elapsed_s          r'   test_dummy_verifyz"CryptContextTest.test_dummy_verify9  s    
 //## G9---s/00
w88KLLLLLr)   c                 T   dd}t          dd          }|                      ||d          g d           |                      ||d          g d           |                    d	           |                      ||d          g d
           |                      ||d          g d
           |                    d           |                      ||d          g d
           |                      ||d          g d           t          dgd          }|                      ||d          dg           |                      ||d          dg           |                     t          t           dd           |                     t          t           dd           dS )z+test deprecated='auto' is handled correctlyNc                 H      fd                                  D             S )Nc                 F    g | ]}                     |          j        S r1   r   )r2   r   r   rc   s     r'   r4   zLCryptContextTest.test_61_autodeprecate.<locals>.getstate.<locals>.<listcomp>Q  s*    YYYCKK11<YYYr)   r>   r   s   ``r'   getstatez8CryptContextTest.test_61_autodeprecate.<locals>.getstateP  s)    YYYYY3;;==YYYYr)   z sha256_crypt,md5_crypt,des_cryptro  r   )FTTr   r-   rC   )TFTr,   r   )TTFrE   Fr   zauto,md5_cryptzmd5_crypt,autor   )r   r\   r!   rs   r   )rY   r  rc   s      r'   test_61_autodeprecatez&CryptContextTest.test_61_autodeprecateM  s
   	Z 	Z 	Z 	Z =&QQQ#$//1D1D1DEEE#w//1D1D1DEEE 	

;
'''#$//1D1D1DEEE#w//1D1D1DEEE 	

;
777#$//1D1D1DEEE#w//1D1D1DEEE N+???#$//%999#w//%999 	*l4L%5 	 	7 	7 	7*l4L%5 	 	7 	7 	7 	7 	7r)   c                 ,   ddl m} ddlm}m} t          dg          }t          ddg          }|                    d          }|                    d          }|                     t          d|j	                   |                     t          d|j	        |           |                     t          d|j	        |           |	                                }| 
                    ||j                   |	                    |          }	| 
                    |	|j        |z              |	                    |          }
| 
                    |
|j        |z              | 
                    |	                    |	          |	           |                     |                    |                     |                     ||j        |           |                     ||j        |           |                     ||j        |	           |                     |                    |                     |                     ||j        |           |                     |                    |                     |                     |                    |	                     |                     ||j        d           |                     t"          |j        d	           | 
                    |                    |          |           |                     ||j        |           |                     ||j        |           |                     ||j        |	           |                     ||j        d           |                     t"          |j        d	           | 
                    |                    |          |           |                     ||j        |           |                     t$          d
|j        |           | 
                    |                    |	          |           d	S )zdisabled hash supportr   )UnknownHashError)r-   unix_disabledr,   r  foozno disabled hasher presentr  Nzcannot restore original hash)passlib.excr  rp  r-   r  r   r   assertRaisesRegexr{   disabler\   default_markerr   
is_enabledrs   r  enablert   r   )rY   r  r-   r  rc   r  h_refh_otherh_dis	h_dis_refh_dis_others              r'   test_disabled_hashesz%CryptContextTest.test_disabled_hashesm  s   
 	10000099999999K=))[/:;;..'' 	|-I"{	, 	, 	,|-I"{E	3 	3 	3|-I"{G	5 	5 	5  <===LL''	M$@5$HIIIll7++m&BW&LMMM 	i00)<<< 	u--...*CNGDDD*CNEBBB*CNIFFF 	..///*CNGDDD//00033444 	*CJ;;;)SZ666E**E222*CJ@@@*CJ>>>*CJ	BBB 	*CJ;;;)T[$777U++U333*DKAAAz+I#{E	3 	3 	3Y//77777r)   r   F)Hr   r   r   descriptionPrefixr   r   r   r^   r(   r_   r   ro   rn   rw   rx   r   r   rz   r  rq   r}   rp   rr   r~   r   r`   r   r   ra   r   r9  rV   rd   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r2  r#  r/  r4  r:  rC  rH  rK  ra  rj  rv  r  r  r  r  r  r  r  r  __classcell__)rZ   s   @r'   r+   r+   1   s*       & POONN=MNNND"!&%*#(#(  M )[3DF F F A 
 
 
 q 
 
 
" GLL}55M )004!!F))DDW\\$77N '..qq~~/0q@ @@Fx@P@P W\\$77N2 D!&!&%*!&  M ![>>N
 D  M
 "k.-@@O
 D# # #"% !#%'"##'#''+!"  M$b b b b b; ; ;6H H H<E E E6= = =:I I I)< )< )<V1 1 10 7  7  7JJB JB JBX"A "A "AHZ2 Z2 Z2x#C #C #CJ. . .(F F F F, , ,(< < <0"b "b "bHM M M^Q Q QD D DB 
r
	+&'	
B	R	
` ` `6.? .? .?b"O "O "OHD D D8/B /B /B /BbD D D41O 1O 1OfEK EK EKN8Z 8Z 8ZtF/ F/ F/jte te tel$A $A $AL-7 -7 -7^Q Q Q"
O 
O 
OM M M(7 7 7@H8 H8 H8 H8 H8 H8 H8r)   r+   c                   H    e Zd ZdZdZej        ZdZdZ	 e
d          Zd ZdS )r  z-dummy hasher which delays by specified amount
delay_hash(   r   z$x$c                     t          j        | j                   t          |t                    r|                    d          }t          t          j        d|z             	                                          S )Nrf   s   prefix)
timesleepr  r[  r   rp   r   rZ  sha1r\  )rY   r  s     r'   r]  zDelayHash._calc_checksum  s`    
4:fg&& 	,]]7++FW\)f*<==GGIIJJJr)   N)r   r   r   __doc__r3   r   LOWER_HEX_CHARSchecksum_charschecksum_sizer  r   r^  r]  r1   r)   r'   r  r    sR        77D'NME1U88LK K K K Kr)   r  c                       e Zd Zd ZdS )dummy_2Nr   r1   r)   r'   r  r    s        DDDr)   r  c                   $    e Zd ZdZd Zd Zd ZdS )LazyCryptContextTestr	   c                 Z    t          d           |                     t           d           d S )Nr  )unload_handler_name
addCleanup)rY   s    r'   rV   zLazyCryptContextTest.setUp  s+    I&&&+Y77777r)   c                    |                      t          d                     t          dd           t          t	          ddg          dg          }|                      t          dd                     |                     |                                d           |                     |                    d          j	                   |                     t          dd                     dS )ztest plain kwdsr  passlib.tests.test_contextr,   r   Tr  r,   N)
r  has_crypt_handlerr   r	   iterr\   r7   r   r   rL   )rY   r   s     r'   test_kwd_constructorz)LazyCryptContextTest.test_kwd_constructor  s    *955666#I/KLLLdI{#;<<+WWW*9d;;<<<'?@@@

;//:;;;))T::;;;;;r)   c                                           t          d                     t          dd           d	 fd	}t          |d          }                      t          dd                                          |                                d                                |                    d          j                                        t          dd                     d S )
Nr  r  Fc                 p                         |            t          t          ddg          dg          S )Nr  r,   r   )r   r   r  )flagrY   s    r'   onloadz>LazyCryptContextTest.test_callable_constructor.<locals>.onload  s7    OOD!!!i%= > >K=YYYYr)   T)r  r  r  r,   r  )	r  r  r   r	   r\   r7   r   r   rL   )rY   r  r   s   `  r'   test_callable_constructorz.LazyCryptContextTest.test_callable_constructor  s    *955666#I/KLLL	Z 	Z 	Z 	Z 	Z 	Z V$777*9d;;<<<'?@@@

;//:;;;))T::;;;;;r)   N)r   r   r   r  rV   r  r  r1   r)   r'   r  r    sG        *8 8 8
< < << < < < <r)   r  )Ar  
__future__r   passlib.utils.compatr   configparserr   ConfigParserr  	functoolsr   logging	getLoggerr   logrw   rW   passlibr   passlib.contextr   r	   r  r
   r   passlib.utilsr   r   r   r   r   r   r   r   passlib.utils.handlersutilsr   r   passlib.tests.utilsr   r   r   r   r   r   passlib.registryr   r   r  r   r  r   rx   abspathdirname__file__r   r(   r+   rZ  r  r   r  r  r  r1   r)   r'   <module>r     s     
 & % % % % % $ $ $ $ $ $ ,+++++++++++++        'g'11 				        : : : : : : : : @ @ @ @ @ @ @ @ * * * * * * * * M M M M M M M M M M M M M M M M # # # # # # # # #N N N N N N N N N N N N N N N N            
wrwx0011  D8 D8 D8 D8 D8x D8 D8 D8T4        K K K K K  K K K"    b   %< %< %< %< %<8 %< %< %< %< %<r)   