HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_secrets.cpython-310.opt-1.pyc
o

�i�@sjdZddlZddlZddlZGdd�dej�ZGdd�dej�ZGdd�dej�Zed	kr3e�	�dSdS)
z�Test the secrets module.

As most of the functions in secrets are thin wrappers around functions
defined elsewhere, we don't need to test them exhaustively.
�Nc@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Compare_Digest_Testsz%Test secrets.compare_digest function.c	CsNdD]"}|d}|d}|�t�||��|�t�|�d�|�d���qdS)N)�aZbcdZxyz123�d�utf-8)�
assertTrue�secrets�compare_digest�encode��self�sr�b�r�./usr/local/lib/python3.10/test/test_secrets.py�
test_equals �zCompare_Digest_Tests.test_equalc	Csz|�t�dd��|�t�dd��dD]&}|dd}|dd}|�t�||��|�t�|�d	�|�d	���qdS)
N�abcZabcdsabcsabcd)�xZmnZa1b2c3r�q�kr)ZassertFalserr	r
rrrr�test_unequals �z!Compare_Digest_Tests.test_unequalcCs6d}|�d�}|�ttj||�|�ttj||�dS)NZabcder)r
�assertRaises�	TypeErrorrr	)rrrrrr�test_bad_types$s
z#Compare_Digest_Tests.test_bad_typescCs,|�t�dd�t�|�t�dd�t�dS)NrZxyz)�assertIsInstancerr	�bool)rrrr�	test_bool-szCompare_Digest_Tests.test_boolN)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrs
	rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Random_Testsz*Test wrappers around SystemRandom methods.cCsVd}dD]$}td�D]}t�|�}|�d|kod|kn|||f�q
qdS)Nzrandbits(%d) returned %d)����r�)�rangerZrandbitsr)r�errmsgZnumbits�i�nrrr�
test_randbits6s
.��zRandom_Tests.test_randbitscCs.gd�}td�D]}|�t�|�|v�qdS)N)�r&���� �@�
)r'rr�choice)r�itemsr)rrr�test_choice>s�zRandom_Tests.test_choicecCsJtdd�D]
}|�t�|�t|��q|�ttjd�|�ttjd�dS)Nr&r2r���)r'ZassertInr�	randbelowr�
ValueError)rr)rrr�test_randbelowDszRandom_Tests.test_randbelowN)rrrr r+r5r9rrrrr!3s
r!c@r)�Token_TestszTest token functions.c
Cs�tjtjtjfD]H}|j|d��8|j}z|�Wnty)|�d|�Ynwz|d�Wnty@|�d|�YnwWd�n1sKwYqtj}|�	t
t�d��|�|�	t
t�d��d|�dS)N)�funcz$%s cannot be called with no argumentz%s cannot be called with Noner&)r�token_bytes�	token_hex�
token_urlsafe�subTestrrZfailZDEFAULT_ENTROPY�assertEqual�len)rr;�name�sizerrr�test_token_defaultsOs*�
�����
zToken_Tests.test_token_defaultsc	CsbdD],}|j|d��|�t�|�t�|�tt�|��|�Wd�n1s)wYqdS)N)r,r.�r�r*)r?rrr<�bytesr@rA)rr*rrr�test_token_bytesas���zToken_Tests.test_token_bytesc	Cs|dD]9}|j|d��)t�|�}|�|t�|�t|�d|�|�tdd�|D���Wd�n1s6wYqdS)N)r,r#��ZrFr&css�|]}|tjvVqdS�N)�string�	hexdigits��.0�crrr�	<genexpr>os�z-Token_Tests.test_token_hex.<locals>.<genexpr>)	r?rr=r�strr@rAr�all�rr*r
rrr�test_token_hexhs
���zToken_Tests.test_token_hexc	s|tjtjd�dD]1}|j|d��!t�|�}|�|t�|�t	�fdd�|D���Wd�n1s6wYq
dS)Nz-_)r,���LrFc3s�|]}|�vVqdSrKrrN�ZlegalrrrQxs�z1Token_Tests.test_token_urlsafe.<locals>.<genexpr>)
rL�
ascii_letters�digitsr?rr>rrRrrSrTrrYr�test_token_urlsafeqs
���zToken_Tests.test_token_urlsafeN)rrrr rDrHrUr\rrrrr:Ls	r:�__main__)
r rZunittestrLZTestCaserr!r:r�mainrrrr�<module>s$/�