HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/fail2ban/tests/__pycache__/banmanagertestcase.cpython-38.pyc
U

ܜ^�$�@sddZdZdZddlZddlmZmZddlmZdd	l	m
Z
Gd
d�dej�ZGdd
�d
ej�Z
dS)z
Cyril Jaquierz Copyright (c) 2004 Cyril JaquierZGPL�N�)�setUpMyTime�tearDownMyTime�)�
BanManager)�	BanTicketcsheZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Z�Z
S)�
AddFailurecs,tt|���t�tdd�|_t�|_dS)�Call before every test case.�
193.168.0.128��;f�AN)�superr�setUprr�_AddFailure__ticketr�_AddFailure__banManager��self��	__class__��C/usr/lib/python3/dist-packages/fail2ban/tests/banmanagertestcase.pyr
#szAddFailure.setUpcstt|���t�dS�zCall after every test case.N)rr�tearDownrrrrrr*szAddFailure.tearDowncCsZ|�|j�|j��|�|j��d�|�|j��d�|j�d�|�|j��d�dS)Nrr)�
assertTruer�addBanTicketr�assertEqual�sizeZgetBanTotalZsetBanTotalrrrr�testAdd/s
zAddFailure.testAddcCs>|�|j�|j��|�|j�|j��|�|j��d�dS)Nr)rrrr�assertFalserrrrrr�testAddDuplicate6szAddFailure.testAddDuplicatecCs�|j��}d}dD]�\}}tdd�}td|�}|dk	r@|�|�|�|j�|��|�|j�|��|�|j��d�|j�	|�
��}|�|�|�|�|��|�|�|�|k�|�|�}|�|��d�|dkr|�|�|�d�qdS)Nr))rN)g�Tf�AN)ri�Q)r���r
rrr)
r�
getBanTimer�
setBanTimerrrrr�
getTicketByID�getIDZgetEndOfBanTime�getTime)rZ
defBanTimeZprevEndOfBanTimeZtnewZbtnewZticket1Zticket2Z	banticketrrr�testAddDuplicateWithTime;s"




z#AddFailure.testAddDuplicateWithTimecCs4|�|j�|j��tdd�}|�|j�|��dS)Nr
r)rrrrr�
_inBanList�r�ticketrrr�testInListOK[s
zAddFailure.testInListOKcCs4|�|j�|j��tdd�}|�|j�|��dS)Nz
111.111.1.111r)rrrrrrr&r'rrr�
testInListNOK`s
zAddFailure.testInListNOKc	Cst|j��|j���}d}dD]f}|j�|j�|d7}|�|�|�|j�|��|�t	|j�
|����d|��|��||f�q|j�|j�|d7}|�d�|�|j�|��|�d�|�|j�|��|�t	|j�
|����d|��|��d|f�dS)Nr)��i�rrzFBanTicket: ip=%s time=%s bantime=%s bancount=%s #attempts=0 matches=[]rr+)rrZgetIPr$rrr!rr�strr")rr(�c�irrr�testBanTimeIncres&
�

�zAddFailure.testBanTimeIncrcCs�|j��}|j��}|�|j�|j��|�|j�|j��|�|j�|�g�|�|j�||d�|jg�|�|j�	�d�|�|j�|j��t
|j��|d�}|�|j�|��|�t
|j�||d��d�|�t
|j�||dd��d�td�D]>}t
d||�}|�|�|�|d�|�|j�|���q|�t
|j�||dd��d�|�t
|j�||dd��d	�|�|j�	�d�dS)
NrriX�z193.168.0.%s�
r�2�)rr rr$rrr&r�	unBanListrrr#r�len�ranger!)r�btimeZstimer(r.rrr�	testUnbanxs&

  $$$zAddFailure.testUnbanc	Cs�|j��}|j�d�z`|�|j�|j��|�|j�|j��|�|j�|j�	�|d�g�|�|j�
�d�W5|j�|�XdS)Nrr)rr r!rrrr&rr4r$r)rr7rrr�testUnbanPermanent�s
"zAddFailure.testUnbanPermanent)�__name__�
__module__�__qualname__r
rrrr%r)r*r/r8r9�
__classcell__rrrrr"s rcs\eZdZ�fdd�Z�fdd�ZdZdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Z�ZS)�StatusExtendedCymruInfocs`tt|���tj��t�d|_d|_d|_	d|_
t|jd�}t�|_
|�|j
�|��dS)r	z
93.184.216.34Z15133ZEUZripenccrN)rr>r
�unittest�F2BZSkipIfNoNetworkrZ _StatusExtendedCymruInfo__ban_ip�_StatusExtendedCymruInfo__asn�!_StatusExtendedCymruInfo__country�_StatusExtendedCymruInfo__rirrr�$_StatusExtendedCymruInfo__banManagerrrr'rrrr
�s
zStatusExtendedCymruInfo.setUpcstt|���t�dSr)rr>rrrrrrr�sz StatusExtendedCymruInfo.tearDown)TNcCs^t}|jdr*|jjtjjr dndd�}n
|jd}|�d�rZd|f|_t�d|d��|S)	Nrr�)Ztimeoutr�errorFz.Skip test because service is not available: %s)	r>�	availablerDZgetBanListExtendedCymruInfor?r@Zfast�getZSkipTest)rZtc�
cymru_inforrr�_getBanListExtendedCymruInfo�s
�


z4StatusExtendedCymruInfo._getBanListExtendedCymruInfocCs,|��}|�||jg|jg|jgd��dS)N�ZasnZcountryZrir)rJ�assertDictEqualrArBrC)rrIrrr�
testCymruInfo�s��z%StatusExtendedCymruInfo.testCymruInfocCs |�|j�|���|jg�dS�N)rrDZgeBanListExtendedASNrJrArrrr�testCymruInfoASN�s�z(StatusExtendedCymruInfo.testCymruInfoASNcCs |�|j�|���|jg�dSrN)rrDZgeBanListExtendedCountryrJrBrrrr�testCymruInfoCountry�s�z,StatusExtendedCymruInfo.testCymruInfoCountrycCs |�|j�|���|jg�dSrN)rrDZgeBanListExtendedRIRrJrCrrrr�testCymruInfoRIR�s�z(StatusExtendedCymruInfo.testCymruInfoRIRcCs�t�|_tdd�}|�|j�|��|��}|�|dgdgdgd��tdd�}|�|j�|��|��}|j|ddgddgdd	gd�d
td�dS)Nz0.0.0.0rZnxdomainrKz8.0.0.0g<f�AZ3356ZUSZarinr)�level�key)	rrDrrrrJrLZassertSortedEqualr,)rr(rIrrr�testCymruInfoNxdomain�s*
��
��z-StatusExtendedCymruInfo.testCymruInfoNxdomain)
r:r;r<r
rrGrJrMrOrPrQrTr=rrrrr>�s

r>)�
__author__Z
__copyright__Z__license__r?ZutilsrrZserver.banmanagerrZ
server.ticketrZTestCaserr>rrrr�<module>s|