Viewing File: /usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyo

ó
ö
5Xc@€s]dZddlmZddlmZddlZddlZyddlmZWne	k
rke
ZnXddlmZddl
mZmZmZddlmZmZddljjZdd	lmZmZdd
lmZmZmZ ee!ƒZ"defd„ƒYZ#d
efd„ƒYZ$dej%fd„ƒYZ&defd„ƒYZ'dS(stests for passlib.context

this file is a clone of the 1.5 test_context.py,
containing the tests using the legacy CryptPolicy api.
it's being preserved here to ensure the old api doesn't break
(until Passlib 1.8, when this and the legacy api will be removed).
iÿÿÿÿ(twith_statement(t	getLoggerN(tresource_filename(thash(tCryptContexttCryptPolicytLazyCryptContext(tto_bytest
to_unicode(tTestCasetset_file(tregister_crypt_handler_patht_has_crypt_handlert_unload_handler_nametCryptPolicyTestcB€sQeZdZdZdZejjejjejj	e
ƒdƒƒZejjeƒrpe
rpe
ddƒZneddddd	gd
dddd
dddddddƒZidd6dd
6dd6dd6dd6dd6dd6Zedejejejejgd
dddd
dddddddƒZdZeddd
ddddd ƒZeddddd	gd
dddddd
ddddddd ƒZed
d	ƒZeddddd	gd
d	ddddd
ddddddd ƒZd!Zedd	gdddd"d#d$d%dƒZed&ZejƒZ e j!d'dgd(ddgƒejƒZ"e"j!idd'6d)d*6ƒejƒZ#e#j!idgd'6ddgd(6ƒ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„Z0d8„Z1d9„Z2d:„Z3d;„Z4d<„Z5RS(=stest CryptPolicy objectRsî[passlib]
schemes = des_crypt, md5_crypt, bsdi_crypt, sha512_crypt
default = md5_crypt
all.vary_rounds = 10%%
bsdi_crypt.max_rounds = 30000
bsdi_crypt.default_rounds = 25000
sha512_crypt.max_rounds = 50000
sha512_crypt.min_rounds = 40000
ssample_config_1s.cfgs
passlib.teststschemest	des_cryptt	md5_cryptt
bsdi_crypttsha512_crypttdefaulttall__vary_roundsgš™™™™™¹?tbsdi_crypt__max_roundsi0utbsdi_crypt__default_roundsi¨atsha512_crypt__max_roundsiPÃtsha512_crypt__min_roundsi@œs.des_crypt, md5_crypt, bsdi_crypt, sha512_cryptsall.vary_roundssbsdi_crypt.max_roundssbsdi_crypt.default_roundsssha512_crypt.max_roundsssha512_crypt.min_roundssˆ[passlib]
bsdi_crypt.min_rounds = 29000
bsdi_crypt.max_rounds = 35000
bsdi_crypt.default_rounds = 31000
sha512_crypt.min_rounds = 45000
tbsdi_crypt__min_roundsiHqi¸ˆiyiȯs£
[passlib]
schemes = sha512_crypt
all.vary_rounds = 10%%
default.sha512_crypt.max_rounds = 20000
admin.all.vary_rounds = 5%%
admin.sha512_crypt.max_rounds = 40000
i Ntadmin__all__vary_roundsgš™™™™™©?tadmin__sha512_crypt__max_roundssJdeprecated = des_crypt
admin__context__deprecated = des_crypt, bsdi_crypt
t
deprecatedtadmin__context__deprecatedsdes_crypt, bsdi_cryptsadmin.context.deprecatedcC€sQtj|ƒtjddƒtjddƒtjddƒtjddƒdS(Ntignores)The CryptPolicy class has been deprecateds,the method.*hash_needs_update.*is deprecateds The 'all' scheme is deprecated.*sbsdi_crypt rounds should be odd(R	tsetUptwarningstfilterwarnings(tself((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR Ñs
		cC€sot|j}|j|jƒ|jƒt|jƒ}|j|jƒ|jƒ|jttiiƒ|jttiddƒ|jttdddddgdd	ƒd
tjfd„ƒY}|jttd|gƒ|jttdtjgƒdtjfd
„ƒY}|jt	td||gƒ|jt	tddgddgƒ|jt	tddgddƒdS(stest CryptPolicy() constructortdummyiRRRRRt bad__key__bsdi_crypt__max_roundsi0utnamelesscB€seZdZRS(N(t__name__t
__module__tNonetname(((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR&ìstdummy_1cB€seZdZRS(R+(R'R(R*(((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR+ôsRRN(
Rtsample_config_1pdtassertEqualtto_dicttassertRaisest	TypeErrortuht
StaticHandlert
ValueErrortKeyError(R#tpolicyR&R+((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_00_constructorÚs(	
	cC€sO|j}tj|ƒ}|j|jƒ|jƒ|jttj|dƒdS(s(test CryptPolicy.from_path() constructortxxxN(tsample_config_1s_pathRt	from_pathR-R.R,R/tEnvironmentError(R#tpathR5((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_01_from_path_simples	cC€sß|jƒ}t||jƒtj|ƒ}|j|jƒ|jƒt||jjddƒƒtj|ƒ}|j|jƒ|jƒt	|jdddƒ}t||ƒtj|ddƒ}|j|jƒ|jƒdS(s7test CryptPolicy.from_path() constructor with encodingss
s
sutf-16tsource_encodingsutf-8tencodingN(
tmktempR
tsample_config_1sRR9R-R.R,treplaceR(R#R;R5tuc2((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_01_from_paths
cC€stj|jƒ}|j|jƒ|jƒtj|jjddƒƒ}|j|jƒ|jƒt|jƒ}tj|ƒ}|j|jƒ|jƒt|jdddƒ}tj|ddƒ}|j|jƒ|jƒtj|j	ƒ}|j|jƒ|j
ƒdS(s*test CryptPolicy.from_string() constructors
s
sutf-16R=sutf-8R>N(Rtfrom_stringR@R-R.R,RARRtsample_config_4stsample_config_4pd(R#R5tdataRB((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_02_from_string"scC€sÖtj|jƒ}|j|jƒ|jƒtj|jƒ}|j|jƒ|jƒtj|jjƒƒ}|j|jƒ|jƒtj|ƒ}|j||ƒ|j	t
tjdƒ|j	t
tjgƒdS(s*test CryptPolicy.from_source() constructoriN(Rtfrom_sourceR8R-R.R,R@tcopytassertIsR/R0(R#R5tp2((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_03_from_source;scC€s‚|jttjgƒtj|jgƒ}|j|jƒ|jƒtj|j|j	|j
gƒ}|j|jƒ|jƒdS(s+test CryptPolicy.from_sources() constructorN(R/R3Rtfrom_sourcesR@R-R.R,R8tsample_config_2stsample_config_3pdtsample_config_123pd(R#R5((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_04_from_sourcesQscC€s”t|j}|j|j}|j|jƒ|jƒ|j|j}|j|jƒ|jƒ|j|jƒ}|j|jƒ|jƒdS(s&test CryptPolicy.replace() constructorN(	RR,RAtsample_config_2pdR-R.tsample_config_12pdRPRQ(R#tp1RLtp2btp3((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_05_replacedscC€sd|jttddgddƒ|jttddgddƒ|jttddgddgƒdS(	s!test CryptPolicy() forbidden kwdsRRtdes_crypt__salttxxt	all__salttuser__context__schemesRN(R/R4R(R#((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_06_forbiddenus			cC€sIt|j}|j|jƒƒt|j}|j|jƒƒdS(stest has_schemes() methodN(RR,t
assertTruethas_schemesRP(R#RURW((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_10_has_schemes‹scC€sgt|j}|jd}|jt|jƒƒ|ƒt|j}|jt|jƒƒgƒdS(stest iter_handlers() methodRN(RR,tsample_config_1prdR-tlistt
iter_handlersRP(R#RUtsRW((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_11_iter_handlers”s

cC€s}t|j}|j|jdƒtjƒ|j|jdƒdƒ|jt|jddt	ƒ|j|jƒtj
ƒdS(stest get_handler() methodRtsha256_crypttrequiredN(RR,RKtget_handlerRRR)R/R4tTrueR(R#RU((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_12_get_handleržs
cC€st|j}|j|jdƒtdddddddd	ƒƒ|j|jd
ƒtddddddƒƒtj|jƒ}|j|jd
ƒtdddd
ƒƒ|j|jd
dƒtdddd
ƒƒ|j|jd
dƒtddddƒƒdS(stest get_options() methodRtvary_roundsgš™™™™™¹?t
min_roundsiHqt
max_roundsi¸ˆtdefault_roundsiyRiȯiPÃi Ntusertadmingš™™™™™©?i@œN(RRTR-tget_optionstdictRDRE(R#tp12tp4((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_13_get_options­s(



cC€s•t|j}t|j}|j|jdƒƒ|j|jtjƒƒ|j|jdƒƒ|j|jdƒƒ|j|jtjƒƒ|j|jdƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒtdddgddgd	dgƒ}|j|jdƒƒ|j|jdƒƒ|j|jddƒƒ|j|jddƒƒd
S(s#test handler_is_deprecated() methodRRRoRRpRRRtuser__context__deprecatedN(RR,tsample_config_5pdtassertFalsethandler_is_deprecatedRRR^(R#tpatpbtpc((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_14_handler_is_deprecatedÔs(	cC€stjddtƒtƒ}|j|jƒdƒ|j|jdƒdƒ|jddƒ}|j|jƒdƒ|j|jdƒdƒdS(s!test get_min_verify_time() methodRtcategoryiRptmin_verify_timegš™™™™™¹?N(R!R"tDeprecationWarningRR-tget_min_verify_timeRA(R#RzR{((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_15_min_verify_timeòs	cC€s|t|j}|jt|jƒƒ|jƒ|jt|jdtƒƒ|jƒ|jt|jdtƒƒ|jƒdS(stest iter_config() methodtresolvetiniN(RRwR-Rrtiter_configRitsample_config_5prdtsample_config_5pid(R#tp5((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_20_iter_configs%cC€sKt|j}|j|jƒ|jƒ|j|jdtƒ|jƒdS(stest to_dict() methodRƒN(RRwR-R.RiR†(R#Rˆ((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_21_to_dict	scC€sit|j}|jƒ}tj|ƒ}|j|jƒ|jƒ|jddƒ}|j|tƒdS(stest to_string() methodR>slatin-1N(RRwt	to_stringRDR-R.tassertIsInstancetbytes(R#RzRdR{((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_22_to_strings(6R'R(t__doc__tdescriptionPrefixR@tosR;tabspathtjointdirnamet__file__R8texistsRRrR,tsample_config_1pidRRRRRRaRORSRTRPRQRERFtsample_config_5sRJRwtupdateR‡R†R R6R<RCRHRMRRRXR]R`ReRjRuR}R‚R‰RŠRŽ(((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR%sÂ	
					
				
		
			(										
		'				tCryptContextTestcB€s§eZdZdZd„Zd„Zd„Zd„Zedddd	d
dgddgd
dddddddddddddddddƒZ	d„Z
d„ZRS(stest CryptContext classRcC€sQtj|ƒtjddƒtjddƒtjddƒtjddƒdS(NRs3CryptContext\(\)\.replace\(\) has been deprecated.*s9The CryptContext ``policy`` keyword has been deprecated.*s=.*(CryptPolicy|context\.policy).*(has|have) been deprecated.*s,the method.*hash_needs_update.*is deprecated(R	R R!R"(R#((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR $s
			cC€s›ttjtjtjgƒ}|jjƒ\}}}|j|tjƒ|j|tjƒ|j|tjƒtdddgƒ}|jjƒ\}}}|j|tjƒ|j|tjƒ|j|tjƒ|j}td|ƒ}|j|j	ƒ|j	ƒƒtd|ddƒ}|j
|j	ƒ|j	ƒƒ|j|j	ƒtddddgddƒƒ|jt
t|ddƒ|jt
tddƒdS(	stest constructorRRRR5RRtxN(RRRRRR5RcRKR-R.tassertNotEqualRrR/R0tsetattrR)(R#tcctctbtaR5((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR61s&	$
cC€stdddgƒ}|j|jjƒtjƒ|jƒ}|j||ƒ|jddƒ}|j||ƒ|j|jjƒtjƒdS(stest replace()RRRRN(	RRKR5RhRRRAtassertIsNotR(R#Ržtcc2tcc3((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_01_replaceNscC€sÊtƒ}|jt|jddtƒ|jt|jdƒ|jt|jddƒtdgƒ}tdgƒ}||_|jt|jddtƒ|jt|jdƒ|jt|jddƒdS(stest no handlersRRgtsecretRRN(	RR/R4tidentifyRiRtverifyRR5(R#Ržtp((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_02_no_handlers_s		RRRtphpassRRfRRRiRitbsdi_crypt__vary_roundsitsha256_crypt__max_roundsi¸tsha256_crypt__min_roundsiÐtsha256_crypt__default_roundst
phpass__identtHtphpass__default_roundsicC€s—t|j}|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|j|jdƒƒdS(stest hash_needs_update() methodt
9XXD4trGYeGJAs"$1$J8HC2RCr$HcmM.7NxB2weSvlw2FgzU0sK$5$rounds=1999$jD81UCoo.zI.UETs$Y7qSTQ6mTiU9qZB4fRr43wRgQq4V.5AAf7F97Pzxey/sK$5$rounds=2000$228SSRje04cnNCaQ$YGV4RYu.5sNiBvorQDlO0WWQjyJVGKBcJXz3OtyQ2u8sK$5$rounds=3000$fS9iazEwTKi7QPW4$VasgBC8FqlOvD7x2HhABaMXCTh9jwHclPA9j5YQdns.sK$5$rounds=3001$QlFHHifXvpFX4PLs$/0ekt7lSs/lOikSerQ0M/1porEHxYq7W/2hdFpxA3fAN(Rtsample_policy_1R^thash_needs_updateRx(R#Rž((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_12_hash_needs_updateƒscC€s£tjddƒtdgƒ}xXdifdidd6fdifdifgD]%\}}|jt|j||qQWtdgƒ}|jt|jdƒdS(	s'test non-string hash values cause errorRs0.*needs_update.*'scheme' keyword is deprecated.*Rtschemeitmysql323N((R!R"RR)R/R0Rµ(R#RžRtkwdsR£((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_30_nonstring_hash–s		(R'R(RRR R6R¥RªRrR´R¶Rº(((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyRš s*	
							tdummy_2cB€seZdZRS(R»(R'R(R*(((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR»³stLazyCryptContextTestcB€s)eZdZd„Zd„Zd„ZRS(RcC€sKtj|ƒtdƒ|jtdƒtjddƒtjddƒdS(NR»Rs1CryptContext\(\)\.replace\(\) has been deprecateds=.*(CryptPolicy|context\.policy).*(has|have) been deprecated.*(R	R tunload_handler_namet
addCleanupR!R"(R#((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR ¹s

	cC€s©|jtdƒƒtddƒttddgƒddgƒ}|jtdtƒƒ|j|jjdƒƒ|j	|jj
ƒddgƒ|jtdtƒƒdS(stest plain kwdsR»spasslib.tests.test_contextRRN(Rxthas_crypt_handlerRRtiterRiR^R5RyR-R(R#Rž((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_kwd_constructorÅs
!c€s¯ˆjtdƒƒtddƒt‡fd†}td|dtƒ}ˆjtdtƒƒˆj|jjdƒƒˆj	|jj
ƒddgƒˆjtdtƒƒdS(s0test create_policy() hook, returning CryptPolicyR»spasslib.tests.test_contextc€s/ˆj|ƒtdtddgƒddgƒS(NRR»RR(R^RRÀ(tflag(R#(sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyt
create_policyØs
RÃRÂRN(RxR¿RtFalseRRiR^R5RyR-R(R#RÃRž((R#sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyttest_callable_constructorÓs
(R'R(RR RÁRÅ(((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyR¼¶s		((Rt
__future__RtloggingRR‘R!t
pkg_resourcesRtImportErrorR)tpasslibRtpasslib.contextRRRt
passlib.utilsRRtpasslib.utils.handlerstutilsthandlersR1tpasslib.tests.utilsR	R
tpasslib.registryRRR¿R
R½R'tlogRRšR2R»R¼(((sI/usr/lib/python2.7/site-packages/passlib/tests/test_context_deprecated.pyt<module>s(

ÿü“
Back to Directory File Manager