
     hr                     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       [/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/passlib/tests/test_apache.pybackdate_file_mtimer      sC     GGT"EGGT"6)EHHTE5>"    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%]Od2:??#-#4#4uJOOZ^`D&HC	B
!#)
,C7Nr   c                 ,    t        d| |g|      \  }}| S )z%
    wrapper for htpasswd verify
    z-vi)r2   )r   userpasswordr/   r1   s        r   _call_htpasswd_verifyr6   9   s"     eT40(;GC6Mr   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 	;$$TE:B	;-$'" 			$'6#6#6=	; 	;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 	*bii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   sj     ,,NN; - 8:;':;8 ##$?@ 	V$$000UB	V:;':;8 	*boowG ##$>? 	'IIgv&	'))'6:;	V 	V	' 	'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  kD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OOGW-::&&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 	(E51 	z*F,D,DZ,PQ34f6N6NOc6de/0&2J2JK[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  sY     ,,T^^<)R%6%67C))'':dBC 1 		AAA 1 1&(F1H EF 1 1&(G D MN			 	*b&7&7&I ##%?$@$BC 	:OOBIIgw78RYYw89	: 	: ' 8		: 	: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&9HM   ,,T-@-@7<@ - Bq%89 ##$EF 	U$$001D1Dt0TB	U%89   ,,T-B-B7@QU - Wq%89	U 	U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##$<= 	9RWWW-x8	9 	9 	9s   "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[ 	GZ(
+-Z[ 	GZ(
+-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23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12BC
G[^DE ,,V4	
G[Y?@ 	G/0 		.tWgFG.tWgFG.tWgFG.tWgFG-dGZHI-dGZHI-dGZ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>?
	.tWgFGOO1$LM 24*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 5N2.JFI>D#	:;<.;V.\:4!<J;,:(9	.*
-1^ "J "JH X---h79R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7G457H568 	*bii'B 	*bii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7H567G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  sg     ,,T^^<(CD'7CD8 	)R__gwG#
)
'8W5 	*boowP*boowP 	*boovxP*boovwO ##$>? 	1IIgx0	1))'6:;	1 	1s   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24ab)RXXq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7GL)R%6%67Kb''A4H! 	PAAAOOB--fQhJKMM"++F1HgwGO	P 	)R%6%6I"))'7;<b''94@ ##%?$@$BC 	COOBIIgw@ARYYwAB	C
 	*b&7&7'6R	C 	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 	!GG%G 	!-	! 	!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wi011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^^<Wg68Z[Wg68Z[Wg6=##$<= 	\RWWWg68Z[	\ 	\ 	\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&9HM   ,,T-@-@7cg,h-(8&:;!M"23q5HI   ,,T-B-BYgk,l-(8&:;!M"23q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   