Ë
    àU.jør  ã                   óp  — d Z ddlmZ ddlmZ ddlZddlZddlmZm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZmZmZmZ dd
lmZ ddlmZ ddlmZ  ee«      Zdd„Zej:                  j=                  d«      xs dZdd„Z d„ Z!d„ Z" e"«       \  Z#Z$ ejJ                  e#d«      Z& G d„ de«      Z' G d„ de«      Z(y)z@tests for passlib.apache -- (c) Assurance Technologies 2008-2011é    )Úwith_statement)Ú	getLoggerN)ÚapacheÚregistry)ÚMissingBackendError)Úirange)Úunittest)ÚTestCaseÚget_fileÚset_fileÚensure_mtime_changed)Úu)Úto_bytes)Úto_unicode_for_identifyc                 ó¶   — t         j                  j                  | «      }t         j                  j                  | «      |z
  }t        j                  | ||f«       y)z)backdate file's mtime by specified amountN)ÚosÚpathÚgetatimeÚgetmtimeÚutime)r   ÚoffsetÚatimeÚmtimes       ú[C:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/tests/test_apache.pyÚbackdate_file_mtimer      sC   € ô �G‰G×Ñ˜TÓ"€EÜ�G‰G×Ñ˜TÓ" 6Ñ)€EÜ‡H�HˆT�E˜5�>Õ"ó    ÚPASSLIB_TEST_HTPASSWD_PATHÚhtpasswdc                 ó4  — |�|j                  d«      }t        j                  t        g| z   t        j                  t        j
                  |rt        j                  nd¬«      }|j                  |«      \  }}|j                  «       }t        |xs d«      }||fS )z$
    helper to run htpasswd cmd
    Núutf-8)ÚstdoutÚstderrÚstdinÚ )	ÚencodeÚ
subprocessÚPopenÚhtpasswd_pathÚPIPEÚSTDOUTÚcommunicateÚwaitr   )Úargsr#   ÚprocÚoutÚerrÚrcs         r   Ú_call_htpasswdr2   +   s‚   € ð ÐØ—‘˜WÓ%ˆÜ×Ñœ]˜O¨dÑ2¼:¿?¹?Ü#-×#4Ñ#4Éu¼J¿OºOÐZ^ô`€Dà×Ñ Ó&�H€CˆØ	�‰‹€BÜ
! #¢)¨Ó
,€CØ�ˆ7€Nr   c                 ó,   — t        d| |g|«      \  }}| S )z%
    wrapper for htpasswd verify
    z-vi)r2   )r   ÚuserÚpasswordr/   r1   s        r   Ú_call_htpasswd_verifyr6   9   s"   € ô ˜e T¨4Ð0°(Ó;�G€CˆØˆ6€Mr   c                  ó|   — 	 t        g «      \  } }|st        j                  d«       d| v }d|fS # t        $ r Y yw xY w)z0
    helper to check if htpasswd is present
    )FFz htpasswd test returned with rc=0z -B T)r2   ÚOSErrorÚlogÚwarning)r/   r1   Úhave_bcrypts      r   Ú_detect_htpasswdr<   A   sQ   € ðÜ  Ó$‰ˆˆRñ Ü�‰Ð6Ô7Ø˜C�-€KØ�ÐÐøô ò ñ ðús   ‚/ ¯	;º;z requires `htpasswd` cmdline toolc                   ó  — e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Ze e jB                   e"jF                  d«      d«      d„ «       «       Z$y )!ÚHtpasswdFileTestztest HtpasswdFile classÚHtpasswdFilest   user2:2CHkkwa2AtqGs
user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
user1:$apr1$t4tc7jTh$GPIWVUo8sQKJlUdV8V5vu0
s4   user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
sy   user2:pass2x
user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
user1:$apr1$t4tc7jTh$GPIWVUo8sQKJlUdV8V5vu0
user5:pass5
s   userÃ¦:2CHkkwa2AtqGs
s   useræ:2CHkkwa2AtqGs
s   user1:pass1
user1:pass2
s  user2:2CHkkwa2AtqGs
user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
user1:$apr1$t4tc7jTh$GPIWVUo8sQKJlUdV8V5vu0
user5:$2a$12$yktDxraxijBZ360orOyCOePFGhuis/umyPNJoL5EbsLk.s6SWdrRO
user6:$5$rounds=110000$cCRp/xUUGVgwR4aP$p0.QKFS5qLNRqw1/47lXYiAcgIjJK.WjCO8nrEKuUK.
c                 ó<  — | j                  «       }t        || j                  «       t        j                  |«      }| j                  |j                  «       | j                  «       | j                  |j                  |«       | j                  |j                  «       |dz   |_        | j                  |j                  |dz   «       | j                  |j                  «       t        j                  |d¬«      }| j                  |j                  «       d«       | j                  |j                  |«       | j                  |j                  «       | j                  d«      5  t        j                  |d¬«      }ddd«       | j                  |j                  «       d«       | j                  |j                  |«       | j                  |j                  «       t        j                  |«       | j                  t        t        j                  |«       y# 1 sw Y   Œ›xY w)	útest constructor autoloadÚxT©Únewr   z ``autoload=False`` is deprecatedF)ÚautoloadN)Úmktempr   Ú	sample_01r   r?   ÚassertEqualÚ	to_stringr   Ú
assertTruer   ÚassertFalseÚassertWarningListr   ÚremoveÚassertRaisesÚIOError©Úselfr   Úhts      r   Útest_00_constructor_autoloadz-HtpasswdFileTest.test_00_constructor_autoload}   s†  € ð �{‰{‹}ˆÜ��t—~‘~Ô&Ü× Ñ  Ó&ˆØ×Ñ˜Ÿ™›¨¯©Ô8Ø×Ñ˜Ÿ™ $Ô'Ø�‰˜Ÿ™Ô!ð ˜‘*ˆŒØ×Ñ˜Ÿ™ $¨¡*Ô-Ø×Ñ˜Ÿ™Ô"ô × Ñ  ¨4Ô0ˆØ×Ñ˜Ÿ™›¨Ô-Ø×Ñ˜Ÿ™ $Ô'Ø×Ñ˜Ÿ™Ô"ð ×#Ñ#Ð$FÕGÜ×$Ñ$ T°EÔ:ˆB÷ Hà×Ñ˜Ÿ™›¨Ô-Ø×Ñ˜Ÿ™ $Ô'Ø×Ñ˜Ÿ™Ô"ô 	�	‰	�$ŒØ×Ñœ'¤6×#6Ñ#6¸Õ=÷ HÐGús   Å HÈHc                 óP  — | j                  «       }t        || j                  «       t        j                  j                  |«      }| j                  |j                  «       | j                  «       | j                  |j                  d «       | j                  |j                  «       y ©N)rF   r   rG   r   r?   Ú	from_pathrH   rI   r   rK   r   rP   s      r   Útest_00_from_pathz"HtpasswdFileTest.test_00_from_pathŸ   sq   € Ø�{‰{‹}ˆÜ��t—~‘~Ô&Ü× Ñ ×*Ñ*¨4Ó0ˆØ×Ñ˜Ÿ™›¨¯©Ô8Ø×Ñ˜Ÿ™ $Ô'Ø×Ñ˜Ÿ™Õ"r   c                 ó¬  — t         j                  j                  | j                  «      }| j	                  |j                  d«      «       | j	                  |j                  d«      «       | j                  |j                  d«      «       | j                  |j                  «       | j                  «       | j                  t        |j
                  d«       y)útest delete()Úuser1Úuser2Úuser5úuser:N)r   r?   Úfrom_stringrG   rJ   ÚdeleterK   rH   rI   Ú	sample_02rN   Ú
ValueError©rQ   rR   s     r   Útest_01_deletezHtpasswdFileTest.test_01_delete§   s�   € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ�‰˜Ÿ	™	 'Ó*Ô+Ø�‰˜Ÿ	™	 'Ó*Ô+Ø×Ñ˜Ÿ™ 7Ó+Ô,Ø×Ñ˜Ÿ™›¨¯©Ô8ð 	×Ñœ* b§i¡i°Õ9r   c                 óH  — | j                  «       }d}t        ||«       t        j                  |«      }|j	                  d«       | j                  t        |«      |«       t        j                  |d¬«      }|j	                  d«       | j                  t        |«      d«       y )Ns   user1:pass1
user2:pass2
rZ   T)Úautosaves   user2:pass2
)rF   r   r   r?   r_   rH   r   ©rQ   r   ÚsamplerR   s       r   Útest_01_delete_autosavez(HtpasswdFileTest.test_01_delete_autosave²   s   € Ø�{‰{‹}ˆØ.ˆÜ��vÔä× Ñ  Ó&ˆØ
�	‰	�'ÔØ×Ñœ $›¨Ô0ä× Ñ  °Ô5ˆØ
�	‰	�'ÔØ×Ñœ $›Ð)9Õ:r   c                 ó¢  — t         j                  j                  | j                  d¬«      }| j	                  |j                  dd«      «       | j                  |j                  dd«      «       | j                  |j                  «       | j                  «       | j                  d«      5  t         j                  j                  | j                  d¬«      }d	d	d	«       | j	                  |j                  dd«      «       | j                  |j                  dd«      «       | j                  |j                  «       | j                  «       | j                  t        |j
                  d
d«       | j                  d«      5  |j                  dd«       d	d	d	«       | j	                  |j                  dd«      «       y	# 1 sw Y   ŒåxY w# 1 sw Y   Œ7xY w)ztest set_password()Ú	plaintext©Údefault_schemer[   Úpass2xr\   Úpass5z``default`` is deprecated)ÚdefaultNr]   Úpassúupdate\(\) is deprecatedÚtest)r   r?   r^   rG   rJ   Úset_passwordrK   rH   rI   Ú	sample_03rL   rN   ra   ÚupdateÚcheck_passwordrb   s     r   Útest_02_set_passwordz%HtpasswdFileTest.test_02_set_password¿   s\  € ä× Ñ ×,Ñ,Ø�N‰N¨;ð -ó 8ˆà�‰˜Ÿ™¨°Ó:Ô;Ø×Ñ˜Ÿ™¨°'Ó:Ô;Ø×Ñ˜Ÿ™›¨¯©Ô8ð ×#Ñ#Ð$?Õ@Ü×$Ñ$×0Ñ0°·±ÈÐ0ÓUˆB÷ Aà�‰˜Ÿ™¨°Ó:Ô;Ø×Ñ˜Ÿ™¨°'Ó:Ô;Ø×Ñ˜Ÿ™›¨¯©Ô8ð 	×Ñœ* b§o¡o°wÀÔGð ×#Ñ#Ð$>Õ?Ø�I‰I�g˜vÔ&÷ @à�‰˜×)Ñ)¨'°6Ó:Õ;÷ AÐ@ú÷ @Ð?ús   Â),F9Å<GÆ9GÇGc                 óN  — | j                  «       }d}t        ||«       t        j                  |«      }|j	                  dd«       | j                  t        |«      |«       t        j                  |dd¬«      }|j	                  dd«       | j                  t        |«      d«       y )Nó   user1:pass1
rZ   Úpass2rj   T)rl   re   s   user1:pass2
)rF   r   r   r?   rs   rH   r   rf   s       r   Útest_02_set_password_autosavez.HtpasswdFileTest.test_02_set_password_autosaveÖ   s…   € Ø�{‰{‹}ˆØ!ˆÜ��vÔä× Ñ  Ó&ˆØ
�‰˜ Ô)Ø×Ñœ $›¨Ô0ä× Ñ  °kÈDÔQˆØ
�‰˜ Ô)Ø×Ñœ $›Ð)9Õ:r   c                 óà  — d„ }| j                   |d«      d«       | j                   |d«      d«       | j                  t        |d«       | j                   |d«      t        j                  d   «       | j                   |d«      t        j                  d   «       | j                   |d«      t        j                  d   «       | j                   |d«      t        j                  d   «       y)	z%test set_password() -- default_schemec                 ó¦   — t        j                  | ¬«      }|j                  dd«       |j                  j	                  |j                  d«      «      S )Nrk   rZ   Úpass1)r   r?   rs   ÚcontextÚidentifyÚget_hash)ÚschemerR   s     r   ÚcheckzCHtpasswdFileTest.test_02_set_password_default_scheme.<locals>.checkæ   s>   € Ü×$Ñ$°FÔ;ˆBØ�O‰O˜G WÔ-Ø—:‘:×&Ñ& r§{¡{°7Ó';Ó<Ð<r   Úsha256_cryptÚ	des_cryptÚxxxÚportableÚportable_apache_22Úhost_apache_22N)rH   rN   ÚKeyErrorr   Úhtpasswd_defaults)rQ   rƒ   s     r   Ú#test_02_set_password_default_schemez4HtpasswdFileTest.test_02_set_password_default_schemeã   sÏ   € ò	=ð 	×Ñ™˜~Ó.°Ô?Ø×Ñ™˜{Ó+¨[Ô9ð 	×Ñœ( E¨5Ô1ð 	×Ñ™˜zÓ*¬F×,DÑ,DÀZÑ,PÔQØ×Ñ™Ð3Ó4´f×6NÑ6NÐOcÑ6dÔeØ×Ñ™Ð/Ó0´&×2JÑ2JÐK[Ñ2\Ô]ð 	×Ñ™˜t›¤f×&>Ñ&>Ð?SÑ&TÕUr   c                 ó  — t         j                  j                  | j                  «      }|j	                  dd«       |j                  d«       |j	                  dd«       | j                  t        |j                  «       «      g d¢«       y)útest users()r\   rn   Úuser3Úpass3©rZ   r[   r�   Úuser4r\   N)	r   r?   r^   rG   rs   r_   rH   ÚsortedÚusersrb   s     r   Útest_03_userszHtpasswdFileTest.test_03_usersú   s`   € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ
�‰˜ Ô)Ø
�	‰	�'ÔØ
�‰˜ Ô)Ø×Ñœ §¡£
Ó+Ò-ZÕ[r   c                 óú  — t         j                  j                  | j                  «      }| j	                  t
        |j                  dd«       | j                  |j                  dd«      du «       t        dd«      D ][  }t        |«      }	 | j                  |j                  d|z   d|z   «      «       | j                  |j                  d|z   d«      du «       Œ] | j	                  t        |j                  d
d«       | j                  dgdz  «      5  | j                  |j                  dd«      «       | j                  |j                  dd«      «       ddd«       y# t        $ r	 |d	k(  rY Œñ‚ w xY w# 1 sw Y   yxY w)útest check_password()é   Úpass9Úuser9Né   r4   rp   FÚ5r]   úverify\(\) is deprecatedé   rZ   r~   rz   )r   r?   r^   Ú	sample_05rN   Ú	TypeErrorrv   rJ   r   Ústrr   ra   rL   ÚverifyrK   ©rQ   rR   Úis      r   Útest_04_check_passwordz'HtpasswdFileTest.test_04_check_password  sM  € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ×Ñœ) R×%6Ñ%6¸¸7ÔCØ�‰˜×)Ñ)¨'°'Ó:¸dÐBÔCô ˜˜1–ˆAÜ�A“ˆAðØ—‘ × 1Ñ 1°&¸±(¸FÀ1¹HÓ EÔFØ—‘ × 1Ñ 1°&¸±(¸GÓ DÈÐ MÕNð	 ð 	×Ñœ* b×&7Ñ&7¸À&ÔIð ×#Ñ#Ð%?Ð$@ÀÑ$BÕCØ�O‰O˜BŸI™I g¨wÓ7Ô8Ø×Ñ˜RŸY™Y w°Ó8Ô9÷ DÐCøô 'ò Ø˜’8áØð	ú÷ DÐCús    Â
AEÄAE1ÅE.Å,E.Å1E:c                 óÞ  — | j                  «       }t        |d«       t        |d«       t        j                  |d¬«      }| j                  |j                  «       d«       |j                  dd«       |j                  «        | j                  |j                  «       d«       t        || j                  «       |j                  «        | j                  |j                  «       | j                  «       |j                  d	d
«       |j                  «        | j                  |j                  «       | j                  «       t        j                  «       }| j                  t        |j                  «       | j                  t        |j                  «       t        || j                  «       t        j                  «       }|j                  |«       | j                  |j                  dd«      «       y)útest load()r$   é   rj   rk   r   rZ   r~   ry   r\   rn   N)rF   r   r   r   r?   rH   rI   rs   Úload_if_changedrG   ÚloadrN   ÚRuntimeErrorÚ
sample_duprJ   rv   ©rQ   r   ÚhaÚhbÚhcs        r   Útest_05_loadzHtpasswdFileTest.test_05_load  sc  € ð �{‰{‹}ˆÜ��rÔÜ˜D !Ô$Ü× Ñ  °kÔBˆØ×Ñ˜Ÿ™›¨Ô-ð 	�‰˜ Ô)Ø
×ÑÔØ×Ñ˜Ÿ™›Ð)9Ô:ô 	��t—~‘~Ô&Ø
×ÑÔØ×Ñ˜Ÿ™›¨¯©Ô8ð 	�‰˜ Ô)Ø
�‰Œ	Ø×Ñ˜Ÿ™›¨¯©Ô8ô × Ñ Ó"ˆØ×Ñœ,¨¯©Ô0Ø×Ñœ,¨×(:Ñ(:Ô;ô 	��t—‘Ô'Ü× Ñ Ó"ˆØ
�‰�ŒØ�‰˜×)Ñ)¨'°'Ó:Õ;r   c                 ó  — | j                  «       }t        || j                  «       t        j                  |«      }|j                  d«       |j                  d«       |j                  «        | j                  t        |«      | j                  «       t        j                  d¬«      }|j                  dd«       | j                  t        |j                  «       |j                  |«       | j                  t        |«      d«       y)útest save()rZ   r[   rj   rk   r~   ry   N)rF   r   rG   r   r?   r_   ÚsaverH   r   r`   rs   rN   r«   ©rQ   r   rR   r¯   s       r   Útest_06_savezHtpasswdFileTest.test_06_saveA  s¾   € ð �{‰{‹}ˆÜ��t—~‘~Ô&Ü× Ñ  Ó&ˆð 	�	‰	�'ÔØ
�	‰	�'ÔØ
�‰Œ	Ø×Ñœ $›¨¯©Ô8ô × Ñ °Ô<ˆØ
�‰˜ Ô)Ø×Ñœ,¨¯©Ô0ð 	�‰�ŒØ×Ñœ $›Ð)9Õ:r   c                 óŒ  — | j                  t        t        j                  d¬«       t        j                  j	                  | j
                  dd¬«      }| j                  |j                  «       t        d«      g«       | j                  d«      5  t        j                  j	                  | j
                  d¬«      }ddd«       | j                  |j                  «       d	g«       t        j                  j	                  | j                  d
d¬«      }| j                  |j                  «       t        d«      g«       y# 1 sw Y   Œ�xY w)ztest 'encoding' kwdúutf-16©Úencodingr    T©rº   Úreturn_unicodeõ   userÃ¦z``encoding=None`` is deprecatedNs   userÃ¦úlatin-1)rN   ra   r   r?   r^   Úsample_04_utf8rH   r”   r   rL   Úsample_04_latin1rb   s     r   Útest_07_encodingsz"HtpasswdFileTest.test_07_encodingsW  s  € ð 	×Ñœ*¤f×&9Ñ&9ÀHÐÔMô × Ñ ×,Ñ,¨T×-@Ñ-@È7Ø<@ð -ó Bˆà×Ñ˜Ÿ™›¤q¨£Ð%8Ô9ð ×#Ñ#Ð$EÕFÜ×$Ñ$×0Ñ0°×1DÑ1DÈtÐ0ÓTˆB÷ Gà×Ñ˜Ÿ™› Ð%8Ô9ô × Ñ ×,Ñ,¨T×-BÑ-BØ7@ÐQUð -ó Wˆà×Ñ˜Ÿ™›¤q¨£Ð%8Õ9÷ GÐFús   Â,D:Ä:Ec                 óª  — t         j                  j                  | j                  «      }| j	                  |j                  d«      d«       | j	                  |j                  d«      d«       | j	                  |j                  d«      d«       | j                  d«      5  | j	                  |j                  d«      d«       ddd«       y# 1 sw Y   yxY w)útest get_hash()r�   s!   {SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=r’   s   pass4r\   Núfind\(\) is deprecated)r   r?   r^   rG   rH   r�   rL   Úfindrb   s     r   Útest_08_get_hashz!HtpasswdFileTest.test_08_get_hashk  sœ   € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ×Ñ˜Ÿ™ WÓ-Ð/SÔTØ×Ñ˜Ÿ™ WÓ-¨xÔ8Ø×Ñ˜Ÿ™ WÓ-¨tÔ4à×#Ñ#Ð$<Õ=Ø×Ñ˜RŸW™W WÓ-¨xÔ8÷ >×=Ñ=ús   Â"C	Ã	Cc                 ó  — t         j                  j                  | j                  «      }| j	                  |j                  «       | j                  «       t        j                  «       }| j	                  |j                  «       d«       y)ztest to_stringr   N)r   r?   r^   rG   rH   rI   rb   s     r   Útest_09_to_stringz"HtpasswdFileTest.test_09_to_stringu  ó^   € ô × Ñ ×,Ñ,¨T¯^©^Ó<ˆØ×Ñ˜Ÿ™›¨¯©Ô8ô × Ñ Ó"ˆØ×Ñ˜Ÿ™›¨Õ-r   c                 óL   — t        j                  dddd¬«      }t        |«       y )NÚfakepathTr¾   )re   rD   rº   )r   r?   Úreprrb   s     r   Útest_10_reprzHtpasswdFileTest.test_10_repr€  s   € Ü× Ñ  °dÀÈyÔYˆÜˆR�r   c                 óÀ   — | j                  t        t        j                  j                  d«       | j                  t        t        j                  j                  d«       y )Ns   realm:user1:pass1
s   pass1
)rN   ra   r   r?   r^   ©rQ   s    r   Útest_11_malformedz"HtpasswdFileTest.test_11_malformed„  sD   € Ø×Ñœ*¤f×&9Ñ&9×&EÑ&EØ"ô	$à×Ñœ*¤f×&9Ñ&9×&EÑ&EØõ	r   c                 óf   — | j                  t        t        j                  j                  dd ¬«       y )Nr   )r   )rN   r    r   r?   r^   rÏ   s    r   Útest_12_from_stringz$HtpasswdFileTest.test_12_from_stringŠ  s*   € à×Ñœ)¤V×%8Ñ%8×%DÑ%DØ Dð 	õ 	*r   c                 óp  — t        d«      }t        j                  j                  |«      }| j	                  t        |j                  «       «      g d¢«       |j                  dd«       | j	                  t        |j                  «       «      g d¢«       |j                  dd«       | j	                  t        |j                  «       «      g d¢«       |j                  d«       | j	                  t        |j                  «       «      g d	¢«       t        d
«      }| j	                  |j                  «       |«       y)zwhitespace & comment handlingz`
user2:pass2
user4:pass4
user7:pass7
 	 
user1:pass1
 # legacy users
#user6:pass6
user5:pass5

)rZ   r[   r’   r\   Úuser7r’   Úalthash4Úuser6Úalthash6)rZ   r[   r’   r\   rÖ   rÔ   rÔ   )rZ   r[   r’   r\   rÖ   zd
user2:pass2
user4:althash4
 	 
user1:pass1
 # legacy users
#user6:pass6
user5:pass5
user6:althash6
N)
r   r   r?   r^   rH   r“   r”   Úset_hashr_   rI   )rQ   ÚsourcerR   Útargets       r   Útest_13_whitespacez#HtpasswdFileTest.test_13_whitespace�  sò   € ô
 ðó

ˆô × Ñ ×,Ñ,¨VÓ4ˆØ×Ñœ §¡£
Ó+Ò-ZÔ[ð 	�‰�G˜ZÔ(Ø×Ñœ §¡£
Ó+Ò-ZÔ[ð 	�‰�G˜ZÔ(Ø×Ñœ §¡£
Ó+Ò-cÔdð 	�	‰	�'ÔØ×Ñœ §¡£
Ó+Ò-ZÔ[ô ðó

ˆð 	×Ñ˜Ÿ™›¨Õ0r   c                 ó  ‡— | j                  «       }t        j                  |d¬«      Šˆfd„}‰j                  d |dd«      «       t        j                  d   }‰j                  d |d|«      «       t        j                  d	   }‰j                  d
 |d|«      «       ‰j                  dd«       ‰j                  «        | j                  t        |dd«      «       | j                  t        |dd«      «       | j                  t        |d
d«      «       | j                  t        |dd«      «       | j                  t        |dd«      «       | j                  t        |dd«      «       | j                  t        |d
d«      «       y)z;
        verify "htpasswd" command can read output
        T©r   rD   c                 óX   •— ‰j                   j                  |«      j                  | «      S rU   ©r   ÚhandlerÚhash©Úpwdr‚   rR   s     €r   Úhash_schemez>HtpasswdFileTest.test_htpasswd_cmd_verify.<locals>.hash_schemeÆ  ó#   ø€ Ø—:‘:×%Ñ% fÓ-×2Ñ2°3Ó7Ð7r   rZ   r5   Úapr_md5_cryptr‰   r[   Úhostr�   r’   z$xxx$foo$bar$bazÚwrongN)	rF   r   r?   rØ   r‹   r´   rK   r6   rJ   )rQ   r   rä   Úhost_no_bcryptÚ	host_bestrR   s        @r   Útest_htpasswd_cmd_verifyz)HtpasswdFileTest.test_htpasswd_cmd_verify¾  sK  ø€ ð
 �{‰{‹}ˆÜ× Ñ  d°Ô5ˆô	8ð 	�‰�G™[¨°OÓDÔEô  ×1Ñ1Ð2BÑCˆØ
�‰�G™[¨°^ÓDÔEô ×,Ñ,¨VÑ4ˆ	Ø
�‰�G™[¨°YÓ?Ô@ð 	�‰�GÐ/Ô0ð 	�‰Œ	à×ÑÔ.¨t°W¸gÓFÔGØ×ÑÔ.¨t°W¸gÓFÔGØ×ÑÔ.¨t°W¸gÓFÔGØ×ÑÔ.¨t°W¸gÓFÔGà�‰Ô-¨d°G¸ZÓHÔIØ�‰Ô-¨d°G¸ZÓHÔIØ�‰Ô-¨d°G¸ZÓHÕIr   Úbcryptzbcrypt support requiredc                 óf  ‡— | j                  «       }t        j                  |d¬«      Šˆfd„}‰j                  d |dd«      «       ‰j	                  «        | j                  t        |dd«      «       t        r| j                  t        |dd«      «       y| j                  t        |dd«      «       y)	zµ
        verify "htpasswd" command can read bcrypt format

        this tests for regression of issue 95, where we output "$2b$" instead of "$2y$";
        fixed in v1.7.2.
        TrÝ   c                 óX   •— ‰j                   j                  |«      j                  | «      S rU   rß   râ   s     €r   rä   zEHtpasswdFileTest.test_htpasswd_cmd_verify_bcrypt.<locals>.hash_schemeî  rå   r   rZ   r5   rì   rè   N)	rF   r   r?   rØ   r´   rK   r6   ÚHAVE_HTPASSWD_BCRYPTrJ   )rQ   r   rä   rR   s      @r   Útest_htpasswd_cmd_verify_bcryptz0HtpasswdFileTest.test_htpasswd_cmd_verify_bcryptã  s�   ø€ ð �{‰{‹}ˆÜ× Ñ  d°Ô5ˆô	8à
�‰�G™[¨°XÓ>Ô?Ø
�‰Œ	Ø×ÑÔ.¨t°W¸gÓFÔGÝØ�O‰OÔ1°$¸ÀÓLÕMð ×ÑÔ2°4¸À*ÓMÕNr   N)%Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚdescriptionPrefixrG   r`   rt   r¿   rÀ   r¬   rŸ   rS   rW   rc   rh   rw   r{   rŒ   r•   r¥   r±   r¶   rÁ   rÆ   rÈ   rÍ   rÐ   rÒ   rÛ   Úrequires_htpasswd_cmdrë   r	   Ú
skipUnlessr   Úhas_backendrð   © r   r   r>   r>   Z   sï   „ Ù!Ø&ÐðB€Ið J€Ið"€Ið 5€NØ2Ðà.€JðF€Iò>òD#ò	:ò;ò<ò.;òVò.\ò:ò4!<òJ;ò,:ò(9ò	.òòò*ò
-1ð^ ñ"Jó ð"JðH Ø€X×ÑÐ-˜×-Ñ-¨hÓ7Ð9RÓSñOó Tó ñOr   r>   c                   óv   — e Zd ZdZdZdZdZdZdZdZ	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚHtdigestFileTestztest HtdigestFile classÚHtdigestFiles´   user2:realm:549d2a5f4659ab39a80dac99e159ab19
user3:realm:a500bb8c02f6a9170ae46af10c898744
user4:realm:ab7b5d5f28ccc7666315f508c7358519
user1:realm:2a6cf53e7d8f8cf39d946dc880b14128
sZ   user3:realm:a500bb8c02f6a9170ae46af10c898744
user4:realm:ab7b5d5f28ccc7666315f508c7358519
sá   user2:realm:5ba6d8328943c23c64b50f8b29566059
user3:realm:a500bb8c02f6a9170ae46af10c898744
user4:realm:ab7b5d5f28ccc7666315f508c7358519
user1:realm:2a6cf53e7d8f8cf39d946dc880b14128
user5:realm:03c55fdc6bf71552356ad401bdb9af19
s0   userÃ¦:realmÃ¦:549d2a5f4659ab39a80dac99e159ab19
s.   useræ:realmæ:549d2a5f4659ab39a80dac99e159ab19
c                 ó°  — | j                  «       }t        || j                  «       t        j                  |«      }| j                  |j                  «       | j                  «       t        j                  |d¬«      }| j                  |j                  «       d«       t        j                  |«       | j                  t        t        j                  |«       y)rA   TrC   r   N)rF   r   rG   r   rü   rH   rI   r   rM   rN   rO   rP   s      r   rS   z-HtdigestFileTest.test_00_constructor_autoload  s–   € ð �{‰{‹}ˆÜ��t—~‘~Ô&Ü× Ñ  Ó&ˆØ×Ñ˜Ÿ™›¨¯©Ô8ô × Ñ  ¨4Ô0ˆØ×Ñ˜Ÿ™›¨Ô-ô 	�	‰	�$ŒØ×Ñœ'¤6×#6Ñ#6¸Õ=r   c                 ó:  — t         j                  j                  | j                  «      }| j	                  |j                  dd«      «       | j	                  |j                  dd«      «       | j                  |j                  dd«      «       | j                  |j                  dd«      «       | j                  |j                  «       | j                  «       | j                  t        |j
                  dd«       | j                  t        |j
                  dd	«       y
)rY   rZ   Úrealmr[   r\   r�   Úrealm5r]   r4   úrealm:N)r   rü   r^   rG   rJ   r_   rK   rH   rI   r`   rN   ra   rb   s     r   rc   zHtdigestFileTest.test_01_delete+  sÊ   € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ�‰˜Ÿ	™	 '¨7Ó3Ô4Ø�‰˜Ÿ	™	 '¨7Ó3Ô4Ø×Ñ˜Ÿ™ 7¨GÓ4Ô5Ø×Ñ˜Ÿ™ 7¨HÓ5Ô6Ø×Ñ˜Ÿ™›¨¯©Ô8ð 	×Ñœ* b§i¡i°¸'ÔBð 	×Ñœ* b§i¡i°¸ÕBr   c                 ó$  — | j                  «       }t        || j                  «       t        j                  |«      }| j                  |j                  dd«      «       | j                  |j                  dd«      «       | j                  |j                  dd«      «       | j                  t        |«      | j                  «       d|_
        | j                  |j                  dd«      «       | j                  t        |«      | j                  «       y )NrZ   rÿ   r�   r   r\   Tr[   )rF   r   rG   r   rü   rJ   r_   rK   rH   r   re   r`   rP   s      r   rh   z(HtdigestFileTest.test_01_delete_autosave:  sÂ   € Ø�{‰{‹}ˆÜ��t—~‘~Ô&ä× Ñ  Ó&ˆØ�‰˜Ÿ	™	 '¨7Ó3Ô4Ø×Ñ˜Ÿ™ 7¨HÓ5Ô6Ø×Ñ˜Ÿ™ 7¨GÓ4Ô5Ø×Ñœ $›¨¯©Ô8àˆŒØ�‰˜Ÿ	™	 '¨7Ó3Ô4Ø×Ñœ $›¨¯©Õ8r   c                 óš  — t         j                  j                  | j                  «      }| j	                  |j                  ddd«      «       | j                  |j                  ddd«      «       | j                  |j                  «       | j                  «       | j                  t        |j
                  dd«       d|_        |j                  dd«       |j                  ddd«       | j                  t        |j
                  ddd	«       | j                  t        |j
                  d
dd	«       | j                  t        |j
                  ddd	«       | j                  t        |j
                  ddd	«       | j                  d«      5  |j!                  ddd«       ddd«       | j	                  |j                  dd«      «       y# 1 sw Y   Œ+xY w)ztest update()r[   rÿ   rm   r\   rn   r�   Úrealm2r]   rp   Á   uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuur4   r  Á   rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrq   rr   N)r   rü   r^   rG   rJ   rs   rK   rH   rI   rt   rN   r    Údefault_realmrv   ra   rL   ru   rb   s     r   rw   z%HtdigestFileTest.test_02_set_passwordH  sb  € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ�‰˜Ÿ™¨°¸(ÓCÔDØ×Ñ˜Ÿ™¨°'¸7ÓCÔDØ×Ñ˜Ÿ™›¨¯©Ô8ð 	×Ñœ) R§_¡_°g¸wÔGØ#ˆÔØ
�‰˜ Ô)Ø
×Ñ˜' 8¨WÔ5ð 	×Ñœ* b§o¡o°wÀÈÔPØ×Ñœ* b§o¡o°wÀÈÔPð 	×Ñœ* b§o¡o°v¸xÈÔPØ×Ñœ* b§o¡o°v¸wÈÔOð ×#Ñ#Ð$>Õ?Ø�I‰I�g˜x¨Ô0÷ @à�‰˜×)Ñ)¨'°6Ó:Õ;÷ @Ð?ús   ÆGÇG
c                 ó`  — t         j                  j                  | j                  «      }|j	                  ddd«       |j                  dd«       |j	                  ddd«       | j                  t        |j                  d«      «      g d¢«       | j                  t        |j                  d«       y)	rŽ   r\   rÿ   rn   r�   r�   r‘   r˜   N)r   rü   r^   rG   rs   r_   rH   r“   r”   rN   r    rb   s     r   r•   zHtdigestFileTest.test_03_usersd  s   € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ
�‰˜ ¨'Ô2Ø
�	‰	�'˜7Ô#Ø
�‰˜ ¨'Ô2Ø×Ñœ §¡¨Ó 1Ó2Ò4aÔbà×Ñœ) R§X¡X¨qÕ1r   c           	      óö  — t         j                  j                  | j                  «      }| j	                  t
        |j                  ddd«       | j	                  t
        |j                  ddd«       | j                  |j                  ddd«      d«       t        dd«      D ][  }t        |«      }| j                  |j                  d|z   dd|z   «      «       | j                  |j                  d|z   dd«      d	«       Œ] | j	                  t
        |j                  dd«       d|_        | j                  |j                  d
d«      «       | j                  |j                  dd«      d«       | j                  dgdz  «      5  | j                  |j                  d
dd«      «       | j                  |j                  d
dd«      «       ddd«       | j	                  t        |j                  ddd«       y# 1 sw Y   Œ-xY w)r—   r˜   rÿ   rn   r4   r\   Nr¨   rp   FrZ   r~   r�   rž   rz   r]   )r   rü   r^   rG   rN   r    rv   ÚassertIsr   r¡   rJ   r  rL   r¢   rK   ra   r£   s      r   r¥   z'HtdigestFileTest.test_04_check_passwordn  s¡  € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ×Ñœ) R×%6Ñ%6¸¸7ÀGÔLØ×Ñœ) R×%6Ñ%6¸ÀÀ7ÔKØ�‰�b×'Ñ'¨°¸ÓAÀ4ÔHÜ˜˜!–ˆAÜ�A“ˆAØ�O‰O˜B×-Ñ-¨f°Q©h¸ÀÈÁÓJÔKØ�M‰M˜"×+Ñ+¨F°1©H°g¸wÓGÈÕOð ð 	×Ñœ) R×%6Ñ%6¸ÀÔIØ"ˆÔØ�‰˜×)Ñ)¨'°7Ó;Ô<Ø�‰�b×'Ñ'¨°Ó9¸4Ô@ð ×#Ñ#Ð%?Ð$@ÀÑ$BÕCØ�O‰O˜BŸI™I g¨w¸Ó@ÔAØ×Ñ˜RŸY™Y w°¸ÓAÔB÷ Dð
 	×Ñœ* b×&7Ñ&7¸À'È6ÕR÷ DÐCús   Å>AG/Ç/G8c                 ó¢  — | j                  «       }t        |d«       t        |d«       t        j                  |«      }| j                  |j                  «       d«       |j                  ddd«       |j                  «        | j                  |j                  «       d«       t        || j                  «       |j                  «        | j                  |j                  «       | j                  «       |j                  ddd	«       |j                  «        | j                  |j                  «       | j                  «       t        j                  «       }| j                  t        |j                  «       | j                  t        |j                  «       t        j                  «       }|j                  |«       | j                  |j                  «       | j                  «       t        |«       t        |d«       | j                  d
«      5  |j                  d¬«       ddd«       | j                  |j                  «       d«       y# 1 sw Y   Œ*xY w)r§   r$   r¨   r   rZ   rÿ   r~   s-   user1:realm:2a6cf53e7d8f8cf39d946dc880b14128
r\   rn   z!load\(force=False\) is deprecatedF)ÚforceN)rF   r   r   r   rü   rH   rI   rs   r©   rG   rª   rN   r«   r   rL   r­   s        r   r±   zHtdigestFileTest.test_05_load‡  s¯  € ð �{‰{‹}ˆÜ��rÔÜ˜D !Ô$Ü× Ñ  Ó&ˆØ×Ñ˜Ÿ™›¨Ô-ð 	�‰˜ ¨'Ô2Ø
×ÑÔØ×Ñ˜Ÿ™›Ð)ZÔ[ô 	��t—~‘~Ô&Ø
×ÑÔØ×Ñ˜Ÿ™›¨¯©Ô8ð 	�‰˜ ¨'Ô2Ø
�‰Œ	Ø×Ñ˜Ÿ™›¨¯©Ô8ô × Ñ Ó"ˆØ×Ñœ,¨¯©Ô0Ø×Ñœ,¨×(:Ñ(:Ô;ô × Ñ Ó"ˆØ
�‰�ŒØ×Ñ˜Ÿ™›¨¯©Ô8ô 	˜TÔ"Ü��rÔØ×#Ñ#Ð$HÕIØ�G‰G˜%ˆGÔ ÷ Jà×Ñ˜Ÿ™›¨Õ-÷ JÐIús   È	IÉIc                 ó.  — | j                  «       }t        || j                  «       t        j                  |«      }|j                  dd«       |j                  dd«       |j                  «        | j                  t        |«      | j                  «       t        j                  «       }|j                  ddd«       | j                  t        |j                  «       |j                  |«       | j                  t        |«      |j                  «       «       y)r³   rZ   rÿ   r[   r~   N)rF   r   rG   r   rü   r_   r´   rH   r   r`   rs   rN   r«   rI   rµ   s       r   r¶   zHtdigestFileTest.test_06_save°  sÇ   € ð �{‰{‹}ˆÜ��t—~‘~Ô&Ü× Ñ  Ó&ˆð 	�	‰	�'˜7Ô#Ø
�	‰	�'˜7Ô#Ø
�‰Œ	Ø×Ñœ $›¨¯©Ô8ô × Ñ Ó"ˆØ
�‰˜ ¨'Ô2Ø×Ñœ,¨¯©Ô0ð 	�‰�ŒØ×Ñœ $›¨¯©«Õ8r   c                 óœ  — t         j                  j                  | j                  «      }| j	                  |j                  d«      d«       | j	                  |j                  «       dg«       | j	                  |j                  d«      d«       | j	                  |j                  «       g «       | j	                  |j                  «       d«       y)ztest realms() & delete_realm()rB   r   rÿ   é   r   N)r   rü   r^   rG   rH   Údelete_realmÚrealmsrI   rb   s     r   Útest_07_realmszHtdigestFileTest.test_07_realmsÆ  s’   € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆà×Ñ˜Ÿ™¨Ó-¨qÔ1Ø×Ñ˜Ÿ™› w iÔ0à×Ñ˜Ÿ™¨Ó1°1Ô5Ø×Ñ˜Ÿ™› bÔ)Ø×Ñ˜Ÿ™›¨Õ-r   c                 ó²  — t         j                  j                  | j                  «      }| j	                  |j                  dd«      d«       | j	                  |j                  dd«      d«       | j	                  |j                  dd«      d«       | j                  d«      5  | j	                  |j                  dd«      d«       ddd«       y# 1 sw Y   yxY w)	rÃ   r�   rÿ   Ú a500bb8c02f6a9170ae46af10c898744r’   Ú ab7b5d5f28ccc7666315f508c7358519r\   NrÄ   )r   rü   r^   rG   rH   r�   rL   rÅ   rb   s     r   rÆ   z!HtdigestFileTest.test_08_get_hashÑ  s¦   € ä× Ñ ×,Ñ,¨T¯^©^Ó<ˆØ×Ñ˜Ÿ™ W¨gÓ6Ð8ZÔ[Ø×Ñ˜Ÿ™ W¨gÓ6Ð8ZÔ[Ø×Ñ˜Ÿ™ W¨gÓ6¸Ô=à×#Ñ#Ð$<Õ=Ø×Ñ˜RŸW™W W¨gÓ6Ð8ZÔ[÷ >×=Ñ=ús   Â!#CÃCc                 óx  — | j                  t        t        j                  d¬«       t        j                  j	                  | j
                  dd¬«      }| j                  |j                  «       t        d«      g«       | j                  |j                  t        d«      «      t        d«      g«       t        j                  j	                  | j                  dd¬«      }| j                  |j                  «       t        d«      g«       | j                  |j                  t        d«      «      t        d«      g«       y	)
ztest encoding parameterr¸   r¹   r    Tr»   u   realmÃ¦r½   r¾   N)rN   ra   r   rü   r^   r¿   rH   r  r   r”   rÀ   rb   s     r   Útest_09_encodingsz"HtdigestFileTest.test_09_encodingsÛ  sñ   € ð 	×Ñœ*¤f×&9Ñ&9ÀHÐÔMô × Ñ ×,Ñ,¨T×-@Ñ-@È7ÐcgÐ,ÓhˆØ×Ñ˜Ÿ™›¬¨-Ó(8Ð&:Ô;Ø×Ñ˜Ÿ™¤! MÓ"2Ó3´q¸³Ð5HÔIô × Ñ ×,Ñ,¨T×-BÑ-BÈYÐgkÐ,ÓlˆØ×Ñ˜Ÿ™›¬¨-Ó(8Ð&:Ô;Ø×Ñ˜Ÿ™¤! MÓ"2Ó3´q¸³Ð5HÕIr   c                 ó  — t         j                  j                  | j                  «      }| j	                  |j                  «       | j                  «       t        j                  «       }| j	                  |j                  «       d«       y)ztest to_string()r   N)r   rü   r^   rG   rH   rI   rb   s     r   Útest_10_to_stringz"HtdigestFileTest.test_10_to_stringê  rÉ   r   c                 óÀ   — | j                  t        t        j                  j                  d«       | j                  t        t        j                  j                  d«       y )Ns   realm:user1:pass1:other
ry   )rN   ra   r   rü   r^   rÏ   s    r   rÐ   z"HtdigestFileTest.test_11_malformedõ  sD   € Ø×Ñœ*¤f×&9Ñ&9×&EÑ&EØ(ô	*à×Ñœ*¤f×&9Ñ&9×&EÑ&EØõ	r   N)rñ   rò   ró   rô   rõ   rG   r`   rt   r¿   rÀ   rS   rc   rh   rw   r•   r¥   r±   r¶   r  rÆ   r  r  rÐ   rù   r   r   rû   rû      sw   „ Ù!Ø&ÐðC€IðC€IðC€Ið V€NØOÐò>ò$Cò9ò<ò82òSò2'.òR9ò,	.ò\òJò	.ór   rû   )é
   rU   ))rô   Ú
__future__r   Úloggingr   r   r&   Úpasslibr   r   Úpasslib.excr   Úpasslib.utils.compatr   Úpasslib.tests.backportsr	   Úpasslib.tests.utilsr
   r   r   r   r   Úpasslib.utilsr   Úpasslib.utils.handlersr   rñ   r9   r   ÚenvironÚgetr(   r2   r6   r<   ÚHAVE_HTPASSWDrï   r÷   rö   r>   rû   rù   r   r   Ú<module>r(     s°   ðÙ Fõ &å Û 	Û ÷ %Ý +Ý 'Ý ,ß RÓ RÝ "Ý "Ý :á�Ó€ó#ð —
‘
—‘Ð;Ó<ÒJÀ
€óòòñ" '7Ó&8Ñ #€Ð#à+˜×+Ñ+¨MÐ;]Ó^Ð ô]O�xô ]OôLy�xõ yr   