AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.138.32.245
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python2.7/site-packages/passlib/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /lib/python2.7/site-packages/passlib/tests/test_totp.pyc
�
���Xc@sdZddlZddlmZddlZeje�ZddlZddl	Z
ddlmZddl
mZmZddlmZmZddlmZddlmZmZmZd	gZeZZejd
dfkr�ddlmZnejd
d
fkr ddlmZnd
Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'ej(j)dksnt*d��ej(j+dks�t*d��d�Z,e,�Z-d�Z.defd��YZ/dj0d�Z1e1dd Z2e1d d! Z3d"efd#��YZ4dS($s"passlib.tests -- test passlib.totpi����N(tpartial(texc(tunicodetu(tTestCaset	time_call(ttotp(tTOTPt	AppWallettAES_SUPPORTt
EngineTestii(tErrortabcdeft�t4AOGGDBBQSYHNTUZs
�c!��vΙs�]�9�0 D�y/�4&��tS3JDVB7QD2R7JPXXtJBSWY3DPEHPK3PXPs
Hello!ޭ��isunexpected float_info.radixi,s#double precision unexpectedly smallcCs�d}d}xetrs|d>}ytjj|d�j}Wntttfk
rYPnX||krjPn|}qW|d8}d}t||�S(s8
    helper to calc max_time_t constant (see below)
    iiiIЇ�:i@(tTruetdatetimetutcfromtimestamptyeart
ValueErrortOSErrort
OverflowErrortmin(tvalueRt
next_valuet	next_yeartmax_datetime_timestamp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt_get_max_time_t8s	



cCs|dddS(Niii((traw_size((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytto_b32_sizeist
AppWalletTestcBsheZdZd�Zd�Zd�Zdd�Zd�Zd�Z	de
d�Zd	�Zd
�Z
RS(spasslib.totp.AppWalletcCs%t�}|j|ji�|j|j�idd6dd6}t|�}|j|j|�|j|j�td�}|j|j|�td�}|j|jidd6dd6�td�}|j|j|�|jttd	�|jttd
�|jttidd6dd6�dS(
s-constructor -- 'secrets' param -- input typestaaat1tbbbt2s
 1: aaa
# comment
 
2: bbb   s"1: aaa: bbb 
# comment
 
2: bbb   saaa: bbbs{"1":"aaa","2":"bbb"}i{s[123]tN(	RtassertEqualt_secretstassertFalsethas_secretst
assertTruetassertRaisest	TypeErrorR(tselftwallettref((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_secrets_typesvs 	!cCs�idd6dd6dd6}t|�}|j|j|�tidtd�6dtd�6dtd�6�}|j|j|�tidd6dd6dd6�}|j|j|�|jttidd
6�tidd6�}|jttidd	6�|jttidd
6�titd�d6dd6dd6�}|j|j|�|jttidd6�|jttidd6�|jttigd6�dS(s9constructor -- 'secrets' param -- tag/value normalizationR!R"R#t02tccctCis1-2_3.4s-abcsab*$i{N(i(RR&R'RR+R,RtNone(R-R/R.((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_secrets_tags�s 3!'cCsStidd6dd6�}|j|jd�|j|j|j�d�tidd6dd6dd6�}|j|jd�|j|j|j�d�tidd6dd6dd6dd�}|j|jd�|j|j|j�d�|jttidd6dd6dd6dd�t�}|j|jd	�|jt|jd	�d	S(
s"constructor -- 'default_tag' paramtoneR"ttwoR1R!tAtdefault_tagtBN(RR&R9t
get_secretR+tKeyErrorR4(R-R.((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_default_tag�s!''	cCs?tr|o|�n%|o+|jt|�|jd��dS(Ns$'cryptography' package not installed(R	R+tRuntimeErrortskipTest(R-tcanary((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytrequire_aes_support�scCs�titd6td6�}tddddddd	d
dd�}|jdt|j|��|j|j|�d
t�tddddddd	ddd�}|j|j|�d
t�tddddddd	ddd�}|j|j|�d
t	�|j
�}|jdd�|j|j|�d
d�|j
�}|jdd�|jt
|j|�|j
�}|jdd�|jt|j|�dS(s.decrypt_key()R"R$tvitci
tst6D7N7W53O7HHS37NLUFQtktMHCTEGSNPFN5CGBJttR@itSPZJ54Y6IPUD2BYA4C6AtZGDXXTVQOWYLC2AUitFCCTARTIJWE7CPQHUDKAt D2DRS32YESGHHINWFFCELKN7Z6NAHM4Ms
�D6.F7�Qt3i�N(RtPASS1tPASS2tdictRARtdecrypt_keyR&tKEY1_RAWtKEY2_RAWtcopytupdateR+R<R(R-R.tCIPHER1tCIPHER2tCIPHER3ttemp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_decrypt_key�s(cCs�|j�titd6td6dd�}tdddddd	d
d	dd�}|j|j|�d�|j�}|jdd�|j	|j|�d�|j�}|jdd�|j	|j|�d�d
S(s$.decrypt_key() -- needs_recrypt flagR"R$tencrypt_costi
RBiRCRDtAAAARFRHiN(
RARRNRORPR(RQRTRUR*(R-R.R/RY((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_decrypt_key_needs_recrypts
 'R"cCs�|jt|�tdddddg��|j|dd�|j|d|�|j|d|j�|jt|d�t|j��|jt|d�tt|���|j|�\}}|j||�|j||�dS(s.check encrypt_key() result has expected formatRBRHRCRDRFiN(R&tsetR[tlenRt	salt_sizeRQ(R-tresultR.tkeyttagt
needs_recryptt
result_keytresult_needs_recrypt((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytassertSaneResult0s+#&cCs�titd6dd�}|jdt|jt��|jt�}|j||t�|jt�}|j||t�|j|d|d�|j|d|d�titd6dd�}|jt�}|j||t�titd6td6�}|jt�}|j||td	d�titd6�}d
|_	|jt�}|j||t�|jt
�}|j||t
�|jt|jd�dS(
s.encrypt_key()R"R[iR@RDRFiR$Rci@R%N(
RRNRARtencrypt_keyRRRgtassertNotEqualROR`RSR+R(R-R.Ratothertwallet2((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_encrypt_keyAs*	cCs�|j�tidd6�}|jd8_tt|jt�dd�\}}|jd7_tt|jt�dd�\}}|j||dd|dd	�d
S(s verify cost parameter via timingR!R"itmaxtimeiiitdeltag�?N(RARR[RRRhRRtassertAlmostEqual(R-R.Rnt_tdelta2((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_encrypt_cost_timingjs
$$N(t__name__t
__module__tdescriptionPrefixR0R5R=R4RARZR]tFalseRgRlRr(((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR os	2	%	 	&		)t12345678901234567890tasciii ii@tTotpTestcBsDeZdZdZd�Zd�Zdod�Zd�Ze	dddd	d
ddd
�Z
e	dddd�dpdqdrdsdtge	dddd
�dudvdwdxdyge	dddd�dzd{ge	dedd!dd	�d|d}d~dd�d�ge	dedd!dd.�d�d�d�d�d�d�ge	de
dd!dd5�d�d�d�d�d�d�ge	dd<dd�d�d�ge	dd<ddAd
dB�d�ge	dedd!d
dE�d�ge	dedd!dd.d
dE�d�ge	de
dd!dd5d
dE�d�ggZdI�ZdJ�ZdK�ZdL�ZdM�ZdN�ZdO�ZdP�ZdQ�ZdR�ZdS�ZdodT�ZdU�ZdV�ZdW�ZdX�ZdY�ZdZ�Z d[ddd\d]�Z!d^�Z"d_�Z#d`�Z$da�Z%dodb�Z&dodc�Z'dd�Z(de�Z)df�Z*dg�Z+dh�Z,di�Z-dj�Z.dk�Z/dl�Z0dm�Z1dn�Z2RS(�s3
    common code shared by TotpTest & HotpTest
    spasslib.totp.TOTPcCsJtt|�j�ddlm}|j�|jtd|j��dS(Ni����(tlookup_hashtrng(	tsuperRytsetUptpasslib.crypto.digestRztclear_cachet	patchAttrttotp_modulet	getRandom(R-Rz((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR}�s
cCs|j�j�tS(sY
        helper to generate random epoch time
        :returns float: epoch time
        (R�trandomt
max_time_t(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytrandtime�scKs�|j�}d|kr%t|d<n|jd|jdd��|jd|jddd	g��|jd
|jdd��|p�t|�S(s@
        helper which generates a random TOTP instance.
        Rbtnewtdigitsii
talgtsha1tsha256tsha512tperiodix(R�Rt
setdefaulttrandinttchoiceR(R-tclstkwdsR{((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytrandotp�s
"cCs�|j�}|j�}|j|j|jd�xCtd�D](}|j|jkrZPn|j�}q>W|jd�xCtd�D](}|j|jkr�Pn|j�}q�W|jd�dS(s,
        internal test -- randotp()
        skey not randomized:i
sdigits not randomizedsalg not randomizedN(R�RiRbtrangeR�tfailR�(R-totp1totp2Rp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_randotp�s
tformattbase32R�R�R�iR�iRbtACDEFGHJKL234567ii��6Tt221105i��6Tt178491i��6Tiռ6Tiּ6Tt915114t20221105t86178491t03915114sS3JD-VB7Q-D2R7-JPXXi5��Tt000492iS��Tt897212trawi;t94287082i�5:Bt07081804i�5:Bt14050471i��It89005924i�5wt69279037I��t65353130R�t46119246t68084774t67062674t91819424t90698825t77737706R�t90693936t25091201t99943326t93441116t38618901t47863826Ri�St727248i.ѡTt122419i	i)i�ѡTt	662331049i<t19360094t40857319t37023009c
cs�ddlm}x�|jD]�}|jj�}|j|d�x�|dD]�}t|�dkru|\}}}n|\}}d}tj	d||||�||�}d|j
||f}	|||||	fVqKWqWdS(	sv
        helper to iterate over test vectors.
        yields ``(totp, time, token, expires, prefix)`` tuples.
        i����(Riiis+test vector: %r time=%r token=%r expires=%rsalg=%r time=%r token=%r: N(tpasslib.totpRtvectorstvector_defaultsRTRUR_R4tlogtdebugR�(
R-RtrowR�tentryttimettokentexpirestotptprefix((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytiter_test_vectors,scCsd|jtt�|jttdddt�tdt�}tdt�}|j|j|j�dS(sconstructor -- 'new'  parameterRbt4aoggdbbqsyhntuzR�N(R+R,RRRiRb(R-R�R�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_newEs
c	CsD|jttdtdd�j�d�|jttdtdd�j�d�|jttdtdd�j�d�|jttdtd	d
�j�d
�|jttdtd	d�j�d�|jttdtd	ddd�|jttdtd	d
�|jtdt	j
dd�g��tdd�}WdQXdS(s constructor -- 'size'  parameterR�R�R�iR�i R�i@tsizei
iii	tcategoryt
message_res-.*for security purposes, secret key must be.*t0AthexNt0A0A0A0A0A0A0A0A0A(R&R_RRRbR+RtassertWarningListRPRtPasslibSecurityWarning(R-Rp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_sizeQs((((("cCs�|jtt�jt�|jttj��jt�|jtd�jt�|jttd�|jtdd�jt�|jttdd�|jttd�jt�dS(s,constructor -- 'key' and 'format' parameterss 4aog gdbb qsyh ntuz sao!ggdbbqsyhntuzte01c630c2184b076ce99R�tX01c630c2184b076ce99R�N(	R&RtKEY1RbRRtlowerR+tBase32DecodeErrortBase16DecodeError(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_key_and_formatiscCs[|jttdd�jd�|jttdd�jd�|jtttdd�dS(sconstructor -- 'alg' parameterR�sSHA-256R�tSHA256sSHA-333N(R&RR�R�R+R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_alg�scCst|jtttdd�|jttdd�jd�|jttdd�jd�|jtttdd�dS(s!constructor -- 'digits' parameterR�iii
iN(R+RRR�R&R�(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_digits�scCs�|jtt�jd�|jttdd�jd�|jtttdd�|jtttdd�|jtttdd�|jtttdd�dS(	s!constructor -- 'period' parameteriR�i?g�?tabcii����N(R&RR�R�R+R,R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_period�scCsU|jtt�jd�|jttdd�jd�|jtttdd�dS(s constructor -- 'label' parametertlabelsfoo@barsfoo:barN(R&RR�R�R4R+R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_label�scCsU|jtt�jd�|jttdd�jd�|jtttdd�dS(s!constructor -- 'issuer' parametertissuersfoo.comsfoo.com:barN(R&RR�R�R4R+R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_issuer�scCs�|jtt�jd�|jtjdd�t�jd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�dS(	susing() -- 'period' parameteriR�i?g�?R�ii����N(R&RR�R�tusingR+R,R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_using_w_period�s%cs|j�}|j|jtj�|j|jd�ttj���dg��fd�}|jdt	j
d|��}|j|jd�d�|j|jd�d�|jt
t	j
dd�d}|jt|t	j
dd	��|jt|t	j
dd
��dS(susing -- 'now' parametergH�z��^@cs�dcd7<�dS(Nii(((tcounter(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytnow�sR�R�i~ii{s)now\(\) function must return non-negativecSsdS(NR�((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt<lambda>�scSsdS(Ni����((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR��sN(R�tassertIsR�t_timeR�Rotnormalize_timeR4tintRR�R&R+R,tassertRaisesRegextAssertionError(R-R�R�tmsg_re((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_using_w_now�s%	cCs|dkr!|jdd�}n|j|jtd��d�|j|jd�d�|j|jd�d�|j|jd�d�|jt|jd�|jt|jd�|jtj|jd�|jtj|jd	�|jtj|jd
�dS(s$normalize_token() -- instance methodR�it1234567i��iG�t0234567g��2At123456t01234567iNa�N(	R4R�R&tnormalize_tokenRR+R,RtMalformedTokenError(R-R�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_normalize_token_instance�scCs |jdtjdd��dS(s!normalize_token() -- class methodR�R�iN(R�RR�(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_normalize_token_classscs)tj�}|j|�}x�td�D]�}|j��t��}|j|j��|�|j|j|d�|�|j|j|�|�tjj	��}|j|j|�|�|j
}z5t�fd��|_
|j|jd�|�Wd||_
Xq(W|j
t|jd�dS(snormalize_time()i
g�?cs�S(N(((R�(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR�sNt1234(RR�R�R�R�R�R&R�RRR�tstaticmethodR4R+R,(R-tTotpFactoryR�Rpttinttdttorig((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_normalize_times 	cCs|j�}ttd�}|j|jt�|j|jd�|j|jt�|j|j�d�|j|jdd�d�|j|jdt	�t�|j|jdd�d	�td
t
d|jdd
��}|j}|j}|j�}dS(s pretty_key() and .key attributesR�R�s4AOG-GDBB-QSYH-NTUZtsept s4AOG GDBB QSYH NTUZR�R�se01c-630c-2184-b076-ce99R�R�i
iN(R�RRRR&Rbthex_keyt
base32_keyR�t
pretty_keyRvRR�(R-R{R�Rp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_key_attrs$s!		cCs�ddlm}m}|d�}|jd�}|j||�|j|jd�|j|jd�|j|jd�|j|d�|jt	|�d�|j|d	d�|j|d
d�|j
t|jd�|j
t|jd�|j
|�d�|_|j|jd
�|j
|j�d�|_|j|jd	�|j|j�|jd�}|j||�|j||�|jd�}|j||�|j||�|jd�}|j||�dS(sgenerate() -- TotpToken() classi����(Rt	TotpTokents3jdvb7qd2r7jpxxiS��TR�i��iT��Tiiii����cSsdS(Ng�Tn'�A((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR�Rsg�?cSsdS(NiU��T((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR�Vsi7��TiW��TN(R�iT��T(R�RRtgeneratetassertIsInstanceR&R�R�texpire_timeR_R+t
IndexErrort__getitem__R*R�t	remainingtvalidR(tassertIsNotRi(R-RRR�Ratresult2tresult3tresult4((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_token=s8
csMddlm}|dt�}|j��|j��}|j}|j|t�|jd}|j	|j|d�j|�|j
|j|d�j|�tjj��}|j	t
|j|��t
���|j	|j|�j|�|jd�fd��d|j�}|j	|j�j|�|jt|jd�d	S(
s
generate()i����(RR�iiR�cs�S(N(((R�(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR��sRbN(R�RRR�RR�R	RR�R&RiRRR�R�R�RR+R(R-RR�RaR�t
start_timeR�R�((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt
test_generatehs	
  %'cCs�x�|j�D]y\}}}}}|j|�}|j|j|d|�|j|j||jd|�|r
|j|j|�q
q
WdS(sgenerate() -- reference vectorstmsgN(R�RR&R�R�R�R
(R-R�R�R�R�R�Ra((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt!test_generate_w_reference_vectors�s" iR%cCs�ddlm}|j||�|j|jt�|j|jj|�|j|j|d|d�||}||}	|j|j|	d|d�|j|j	|d|d�|j|j
|d|d�|j|j||�|	d|}
|j|j|
�|j|j
|
|�|jt|�d	�|j||	|f�|jt|jd
�|j|d|	�|j|d|�|jt|jd	�|j|�dS(Ni����(t	TotpMatchRs matched time:s matched counter:s expected counter:s	 skipped:iii����i(R�RR	RRR&R�R�R�texpected_countertskippedt
cache_secondsR
t
cache_timeR_R+RRR*(R-tmatchR�RR�twindowRRtexpectedR�R
((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytassertTotpMatch�s*

cs\d�d}tjd�fd��t�}|j|��}|j|d�dd�dS(	s!match() -- valid TotpMatch objecti�kt781501R�cs�dS(Niii�Q(((R�(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR��sR�RiN(RR�tKEY3RR (R-R�R�Ra((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_valid_token�s
!cstddlm}d�d}tjd�fd��t�}|j|�d�}|j|d�dd	d
�dS(s3match() -- valid TotpMatch object with future tokeni����(Ri�kR!R�cs�dS(Niii�Q(((R�(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR��siR�RiN(R�RRR�R"RR (R-RR�R�Ra((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_older_token�s!csdd�d}tjd�fd��t�}|j|�d�}|j|d�ddd�d	S(
s1match() -- valid TotpMatch object with past tokeni�kR!R�cs�dS(Niii�Q(((R�(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR��siR�Ri����N(RR�R"RR (R-R�R�Ra((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_new_token�s
!csQd�d}tjd�fd��t�}|jtj|j|�d�dS(s#match() -- invalid TotpMatch objecti�kR!R�cs�dS(Niii�Q(((R�(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR��si<N(RR�R"R+RtInvalidTokenErrorR(R-R�R�((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_invalid_token�s!c	Ks�d|j|j|j|||f}|j|||�}|j|d|j|�d|jd|jdd�d|d|�dS(	s,helper to test otp.match() output is corrects5key=%r alg=%r period=%r token=%r gen_time=%r time=%r:R�R�RiRRN(RR�R�RR R�tget(	R-texpect_skippedR�R�R�tgen_timeR�RRa((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytassertVerifyMatches�s"	cKsGd|j|j|j|||f}|j||j||d||�S(s/helper to test otp.match() throws correct errors5key=%r alg=%r period=%r token=%r gen_time=%r time=%r:t__msg__(RR�R�R+R(R-t	exc_classR�R�R�R*R�R((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytassertVerifyRaises�s"c	Cs�|j�}|j}|j�}|j|�j}td|d|�}t|j|�}t|j|�}|t	j
|||dd�|d
|||d|�|d
|||dd|�|d||dd�|t	j
|||dd�|d|||d|�|d|||dd|�|t	j
||d|dd�|t	j
||d|d|�|d||d|dd|�tjj|�}|d||dd�|t
|d�d	S(
s)match() -- 'time' and 'window' parametersR�R*Riiii����i����N(R�R�R�RR�RPRR+R.RR&RRR(	R-R�R�R�R�tcommont
assertMatchesR+R�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_match_w_window�s(	!!"
c
Cs|j�}|j}|j�}td|d|�}t|j|�}t|j|�}d|}|j||�j}|t	j
||dd�|d||ddd|�|j||�j}	|t	j
|	|dd�|d
|	|ddd|�dS(	smatch() -- 'skew' parametersR�R*iRii����tskewN(R�R�R�RPRR+R.RR�RR&(
R-R�R�R�R/R0R+R2tbehind_tokentahead_token((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_match_w_skew$s	
cCsY|j�}|j}|j�}|j|�}|j}|j}|j}td|d|�}t|j	|�}	t|j
|�}
|	d|||d|�|	d|||d|dd|�|
tj||d|d|d|�|
tj
|||d|d|�}|j|j|�|
tj
||d|dd�}|j|j|�d	S(
s0match() -- 'reuse' and 'last_counter' parametersR�R*i����Rtlast_counteriiiN(R�R�R�RR�R�R
RPRR+R.RR&tUsedTokenErrorR&(R-R�R�R�ttdataR�R�R
R/R0R+terr((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_match_w_reuse;s*				
cCs�td�}|j}d}|j|d|��|j|d|��|jtj|d|�|jtj|d|�|jtj|d|�dS(	smatch() -- token normalizationtotxl2f5cctbprpzxi�6Ts    3 32-136  t332136t12345t12345Xt0123456N(RRR*R+RR�(R-R�RR�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_match_w_token_normalizationds	cCs�x�|j�D]}\}}}}}|j}|||�}|j|�|j|j||jd|�|jtj|||ddd�q
WdS(smatch() -- reference vectorsRidRiN(	R�RR*R&R�R�R+RR&(R-R�R�R�R�RRRa((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_match_w_reference_vectorszs"	
 cs0ddlm}d�|jd�fd��}tdddd	d
d�}|jd|�}|j|d
��tdddd	d
d�}|jtj|jd|�tdddd	�}|jt	|jd|�d}|jd|�}|j|d
��d}|jd|�}|j|d
��dS(sverify()i����(Ri�6TR�cs�S(N(((R�(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR��sRBittypeRRbR;R<R�t332155s3{"v": 1, "type": "totp", "key": "otxl2f5cctbprpzx"}s,otpauth://totp/Label?secret=otxl2f5cctbprpzxN(
R�RR�RPtverifyR R+RR&R(R-RR�tsource1Rtsource1jsont
source1uri((R�s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_verify�s cCs�ddlm}|j}|td��}|j|jt�|d�}|j|jt�|tdddddt��}|j|jt�|td	��}|j|jt�|d	�}|j|jt�|j	||�|�t
�}|jd
|�j|�}|j||�|j|j
�|j
��|jd
|�j|�}|j	||�|jt|td��|jt|d�dS(
s
from_source()i����(RsNotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=ExampleRBiRBRRbs3{"v": 1, "type": "totp", "key": "JBSWY3DPEHPK3PXP"}R.tfooN(R�Rtfrom_sourceRR&RbtKEY4_RAWRPtKEY4R�RR�Rtto_dictR+R(R-RRJR�twallet1R�R�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_from_source�s*	!	cCs�ddlm}|j}|d�}|j||�|j|jt�|j|jd�|j|jd�|j|j	d�|j|j
d�|j|jd�|d	�}|j|jt�|jt
|d
�|jt|d�|d�}|j|jd
�|j|jd�|d�}|j|jd�|j|jd�|d�}|j|jd�|j|jd�|jt
|jd�|d�}|j|j	d�|jt
|d�|d�}|j|jd�|jt
|d�|jt
|d�|jt
|d�|d�}|j|j
d�|jt
|d�|jt
|d�|jtd tjd!d"�g��|d#�}Wd$QX|j|jt�|j|j
d�d$S(%s
from_uri()i����(RsNotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Examplesalice@google.comtExampleR�iisNotpauth://totp/Example:alice@google.com?secret=jbswy3dpehpk3pxp&issuer=Examples0otpauth://totp/Example:alice@google.com?digits=6s?otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHP@3PXPsOotpauth://totp/Provider1:Alice%20Smith?secret=JBSWY3DPEHPK3PXP&issuer=Provider1sAlice Smitht	Provider1sMotpauth://totp/Big%20Corporation%3A%20alice@bigco.com?secret=JBSWY3DPEHPK3PXPsalice@bigco.comsBig CorporationsOotpauth://totp/alice@bigco.com?secret=JBSWY3DPEHPK3PXP&issuer=Big%20CorporationsGotpauth://totp/Provider1:alice?secret=JBSWY3DPEHPK3PXP&issuer=Provider2sPotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&algorithm=SHA256R�sPotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&algorithm=SHA333sHotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&digits=8isHotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&digits=AsJotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&digits=%20sIotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&digits=15sIotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&period=63i?sHotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&period=0sIotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&period=-1R�R�s!unexpected parameters encounteredsQotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&foo=bar&period=63N(R�Rtfrom_uriR	R&RbRKR�R�R�R�R�R+RR�R�RPRtPasslibRuntimeWarningRRL(R-RRRR�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt
test_from_uri�sT	cCsLttdddddd�}|j|jdd�d	�|jt|jdd�|j|jd�d
�d|_|j|j�d
�d|_|j|j�d	�|jt|jd�|jt|jdd�|jttdd
�jd�d�|jttdd�jd�d�|jttdd�jd�d�dS(sto_uri()R�R�R�iR�isalice@google.comsExample OrgsLotpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example%20Orgs7otpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXPslabel:with:semicolonssissuer:with:semicolonsR�sHotpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP&algorithm=SHA256is@otpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP&digits=8i?sAotpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP&period=63N(	RRLR&tto_uriR+RR4R�R�(R-R�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_to_uriUs(		cCsddlm}|j}|tdddddtdd	d
d��}|j||�|j|jt�|j|j	d	�|j|j
d�|j|jd�|j|jd
�|j|j
d�|jt|tdddt��|jt|tdddddt��|jt|tdddddt��|jt|tdddt��|tdddddtj�dd	d
d��}|j|jt�|jt|tdddd��|jt|tdddddd��|tdddddtddd
d��}|j|j	d�|j|j
d�|tdddddtdd��}|j|jd�|jt|tdddddtdd��|tdddddtdd��}|j|j
d�|jt|tdddddtdd��|jt|tdddddtdd��|tdddddtdd��}|j|jd�|jt|tdddddtdd��|jt|tdddddtdd��|jt|tdddddtdd��dS( sfrom_dict()i����(RRBiRBRRbR�salice@google.comR�RPR�iiii�sJBSWY3DPEHP@3PXPsAlice SmithRQR�R�tsha333R�iR8iR�i?tINVALIDi{N(R�Rt	from_dictRPRLR	R&RbRKR�R�R�R�R�R+RR�R�R,(R-RRYR�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_from_dict�sD	-"(("3"-'.'..'..c
Cs�ttdddddd�}|j|j�tddd	d
dt��ttdddddddd
dd�}|j|j�tddd	d
dtdd
dd��ttdddddddd
�}|j|j�tddd	d
dtdd
��ttdddddddd�}|j|j�tddd	d
dtdd��tjdd�}|t�}|j|j�tddd	d
dt��|tdd�}|j|j�tddd	d
dt��|jttdd�j�tddd	d
dtdd��|jttdd�j�tddd	d
dtdd��|jttdd�j�tddd	d
dtdd��dS(s	to_dict()R�R�R�iR�iRBiRBRRbR�salice@google.comR�sExample OrgR�ii?N(RRLR&RMRPR�(R-R�R�((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_to_dict�s8+	
	
++""N(i��6TR�(i��6TR�(i��6TR�(iռ6TR�(iּ6TR�(i��6TR�(i��6TR�(i��6TR�(iռ6TR�(iּ6TR�(i5��TR�(iS��Ts897212(i;R�(i�5:BR�(i�5:BR�(i��IR�(i�5wR�(I��R�(i;R�(i�5:BR�(i�5:BR�(i��IR�(i�5wR�(I��R�(i;R�(i�5:BR�(i�5:BR�(i��IR�(i�5wR�(I��R�(i�SR�(i.ѡTR�(i�ѡTR�(i�5:BR�(i�5:BR�(i�5:BR�(3RsRtt__doc__RuR}R�R4R�R�RPR�tRFC_KEY_BYTES_20tRFC_KEY_BYTES_32tRFC_KEY_BYTES_64R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRR R#R$R%R'R+R.R1R5R:R@RARHRORTRVRZR[(((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRy�s�	
		!$*					
						"				+	 	!		
				0		)			$	/	w	=	^(5R\Rt	functoolsRtloggingt	getLoggerRsR�tsysR�R�tpasslibRtpasslib.utils.compatRRtpasslib.tests.utilsRRRR�R�RRR	t__all__R,R�R�tversion_infotbinasciiRRNROR�RRRSR"RLRKt
float_infotradixR�tmant_digRR�RR tencodeR]R^R_Ry(((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt<module>sH	
	/		�

Anon7 - 2022
AnonSec Team