AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_http_headers.cpython-310.pyc
o

�b�Z�@s\dZddlmZddlmZddlmZmZmZdd�Z	Gdd�de�Z
Gd	d
�d
e�ZdS)z(
Tests for L{twisted.web.http_headers}.
�)�TestCase)�Headers)�bytesLinearWhitespaceComponents�sanitizedBytes�textLinearWhitespaceComponentscCs�|D]H}g}|�t||gi��t�}|�||�|�|�t�}|�||g�|�|�|D]}|�t|���||gfg�|�|�|�|g�q/qdS)a
    Assert that the components are sanitized to the expected value as
    both a header name and value, across all of L{Header}'s setters
    and getters.

    @param testCase: A test case.

    @param components: A sequence of values that contain linear
        whitespace to use as header names and values; see
        C{textLinearWhitespaceComponents} and
        C{bytesLinearWhitespaceComponents}

    @param expected: The expected sanitized form of the component for
        both headers names and their values.
    N)�appendr�addRawHeader�
setRawHeaders�assertEqual�list�getAllRawHeaders�
getRawHeaders)�testCase�
components�expected�	component�headers�added�	setHeader�header�r�D/usr/lib/python3/dist-packages/twisted/web/test/test_http_headers.py�assertSanitizeds 

���rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4S)5�BytesHeadersTestszE
    Tests for L{Headers}, using L{bytes} arguments for methods.
    cC�t|tt�dS�zf
        Linear whitespace in header names or values is replaced with a
        single space.
        N)rrr��selfrrr�test_sanitizeLinearWhitespace:�z/BytesHeadersTests.test_sanitizeLinearWhitespacecCs&tddgi�}|�|�d�dg�dS)zx
        The header values passed to L{Headers.__init__} can be retrieved via
        L{Headers.getRawHeaders}.
        �Foo�bar�fooN�rr
r
�r�hrrr�test_initializerAsz"BytesHeadersTests.test_initializercCsPddg}t�}|�d|�|�|�d��|�|�d��|�|�d�|�dS)z�
        L{Headers.setRawHeaders} sets the header values for the given
        header name to the sequence of byte string values.
        �value1�value2�test�TestN�rr	�
assertTrue�	hasHeaderr
r
)r�rawValuer%rrr�test_setRawHeadersIsz$BytesHeadersTests.test_setRawHeaderscC� t�}|�t|jdddi�dS)zN
        L{Headers.setRawHeaders} requires values to be of type list.
        �keyr r!N�r�assertRaises�	TypeErrorr	r$rrr�)test_rawHeadersTypeCheckingValuesIterableU�z;BytesHeadersTests.test_rawHeadersTypeCheckingValuesIterablecCs0t�}|�t|jddg�}|�|jdd�dS)zf
        L{Headers.setRawHeaders} requires C{name} to be a L{bytes} or
        L{str} string.
        Nr"r�BHeader name is an instance of <class 'NoneType'>, not bytes or str�rr3r4r	r
�args�rr%�errr�test_rawHeadersTypeCheckingName\s�z1BytesHeadersTests.test_rawHeadersTypeCheckingNamecCs2t�}|�t|jdddg�}|�|jdd�dS)zn
        L{Headers.setRawHeaders} requires values to a L{list} of L{bytes} or
        L{str} strings.
        r1r!NrzQHeader value at position 1 is an instance of <class 'NoneType'>, not bytes or strr8r:rrr�*test_rawHeadersTypeCheckingValuesAreStringhs�z<BytesHeadersTests.test_rawHeadersTypeCheckingValuesAreStringcCsLt�}|�dd�|�|�d�dg�|�dd�|�|�d�ddg�dS)�N
        L{Headers.addRawHeader} adds a new value for a given header.
        r)�lemur�pandaN�rrr
r
r$rrr�test_addRawHeaderus
z#BytesHeadersTests.test_addRawHeadercCs.t�}|�t|jdd�}|�|jdd�dS)ze
        L{Headers.addRawHeader} requires C{name} to be a L{bytes} or L{str}
        string.
        Nr"rr7�rr3r4rr
r9r:rrr�test_addRawHeaderTypeCheckName��z0BytesHeadersTests.test_addRawHeaderTypeCheckNamecCs.t�}|�t|jdd�}|�|jdd�dS)zc
        L{Headers.addRawHeader} requires value to be a L{bytes} or L{str}
        string.
        r1NrzCHeader value is an instance of <class 'NoneType'>, not bytes or strrCr:rrr�test_addRawHeaderTypeCheckValue�rEz1BytesHeadersTests.test_addRawHeaderTypeCheckValuecC�|�t��d��dS)�z
        L{Headers.getRawHeaders} returns L{None} if the header is not found and
        no default is specified.
        r)N��assertIsNonerr
rrrr�test_getRawHeadersNoDefault��z-BytesHeadersTests.test_getRawHeadersNoDefaultcCs$t�}t�}|�|�d|�|�dS)�o
        L{Headers.getRawHeaders} returns the specified default value when no
        header is found.
        r)N)r�object�assertIdenticalr
�rr%�defaultrrr�test_getRawHeadersDefaultValue�sz0BytesHeadersTests.test_getRawHeadersDefaultValuecCsJt�}dg}|�d|�|�|�d|�dt�|�|�d|�dg�dS)z�
        If the object passed as the value list to L{Headers.setRawHeaders}
        is later passed as a default to L{Headers.getRawHeaders}, the
        result nevertheless contains encoded values.
        �valuer1r�valueN)rr	�assertIsInstancer
�bytesr
rPrrr�*test_getRawHeadersWithDefaultMatchingValue��
z<BytesHeadersTests.test_getRawHeadersWithDefaultMatchingValuecCs@t�}|�ddg�|�|�d�dg�|�|�d�dg�dS)�m
        L{Headers.getRawHeaders} returns the values which have been set for a
        given header.
        r)r?r*N�rr	r
r
r$rrr�test_getRawHeaders�sz$BytesHeadersTests.test_getRawHeaderscCs8t�}|�ddg�|�|�d��|�|�d��dS)�i
        Check that L{Headers.hasHeader} returns C{True} when the given header
        is found.
        r)r?r*N�rr	r,r-r$rrr�test_hasHeaderTrue�sz$BytesHeadersTests.test_hasHeaderTruecCrG)�c
        L{Headers.hasHeader} returns C{False} when the given header is not
        found.
        r)N��assertFalserr-rrrr�test_hasHeaderFalse�rLz%BytesHeadersTests.test_hasHeaderFalsecCszt�}|�ddg�|�|�d��|�d�|�|�d��|�ddg�|�|�d��|�d�|�|�d��dS)�N
        Check that L{Headers.removeHeader} removes the given header.
        r"r?r!r@sBarN�rr	r,r-�removeHeaderrar$rrr�test_removeHeader�s

z#BytesHeadersTests.test_removeHeadercC�(t�}|�d�|�t|���g�dS)�k
        L{Headers.removeHeader} is a no-operation when the specified header is
        not found.
        r)N�rrer
rrr$rrr�test_removeHeaderDoesntExist��
z.BytesHeadersTests.test_removeHeaderDoesntExistcCs�t�}|�|�d�d�|�|�d�d�|�|�d�d�|�|�d�d�|�|�d	�d
�|�|�d�d�|�|�d
�d�|�|�d�d�|�|�d�d�dS)zr
        L{Headers._canonicalNameCaps} returns the canonical capitalization for
        the given header.
        r)r*s
test-stuffs
Test-Stuffscontent-md5�Content-MD5sdntsDNTsetagsETagsp3psP3PstesTE�www-authenticate�WWW-Authenticatesx-xss-protectionsX-XSS-ProtectionN)rr
�_canonicalNameCapsr$rrr�test_canonicalNameCaps�sz(BytesHeadersTests.test_canonicalNameCapscCsHt�}|�ddg�|�ddg�dd�|��D�}|�|ddh�d	S)
��
        L{Headers.getAllRawHeaders} returns an iterable of (k, v) pairs, where
        C{k} is the canonicalized representation of the header name, and C{v}
        is a sequence of values.
        r)�lemursrm�basic aksljdlk=cS�h|]
\}}|t|�f�qSr��tuple��.0�k�vrrr�	<setcomp>�z:BytesHeadersTests.test_getAllRawHeaders.<locals>.<setcomp>�rn)rs)r*�rrN�rr	rr
�rr%�
allHeadersrrr�test_getAllRawHeaders�s�z'BytesHeadersTests.test_getAllRawHeaderscCsft�}|�ddg�t�}|�ddg�t�}|�dddg�|�||�|�||�|�||�dS)��
        A L{Headers} instance compares equal to itself and to another
        L{Headers} instance with the same values.
        r"r@r?N�rr	r
�assertNotEqual)r�first�second�thirdrrr�test_headersComparisonsz(BytesHeadersTests.test_headersComparisoncC�0t�}|�|d�|�|t��|�|d�dS)�f
        An instance of L{Headers} does not compare equal to other unrelated
        objects.
        rr"N�rr�rNr$rrr�test_otherComparison�z&BytesHeadersTests.test_otherComparisonc
C�@d}d}d}|�tt|||gi��d|�d|�d|�d��dS)	zy
        The L{repr} of a L{Headers} instance shows the names and values of all
        the headers it contains.
        r"r!�baz�	Headers({�: [�, �]})N�r
�reprr�r�foo�bar�bazrrr�	test_repr!s�zBytesHeadersTests.test_reprc
Cr�)	z�
        The L{repr} of a L{Headers} instance shows the names and values of all
        the headers it contains, not attempting to decode any raw bytes.
        r"sbar�sbaz�r�r�r�r�Nr�r�rrr�test_reprWithRawBytes.s�z'BytesHeadersTests.test_reprWithRawBytesc
CsPd}d}d}Gdd�dt�}|�t||||gi��d|�d|�d|�d	��d
S)��
        The L{repr} of an instance of a subclass of L{Headers} uses the name
        of the subclass instead of the string C{"Headers"}.
        r"r!r�c@�eZdZdS)z9BytesHeadersTests.test_subclassRepr.<locals>.FunnyHeadersN��__name__�
__module__�__qualname__rrrr�FunnyHeadersH�r�zFunnyHeaders({r�r�r�N)rr
r�)rr�r�r�r�rrr�test_subclassRepr?s�z#BytesHeadersTests.test_subclassReprcCsvt�}|�ddg�|��}|�|�d�dg�|�dd�|�|�d�dg�|�dd�|�|�d�ddg�dS)��
        L{Headers.copy} creates a new independent copy of an existing
        L{Headers} instance, allowing future modifications without impacts
        between the copies.
        r)r"r!r�N�rr	�copyr
r
r�rr%�irrr�	test_copyPszBytesHeadersTests.test_copyN)r�r�r��__doc__rr&r/r5r<r=rBrDrFrKrRrWr[r^rbrfrjrpr�r�r�r�r�r�r�rrrrr5s6

	

	

rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.S)/�UnicodeHeadersTestszC
    Tests for L{Headers}, using L{str} arguments for methods.
    cCrr)rrrrrrrrerz1UnicodeHeadersTests.test_sanitizeLinearWhitespacecCs:tddgi�}|�|�d�dg�|�|�d�dg�dS)aC
        The header values passed to L{Headers.__init__} can be retrieved via
        L{Headers.getRawHeaders}. If a L{bytes} argument is given, it returns
        L{bytes} values, and if a L{str} argument is given, it returns
        L{str} values. Both are the same header value, just encoded or
        decoded.
        �Foor�r"r!r�Nr#r$rrrr&lsz$UnicodeHeadersTests.test_initializercCs�ddg}ddg}t�}|�d|�|�|�d��|�|�d��|�|�d��|�|�d��|�|�d�|�|�|�d�|�d	S)
z�
        L{Headers.setRawHeaders} sets the header values for the given
        header name to the sequence of strings, encoded.
        �value1�value2r'r(�testr)r*�TestNr+)rr.�rawEncodedValuer%rrrr/xsz&UnicodeHeadersTests.test_setRawHeaderscCsxt�}|�t��|�ddg�Wd�n1swY|�t��|�d�Wd�dS1s5wYdS)z�
        Passing L{str} to any function that takes a header name will encode
        said header name as ISO-8859-1, and if it cannot be encoded, it will
        raise a L{UnicodeDecodeError}.
        �☃�valN)rr3�UnicodeEncodeErrorr	r-r$rrr�test_nameNotEncodable�s�"�z)UnicodeHeadersTests.test_nameNotEncodablecCsLt�}|�ddg�|�|�d��|�|�d�dg�|�|�d��dS)z}
        Passing L{str} to any function that takes a header name will encode
        said header name as ISO-8859-1.
        �ár"��Nr+r$rrr�test_nameEncoding�s
z%UnicodeHeadersTests.test_nameEncodingcCs@t�}|�dddg�|�|�d��|�|�d�ddg�dS)z|
        Passing L{str} to L{Headers.setRawHeaders} will encode the name as
        ISO-8859-1 and values as UTF-8.
        r�r�r"r�s☃Nr+r$rrr�test_rawHeadersValueEncoding�sz0UnicodeHeadersTests.test_rawHeadersValueEncodingcCr0)zQ
        L{Headers.setRawHeaders} requires values to be of type sequence
        �keyr�r�Nr2r$rrr�test_rawHeadersTypeChecking�r6z/UnicodeHeadersTests.test_rawHeadersTypeCheckingcCsbt�}|�dd�|�|�d�dg�|�dd�|�|�d�ddg�|�|�d�ddg�dS)r>r��lemur�pandar)r?r@NrAr$rrrrB�sz%UnicodeHeadersTests.test_addRawHeadercCrG)rHr�NrIrrrrrK�rLz/UnicodeHeadersTests.test_getRawHeadersNoDefaultcCsht�}t�}|�|�d|�|�|�|�dd�d�|�|�ddg�dg�|�|�ddg�dg�dS)rMr�Nr�)rrNrOr
r
rPrrrrR�s�z2UnicodeHeadersTests.test_getRawHeadersDefaultValuecCsJt�}dg}|�d|�|�|�d|�dt�|�|�d|�dg�dS)z�
        If the object passed as the value list to L{Headers.setRawHeaders}
        is later passed as a default to L{Headers.getRawHeaders}, the
        result nevertheless contains decoded values.
        rTr1r�rrSN)rr	rUr
�strr
rPrrrrW�rXz>UnicodeHeadersTests.test_getRawHeadersWithDefaultMatchingValuecCsht�}|�ddg�|�|�d�dg�|�|�d�dg�|�|�d�dg�|�|�d�dg�dS)rY�testár��Testá�test�r?�Test�NrZr$rrrr[�sz&UnicodeHeadersTests.test_getRawHeaderscCsXt�}|�ddg�|�|�d��|�|�d��|�|�d��|�|�d��dS)r\r�r�r�r�r�Nr]r$rrrr^�sz&UnicodeHeadersTests.test_hasHeaderTruecCrG)r_r�Nr`rrrrrb�rLz'UnicodeHeadersTests.test_hasHeaderFalsecCs�t�}|�ddg�|�|�d��|�d�|�|�d��|�|�d��|�ddg�|�|�d��|�d�|�|�d��|�|�d��dS)	rcr�r�r"r�r��Barr!Nrdr$rrrrfs

z%UnicodeHeadersTests.test_removeHeadercCrg)rhr�Nrir$rrrrjrkz0UnicodeHeadersTests.test_removeHeaderDoesntExistcCsVt�}|�ddg�|�ddg�|�ddg�dd�|��D�}|�|hd	��d
S)rqr��lemurszwww-authenticatezbasic aksljdlk=zcontent-md5�
kjdfdfgdfgnsdcSrtrrurwrrrr{+r|z<UnicodeHeadersTests.test_getAllRawHeaders.<locals>.<setcomp>>�r�r~�rl)s
kjdfdfgdfgnsdr}Nrr�rrrr� s�z)UnicodeHeadersTests.test_getAllRawHeaderscCs�t�}|�ddg�t�}|�ddg�t�}|�dddg�|�||�|�||�|�||�t�}|�ddg�t�}|�ddg�t�}|�dddg�|�||�|�||�|�||�dS)r��fooár�r�sfoo�r@r?Nr�)rr�r�r��
firstBytes�secondBytes�
thirdBytesrrrr�6s$z*UnicodeHeadersTests.test_headersComparisoncCr�)r�rr�Nr�r$rrrr�Rr�z(UnicodeHeadersTests.test_otherComparisonc
CsTd}d}d}d}d}d|}d|}|�tt|||gi��d�|||�d���d	S)
z�
        The L{repr} of a L{Headers} instance shows the names and values of all
        the headers it contains. This shows only reprs of bytes values, as
        undecodable headers may cause an exception.
        r��bar☃r�z	'foo\xe1'z'bar\xe2\x98\x83'�bzHeaders({{{}: [{}, {!r}]}})�utf8N)r
r�r�format�encode)rr�r�r��
fooEncoded�
barEncodedrrrr�\s��zUnicodeHeadersTests.test_reprc	CsTd}d}d}d}d}Gdd�dt�}|�t||||gi��d|||�d	�f�d
S)r�r�r�r�z
b'foo\xe1'zb'bar\xe2\x98\x83'c@r�)z;UnicodeHeadersTests.test_subclassRepr.<locals>.FunnyHeadersNr�rrrrr�{r�r�zFunnyHeaders({%s: [%s, %r]})r�N)rr
r�r�)rr�r�r�r�r�r�rrrr�ps��z%UnicodeHeadersTests.test_subclassReprcCs�t�}|�ddg�|��}|�|�d�dg�|�|�d�dg�|�dd�|�|�d�dg�|�|�d�dg�|�dd�|�|�d�ddg�|�|�d�ddg�dS)	r�r�ufoo☃r�sfoo☃r�r�r!Nr�r�rrrr��szUnicodeHeadersTests.test_copyN)r�r�r�r�rr&r/r�r�r�r�rBrKrRrWr[r^rbrfrjr�r�r�r�r�r�rrrrr�`s0
	
r�N)r��twisted.trial.unittestr�twisted.web.http_headersr�twisted.web.test.requesthelperrrrrrr�rrrr�<module>s#-

Anon7 - 2022
AnonSec Team