https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/fail2ban/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/fail2ban/tests/__pycache__/banmanagertestcase.cpython-310.pyc
o

��_:&�@sddZdZdZddlZddlmZmZddlmZdd	l	m
Z
Gd
d�dej�ZGdd
�d
ej�Z
dS)z
Cyril Jaquierz Copyright (c) 2004 Cyril Jaquier�GPL�N�)�setUpMyTime�tearDownMyTime�)�
BanManager)�	BanTicketcspeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�
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.setUpc�tt|���t�dS�zCall after every test case.N)r
r	�tearDownrrrrrr*�
zAddFailure.tearDowncCsZ|�|j�|j��|�|j��d�|�|j��d�|j�d�|�|j��d�dS)Nrr)�
assertTruer�addBanTicketr�assertEqual�size�getBanTotal�setBanTotalrrrr�testAdd/s
zAddFailure.testAddcCs>|�|j�|j��|�|j�|j��|�|j��d�dS)Nr)rrrr�assertFalserrrrrr�testAddDuplicate6szAddFailure.testAddDuplicatecCs�|j��}d}dD]j\}}tdd�}td|�}|dur |�|�|�|j�|��|�|j�|��|�|j��d�|j�	|�
��}|�|�|�|�|��|�|�|�|k�|�|�}|�|��d�|dkrs|�|�|�d�q	dS)Nr))rN)g�Tf�AN)ri�Q)r���rrrr$)
r�
getBanTimer�
setBanTimerrr"rr�
getTicketByID�getID�getEndOfBanTime�getTime)r�
defBanTime�prevEndOfBanTime�tnew�btnew�ticket1�ticket2�	banticketrrr�testAddDuplicateWithTime;s&




��z#AddFailure.testAddDuplicateWithTimecCs4|�|j�|j��tdd�}|�|j�|��dS)Nrr)rrrrr�
_inBanList�r�ticketrrr�testInListOK[�
zAddFailure.testInListOKcCs4|�|j�|j��tdd�}|�|j�|��dS)Nz
111.111.1.111r)rrrrrr"r3r4rrr�
testInListNOK`r7zAddFailure.testInListNOKc	Cst|j��|j���}d}dD]3}|j�|j�|d7}|�|�|�|j�|��|�t	|j�
|����d|��|��||f�q|j�|j�|d7}|�d�|�|j�|��|�d�|�|j�|��|�t	|j�
|����d|��|��d|f�dS)Nr)��i�r$rzFBanTicket: ip=%s time=%s bantime=%s bancount=%s #attempts=0 matches=[]r$r9)rr�getIPr*rrr&r"r�strr')rr5�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*rrr3r�	unBanListrrr(r"�len�ranger&)r�btime�stimer5r=rrr�	testUnbanxs&

  $$$zAddFailure.testUnbanc	Cs�|j��}|j�d�z7|�|j�|j��|�|j�|j��|�|j�|j�	�|d�g�|�|j�
�d�W|j�|�dS|j�|�w)Nr$r)rr%r&rrrr3rrCr*r)rrFrrr�testUnbanPermanent�s
"zAddFailure.testUnbanPermanentcCsXtdd�tdd�g}|d�d�|D]}|j�|�q|�|jjddd�dd	g�dS)
Nz	192.0.2.1rz	192.0.2.2rr$T)�ordered�withTimez:192.0.2.1 	2006-12-31 23:59:59 + 600 = 2007-01-01 00:09:59z9192.0.2.2 	2006-12-31 23:59:59 + -1 = 9999-12-31 23:59:59)rr&rr�assertSortedEqual�
getBanList)r�tickets�trrr�testBanList�s���zAddFailure.testBanList)�__name__�
__module__�__qualname__rrr!r#r2r6r8r>rHrIrP�
__classcell__rrrrr	"s r	cs\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.34�15133�EU�ripenccrN)r
rUr�unittest�F2B�SkipIfNoNetworkr� _StatusExtendedCymruInfo__ban_ip�_StatusExtendedCymruInfo__asn�!_StatusExtendedCymruInfo__country�_StatusExtendedCymruInfo__rirrr�$_StatusExtendedCymruInfo__banManagerrrr4rrrr�s
zStatusExtendedCymruInfo.setUpcrr)r
rUrrrrrrr�rz StatusExtendedCymruInfo.tearDown)TNcCs^t}|jdr|jjtjjrdndd�}n|jd}|�d�r-d|f|_t�d|d��|S)	Nrr�)�timeoutr�errorFz.Skip test because service is not available: %s)	rU�	availabler`�getBanListExtendedCymruInforYrZ�fast�get�SkipTest)r�tc�
cymru_inforrr�_getBanListExtendedCymruInfo�s
�


z4StatusExtendedCymruInfo._getBanListExtendedCymruInfocCs,|��}|�||jg|jg|jgd��dS)N��asn�country�rir)rk�assertDictEqualr]r^r_)rrjrrr�
testCymruInfo�s��z%StatusExtendedCymruInfo.testCymruInfocC� |�|j�|���|jg�dS�N)rr`�geBanListExtendedASNrkr]rrrr�testCymruInfoASN���z(StatusExtendedCymruInfo.testCymruInfoASNcCrrrs)rr`�geBanListExtendedCountryrkr^rrrr�testCymruInfoCountry�rvz,StatusExtendedCymruInfo.testCymruInfoCountrycCrrrs)rr`�geBanListExtendedRIRrkr_rrrr�testCymruInfoRIR�rvz(StatusExtendedCymruInfo.testCymruInfoRIRcCs�t�|_tdd�}|�|j�|��|��}|�|dgdgdgd��tdd�}|�|j�|��|��}|j|ddgddgdd	gd�d
td�dS)Nz0.0.0.0r�nxdomainrlz8.0.0.0g<f�A�3356�US�arinr$)�level�key)	rr`rrrrkrprLr;)rr5rjrrr�testCymruInfoNxdomain�s(
��
�
�z-StatusExtendedCymruInfo.testCymruInfoNxdomain)
rQrRrSrrrdrkrqrurxrzr�rTrrrrrU�s

rU)�
__author__�
__copyright__�__license__rY�utilsrr�server.banmanagerr�
server.ticketr�TestCaser	rUrrrr�<module>s

https://t.me/RX1948 - 2025