Xc@sdZddlZddlmZddlZejeZddlZddl Z ddl m Z ddl mZmZddlmZmZddl mZddlmZmZmZd gZeZZejd d fkrdd lmZnejd d fkr dd lmZnd Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'ej(j)dksnt*dej(j+dkst*ddZ,e,Z-dZ.defdYZ/dj0dZ1e1dd Z2e1d d! Z3d"efd#YZ4dS($s"passlib.tests -- test passlib.totpiN(tpartial(texc(tunicodetu(tTestCaset time_call(ttotp(tTOTPt AppWallett AES_SUPPORTt EngineTestii(tErrortabcdeftt4AOGGDBBQSYHNTUZs c !vΙs]90 Dy/4&tS3JDVB7QD2R7JPXXtJBSWY3DPEHPK3PXPs Hello!ޭisunexpected float_info.radixi,s#double precision unexpectedly smallcCsd}d}xetrs|d>}ytjj|dj}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.pyt to_b32_sizeist AppWalletTestcBsheZdZdZdZdZd dZdZdZ de dZ d Z d Z RS( spasslib.totp.AppWalletcCs%t}|j|ji|j|jidd6dd6}t|}|j|j||j|jtd}|j|j|td}|j|jidd6dd6td}|j|j||jttd |jttd |jttidd6d d6d 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( Rt assertEqualt_secretst assertFalset has_secretst assertTruet assertRaisest TypeErrorR(tselftwallettref((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_secrets_typesvs     ! cCsidd6dd6dd6}t|}|j|j|tidtd6dtd6dtd6}|j|j|tidd6dd6dd6}|j|j||jttidd 6tidd6}|jttidd 6|jttidd 6titdd6dd6dd6}|j|j||jttid d6|jttid d6|jttigd6d 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_tagss  3!'cCsStidd6dd6}|j|jd|j|j|jdtidd6dd6dd6}|j|jd|j|j|jdtidd6dd6dd6dd}|j|jd|j|j|jd|jttidd6dd6dd6ddt}|j|jd |jt|jd d S( s"constructor -- 'default_tag' paramtoneR"ttwoR1R!tAt default_tagtBN(RR&R9t get_secretR+tKeyErrorR4(R-R.((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_default_tags!'' cCs?tr|o|n%|o+|jt||jddS(Ns$'cryptography' package not installed(R R+t RuntimeErrortskipTest(R-tcanary((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytrequire_aes_supportsc Cstitd6td6}tddddddd d d d}|jd t|j||j|j|d ttddddddd dd d}|j|j|d ttddddddd dd d}|j|j|d t |j }|j d d|j|j|d d|j }|j d d|j t |j||j }|j dd|j t|j|dS(s.decrypt_key()R"R$tvitci tst6D7N7W53O7HHS37NLUFQtktMHCTEGSNPFN5CGBJttR@itSPZJ54Y6IPUD2BYA4C6AtZGDXXTVQOWYLC2AUitFCCTARTIJWE7CPQHUDKAt D2DRS32YESGHHINWFFCELKN7Z6NAHM4Ms D6.F7Qt3iN(RtPASS1tPASS2tdictRARt decrypt_keyR&tKEY1_RAWtKEY2_RAWtcopytupdateR+R<R(R-R.tCIPHER1tCIPHER2tCIPHER3ttemp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_decrypt_keys(   c Cs|jtitd6td6dd}tdddddd d d d d}|j|j|d|j}|jdd |j |j|d|j}|jd d|j |j|dd 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|dt|j|jt|dtt||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+#&cCstitd6dd}|jdt|jt|jt}|j||t|jt}|j||t|j|d|d|j|d|dtitd6dd}|jt}|j||ttitd6td6}|jt}|j||td dtitd6}d |_ |jt}|j||t|jt }|j||t |j t |jd d S( s.encrypt_key()R"R[iR@RDRFiR$Rci@R%N( RRNRARt encrypt_keyRRRgtassertNotEqualROR`RSR+R(R-R.Ratothertwallet2((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_encrypt_keyAs* cCs|jtidd6}|jd8_tt|jtdd\}}|jd7_tt|jtdd\}}|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@tTotpTestcBsDeZdZdZdZdZdodZdZe dddd d d d d Z e ddd ddpdqdrdsdtge ddd d dudvdwdxdyge ddd ddzd{ge de dd!dd d|d}d~dddge de dd!dd.ddddddge de dd!dd5ddddddge dd<d dddge dd<d dAd dBdge de dd!d dEdge de dd!dd.d dEdge de dd!dd5d dEdgg ZdIZdJZdKZdLZdMZdNZdOZdPZdQZdRZdSZdodTZdUZdVZdWZdXZdYZdZZ d[d d d\d]Z!d^Z"d_Z#d`Z$daZ%dodbZ&dodcZ'ddZ(deZ)dfZ*dgZ+dhZ,diZ-djZ.dkZ/dlZ0dmZ1dnZ2RS(s3 common code shared by TotpTest & HotpTest spasslib.totp.TOTPcCsJtt|jddlm}|j|jtd|jdS(Ni(t lookup_hashtrng( tsuperRytsetUptpasslib.crypto.digestRzt clear_cachet patchAttrt totp_modulet getRandom(R-Rz((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyR}s cCs|jjtS(sY helper to generate random epoch time :returns float: epoch time (Rtrandomt max_time_t(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytrandtimescKs|j}d|kr%t|dW|jdxCtdD](}|j|jkrPn|j}qW|jddS(s, internal test -- randotp() skey not randomized:i sdigits not randomizedsalg not randomizedN(RRiRbtrangeRtfailR(R-totp1totp2Rp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_randotps   tformattbase32RRRiRiRbtACDEFGHJKL234567ii6Tt221105i6Tt178491i6Tiռ6Tiּ6Tt915114t20221105t86178491t03915114sS3JD-VB7Q-D2R7-JPXXi5Tt000492iSTt897212trawi;t94287082i5:Bt07081804i5:Bt14050471iIt89005924i5wt69279037It65353130Rt46119246t68084774t67062674t91819424t90698825t77737706Rt90693936t25091201t99943326t93441116t38618901t47863826RiSt727248i.ѡTt122419i i)iѡTt 662331049i<t19360094t40857319t37023009c csddlm}x|jD]}|jj}|j|dx|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-RtrowRtentryttimettokentexpirestotptprefix((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytiter_test_vectors,s  cCsd|jtt|jttdddttdt}tdt}|j|j|jdS(sconstructor -- 'new' parameterRbt4aoggdbbqsyhntuzRN(R+R,RRRiRb(R-RR((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_newEs c CsD|jttdtddjd|jttdtddjd|jttdtddjd|jttdtd d jd |jttdtd d jd |jttdtd d dd|jttdtd d |jtdt j ddgtdd}WdQXdS(s constructor -- 'size' parameterRRRiRi Ri@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|jttjt|jttjjt|jtdjt|jttd|jtddjt|jttdd|jttdjtdS(s,constructor -- 'key' and 'format' parameterss 4aog gdbb qsyh ntuz sao!ggdbbqsyhntuzte01c630c2184b076ce99RtX01c630c2184b076ce99RN( R&RtKEY1RbRRtlowerR+tBase32DecodeErrortBase16DecodeError(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_key_and_formatiscCs[|jttddjd|jttddjd|jtttdddS(sconstructor -- 'alg' parameterRsSHA-256RtSHA256sSHA-333N(R&RRRR+R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_algscCst|jtttdd|jttddjd|jttddjd|jtttdddS(s!constructor -- 'digits' parameterRiii i N(R+RRRR&R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_digitsscCs|jttjd|jttddjd|jtttdd|jtttdd|jtttdd|jtttdddS( s!constructor -- 'period' parameteriRi?g?tabciiN(R&RRRR+R,R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_periods cCsU|jttjd|jttddjd|jtttdddS(s constructor -- 'label' parametertlabelsfoo@barsfoo:barN(R&RRRR4R+R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_labelscCsU|jttjd|jttddjd|jtttdddS(s!constructor -- 'issuer' parametertissuersfoo.coms foo.com:barN(R&RRRR4R+R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_ctor_w_issuerscCs|jttjd|jtjddtjd|jttjdd|jttjdd|jttjdd|jttjdddS( susing() -- 'period' parameteriRi?g?RiiN(R&RRRtusingR+R,R(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_using_w_periods %cs|j}|j|jtj|j|jd ttjdgfd}|jdt j d|}|j |jd d|j |jd d|j t t j ddd}|jt|t j dd |jt|t j dd d S( susing -- 'now' parametergHz^@csdcd7<dS(Nii(((tcounter(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytnowsRRi~ii{s)now\(\) function must return non-negativecSsdS(NR((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytscSsdS(Ni((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsN(RtassertIsRt_timeRRotnormalize_timeR4tintRRR&R+R,tassertRaisesRegextAssertionError(R-RRtmsg_re((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_using_w_nows % cCs|d kr!|jdd}n|j|jtdd|j|jdd|j|jdd|j|jdd|jt|jd|jt|jd |jtj|jd|jtj|jd |jtj|jd d S( s$normalize_token() -- instance methodRit1234567iiGt0234567g2At123456t01234567iNaN( R4RR&tnormalize_tokenRR+R,RtMalformedTokenError(R-R((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_normalize_token_instances cCs |jdtjdddS(s!normalize_token() -- class methodRRiN(RRR(R-((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_normalize_token_classscs)tj}|j|}xtdD]}|jt}|j|j||j|j|d||j|j||tjj }|j|j|||j }z5t fd|_ |j|jd|Wd||_ Xq(W|j t|jddS(snormalize_time()i g?csS(N(((R(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsNt1234(RRRRRRR&RRRRt staticmethodR4R+R,(R-t TotpFactoryRRpttinttdttorig((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_normalize_times     cCs|j}ttd}|j|jt|j|jd|j|jt|j|jd|j|jddd|j|jdt t|j|jddd td t d |j d d }|j}|j}|j}dS(s pretty_key() and .key attributesRRs4AOG-GDBB-QSYH-NTUZtsept s4AOG GDBB QSYH NTUZRRse01c-630c-2184-b076-ce99RRi iN( RRRRR&Rbthex_keyt base32_keyRt pretty_keyRvRR(R-R{RRp((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_key_attrs$s !  cCsddlm}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 |jd|_|j|jd |j|j|jd}|j|||j|||jd}|j|||j|||jd}|j||dS(sgenerate() -- TotpToken() classi(Rt TotpTokents3jdvb7qd2r7jpxxiSTRiiTTiiiicSsdS(NgTn'A((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRRsg?cSsdS(NiUT((((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRVsi7TiWTN(RiTT(RRRtgeneratetassertIsInstanceR&RRt expire_timeR_R+t IndexErrort __getitem__R*Rt remainingtvalidR(t assertIsNotRi(R-RRRRatresult2tresult3tresult4((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|dj||j |j|dj|t j j }|j t |j|t |j |j|j||jdfdd|j}|j |jj||jt|jdd S( s generate()i(RRiiRcsS(N(((R(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsRbN(RRRRRRR RRR&RiRRRRRRR+R(R-RRRaRt start_timeRR((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_generatehs     %'cCsx|jD]y\}}}}}|j|}|j|j|d||j|j||jd||r |j|j|q q WdS(sgenerate() -- reference vectorstmsgN(RRR&RRRR (R-RRRRRRa((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt!test_generate_w_reference_vectorss " iR%c Csddlm}|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:iiii(RRR RRR&RRRtexpected_countertskippedt cache_secondsR t cache_timeR_R+R R R*( R-tmatchRRRtwindowRRtexpectedRR ((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytassertTotpMatchs*  cs\dd}tjdfdt}|j|}|j|ddddS( s!match() -- valid TotpMatch objectikt781501RcsdS(NiiiQ(((R(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsRRiN(RRtKEY3RR (R-RRRa((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_valid_tokens !cstddlm}dd}tjdfdt}|j|d}|j|ddd d d S( s3match() -- valid TotpMatch object with future tokeni(RikR!RcsdS(NiiiQ(((R(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsiRRiN(RRRRR"RR (R-RRRRa((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_older_tokens !csddd}tjdfdt}|j|d}|j|ddddd S( s1match() -- valid TotpMatch object with past tokenikR!RcsdS(NiiiQ(((R(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsiRRiN(RRR"RR (R-RRRa((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_new_tokens !csQdd}tjdfdt}|jtj|j|ddS(s#match() -- invalid TotpMatch objectikR!RcsdS(NiiiQ(((R(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsi<N(RRR"R+RtInvalidTokenErrorR(R-RR((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_totp_match_w_invalid_tokens!c Ksd|j|j|j|||f}|j|||}|j|d|j|d|jd|jddd|d|dS( s,helper to test otp.match() output is corrects5key=%r alg=%r period=%r token=%r gen_time=%r time=%r:RRRiRRN(RRRRR Rtget( R-texpect_skippedRRRtgen_timeRRRa((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytassertVerifyMatchess"  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__(RRRR+R(R-t exc_classRRRR*RR((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytassertVerifyRaisess"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|t j j |}|d||dd|t |dd S( s)match() -- 'time' and 'window' parametersRR*RiiiiiN(RRRRRRPRR+R.RR&RRR( R-RRRRtcommont assertMatchesR+R((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_match_w_windows(   !!" 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' parametersRR*iRiitskewN( RRRRPRR+R.RRRR&( R-RRRR/R0R+R2t behind_tokent ahead_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|| t j ||d|d|d|| t j |||d|d|} |j| j|| t j ||d|dd} |j| j|d S( s0match() -- 'reuse' and 'last_counter' parametersRR*iRt last_counteriiiN(RRRRRRR RPRR+R.RR&tUsedTokenErrorR&( R-RRRttdataRRR R/R0R+terr((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_match_w_reuse;s*       cCstd}|j}d}|j|d||j|d||jtj|d||jtj|d||jtj|d|dS( smatch() -- token normalizationtotxl2f5cctbprpzxi6Ts 3 32-136 t332136t12345t12345Xt0123456N(RRR*R+RR(R-RRR((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_match_w_token_normalizationds  cCsx|jD]}\}}}}}|j}|||}|j||j|j||jd||jtj|||dddq WdS(smatch() -- reference vectorsRidRiN( RRR*R&RRR+RR&(R-RRRRRRRa((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_match_w_reference_vectorszs "   cs0ddlm}d|jdfd}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(Ri6TRcsS(N(((R(s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRsRBittypeRRbR;R<Rt332155s3{"v": 1, "type": "totp", "key": "otxl2f5cctbprpzx"}s,otpauth://totp/Label?secret=otxl2f5cctbprpzxN( RRRRPtverifyR R+RR&R(R-RRtsource1Rt source1jsont source1uri((Rs;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_verifys cCsddlm}|j}|td}|j|jt|d}|j|jt|tdddddt}|j|jt|td }|j|jt|d }|j|jt|j |||t }|j d |j|}|j |||j|j |j |j d |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(RRt from_sourceRR&RbtKEY4_RAWRPtKEY4RRRRtto_dictR+R(R-RRJRtwallet1RR((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_from_sources*  !  cCsddlm}|j}|d}|j|||j|jt|j|jd|j|jd|j|j d|j|j d|j|j d|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|j d|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 dd$S(%s from_uri()i(RsNotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Examplesalice@google.comtExampleRiisNotpauth://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=Provider1s Alice 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=SHA256RsPotpauth://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=-1RRs!unexpected parameters encounteredsQotpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&foo=bar&period=63N(RRtfrom_uriR R&RbRKRRRRRR+RRRRPRtPasslibRuntimeWarningRRL(R-RRRR((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_from_urisT         cCsLttdddddd}|j|jddd |jt|jdd|j|jdd d|_|j|jd d|_|j|jd |jt|jd |jt|jdd |jttdd jdd|jttddjdd|jttddjdddS(sto_uri()RRRiRisalice@google.coms Example OrgsLotpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example%20Orgs7otpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXPslabel:with:semicolonssissuer:with:semicolonsRsHotpauth://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+RR4RR(R-R((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_to_uriUs(  c Csddlm}|j}|tdddddtdd d d }|j|||j|jt|j|j d |j|j d |j|j d |j|j d |j|j d|jt|tdddt|jt|tdddddt|jt|tdddddt|jt|tdddt|tdddddtjdd d d }|j|jt|jt|tdddd|jt|tdddddd|tdddddtddd d}|j|j d|j|j d|tdddddtdd}|j|j d|jt|tdddddtdd|tdddddtdd}|j|j d|jt|tdddddtdd|jt|tdddddtdd|tdddddtdd}|j|j d|jt|tdddddtdd|jt|tdddddtdd|jt|tdddddtdddS( s from_dict()i(RRBiRBRRbRsalice@google.comRRPRiiiisJBSWY3DPEHP@3PXPs Alice SmithRQRRtsha333RiR8iRi?tINVALIDi{N(RRt from_dictRPRLR R&RbRKRRRRRR+RRRR,(R-RRYR((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyttest_from_dictsD -"(("3" -'.'..'..c Csttdddddd}|j|jtddd d d tttddddddd d dd}|j|jtddd d d td d ddttddddddd d }|j|jtddd d d td d ttdddddddd}|j|jtddd d d tddtjdd}|t}|j|jtddd d d t|tdd}|j|jtddd d d t|jttddjtddd d d tdd|jttddjtddd d d tdd|jttddjtddd d d tdddS(s to_dict()RRRiRiRBiRBRRbRsalice@google.comRs Example OrgRii?N(RRLR&RMRPR(R-RR((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyt test_to_dicts8+     ++""N(i6TR(i6TR(i6TR(iռ6TR(iּ6TR(i6TR(i6TR(i6TR(iռ6TR(iּ6TR(i5TR(iSTs897212(i;R(i5:BR(i5:BR(iIR(i5wR(IR(i;R(i5:BR(i5:BR(iIR(i5wR(IR(i;R(i5:BR(i5:BR(iIR(i5wR(IR(iSR(i.ѡTR(iѡTR(i5:BR(i5:BR(i5:BR(3RsRtt__doc__RuR}RR4RRRPRtRFC_KEY_BYTES_20tRFC_KEY_BYTES_32tRFC_KEY_BYTES_64RRRRRRRRRRRRRRRRRRRR R#R$R%R'R+R.R1R5R:R@RARHRORTRVRZR[(((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pyRys  !  $*        "     + !    0  )   $ / w = ^(5R\Rt functoolsRtloggingt getLoggerRsRtsysRRtpasslibRtpasslib.utils.compatRRtpasslib.tests.utilsRRRRRRRR t__all__R,RRt version_infotbinasciiR RNRORRRRSR"RLRKt float_infotradixRtmant_digRRRR tencodeR]R^R_Ry(((s;/usr/lib/python2.7/site-packages/passlib/tests/test_totp.pytsH      /