
     h2#                    2   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jh                  jk                  ejh                  jm                  e7            Z8d Z9 G d de'      Z:ddl;Z;ddl<Z< G d de%jz                        Z> G d de%jz                        Z? G d de'      Z@y)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                 |    | j                         }|D ]  }|j                  |        |r|j                  |       |S N)copyupdate)firstargskwdstargetargs        \/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/passlib/tests/test_context.pymerge_dictsr(   &   s<    ZZ\F cdM    c                      e Zd ZdZg dZeD  cg c]  }t        |       c}}} Z eedddddd	      Z e	ee
      Z
 ed      Z ed      Zej                  j!                  ed      Zej'                   ed       ed            Zej                  j!                  ed      Zej'                   ed       ed            j-                  d      Zej                  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%d. Z&d/ Z'd0 Z(d1 Z)d2 Z*d3 Z+d4 Z,d5 Z-dSd7Z.d8 Z/d9 Z0d: Z1d; Z2d< Z3d= Z4d6i fd6d>difd?i fd@i fgZ5dA Z6dB Z7dC Z8dD Z9dTdEZ:dF Z;dG Z<dH Z=dI Z>dJ Z?dK Z@dL ZAdM ZBdN ZCdO ZDdP ZEdQ ZFdR ZGxZHS c c}}} w )UCryptContextTestr   )	des_crypt	md5_crypt
bsdi_cryptsha512_cryptr-   皙?i1u  ia  iP  @  )schemesdefaultall__vary_roundsbsdi_crypt__max_roundsbsdi_crypt__default_roundssha512_crypt__max_roundssha512_crypt__min_roundsr2   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.cfgiIq  i  iy  iȯ  )bsdi_crypt__min_roundsr5   r6   r8   z[passlib]
bsdi_crypt__min_rounds = 29001
bsdi_crypt__max_rounds = 35001
bsdi_crypt__default_rounds = 31001
sha512_crypt__min_rounds = 45000
r/   r3   )r,   r-   phpassr.   sha256_cryptr,   r@         r       H   )r2   
deprecatedr3   r5   r6   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       y )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'   rQ   zCryptContextTest.setUp   s3    +-*LM*`ar)   c                    t               }| j                  |j                         i        t        di | j                  }| j                  |j                         | j                         t        di | j                  }| j                  |j                         | j                         t        di | j
                  }| j                  |j                         | j
                         t        di | j                  }| j                  |j                         | j                         t        t        d      g      }| j                  |j                         d       y)ztest class constructorr@   r9   )r@   N )	r   assertEqualto_dictsample_1_dictsample_1_resolved_dictsample_2_dictsample_3_dictr   r2   rT   ctxs     r'   test_01_constructorz$CryptContextTest.test_01_constructor   s    n+ 0T//0(:(:; 9T889(:(:; 0T//0(:(:; 0T//0(:(:; An$5#67(9:r)   c                    t        j                  | j                        }| j                  |j	                         | j
                         t        j                  | j                        }| j                  |j	                         | j
                         t        j                  | j                  j                  d            }| j                  |j	                         | j
                         t        j                  | j                        }| j                  |j	                         | j
                         t        j                  | j                  dd      }| j                  |j	                         | j
                         | j                  t        t         j                  d       | j                  t        t         j                  | j                  d       y)ztest from_string() constructorutf-8mypolicyr<   sectionencodingNfakesectionre   )r   from_stringsample_1_unicoderX   rY   rZ   sample_1_unnormalizedencodesample_1b_unicodesample_1c_bytesassertRaises	TypeErrorr   r^   s     r'   test_02_from_stringz$CryptContextTest.test_02_from_string   s]    &&t'<'<=(:(:; &&t'A'AB(:(:; &&t'<'<'C'CG'LM(:(:; &&t'='=>(:(:; &&t';';Z.68(:(:; 	)\%=%=tD 	.,*B*B// 	 	Hr)   c                 2   t         j                  j                  | j                        st	        d| j                  z        t        j                  | j                        }| j                  |j                         | j                         t        j                  | j                        }| j                  |j                         | j                         t        j                  | j                  dd      }| j                  |j                         | j                         | j                  t        t
        j                  t         j                  j                  t        d             | j                  t         t
        j                  | j                  d       y)	ztest from_path() constructorzcan't find data file: %rrc   r<   rd   zsample1xxx.cfgrg   rh   N)ospathexistssample_1_pathRuntimeErrorr   	from_pathrX   rY   rZ   sample_1b_pathsample_1c_pathro   EnvironmentErrorjoinherer   r^   s     r'   test_03_from_pathz"CryptContextTest.test_03_from_path   s.    ww~~d0019D<N<NNOO $$T%7%78(:(:; $$T%8%89(:(:; $$T%8%8*.68(:(:; 	*L,B,B'',,t-=>	@ 	.,*@*@,,m 	 	Er)   c                 F   t        di | j                  } |j                  di | j                  }| j	                  |j                         | j                         | j	                  |j                         | j                          |j                  di | j                  }| j	                  |j                         | j                         | j	                  |j                         | j                          |j                  di | j                  }| j	                  |j                         | j                         |j                         }| j                  ||       | j	                  |j                         | j                         | j	                  |j                         | j                          |j                  di | j                   | j	                  |j                         | j                         | j	                  |j                         | j                         y)ztest copy() methodNrW   )r   rZ   r    r\   rX   rY   sample_12_dictr]   sample_123_dictassertIsNotr!   )rT   cc1cc2cc2bcc3cc4s         r'   test_04_copyzCryptContextTest.test_04_copy  s   0T//0 chh,++,(:(:;(;(;< sxx-$,,-(:(:;)<)<= chh,++,(<(<= hhjc"(:(:;(:(:; 	

(T''((:(:;(;(;<r)   c                 d    t        di | j                  }| j                  t        |      d       y)ztest repr()z!^<CryptContext at 0x-?[0-9a-f]+>$NrW   )r   rZ   assertRegexrepr)rT   r   s     r'   test_09_reprzCryptContextTest.test_09_repr+  s*    0T//0c$GHr)   c                    t               }|j                  | j                         | j                  |j	                         | j                         |j                  | j
                         | j                  |j	                         | j                         |j                  | j
                  j                  d             | j                  |j	                         | j                         | j                  t        |j                  d       t        di | j                  }|j                  i d       | j                  |j	                         | j                         t               }|j                  | j                         |j                  | j                         | j                  |j	                         | j                         y)z test load() / load_path() methodrb   NT)r!   rW   )
r   loadrZ   rX   rY   rj   rl   ro   rp   r\   r^   s     r'   test_10_loadzCryptContextTest.test_10_load4  sH    n 	##$(:(:; 	&&'(:(:; 	&&--g67(:(:; 	)SXXt4 0T//0D!(:(:; n##$##$(:(:;r)   c                    t        ddgdd      }|j                         }| j                  t        |j                  d       | j                  |j                         |       | j                  t        |j                  d       | j                  |j                         |       | j                  t        |j                  d	
       | j                  |j                         |       y)z$test load() errors restore old stater,   r@   i  r0   )rK   r4   T)too__many__key__parts)fake_context_optioni'  rJ   N)r   	to_stringro   rp   r!   rX   KeyError
ValueError)rT   ccresults      r'   test_11_load_rollbackz&CryptContextTest.test_11_load_rollback_  s     ;7)-   	)RYYdK0
 	(BII4H0 	*bii%P0r)   c                    t        di | j                  }|j                          | j                  |j	                         | j                         t        di | j                  } |j                  di | j
                   | j                  |j	                         | j                          |j                  di | j                   | j                  |j	                         | j                         t        di | j                  }|j                  | j
                         | j                  |j	                         | j                         t        di | j                  }|j                  | j                         | j                  |j	                         | j                         | j                  t        |j                  i i        | j                  t        |j                  i dg       | j                  t        |j                  d       y)ztest update() methodr,   r9   NrW   )r   rZ   r!   rX   rY   r\   r   r]   r   sample_2_unicodero   rp   r^   s     r'   test_12_updatezCryptContextTest.test_12_updatew  s    0T//0

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

(T''((;(;< 	

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

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

4(()(;(;< 	)SZZR8)SZZk]K 	)SZZ6r)   c                    d }| j                  t        t        d       | j                  t        t        d       | j                  t        t        d       | j                  t        t        d       | j                  t        t        d       | j                  t        t        d	
        | j                   t        |fi ddi t        d&i ddd}| j	                  |j                  d      d       t        d      }| j	                   |d      |       | j	                   |d      |       | j	                   |d      |       | j	                   |d&i ddi|       | j	                   |d&i ddi|       t        d      }| j	                   |d      |       | j	                   |d&i ddi|       t        d      }| j	                   |d      |       | j	                   |d      |       | j	                   |d&i ddi|       | j	                   |d&i ddi|       t        d      }| j	                   |d      |       | j	                   |d&i ddi|       t        ddgd       }| j                  t        |j                  d!       | j                  t        t        dgd"#       | j                  t        t        dgd"$       y%)'ztest basic option parsingc                  4    t        di | j                         S )NrW   r   rY   )r$   s    r'   parsez/CryptContextTest.test_20_options.<locals>.parse  s    '$'//11r)   r0   )__x)default__scheme__)__option)default____option)__scheme__optioni0u  )!category__scheme__option__invalidzadmin.context__schemesr-   md5_crypt,des_cryptr,   )r2   zadmin.context__defaultadminr>   )context__default)default__context__defaultzcontext.defaultzdefault.context.defaultadmin__context__defaultzadmin.context.defaultr4   )default__all__vary_roundszall.vary_roundszdefault.all.vary_rounds)admin__all__vary_roundszadmin.all.vary_roundsr?   P)rL   )md5_crypt__identxx)r2   des_crypt__salt)r2   	all__saltNrW   )ro   rp   r   r   rX   default_schemedictr    )rT   r   r_   r   s       r'   test_20_optionsz CryptContextTest.test_20_options  s   	2 	)\c:)\SI 	)\C@)\SI 	)\CH 	)\>C 	 	E
 	(E 	D5kB	D E(=7BD E++G4kB k*{3V<<fEEvNA"3K!@A6JI";K!HI6R k:{CVLG"9+!FGP s+4f==vF9"3C!896BA";C!@A6J c2s;VD?"9#!>?H Hk2#F(CHHsC 	(L;-BF 	 	H(L;-<@ 	 	Br)   c                    t        d      }| j                  |j                         d       t        ddg      }| j                  |j                         d       t        d      }| j                  |j                         d       t        t        j                  t        j
                  g      }| j                  |j                         d       | j                  t        t         t        j                  g        G d d	t        j                        }| j                  t        t         |g        G d
 dt        j                        }| j                  t        t         ||g       | j                  t        t         dg       y)z%test 'schemes' context option parsingNr9   rW   r,   r-   )r,   r-   z des_crypt, md5_crypt, c                       e Zd ZdZy)2CryptContextTest.test_21_schemes.<locals>.namelessN__name__
__module____qualname__namerW   r)   r'   namelessr     s    Dr)   r   c                       e Zd ZdZy)1CryptContextTest.test_21_schemes.<locals>.dummy_1dummy_1Nr   rW   r)   r'   r   r     s    Dr)   r   )admin__context__schemes)r   rX   r2   r   r,   r-   ro   rp   uhStaticHandlerr   r   )rT   r   r   r   s       r'   test_21_schemesz CryptContextTest.test_21_schemes  s4    $'r* ;"<='AB ";<'AB 4>>4>>"BC'AB 	)\B<L<L;MN	r'' 	*lXJG	b&& 	(L7G:LM 	(L3>- 	 	Ar)   c                    dd}t        dg      }|j                  ddg       | j                   ||      dg       t        dgddg      }| j                   ||      dg       | j                  t        t         t
        j                  gddg       t        dg d	      }| j                   ||      ddg       | j                  t        t         dgdg
       | j                  t        t         dgdg
       | j                  t        t         ddgddg       | j                  t        t         ddgdd       | j                  t        t         ddgdd       | j                  t        t         ddgdd       | j                  t        t         ddgdd       t        ddgddg        | j                  t        t         d       t        dgddgdg      }| j                   ||      dg       | j                   ||d      dg       | j                   ||d      dg       t        dgddgg       }| j                   ||      dg       | j                   ||d      dg       | j                   ||d      g        y)z(test 'deprecated' context option parsingNc                     | j                         D cg c]   }| j                  ||      j                  r|" c}S c c}w r   r2   handlerrG   )r_   categoryr   s      r'   getdepz3CryptContextTest.test_22_deprecated.<locals>.getdep  s;    %([[] ?T{{42==  ? ? ?s   %;r-   rG   r,   r9   )rG   r2   r   )r-   r,   r@   r2   rG   )r2   admin__context__deprecated)r2   r3   rG   )r2   r3   r   )r2   r   rG   )r2   r   r   )r2   rG   r   r   {   )rG   r2   r   userr   r   )	r   r!   rX   ro   rp   r   r-   r   r   )rT   r   r   s      r'   test_22_deprecatedz#CryptContextTest.test_22_deprecated  s   	?
 k]3
		;4	5[M2 k][+<VWk]3 	)\t~~>N#."< 	 	> %:Dnok;%?@ 	(L;->I] 	 	L 	*l#.-&1] 	 	4 	*l#."<6A;5O 	 	Q 	*l#."<"-%0 	 	2 	*l#."<"-5@ 	 	B 	*l#."<2=%0 	 	2 	*l#."<2=5@ 	 	B 	#."<%02=57		9 	)\cB k]#."<6A] 	k]3F+k];G,{m< k]#."<57 	k]3F+k];G,b1r)   c                 \   | j                  t        d      j                         t        d             t        dddg      }| j                  |j	                         d       t        t
        j                  ddg      }| j                  |j	                         d       t        ddg      }| j                  |j	                         d       |j                  d       | j                  |j	                         d       | j                  t        t        dgd       | j                  t        t        d       t        dddgd	      }| j                  |j	                         d       | j                  |j	                  d
      d       | j                  |j	                  d      d       y)z%test 'default' context option parsingr-   r>   r,   )r3   r2   r9   r   )r2   r3      )r3   r2   r   r   r   N)rX   r   rY   r   r   r   r-   r!   ro   r   rp   r^   s     r'   test_23_defaultz CryptContextTest.test_23_defaulth  sz    	k:BBDk2	4 ;k8RS++-{; 4>>K;UV++-{; K#=>++-{;

k
*++-{; 	(L;-:E 	 	G 	)\1= ;$/#=3>@ 	++-{;++F3[A++G4kBr)   c                     d }| j                   |d      d       | j                   |d      d       | j                   |d      d       | j                   |d      d       | j                   |d      d       y)z&test 'vary_rounds' hash option parsingc                 <    t        |       j                         d   S )Nr   r4   r   )vs    r'   r   z3CryptContextTest.test_24_vary_rounds.<locals>.parse  s    3;;=>PQQr)   r0   z0.1z10%i  1000N)rX   )rT   r   s     r'   test_24_vary_roundsz$CryptContextTest.test_24_vary_rounds  sr    	R 	sS)us+ 	us+ 	td+v-r)   Nc                 >    | j                  t        ||      |       y )N)msg)
assertTruer   )rT   r   baser   s       r'   assertHandlerDerivedFromz)CryptContextTest.assertHandlerDerivedFrom  s    ,Wd;Er)   c                    t               }| j                  |j                         d       | j                  |j                  d      d       t        di | j                  }| j                  |j                         t	        | j
                               | j                  |j                  dd      t	        | j                               t        |j                  d      | j                        D ]   \  }}| j                  t        ||             " t        di | j                  }| j                  |j                         d       y)ztest schemes() methodrW   Tresolver   unconfiguredN)r   rX   r2   rZ   tuplesample_1_schemessample_1_handlerszipr   r   r\   )rT   r_   r   corrects       r'   test_30_schemesz CryptContextTest.test_30_schemes  s   
 n+T2B7 0T//0d.C.C(DETEuTMcMcGde"3;;t;#<d>T>TU 	COFGOO0AB	C 0T//0+r)   c                 Z   t               }| j                  t        |j                         t        di | j                  }| j                  |j                         d       | j                  |j                  dd      t        j                         | j                  |j                  d      t        j                         t        di | j                  }| j                  t        |j                         t        | j                        }| j                  |j                         d       y)	ztest default_scheme() methodr-   Tr   r   r9   r,   NrW   )r   ro   r   r   rZ   rX   r   r-   r   r\   r   r^   s     r'   test_31_default_schemez'CryptContextTest.test_31_default_scheme  s    
 n(C$6$67 0T//0++-{;++Dt+Ldnn]%%c&8&8&8&FW 0T//0(C$6$67 4#8#89++-{;r)   c                    t               }| j                  t        |j                         | j                  t        |j                  d       t        di | j                  }| j                  |j                  d      t        j                         | j                  |j                         t        j                         | j                  |j                  dd      t        j                         | j                  |j                  d      t        j                         | j                  t        |j                  d       t        dd      }| j                  |j                  d      t        j                         | j                  |j                         t        j                         | j                  |j                  dd	      t        j                         | j                  |j                  d
      t        j                         | j                  |j                  dd	      t        j                         | j                  |j                  d
      t        j                         t        ru| j                  |j                  t        d      d	      t        j                         | j                  |j                  t        d      d	      t        j                         yy)ztest handler() methodr-   T)r   r,   mysql323sha256_crypt,md5_cryptr   staff)r   r   r   r   NrW   )r   ro   r   r   rZ   rX   r   r-   r   r,   r@   r   r   r^   s     r'   test_32_handlerz CryptContextTest.test_32_handler  s    n(CKK0(CKK= 0T//0$7H%%ckkmT^^D 	[tDdnnU%%ckk+&>O 	(CKK< 3[Y$79J9JK%%ckkmT5F5FGgDI4K\K\]%%ckk7k&CTEVEVWgDI4>>Z%%ckk7k&CTEVEVW S[[!G*4[PRVRcRcdS[[!G*4[PRVR`R`a r)   c                 "   dd}t        dg dddgddd	dd
gddd
      }| j                  |j                  j                  d       | j                   ||d      t	        ddd	             | j                   ||dd      t	        ddd	             | j                   ||dd      t	        dd             | j                   ||d      t	        dd             | j                   ||dd      t	        dd             | j                   ||dd      t	        dd             | j                   ||d
      t	        d             | j                   ||d
d      t	        d             | j                   ||d
d      t	        dd             y)z*test internal _get_record_options() methodNc                 @    | j                   j                  ||      d   S )Nr   )_config_get_record_options_with_flag)r_   schemer   s      r'   optionsz1CryptContextTest.test_33_options.<locals>.options  s    ;;<<VXNqQQr)   T)r/   r,   r.   r/   r,   r0   皙?i N  r.   皙?g333333?r1   )
truncate_errorr2   rG   r4   rH   r7   r   r   admin__bsdi_crypt__vary_roundsadmin__sha512_crypt__max_rounds)r   )rG   vary_rounds
max_roundsr   r   )r   r  )rG   r   )r   )r   rG   r   )r   rX   r   
categoriesr   )rT   r   r   s      r'   test_33_optionsz CryptContextTest.test_33_options  s   	R
 B(+6"$'',+6)F&*+..3
 	//< 	n5t8
 	 	nf=t@
 	 	ng>A
 	 	k2D5
 	
 	k6:D=
 	
 	k7;T>
 	 	l3T6
 	 	lF;T>
 	 	lG<d?
 	r)   c                     t        di | j                  }| j                  |j                         | j                         | j                  |j                  d      | j                         y)ztest to_dict() methodTr   NrW   )r   rZ   rX   rY   r[   r^   s     r'   test_34_to_dictz CryptContextTest.test_34_to_dictC  sT     0T//0(:(:;T2D4O4OPr)   c                    t        d
i | j                  }|j                         }t        s| j	                  || j
                         t        j                  |      }| j	                  |j                         | j                         |j                  d      }| j	                  ||j                  dd             ddl	m
} t        |dg      }|j                         }| j                  |d       y	)ztest to_string() methodzpassword-securityrh   r;   z[password-security]r   )UnsaltedHashr-   zM# NOTE: the 'unsalted_test_hash' handler\(s\) are not registered with PasslibNrW   )r   rZ   r   r   rX   rj   ri   rY   replace!passlib.tests.test_utils_handlersr  r   )rT   r_   dumpctx2otherr  ctx3s          r'   test_35_to_stringz"CryptContextTest.test_35_to_stringJ  s     0T//0}} T4#8#89 ''-););< &9:[9N OP 	C\;78~~  C 	Dr)   r   r   rW   c                    t         j                  t         j                  t         j                  g}t	        |d      }|D ]  }|j                  d|j
                        }| j                  |j                  |      |j
                         | j                  |j                  |dd      |       | j                  |j                  |d      |       | j                  |j                  d|             | j                  |j                  d|              |j                  d      }| j                  |j                  |      d	       |j                  d
|j                               }| j                  |j                  |      d	       |j                  d
|j                         d	      }| j                  |j                  |      d	       | j                  t        |j                  d
|j                         d       y)z-test basic hash/identify/verify functionality   r6   testr   Tr   r   notestr-   secretr,   N)r   r-   r,   r.   r   r   rX   identifyr   r   verifyassertFalsegenhash	genconfigro   r   )rT   handlersr   crypths        r'   test_40_basiczCryptContextTest.test_40_basicq  s   NNDNNDOOD(qA  	5Euzz2AR[[^UZZ8R[[Dt[LeT))"++a+*FNOOBIIfa01RYYx34	5 GGFOQ5 JJx0Q5JJxJDQ5*bjj(BLLNS^_r)   c                    t        ddgddd      }| j                  |j                         j                  d             | j                  |j                  d      j                  d	             | j                  |j                  dd
      j                  d             | j                  |j                  dd      j                  d	             | j	                  |j                  dddd      d       t
        r|j                  d      }| j                  |j                  t        d
            j                  d             | j                  |j                  t        d            j                  d	             | j                  t        t               j                         | j                  t        t               j                  d       | j                  t        |j                  d       | j                  t        |j                  dd       | j                  t        |j                  d       | j                  t        |j                  d       y)ztest genconfig() methodr-   r?   rE   rF   r   )r2   rL   rM   admin__phpass__identz$1$r  z$H$5r   )r   r   z$P$5r   ........   )r   saltroundsidentz"$P$6........22zGEuacuPOqEpYPDeR0R/r>   r   faker   N)r   r   r  
startswithrX   r   r    r   ro   r   rp   rT   r   c2s      r'   test_41_genconfigz"CryptContextTest.test_41_genconfig  s   ;"9(+12/2 	11%89 	H5@@HI 	HwGRRSYZ[HwGRRSYZ[ 	LLuQcLJ0	 *BOOBLL!G*L=HHPQOOBLL!G*L=HHPQ 	(LN$<$<=(LN$<$<[Q 	(BLL@)R\\!gN)R\\!< 	)R\\A>r)   c                    t        dg      }|j                  d      }| j                  D ])  \  }} | j                  t        |j
                  ||fi | + t        dg      }| j                  D ],  \  }}|	 | j                  t        |j
                  d|fi | . t        dg      }| j                  t        |j
                  dd       | j                  t        t               j
                  dd       | j                  t        |j
                  d|d       | j                  t        |j
                  d|d	       | j                  t        |j                  d|d	
       y)ztest genhash() methodr,   stubNr  r   r   r&  r  r   r   )r   r   nonstring_vectorsro   rp   r  r   r  )rT   r   r   r  r$   configs         r'   test_42_genhashz CryptContextTest.test_42_genhash  sH    ;-(wwv 22 	KLFDDiVTJTJ	K ;-( 22 	OLFD| DiXvNN	O :,')RZZ> 	(LN$:$:HfM 	(BJJ$vN)RZZ4J 	)R\\8TANr)   c                 x   t        di | j                  }|j                  d      }| j                   |j                  d             | j                  |j                  d|             | j                  |j                  d|             | j                  t        |j                  d       t        dg      }| j                  D ](  \  }} | j                  t        |j                  |fi | * | j                  t        t               j                  d       | j                  t        |j                  dd	       y
)ztest hash() methodpasswordz$5$rounds=3000$	passwordxi  rK   r,   r  r   r   NrW   )r   sample_4_dictr   r   r'  r  r  ro   r   r    r-  rp   r   )rT   r   r   r  r$   s        r'   test_43_hashzCryptContextTest.test_43_hash  s    /D../wwz"(9:;		*d34;56 	*bgg7; 	 	= ;-( 22 	BLFDDi&ADA	B 	(LN$7$7B 	)RWWhCr)   c           	         t        di | j                  }| j                  dg      5  | j                  |j	                  ddd      d       ddd       | j                  dg      5  | j                  |j	                  dddd	      d
       ddd       | j                  dg      5  | j                  |j	                  ddd      d       ddd       | j                  dg      5  | j                  |j	                  ddd      d       ddd       | j                  t        |j                  dd       | j                  t        |j                  dd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   uxY w)z;test hash() method -- legacy 'scheme' and settings keywords"passing settings to.*is deprecatedr1  r?   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   rW   )r   r4  assertWarningListrX   r   ro   r   rp   )rT   use_16_legacyr   s      r'   test_43_hash_legacyz$CryptContextTest.test_43_hash_legacy  s   /D../  ##%I$JK 	
8%@4	
 ##%I$JK 	
8%sK4	 ##%I$JK 	
4f=Q	 ##%I$JK 	
4f=Q	 	(BGGXfE)RWWhqA;	 	
	 		 		 	s/   %E'&E''%E3&%E?E$'E03E<?Fc                    g d}t        |d      }| j                  |j                  d      d       | j                  t        |j                  dd       t        dg      }| j
                  D ](  \  }} | j                  t        |j                  |fi | * t               }| j                  |j                  d	      d       | j                  t        |j                  d	d       | j                  t        |j                  dd
       y)ztest identify() border casesr-   r,   r.   r  r  z$9$232323123$1287319827NT)requiredr,   r   r   r   )	r   rX   r  ro   r   r-  rp   assertIsr   )rT   r  r   r   r$   s        r'   test_44_identifyz!CryptContextTest.test_44_identify.  s    ;(qA 	%>?F*bkk3LW[\ ;-(00 	DJD$DidCdC	D ^bkk&)40(BKK$G 	)R[[$Cr)   c                    g d}t        |d      }t        j                  j                  d      }| j                  |j	                  d|             | j                  |j	                  d|              | j                  |j	                  d|d             | j                  |j	                  d|d              | j                  t        |j                  d|d       | j                  t        |j                  d	d
       t        dg      }|j                  d	      x}}| j                  D ])  \  }} | j
                  t        |j                  ||fi | + | j                  |j	                  d             t        dg      }| j                  D ],  \  }}|	 | j
                  t        |j                  d|fi | . | j                  t        t               j                  dd       | j                  t        |j                  d|d       | j                  t        |j                  d|d       | j                  t        |j                  d|d       y)ztest verify() scheme kwdr@  r  r  r  r  r-   r  r.   r,  z$6$232323123$1287319827r,   Nr  r   r&  r   r   )r   r   r-   r   r  ro   r   r-  rp   r  r   )rT   r  r   r  refhashr  r$   s          r'   test_45_verifyzCryptContextTest.test_45_verifyH  s   ;(qANN' 			&!,-BIIh223 			&!K	@ABIIh+IFFG 	*bii<P 	*bii9RS ;-(ggfo%G 22 	GLFDDiFAFF	G 	6401 ;-(-- 	IGAtyDiHaH4H	I 	(LN$9$98VL 	(BIIxP)RYY'!L 	)RYY'ANr)   c                 6   t        di | j                  }| j                  |j                  d             | j	                  |j                  d             | j                  |j                  d             | j	                  |j                  d             | j	                  |j                  d             | j                  |j                  d             g  G fddt
        j                        }t        |g      }|j                  d	      x}}| j	                  |j                  |             | j                  |d
fg       d
d
= | j	                  |j                  |d             | j                  |dfg       d
d
= | j                  |j                  |d             | j                  |dfg       d
d
= t        dg      }| j                  D ](  \  }} | j                  t        |j                  |fi | * | j                  t        t               j                  d       | j                  t        |j                  |d       | j                  t        |j                  |d       | j                  t        |j                  |d       y
)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                   2    e Zd ZdZdZed fd	       Zd Zy)4CryptContextTest.test_46_needs_update.<locals>.dummydummy@Nc                 4    j                  ||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~%r)   c                     ddl m} t        |t              r|j	                  d      }t         ||      j                               S )Nr   )md5rb   )hashlibrT  
isinstancer   rl   r   	hexdigest)rT   r  rT  s      r'   _calc_checksumzCCryptContextTest.test_46_needs_update.<locals>.dummy._calc_checksum  s5    'fg.#]]73F$S[%:%:%<==r)   r   )r   r   r   r   _hash_prefixclassmethodrR  rX  )rQ  s   r'   rK  rJ    s$    DL& &>r)   rK  r  Nbob)r  rN  r,   r   r&  r  r   r   rW   )r   r4  r   rR  r  r   r   r   rX   r-  ro   rp   r   )rT   r   rK  r_   r   rE  r$   rQ  s          @r'   test_46_needs_updatez%CryptContextTest.test_46_needs_update{  sD   /D../ 	89)MNO 	(uvw)vwx 	)vwx(uvw
 	>B$$ 	>  E7#F++w))$/0T{m4N 	))$u)=>U|n5N 	((d(;<T{m4N ;-(00 	HJD$Di$G$G	H 	(LN$?$?H 	(BOOWVL)R__gaH 	)R__gJr)   c                 8   t        di | j                  }|j                  d      j                  d      }|j                  d      j                  d      }|j	                  d|      \  }}| j                  |       | j                  |d       |j	                  d|      \  }}| j                  |       | j                  |d       |j	                  d|      \  }}| j                  |       | j                  |j                  |      d       |j	                  d|      \  }}| j                  |       | j                  |d       t        dg      }|j                  d      x}}| j                  D ])  \  }}	 | j                  t        |j                  ||fi |	 + | j                  |j	                  d      d       t        dg      }| j                  D ],  \  }}	|	 | j                  t        |j                  d|fi |	 . | j                  t        t               j                  dd	       | j                  t        |j                  d|d
       | j                  t        |j                  d|d       | j                  t        |j                  d|d       y)ztest verify_and_update()r,   r1  r@   	wrongpassNr,  FNr  r   r&  r  r   r   rW   )r   r4  r   r   verify_and_updater  rB  r   r  r-  ro   rp   rX   r   )
rT   r   h1h2oknew_hashr   rE  r  r$   s
             r'   test_47_verify_and_updatez*CryptContextTest.test_47_verify_and_update  so   /D../ ZZ$))*5ZZ',,Z8 ++K<Hh% ++K<Hh% ++J;HH-~> ++J;Hh% ;-((w 22 	ULFDDi)=)=vtTtT	U 	--fd;]K ;-(00 	WJD$|Di)=)=xVQUV	W 	(LN$D$DhPVW 	(B$8$8(GTZ[)R%9%98WUVW 	)R%9%98WWXYr)   c                    ddl m}m}m} |j	                  d      }|j	                  dd      }|j	                  dd      }t        ||g      }| j                  |j                  t                      | j                  |j                  |j	                  d            d       | j                  |j                  d|             | j                  |j                  d|      d       | j                  d	g      5  | j                  t        |j                  dd       d
d
d
       | j                  t        |j                  d|d       | j                  t        |j                  d|d       t        ||g      }| j                  |j                  t        dg             | j                  |j                  |j	                  d            d       | j                  |j                  d|             | j                  |j                  d|      d       | j                  |j                  |j	                  dd            d       | j                  |j                  d|d             | j                  |j                  d|d      d       | j                  d	g      5  | j                  t        |j                  dd       d
d
d
       | j                  t        |j                  d|d       | j                  t        |j                  d|d       t        ||gd      }	| j                  |	j                  t        dg             | j                  t        |	j                  d       | j                  t        |	j                  d|       | j                  t        |	j                  d|       | j                  |	j	                  dd      |       | j                  |	j                  d|d             | j                  |	j                  d|d      d       | j                  |	j                  d|d      d       | j                  |	j                  d|d      d|f       y
# 1 sw Y   FxY w# 1 sw Y   xY w)zLhash(), verify(), and verify_and_update() -- discard unused context keywordsr   )r,   r-   postgres_md5r,  root)r   r   r,   )TNr7  Nr   )badkwdautor   r_  T)passlib.hashr,   r-   rg  r   r   rX   context_kwdssetr   r  r  r`  r<  ro   rp   )
rT   r,   r-   rg  des_hashpg_root_hashpg_admin_hashr   r   r   s
             r'   test_48_context_kwdsz%CryptContextTest.test_48_context_kwds  s   
 	DC>>&)#((f(=$))&w)?
 Iy12))351 		**388F+;<kJ

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

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

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

6<f
EF..v|&.QS_` 	..v|'.RTab 	..vxf.M-	/_	H 	H,	J 	Js   8$Q $Q- Q*-Q7c                 	   t        dgddd      }d}|j                  dd      }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       | j                  t        gdz        5  |j                  d	dd	
      }ddd       | j                  j                  d      d|z          | j                  g       5  | j                  |j                  dd      d|z          ddd       | j                  |j                  dd      d|z          | j                  |j                  dd      d|z          | j                  t        gdz        5  |j                  t        d      d	z   dt        d      d	z         }ddd       | j                  |j                  d      d|z          | j                  g       5  | j                  |j                  dd      d|z          ddd       | j                  |j                  dd      d|z          | j                  |j                  dd      d|z          | j                  |j                  d      d|z          t        j                  j
                  }|j                  d|dz        }| j                  |j                  d      d||fz         |j                  dd      }| j                  |j                  d      d|z          | j                  t        |j                  d        |j                  d        |j                  d        | j                  t        |j                  d        t        dg!      }| j                  t        |j                  dd"       | j                  t        t         d#$       | j                  t        t         d#%       | j                  t        t         d#&       | j                  t        t         d#        t        j                  j!                         }| j                  t"        t         d|$       | j                  t"        t         d|%       | j                  t"        t         d|&       | j                  t"        t         d|        y# 1 sw Y   	xY w# 1 sw Y   xY w# 1 sw Y   $xY w# 1 sw Y   xY w)'ztest rounds limitsr@   rD   rC   i	  r2   rJ   rI   rK   z+...........................................N   i  )rJ   rI   rK   r9  r#  z$5$rounds=1000$nacl$r8  r:  z$5$rounds=1999$nacl$z$5$rounds=2000$nacl$r;  z$5$rounds=2001$nacl$g    eA)rI   rJ   rK   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   )rK   rI   z$5$rounds=%d$nacl$%sr3  r9   )rJ   rI   r   r   )rI   r   )r   _get_recordrX   min_desired_roundsmax_desired_roundsdefault_roundsr<  r   r    r  intr   r@   ro   r   datetimenowrp   )rT   r   STUBcustom_handlerr)  dfbads          r'   test_50_rounds_limitsz&CryptContextTest.test_50_rounds_limitsQ  s   >"237377; = =::DA::DA66= ##%7$8$:; 	>#PT9<  >B	> 	624JT4QR ##B' 	WDv68NQU8UW	W
 	LL6L24JT4Q	S 	LL6L24JT4Q	S ##%7$8$:; 	G#c(3,Y]9<S#  GB	G 	624ORV4VW ##B' 	WDv68NQU8UW	W
 	LL6L24JT4Q	S 	LL6L24JT4Q	S 	624JT4QR --WW$QSUVQVWW624JbRVZ4WX WW$QUWV624JT4QR
 	*bggDQ
T2
T2*bggDQ >"23 	*bgg37 	 	9 	*lSQ*lSQ*lSI*lQTU ##%)\>\_`)\>\_`)\>TWX)\>`cdw	> 	>	W 	W"	G 	G	W 	Ws0   R.%'R;9-S$'S.R8;SSSc                    t        dgddd      }| j                  t        |j                  d       | j                  t        |j                  d       | j                  t        |j                  d	       |j                  d
      }| j	                  |j                  dd      j                  d
       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d
       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       y)ztest linear vary roundsr@   i  i  rD   rs  r   -1%101%r   N0%r   r8  r;  d   z0.1%gMbP?i  i  100%      ?r   ro   r   r    rX   rv  r   assert_rounds_ranger(  s      r'   test_51_linear_vary_roundsz+CryptContextTest.test_51_linear_vary_rounds  s   >"237377; 	*bggC*bggF*bggG WWaW(=II1M  ^T4@WWdW+=II1M  ^T4@ WWaW(=II1M  ^T4@WWcW*=II3O  ^T4@ WWfW-=II5Q  ^T4@WWfW-=II3O  ^T4@r)   c                    t        dgddd      }| j                  t        |j                  d       | j                  t        |j                  d       | j                  t        |j                  d	       |j                  d
      }| j	                  |j                  dd      j                  d
       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d
       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       |j                  d      }| j	                  |j                  dd      j                  d       | j                  |ddd       y)ztest log2 vary roundsbcrypt   rB      )r2   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 	*bggC*bggF*bggG WWaW($7CCQG  Xr26WWdW+$7CCQG  Xr26 WWaW($7CCQG  Xr26WWcW*$7CCSI  Xr26 WWdW+$7CCTJ  Xr26WWeW,$7CCTJ  Xr26WWeW,$7CCSI  Xr26WWfW-$7CCSI  Xr26r)   c                    |j                  |      }|j                  dd |j                  z  }t               }t	        d      D ]A  }|j                  ||      }	|j                  |	      j                  }
|j                  |
       C | j                  t        |      |d       | j                  t        |      |d       y)z2helper to check vary_rounds covers specified ranger   r   i,  ru  z"vary_rounds had wrong lower limit:z"vary_rounds had wrong upper limit:N)r   default_salt_charsmax_salt_sizerm  r   r  ri   r$  addrX   minmax)rT   contextr   lowerupperr   r#  seenir  rs              r'   r  z$CryptContextTest.assert_rounds_range  s     //&)))!A.1F1FFu 	A!!&t!4A##A&--AHHQK	 	TE+OPTE+OPr)   c                    t        j                  ddt               t        dg      }| j	                  |j
                  d       | j	                  |j                  d      j
                  d       | j	                  |j                  d	      j
                  d       | j	                  |j                  d
      j
                  d       y)zharden_verify -- parsingrO   z.*harden_verify.*r   r@   r9   N )harden_verifytruefalse)rR   rS   DeprecationWarningr   rX   r  usingr^   s     r'   test_harden_verify_parsingz+CryptContextTest.test_harden_verify_parsing-  s    *=);	= N#34**D14BBDI8FFM9GGNr)   c                     d}d}t         j                         }||_        t        |g      }|j	                          t        |j                        \  }}| j                  ||||z         y)z'
        dummy_verify() method
        r   r   r9   )deltaN)	DelayHashr  delayr   dummy_verifyr   assertAlmostEqual)rT   expectedaccuracyr   r_   elapsed_s          r'   test_dummy_verifyz"CryptContextTest.test_dummy_verify9  sg    
 //# G9-s//0
w88KLr)   c                    dd}t        dd      }| j                   ||d      g d       | j                   ||d      g d       |j                  d	       | j                   ||d      g d
       | j                   ||d      g d
       |j                  d       | j                   ||d      g d
       | j                   ||d      g d       t        dgd      }| j                   ||d      dg       | j                   ||d      dg       | j                  t        t         dd       | j                  t        t         dd       y)z+test deprecated='auto' is handled correctlyNc                 |    | j                         D cg c]  }| j                  ||      j                    c}S c c}w r   r   )r_   r   r   s      r'   getstatez8CryptContextTest.test_61_autodeprecate.<locals>.getstateP  s-    KN;;=YCKK1<<YYYs   #9z sha256_crypt,md5_crypt,des_cryptrj  r   )FTTr   r-   r>   )TFTr,   r   )TTFr@   Fr   zauto,md5_cryptzmd5_crypt,autor   )r   rX   r!   ro   r   )rT   r  r_   s      r'   test_61_autodeprecatez&CryptContextTest.test_61_autodeprecateM  sF   	Z =&Q#$/1DE#w/1DE 	

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

;
7#$/1DE#w/1DE N+?#$/%9#w/%9 	*l4L%5 	 	7*l4L%5 	 	7r)   c                    ddl m} ddlm}m} t        dg      }t        ddg      }|j                  d      }|j                  d      }| j                  t        d|j                         | j                  t        d|j                  |       | j                  t        d|j                  |       |j                         }| j                  ||j                         |j                  |      }	| j                  |	|j                  |z          |j                  |      }
| j                  |
|j                  |z          | j                  |j                  |	      |	       | j                  |j                  |             | j                  ||j                  |       | j                  ||j                  |       | j                  ||j                  |	       | j                  |j                  |             | j                  ||j                  |       | j                  |j                  |             | j                  |j                  |	             | j                  ||j                   d       | j                  t"        |j                   d	       | j                  |j!                  |      |       | j                  ||j                   |       | j                  ||j                   |       | j                  ||j                   |	       | j                  ||j                   d       | j                  t"        |j                   d	       | j                  |j!                  |      |       | j                  ||j                   |       | j                  t$        d
|j                   |       | j                  |j!                  |	      |       y	)zdisabled hash supportr   )UnknownHashError)r-   unix_disabledr,   r  foozno disabled hasher presentr  Nzcannot restore original hash)passlib.excr  rk  r-   r  r   r   assertRaisesRegexrw   disablerX   default_markerr   
is_enabledro   r  enablerp   r   )rT   r  r-   r  r_   r  h_refh_otherh_dis	h_dis_refh_dis_others              r'   test_disabled_hashesz%CryptContextTest.test_disabled_hashesm  s   
 	19K=)[/:;..' 	|-I"{{	,|-I"{{E	3|-I"{{G	5  < <=LL'	M$@$@5$HIll7+m&B&BW&LM 	i0)< 	u-.*CNNGD*CNNEB*CNNIF 	./*CNNGD/034 	*CJJ;)SZZ6E*E2*CJJ@*CJJ>*CJJ	B 	*CJJ;)T[[$7U+U3*DKKAz+I#{{E	3Y/7r)   r   F)Ir   r   r   descriptionPrefixr   r   r   r   rZ   r(   r[   r   rk   rj   rs   rt   r|   r}   rv   r  rm   ry   rl   rn   rz   r   r\   r   r   r]   r   r4  rQ   r`   rq   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r-  r  r*  r/  r5  r>  rC  rF  r\  re  rq  r  r  r  r  r  r  r  r  __classcell__).0r   r   rU   s   000@r'   r+   r+   1   s   & P=MNNT*40N"!&%*#(#(M )3DF  
 
  
 
" GGLL}5M )004!F)DWW\\$7N '..q~/0@@Fx@P WW\\$7N  !&!&%*!&M !>N
 M
 ".-@O
 #"% !#%'"##'#''+!"M$b;6H<E6=:I)<V10 7JJBX"AHZ2x#CJ.(F,(<0"bHM^QDB 
r
	+&'	
B	R	
`6.?b"OHD8/BbD41OfEKN8ZtF/jtel$AL-7^Q"
OM(7@H8]1 Os   F>r+   c                   J    e Zd ZdZdZej                  ZdZdZ	 e
d      Zd Zy)r  z-dummy hasher which delays by specified amount
delay_hash(   r   z$x$c                     t        j                  | j                         t        |t              r|j                  d      }t        t        j                  d|z         j                               S )Nrb   s   prefix)
timesleepr  rV  r   rl   r   rU  sha1rW  )rT   r  s     r'   rX  zDelayHash._calc_checksum  sL    

4::fg&]]7+FW\\)f*<=GGIJJr)   N)r   r   r   __doc__r   r   LOWER_HEX_CHARSchecksum_charschecksum_sizer  r   rY  rX  rW   r)   r'   r  r    s.    7D''NMEU8LKr)   r  c                       e Zd Zd Zy)dummy_2Nr   rW   r)   r'   r  r    s    Dr)   r  c                   "    e Zd ZdZd Zd Zd Zy)LazyCryptContextTestr	   c                 F    t        d       | j                  t         d       y )Nr  )unload_handler_name
addCleanup)rT   s    r'   rQ   zLazyCryptContextTest.setUp  s    I&+Y7r)   c                    | j                  t        d             t        dd       t        t	        ddg      dg      }| j                  t        dd             | j                  |j                         d       | j                  |j                  d      j                         | j                  t        dd             y)ztest plain kwdsr  passlib.tests.test_contextr,   r   Tr  r,   N)
r  has_crypt_handlerr   r	   iterrX   r2   r   r   rG   )rT   r   s     r'   test_kwd_constructorz)LazyCryptContextTest.test_kwd_constructor  s    *956#I/KLdI{#;<+W*9d;<'?@

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

;/::;))T:;r)   N)r   r   r   r  rQ   r  r  rW   r)   r'   r  r    s    *8
<<r)   r  )Ar  
__future__r   passlib.utils.compatr   configparserr   ConfigParserr{  	functoolsr   logging	getLoggerr   logrs   rR   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   rt   abspathdirname__file__r}   r(   r+   rU  r  r   r  r  r  rW   r)   r'   <module>r     s    
 & $++   'g''1 	   : @ * M M # #N N  
wwrwwx01D8x D8T4 K   K"b %<8 %<r)   