%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/names/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/names/test/__pycache__/test_dns.cpython-312.pyc

�

Ϫ�f?x���dZddlZddlmZddlmZddlmZmZddl	m
Z
mZddlm
Z
ddlmZdd	lmZmZdd
lmZddlmZddlmZe
j2e
j4e
j6e
j8e
j:e
j<e
j>e
j@e
jBe
jDe
jFe
jHe
jJe
jLe
jNe
jPe
jRe
jTe
jVe
jXe
jZe
j\e
j^e
j`e
jbe
jdgZ3Gd
�dejh�Z5Gd�dejl�Z7Gd�dejl�Z8Gd�dejl�Z9Gd�dejl�Z:dZ;dZ<Gd�dejh�Z=Gd�deejh�Z>Gd�d�Z?Gd�d ejl�Z@Gd!�d"e?�ZAGd#�d$ejl�ZBGd%�d&ejl�ZCGd'�d(eejl�ZDGd)�d*ejl�ZEGd+�d,ejh�ZFd-�ZGd.�ZHGd/�d0ejh�ZIGd1�d2�ZJGd3�d4eejl�ZKGd5�d6eejl�ZLGd7�d8eM�ZNGd9�d:�ZOGd;�d<�ZPGd=�d>�ZQGd?�d@�ZRGdA�dB�ZSGdC�dD�ZTGdE�dF�ZUGdG�dH�ZVGdI�dJee�ZW	dfdK�ZXGdL�dM�ZYGdN�dO�ZZGdP�dQeYeZejh�Z[GdR�dSeYeZejh�Z\GdT�dUeYejh�Z]GdV�dWeejh�Z^GdX�dY�Z_GdZ�d[e_ejh�Z`Gd\�d]e_ejh�ZaGd^�d_ejh�ZbGd`�daejh�ZcGdb�dc�ZdGdd�deejh�Zey)gz
Tests for twisted.names.dns.
�N)�BytesIO)�verifyClass)�address�task)�CannotListenError�ConnectionDone)�dns)�Failure)�FancyEqMixin�
FancyStrMixin)�
proto_helpers)�ComparisonTestsMixin)�unittestc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�DomainStringTestsc�N�|jdtjd��y)zA
        L{dns.domainString} returns L{bytes} unchanged.
        stwistedmatrix.comN��assertEqualr	�domainString��selfs �=/usr/lib/python3/dist-packages/twisted/names/test/test_dns.py�
test_byteszDomainStringTests.test_bytes7s$��	
��� ����1�2�	
�c�N�|jdtjd��y)z`
        L{dns.domainString} converts a native string to L{bytes}
        if necessary.
        �example.com�example.comNrrs r�test_nativezDomainStringTests.test_native@s��
	
�����)9�)9�-�)H�Irc�N�|jdtjd��y)zS
        L{dns.domainString} always converts a unicode string to L{bytes}.
        sfoo.examplezfoo.exampleNrrs r�	test_textzDomainStringTests.test_textGs��	
�����)9�)9�-�)H�Irc�N�|jdtjd��y)�A
        L{dns.domainString} encodes Unicode using IDNA.
        sxn--fwg.testu‽.testNrrs r�	test_idnazDomainStringTests.test_idnaMs��	
����#�*:�*:�=�*I�Jrc��|jttjd�|jttjtjd��y)r"i(#zbar.exampleN)�assertRaises�	TypeErrorr	r�Namers r�
test_nonsensezDomainStringTests.test_nonsenseSs=��	
���)�S�%5�%5�t�<����)�S�%5�%5�s�x�x�
�7N�OrN)�__name__�
__module__�__qualname__rrr r#r(�rrrr6s��
�J�J�K�Prrc��eZdZdZd�Zy)�
Ord2ByteTestsz&
    Tests for L{dns._ord2bytes}.
    c�N�|jdtjd��y)z�
        L{dns._ord2byte} accepts an integer and returns a byte string of length
        one with an ordinal value equal to the given integer.
        ��N)rr	�
_ord2bytesrs r�
test_ord2bytezOrd2ByteTests.test_ord2byte`s��
	
����#�.�.��"6�7rN)r)r*r+�__doc__r3r,rrr.r.[s���8rr.c�H�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd�Zy
)
�
Str2TimeTestsz$
    Tests for L{dns.str2name}.
    c�b�t�}|j|tj|��y)zY
        When passed a non-string object, L{dns.str2name} returns it unmodified.
        N)�object�assertIsr	�str2time)r�times  r�test_nonStringzStr2TimeTests.test_nonStringms"���x���
�
�d�C�L�L��.�/rc�N�|jdtjd��y)z�
        Passed a string giving a number of seconds, L{dns.str2time} returns the
        number of seconds represented.  For example, C{"10S"} represents C{10}
        seconds.
        �
�10SN�rr	r:rs r�test_secondszStr2TimeTests.test_secondsts��	
����S�\�\�%�0�1rc�N�|jdtjd��y)z�
        Like C{test_seconds}, but for the C{"M"} suffix which multiplies the
        time value by C{60} (the number of seconds in a minute!).
        �x�2MNr@rs r�test_minuteszStr2TimeTests.test_minutes|s��
	
�������d�!3�4rc�N�|jdtjd��y)z�
        Like C{test_seconds}, but for the C{"H"} suffix which multiplies the
        time value by C{3600}, the number of seconds in an hour.
        i0*�3HNr@rs r�
test_hourszStr2TimeTests.test_hours�s��
	
����3�<�<��#5�6rc�N�|jdtjd��y)z�
        Like L{test_seconds}, but for the C{"D"} suffix which multiplies the
        time value by C{86400}, the number of seconds in a day.
        iF�4DNr@rs r�	test_dayszStr2TimeTests.test_days�s��
	
����C�L�L��$6�7rc�N�|jdtjd��y)z�
        Like L{test_seconds}, but for the C{"W"} suffix which multiplies the
        time value by C{604800}, the number of seconds in a week.
        i�$.�5WNr@rs r�
test_weekszStr2TimeTests.test_weeks�s��
	
����S�\�\�$�%7�8rc�N�|jdtjd��y)z�
        Like L{test_seconds}, but for the C{"Y"} suffix which multiplies the
        time value by C{31536000}, the number of seconds in a year.
        i5G�6YNr@rs r�
test_yearszStr2TimeTests.test_years�s��
	
����s�|�|�D�'9�:rc�N�|jttjd�y)zY
        If a non-integer prefix is given, L{dns.str2time} raises L{ValueError}.
        �fooSN�r%�
ValueErrorr	r:rs r�test_invalidPrefixz Str2TimeTests.test_invalidPrefix�s��	
���*�c�l�l�F�;rNc�N�|jttjd�y)zV
        If an invalid suffix is given, L{dns.str2time} raises L{ValueError}.
        �1QNrTrs r�test_invalidSuffixz Str2TimeTests.test_invalidSuffix�s��	
���*�c�l�l�D�9r)�returnN)
r)r*r+r4r<rArErHrKrNrQrVrYr,rrr6r6hs4���0�2�5�7�8�9�;�<�:rr6c�L�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�	NameTestsz�
    Tests for L{Name}, the representation of a single domain name with support
    for encoding into and decoding from DNS message format.
    c���|jttjd�|jttjt	��|jttjg�y)zy
        When constructed with a name which is neither C{bytes} nor C{str},
        L{Name} raises L{TypeError}.
        �{N)r%r&r	r'r8rs r�test_nonStringNamezNameTests.test_nonStringName�sH��
	
���)�S�X�X�s�3����)�S�X�X�v�x�8����)�S�X�X�r�2rc��tjd�}|j|jt�|jd|j�y)zg
        L{dns.Name} automatically encodes unicode domain name using C{idna}
        encoding.
        uéchec.example.orgsxn--chec-9oa.example.orgN)r	r'�assertIsInstance�name�bytesr)rrbs  r�test_unicodeNamezNameTests.test_unicodeName�s<��
�x�x�0�1�����d�i�i��/����4�d�i�i�@rc��tj�}|jtd��|j	|j
d�y)z�
        L{Name.decode} populates the L{Name} instance with name information read
        from the file-like object passed to it.
        �
examplecomrN)r	r'�decoderrrb)r�ns  r�test_decodezNameTests.test_decode�s5��

�H�H�J��	����2�3�4��������0rc��tjd�}t�}|j|�|j	|j�d�y)zy
        L{Name.encode} encodes its name information and writes it to the
        file-like object passed to it.
        �foo.example.comsfooexamplecomN)r	r'r�encoder�getvalue�rrb�streams   r�test_encodezNameTests.test_encode�s>��
�x�x�*�+��������F��������*�,L�Mrc�b�tjd�}ddi}d}t�}|j|�t	|�tj
jz}|j||�|jd|j�t	|�d�|jd|d�|�y)am
        If a compression dictionary is passed to it, L{Name.encode} uses offset
        information from it to encode its name with references to existing
        labels in the stream instead of including another copy of them in the
        output.  It also updates the compression dictionary with the location of
        the name it writes to the stream.
        rkr�ssome prefix to change .tell()sfoo�N)rrk)
r	r'r�write�len�Message�
headerSizerlrrm)rrb�compression�previousro�expecteds      r�test_encodeWithCompressionz$NameTests.test_encodeWithCompression�s����x�x�*�+��%�t�,��4��������X���x�=�3�;�;�#9�#9�9�����F�K�(����+�V�_�_�->�s�8�}��-O�P����!�x�@�+�	
rc
�\�d}tj�}|j|�|j|jtj
ddd��g�|j|jtjddddtjdd���	�g�|j|jtjd
tjtjdtjdd���	�g�|j�}|j||�y)
z�
        A resource record of unknown type and class is parsed into an
        L{UnknownRecord} instance with its data preserved, and an
        L{UnknownRecord} instance is serialized to a string equal to the one it
        was parsed from.
        sDfoobarޭ��ޭ��somedatabazban�foo.bari��i�)�type�clsissomedata��ttl�r}r~r��payloadsbaz.ban�1.2.3.4N)r	ru�fromStrr�queries�Query�answers�RRHeader�
UnknownRecord�
additional�A�IN�Record_A�toStr)r�wire�msg�encs    r�test_unknownzNameTests.test_unknown�s���
 �	
�:�k�k�m�����D������K�K��	�	�*�6�v�>�
�	
�	
����K�K���������-�-�k�s�C��
�	
�	
����N�N�������������L�L���<��
�	
��i�i�k������d�#rc�2�td�}|jd�tj�}|j	|�|jd|j�|jd|j��|j	|�|j|jd�|jd|j��|j	|�|j|jd�|jd|j��y	)
a
        If the leading byte of an encoded label (in bytes read from a stream
        passed to L{Name.decode}) has its two high bits set, the next byte is
        treated as a pointer to another label in the stream and that label is
        included in the name being decoded.
        s,xxxxxxxxxxxxxxxxxxxxfisiarpafoo�bar� �s
f.isi.arpa� sfoo.f.isi.arpa�&sbar.foo.f.isi.arpa�,N)r�seekr	r'rgrrb�tell)rrorbs   r�test_decodeWithCompressionz$NameTests.test_decodeWithCompression:s����
�
��
	���B���x�x�z�����F��	
�����	�	�2�����V�[�[�]�+�	
���F��������$5�6�����V�[�[�]�+�	
���F��������$9�:�����V�[�[�]�+rc��tj�}td�}|jt|j
|�y)z�
        L{Name.decode} raises L{ValueError} if the stream passed to it includes
        a compression pointer which forms a loop, causing the name to be
        undecodable.
        s�N)r	r'rr%rUrgrns   r�test_rejectCompressionLoopz$NameTests.test_rejectCompressionLoopYs/���x�x�z����%�����*�d�k�k�6�:rc���tjd�}tjd�}|j||�tjd�}|j||�y)z�
        L{Name} instances are equal as long as they have the same value for
        L{Name.name}, regardless of the case.
        r|sfOO.barN)r	r'r)r�name1�name2�name3s    r�
test_equalityzNameTests.test_equalitycsN��
����$������$�������&�����$�������&rc�|�tjd�}tjd�}|j||�y)zq
        L{Name} instances are not equal as long as they have different
        L{Name.name} attributes.
        r|sbar.fooN)r	r'�assertNotEqual)rr�r�s   r�test_inequalityzNameTests.test_inequalityos0��
����$������$�����E�5�)rN)r)r*r+r4r_rdrirprzr�r�r�r�r�r,rrr\r\�s=���
3�A�1�N�
�2H$�T,�>;�
'�*rr\c��eZdZdZgd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�RoundtripDNSTestsz5
    Encoding and then decoding various objects.
    )�example.orgsgo-away.fish.tvs23strikesback.netc�(�|jD]�}t�}tj|�j	|�|jdd�tj�}|j
|�|j|j|���y)Nr)	�namesrr	r'rlr�rgrrb�rrh�f�results    r�	test_namezRoundtripDNSTests.test_name�sl�����		-�A��	�A��H�H�Q�K���q�!�
�F�F�1�a�L��X�X�Z�F��M�M�!�����V�[�[�!�,�		-rc���|jD]�}tdd�D]�}tdd�D]�}t�}tj|||�j|�|j
dd�tj�}|j|�|j|jj|�|j|j|�|j|j|�������y)z�
        L{dns.Query.encode} returns a byte string representing the fields of the
        query which can be decoded into a new L{dns.Query} instance using
        L{dns.Query.decode}.
        ���rN)r��rangerr	r�rlr�rgrrbr}r~)rrh�dnstype�dnsclsr�r�s      r�
test_queryzRoundtripDNSTests.test_query�s������
	9�A� ��B�<�
9��#�A�q�k�9�F��	�A��I�I�a��&�1�8�8��;��F�F�1�a�L� �Y�Y�[�F��M�M�!�$��$�$�V�[�[�%5�%5�q�9��$�$�V�[�[�'�:��$�$�V�Z�Z��8�9�
9�
	9rc���t�}tjdddd�j|�|j	dd�tj�}|j|�|j
|jtjd��|j
|jd�|j
|jd�|j
|jd�y)a
        L{dns.RRHeader.encode} encodes the record header's information and
        writes it to the file-like object passed to it and
        L{dns.RRHeader.decode} reads from a file-like object to re-construct a
        L{dns.RRHeader} instance.
        stest.org��r�rN)rr	r�rlr�rgrrbr'r}r~r�)rr�r�s   r�test_resourceRecordHeaderz+RoundtripDNSTests.test_resourceRecordHeader�s���
�I�����[�!�Q��+�2�2�1�5�	
���q�!��������
�
�a��������c�h�h�{�&;�<�������a�(�������Q�'�������R�(rc���|jtd�5tjtjtj
���ddd�y#1swYyxYw)zy
        L{RRHeader()} raises L{ValueError} when the given type and the type
        of the payload don't match.
        z#Payload type \(AAAA\) .* type \(A\)�r}r�N)�assertRaisesRegexrUr	r�r��Record_AAAArs r�%test_resourceRecordHeaderTypeMismatchz7RoundtripDNSTests.test_resourceRecordHeaderTypeMismatch�sG���
#�
#�J�0V�
W�	@��L�L�c�e�e�S�_�_�->�?�	@�	@�	@�s�8A�A!c�>�d}|D]�}t�}tj|�j|�|j	dd�tj�}|j|�|j
|jtj|����y)a

        L{dns.SimpleRecord.encode} encodes the record's name information and
        writes it to the file-like object passed to it and
        L{dns.SimpleRecord.decode} reads from a file-like object to re-construct
        a L{dns.SimpleRecord} instance.
        )sthis.are.test.names0will.compress.will.this.will.name.will.hopefullystest.CASE.preSErVatIOn.YeAHsa.s.h.o.r.t.c.a.s.e.t.o.t.e.s.ts	singletonrN)	rr	�SimpleRecordrlr�rgrrbr')rr��sr�r�s     r�test_resourcesz RoundtripDNSTests.test_resources�s}��
���	7�A��	�A����Q��&�&�q�)�
�F�F�1�a�L��%�%�'�F��M�M�!�����V�[�[�#�(�(�1�+�6�
	7rc��tD]B}|�|�}}t|�}t|�}|j|||�d|�d|�d���Dy)z=
        Instances of all record types are hashable.
        z != z (for �)N)�RECORD_TYPES�hashr)r�k�k1�k2�hk1�hk2s      r�
test_hashablezRoundtripDNSTests.test_hashable�sY���	D�A��S�!�#��B��r�(�C��r�(�C����S�#�#��d�3�%�v�a�S��'B�C�		Drc�(�|jD]�}t�}tj|�j	|�|jdd�tj�}|j
|�|j|j|���y)z8
        Test L{dns.Charstr} encode and decode.
        rN)	r�rr	�Charstrrlr�rgr�stringr�s    r�test_CharstrzRoundtripDNSTests.test_Charstr�sn�����		/�A��	�A��K�K��N�!�!�!�$�
�F�F�1�a�L��[�[�]�F��M�M�!�����V�]�]�A�.�		/rc���t�}|j|�|j�}|jdd�|j	�}|j||�|j
||�y)z�
        Assert that encoding C{record} and then decoding the resulting bytes
        creates a record which compares equal to C{record}.

        @type record: L{dns.IEncodable}
        @param record: A record instance to encode
        rN)rrlr�r��	__class__rgr)r�recordro�length�replicas     r�_recordRoundtripTestz&RoundtripDNSTests._recordRoundtripTest�s\������
�
�f����������A�q���"�"�$�����v�v�&������)rc�z�t�}|j|�|j|j�|�y)a3
        Assert that encoding C{record} produces the expected bytes.

        @type record: L{dns.IEncodable}
        @param record: A record instance to encode

        @type expectedEncoding: L{bytes}
        @param expectedEncoding: The value which C{record.encode()}
            should produce.
        N)rrlrrm)r�expectedEncodingr�ros    r�assertEncodedFormatz%RoundtripDNSTests.assertEncodedFormat�s/������
�
�f��������*�,<�=rc�Z�|jtjddddddd���y	)
z�
        The byte stream written by L{dns.Record_SOA.encode} can be used by
        L{dns.Record_SOA.decode} to reconstruct the state of the original
        L{dns.Record_SOA} instance.
        �foo�bar��"�8�N�Z)�mname�rname�serial�refresh�retry�expire�minimumN)r�r	�
Record_SOArs r�test_SOAzRoundtripDNSTests.test_SOAs3��	
�!�!��N�N��������
�
	
rc�L�|jtjd��y)z�
        The byte stream written by L{dns.Record_A.encode} can be used by
        L{dns.Record_A.decode} to reconstruct the state of the original
        L{dns.Record_A} instance.
        r�N)r�r	r�rs r�test_AzRoundtripDNSTests.test_A s��	
�!�!�#�,�,�y�"9�:rc�L�|jtjd��y)z�
        The byte stream written by L{dns.Record_NULL.encode} can be used by
        L{dns.Record_NULL.decode} to reconstruct the state of the original
        L{dns.Record_NULL} instance.
        sfoo barN)r�r	�Record_NULLrs r�	test_NULLzRoundtripDNSTests.test_NULL(s��	
�!�!�#�/�/�*�"=�>rc�P�|jtjddd��y)z�
        The byte stream written by L{dns.Record_WKS.encode} can be used by
        L{dns.Record_WKS.decode} to reconstruct the state of the original
        L{dns.Record_WKS} instance.
        r�r�sxyzN)r�r	�
Record_WKSrs r�test_WKSzRoundtripDNSTests.test_WKS0s��	
�!�!�#�.�.��A�v�"F�Grc�L�|jtjd��y)z�
        The byte stream written by L{dns.Record_AAAA.encode} can be used by
        L{dns.Record_AAAA.decode} to reconstruct the state of the original
        L{dns.Record_AAAA} instance.
        z::1N)r�r	r�rs r�	test_AAAAzRoundtripDNSTests.test_AAAA8s��	
�!�!�#�/�/�%�"8�9rc�P�|jtjddd��y)z�
        The byte stream written by L{dns.Record_A6.encode} can be used by
        L{dns.Record_A6.decode} to reconstruct the state of the original
        L{dns.Record_A6} instance.
        �z::1:2r�N)r�r	�	Record_A6rs r�test_A6zRoundtripDNSTests.test_A6@s��	
�!�!�#�-�-��7�F�"C�Drc�T�|jtjdddd���y)z�
        The byte stream written by L{dns.Record_SRV.encode} can be used by
        L{dns.Record_SRV.decode} to reconstruct the state of the original
        L{dns.Record_SRV} instance.
        r��r�r)�priority�weight�port�targetN)r�r	�
Record_SRVrs r�test_SRVzRoundtripDNSTests.test_SRVHs$��	
�!�!��N�N�A�a�a��O�	
rc���d}tjtjjtjj|��}|j	|�|jd|z|�y)z�
        The byte stream written by L{dns.Record_SSHFP.encode} can be used by
        L{dns.Record_SSHFP.decode} to reconstruct the state of the original
        L{dns.Record_SSHFP} instance.
        s�9��^kK
2U��`���	)�	algorithm�fingerprintType�fingerprintsN)r	�Record_SSHFP�
ALGORITHM_DSS�FINGERPRINT_TYPE_SHA1r�r�)r�fp�rrs   r�
test_SSHFPzRoundtripDNSTests.test_SSHFPRse��
B�	��
�
��&�&�4�4��,�,�B�B��
��
	
�!�!�"�%�� � ��r�!1�2�6rc	�@�ddg}|D�]�\}}}}}}tj||||||�}t�}	|j|	�|	j	dd�tj�}
|
j|	�|j
|j|
j�|j
|j|
j�|j
|j|
j�|j
|j|
j�|j
|j|
j�|j
|jj|
jj�|j
|j|
j����y)z=
        Test L{dns.Record_NAPTR} encode and decode.
        )�dr>�u�sip+E2Us!!^.*$!sip:information@domain.tld!r)r�2�sshttp+I2L+I2C+I2Rrs_http._tcp.gatech.edurN)r	�Record_NAPTRrrlr�rgr�order�
preference�flags�service�regexp�replacementrbr�)r�naptrsrrrrrr�rin�e�routs           r�
test_NAPTRzRoundtripDNSTests.test_NAPTRes?��

S�O�
��
GM�	0�B�E�:�u�g�v�{��"�"��z�5�'�6�;��C��	�A��J�J�q�M�
�F�F�1�a�L��#�#�%�D��K�K��N����S�Y�Y��
�
�3����S�^�^�T�_�_�=����S�Y�Y��
�
�3����S�[�[�$�,�,�7����S�Z�Z����5����S�_�_�1�1�4�3C�3C�3H�3H�I����S�W�W�d�h�h�/�	0rc�P�|jtjdd���y)z�
        The byte stream written by L{dns.Record_AFSDB.encode} can be used by
        L{dns.Record_AFSDB.decode} to reconstruct the state of the original
        L{dns.Record_AFSDB} instance.
        r�r)�subtype�hostnameN)r�r	�Record_AFSDBrs r�
test_AFSDBzRoundtripDNSTests.test_AFSDBs��	
�!�!�#�"2�"2�1�~�"V�Wrc�P�|jtjdd���y)z�
        The byte stream written by L{dns.Record_RP.encode} can be used by
        L{dns.Record_RP.decode} to reconstruct the state of the original
        L{dns.Record_RP} instance.
        �alice.example.comr)�mbox�txtN)r�r	�	Record_RPrs r�test_RPzRoundtripDNSTests.test_RP�s!��	
�!�!��M�M�3��H�	
rc�P�|jtjdd���y)z�
        The byte stream written by L{dns.Record_HINFO.encode} can be used by
        L{dns.Record_HINFO.decode} to reconstruct the state of the original
        L{dns.Record_HINFO} instance.
        sfastsgreat)�cpu�osN)r�r	�Record_HINFOrs r�
test_HINFOzRoundtripDNSTests.test_HINFO�s��	
�!�!�#�"2�"2�w�8�"L�Mrc�P�|jtjdd���y)z�
        The byte stream written by L{dns.Record_MINFO.encode} can be used by
        L{dns.Record_MINFO.decode} to reconstruct the state of the original
        L{dns.Record_MINFO} instance.
        r�r�)�rmailbx�emailbxN)r�r	�Record_MINFOrs r�
test_MINFOzRoundtripDNSTests.test_MINFO�s��	
�!�!�#�"2�"2�6�6�"R�Src�P�|jtjdd���y)z�
        The byte stream written by L{dns.Record_MX.encode} can be used by
        L{dns.Record_MX.decode} to reconstruct the state of the original
        L{dns.Record_MX} instance.
        r�r)rrbN)r�r	�	Record_MXrs r�test_MXzRoundtripDNSTests.test_MX�s��	
�!�!�#�-�-�1�>�"R�Src�:�d}tjdddd|��}|j|�d|zdz}|j||�tjd	d
dtjd|�
�}|j|�d|zdz}|j||�y)z�
        The byte stream written by L{dns.Record_TSIG.encode} can be used by
        L{dns.Record_TSIG.decode} to reconstruct the state of the original
        L{dns.Record_TSIG} instance.
        s !"#0123zhmac-md5.sig-alg.reg.int�/qUZ�*r�)r�
timeSigned�
originalID�fudge�MACs$hmac-md5sig-algregintZUq/s*zhmac-sha256l'��s�)rr8r9�error�	otherDatar;shmac-sha256�'s���N)r	�Record_TSIGr�r��EBADTIME)r�macr	�rdatas    r�	test_TSIGzRoundtripDNSTests.test_TSIG�s���V��
�_�_�0�!����
��	
�!�!�"�%�
8��
�*�
*�	�	
� � ���+�
�_�_�#�!���,�,�1��

��	
�!�!�"�%�
8��
�(�
(�	�	
� � ���+rc�N�|jtjdd��y)z�
        The byte stream written by L{dns.Record_TXT.encode} can be used by
        L{dns.Record_TXT.decode} to reconstruct the state of the original
        L{dns.Record_TXT} instance.
        r�r�N)r�r	�
Record_TXTrs r�test_TXTzRoundtripDNSTests.test_TXT�s��	
�!�!�#�.�.���"@�ArN)r)r*r+r4r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr
rr!r'r,r1r4rCrFr,rrr�r�ys����
G�E�
-�9�*)�(@�7�,D�
/�*�">� 
�$;�?�H�:�E�
�7�&0�4X�
�N�T�T�',�RBrr�s sc�|�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�MessageTestsz1
    Tests for L{twisted.names.dns.Message}.
    c�`�|jtj�jd�y)zC
        L{dns.Message.authenticData} has default value 0.
        rN�rr	ru�
authenticDatars r�test_authenticDataDefaultz&MessageTests.test_authenticDataDefault�s ��	
�������4�4�a�8rc�d�|jtjd��jd�y)z�
        L{dns.Message.__init__} accepts a C{authenticData} argument which
        is assigned to L{dns.Message.authenticData}.
        r��rKNrJrs r�test_authenticDataOverridez'MessageTests.test_authenticDataOverride�s#��
	
������1�5�C�C�Q�Grc�t�|jtjd��j�t�y)zr
        L{dns.Message.toStr} encodes L{dns.Message.authenticData} into
        byte4 of the byte string.
        r�rNN)rr	rur��MESSAGE_AUTHENTIC_DATA_BYTESrs r�test_authenticDataEncodez%MessageTests.test_authenticDataEncodes*��
	
����K�K�a�(�.�.�0�2N�	
rc��tj�}|jt�|j	|j
d�y)zp
        L{dns.Message.fromStr} decodes byte4 and assigns bit3 to
        L{dns.Message.authenticData}.
        r�N)r	rur�rQrrK�r�ms  r�test_authenticDataDecodez%MessageTests.test_authenticDataDecodes0��

�K�K�M��	�	�	�.�/�������!�,rc�`�|jtj�jd�y)zF
        L{dns.Message.checkingDisabled} has default value 0.
        rN�rr	ru�checkingDisabledrs r�test_checkingDisabledDefaultz)MessageTests.test_checkingDisabledDefaults ��	
�������7�7��;rc�d�|jtjd��jd�y)z�
        L{dns.Message.__init__} accepts a C{checkingDisabled} argument which
        is assigned to L{dns.Message.checkingDisabled}.
        r��rYNrXrs r�test_checkingDisabledOverridez*MessageTests.test_checkingDisabledOverrides#��
	
������a�8�I�I�1�Mrc�t�|jtjd��j�t�y)zu
        L{dns.Message.toStr} encodes L{dns.Message.checkingDisabled} into
        byte4 of the byte string.
        r�r\N)rr	rur��MESSAGE_CHECKING_DISABLED_BYTESrs r�test_checkingDisabledEncodez(MessageTests.test_checkingDisabledEncode#s*��
	
����K�K��+�1�1�3�5T�	
rc��tj�}|jt�|j	|j
d�y)zs
        L{dns.Message.fromStr} decodes byte4 and assigns bit4 to
        L{dns.Message.checkingDisabled}.
        r�N)r	rur�r_rrYrTs  r�test_checkingDisabledDecodez(MessageTests.test_checkingDisabledDecode,s2��

�K�K�M��	�	�	�1�2�����+�+�Q�/rc�^�|jdttj���y)z�
        L{dns.Message.__repr__} omits field values and sections which are
        identical to their defaults. The id field value is always shown.
        z<Message id=0>N)r�reprr	rurs r�test_reprDefaultszMessageTests.test_reprDefaults6s ��
	
���)�4����
�+>�?rc	�r�tjddddddd��}|jdt|��y)zM
        L{dns.Message.__repr__} displays flags if they are L{True}.
        T)�answer�auth�trunc�recDes�recAvrKrYzR<Message id=0 flags=answer,auth,trunc,recDes,recAv,authenticData,checkingDisabled>N�r	rurrdrTs  r�test_reprFlagsIfSetz MessageTests.test_reprFlagsIfSet=sE��
�K�K�������!�
��	
���
�

��G�
	
rc�l�tjdddd��}|jdt|��y)zk
        L{dns.Message.__repr__} displays field values if they differ from their
        defaults.
        r>r���()�id�opCode�rCode�maxSizez-<Message id=10 opCode=20 rCode=30 maxSize=40>NrlrTs  r�test_reprNonDefautFieldsz%MessageTests.test_reprNonDefautFieldsSs0��

�K�K�2�b��B�?�����J���G�	
rc��tj�}gd�|_gd�|_gd�|_gd�|_|j
dt|��y)�e
        L{dns.Message.__repr__} displays sections which differ from their
        defaults.
        �r�r�r��r�r����r��	�r>�r�z^<Message id=0 queries=[1, 2, 3] answers=[4, 5, 6] authority=[7, 8, 9] additional=[10, 11, 12]>N)r	rur�r��	authorityr�rrdrTs  r�test_reprNonDefaultSectionsz(MessageTests.test_reprNonDefaultSections^sG��

�K�K�M����	���	����#������
�
��G�		
rc�n�tj�}|jt|jd�y)zy
        Test that a message which has been truncated causes an EOFError to
        be raised when it is parsed.
        rN)r	rur%�EOFErrorr��rr�s  r�test_emptyMessagezMessageTests.test_emptyMessagess%��
�k�k�m�����(�C�K�K��5rc�b�tj�}|jd�|j|jd�|j|jd�|j|jtj�|j|jd�|j|jd�|j|jg�|j|jg�|j|jg�|j|jg�y)ze
        Test that bytes representing an empty query message can be decoded
        as such.
        s�z)Message was not supposed to be an answer.z-Message was not supposed to be authoritative.z)Message was not supposed to be truncated.N)r	rur�rrq�assertFalsergrr�OP_QUERYrhrir�r�r�r�r�s  r�test_emptyQueryzMessageTests.test_emptyQuery{s���
�k�k�m�����
�		
�	
�������%�������%P�Q�������S�\�\�2�������#R�S�������$O�P�������b�)�������b�)��������+��������,rc���djtd�D�cgc]}tj|���c}�}tj|�}tj
dtj|��}tj�}|jj|�t�}|j|�|jdd�tj�}|j|�|j|jdjtj�|j!|jdjj|�ycc}w)z|
        A I{NULL} record with an arbitrary payload can be encoded and decoded as
        part of a L{dns.Message}.
        rr��testname�r�rN)�joinr�r	r2r�r��NULLrur��appendrrlr�rgrar�r�r�irc�recr	�msg1r��msg2s        rr�zMessageTests.test_NULL�s���
���U�3�Z�@��#�.�.��+�@�A���o�o�e�$��
�\�\�+�s�x�x��
=���{�{�}�������B���I�����A��	���q�!���{�{�}�����A�����d�l�l�1�o�5�5�s���G�������a��0�0�8�8�%�@��As�E#c��|jtj�jd�tj�y)z�
        L{Message.lookupRecordType} returns C{dns.UnknownRecord} if it is
        called with an integer which doesn't correspond to any known record
        type.
        i�N)r9r	ru�lookupRecordTyper�rs r�test_lookupRecordTypeDefaultz)MessageTests.test_lookupRecordTypeDefault�s)��	
�
�
�c�k�k�m�4�4�U�;�S�=N�=N�Orc��t�}tjtjdd����}|j	|�tj
�}|j
d|j�z�|j|j|g�|j|jdj�y)z�
        The L{RRHeader} instances created by L{Message} from a non-authoritative
        message are marked as not authoritative.
        r�rrr�sN)rr	r�r�rlrur�rmrr�r�rh�r�bufrg�messages    r�test_nonAuthoritativeMessagez)MessageTests.test_nonAuthoritativeMessage�s���
�i�����c�l�l�9�!�&D�E���
�
�c���+�+�-�����	
��,�,�.�	
)�	
�	
������6�(�3��������+�0�0�1rc��t�}tjtjdd����}|j	|�tj
�}|j
d|j�z�d|_|j|j|g�|j|jdj�y)z�
        The L{RRHeader} instances created by L{Message} from an authoritative
        message are marked as authoritative.
        r�rrr�sTN)rr	r�r�rlrur�rmrhrr��
assertTruer�s    r�test_authoritativeMessagez&MessageTests.test_authoritativeMessage�s���
�i�����c�l�l�9�!�&D�E���
�
�c���+�+�-�����	
��,�,�.�	
)�	
����������6�(�3��������*�/�/�0rN)r)r*r+r4rLrOrRrVrZr]r`rbrermrur�r�r�r�r�r�r�r,rrrHrH�sf���9�H�
�-�<�N�
�0�@�
�,	
�
�*6�-�4A�&	P�2�01rrHc�p�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zy)�MessageComparisonTestszD
    Tests for the rich comparison of L{dns.Message} instances.
    c��|jdg�}|jdg�}|jdg�}|jdg�}tjdi|��}|r||_|r||_|r||_|r||_|S)a�
        Create a L{dns.Message}.

        The L{dns.Message} constructor doesn't accept C{queries}, C{answers},
        C{authority}, C{additional} arguments, so we extract them from the
        kwargs supplied to this factory function and assign them to the message.

        @param args: Positional arguments.
        @param kwargs: Keyword arguments.
        @return: A L{dns.Message} instance.
        r�r�r�r�r,)�popr	rur�r�r�r�)r�args�kwargsr�r�r�r�rUs        r�messageFactoryz%MessageComparisonTests.messageFactory�s����*�*�Y��+���*�*�Y��+���J�J�{�B�/�	��Z�Z��b�1�
��K�K�!�&�!����A�I���A�I��#�A�K��%�A�L��rc��|j|jd��|jd��|jd���y)zd
        Two L{dns.Message} instances compare equal if they have the same id
        value.
        r>�rqr�N��"assertNormalEqualityImplementationr�rs r�test_idzMessageComparisonTests.test_idsE��
	
�/�/����2��&����2��&����2��&�	
rc��|j|jd��|jd��|jd���y)zg
        Two L{dns.Message} instances compare equal if they have the same answer
        flag.
        r��rgrNr�rs r�test_answerz"MessageComparisonTests.test_answer�E��
	
�/�/����q��)����q��)����q��)�	
rc��|j|jd��|jd��|jd���y)zh
        Two L{dns.Message} instances compare equal if they have the same opCode
        value.
        r>�rrr�Nr�rs r�test_opCodez"MessageComparisonTests.test_opCodesE��
	
�/�/����r��*����r��*����r��*�	
rc��|j|jd��|jd��|jd���y)zg
        Two L{dns.Message} instances compare equal if they have the same recDes
        flag.
        r��rjrNr�rs r�test_recDesz"MessageComparisonTests.test_recDes&r�rc��|j|jd��|jd��|jd���y)zf
        Two L{dns.Message} instances compare equal if they have the same recAv
        flag.
        r��rkrNr�rs r�
test_recAvz!MessageComparisonTests.test_recAv1�E��
	
�/�/����a��(����a��(����a��(�	
rc��|j|jd��|jd��|jd���y)ze
        Two L{dns.Message} instances compare equal if they have the same auth
        flag.
        r��rhrNr�rs r�	test_authz MessageComparisonTests.test_auth<sE��
	
�/�/����Q��'����Q��'����Q��'�	
rc��|j|jd��|jd��|jd���y)zg
        Two L{dns.Message} instances compare equal if they have the same rCode
        value.
        r>�rsr�Nr�rs r�
test_rCodez!MessageComparisonTests.test_rCodeG�E��
	
�/�/����b��)����b��)����b��)�	
rc��|j|jd��|jd��|jd���y)zf
        Two L{dns.Message} instances compare equal if they have the same trunc
        flag.
        r��rirNr�rs r�
test_truncz!MessageComparisonTests.test_truncRr�rc��|j|jd��|jd��|jd���y)zi
        Two L{dns.Message} instances compare equal if they have the same
        maxSize value.
        r>�rtr�Nr�rs r�test_maxSizez#MessageComparisonTests.test_maxSize]sE��
	
�/�/������+������+������+�	
rc��|j|jd��|jd��|jd���y)zn
        Two L{dns.Message} instances compare equal if they have the same
        authenticData flag.
        r�rNrNr�rs r�test_authenticDataz)MessageComparisonTests.test_authenticDatahsE��
	
�/�/����a��0����a��0����a��0�	
rc��|j|jd��|jd��|jd���y)zq
        Two L{dns.Message} instances compare equal if they have the same
        checkingDisabled flag.
        r�r\rNr�rs r�test_checkingDisabledz,MessageComparisonTests.test_checkingDisabledssE��
	
�/�/������3������3������3�	
rc	��|j|jtjd�g��|jtjd�g��|jtjd�g���y)zc
        Two L{dns.Message} instances compare equal if they have the same
        queries.
        r�r�r�N�r�r�r	r�rs r�test_queriesz#MessageComparisonTests.test_queries~�i��
	
�/�/�������>�)B�(C��D�������>�)B�(C��D�������>�)B�(C��D�	
rc��|j|jtjdtjd���g��|jtjdtjd���g��|jtjdtjd���g���y)zc
        Two L{dns.Message} instances compare equal if they have the same
        answers.
        rr�r��r�r��4.3.2.1N�r�r�r	r�r�rs r�test_answersz#MessageComparisonTests.test_answers����
	
�/�/�������n�c�l�l�9�>U�V�W�
 �
�
������n�c�l�l�9�>U�V�W�
 �
�
������n�c�l�l�9�>U�V�W�
 �
�
	
rc���|j|jtjdtjtj
���g��|jtjdtjtj
���g��|jtjdtjtj
���g���y)zm
        Two L{dns.Message} instances compare equal if they have the same
        authority records.
        rr��r�r�N�r�r�r	r��SOAr�rs r�test_authorityz%MessageComparisonTests.test_authority����
	
�/�/�����L�L��c�g�g�s�~�~�GW�X��
 �
�

����L�L��c�g�g�s�~�~�GW�X��
 �
�

����L�L��c�g�g�s�~�~�GW�X��
 �
�	
rc��|j|jtjdtjd���g��|jtjdtjd���g��|jtjdtjd���g���y)zn
        Two L{dns.Message} instances compare equal if they have the same
        additional records.
        rr�r��r�r�Nr�rs r�test_additionalz&MessageComparisonTests.test_additional����
	
�/�/�����L�L�����i�9P�Q��
 �
�

����L�L�����i�9P�Q��
 �
�

����L�L�����i�9P�Q��
 �
�	
rN)r)r*r+r4r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r,rrr�r��sW����6	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�
�"
�.
rr�c��eZdZdZd�Zdd�Zy)�TestControllerz�
    Pretend to be a DNS query processor for a DNSDatagramProtocol.

    @ivar messages: the list of received messages.
    @type messages: C{list} of (msg, protocol, address)
    c��g|_y)zG
        Initialize the controller: create a list of messages.
        N)�messagesrs r�__init__zTestController.__init__�s����
rNc�@�|jj|||f�y)zN
        Save the message so that it can be checked during the tests.
        N)r�r�)rr��proto�addrs    r�messageReceivedzTestController.messageReceived�s��	
�
�
���c�5�$�/�0r�N)r)r*r+r4r�r�r,rrr�r��s����1rr�c�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�DatagramProtocolTestsz=
    Test various aspects of L{dns.DNSDatagramProtocol}.
    c�D�tj�|_t�|_tj|j�|_tj�}|jj|�|jj|j_y)zQ
        Create a L{dns.DNSDatagramProtocol} with a deterministic clock.
        N)r�Clock�clockr��
controllerr	�DNSDatagramProtocolr�r
�FakeDatagramTransport�makeConnection�	callLater)r�	transports  r�setUpzDatagramProtocolTests.setUp�sg���Z�Z�\��
�(�*����,�,�T�_�_�=��
�!�7�7�9�	��
�
�!�!�)�,�#�z�z�3�3��
�
�rc��|jjdtjddd��|j	|j
jg�y)z�
        Test that when a short datagram is received, datagramReceived does
        not raise an exception while processing it.
        r�UDP�	127.0.0.1�90N�r��datagramReceivedr�IPv4Addressrr�r�rs r�test_truncatedPacketz*DatagramProtocolTests.test_truncatedPacket�sB��
	
�
�
�#�#�C��)<�)<�U�K�QV�)W�X�������1�1�2�6rc��d}|jj|tjddd��|j	|j
jg�y)z�
        Test that when an unparsable message is received, datagramReceived does
        not raise an exception while processing it.
        s�WWWWWWWWWW-XXXXXX_arduino_tcplocal���7��V�V!� J���V�Kauth_upload=no board="ESP8266_WEMOS_D1MINILITE"
ssh_upload=notcp_check=no��x��)r�r�r�Nr�)r�
unparsables  r�test_malformedMessagez+DatagramProtocolTests.test_malformedMessage�sP��
*�	�	
�
�
�#�#���+�+�E�;��F�	
�	
������1�1�2�6rc�`���jjdtjd�g�}�j	t�jjj��d�tj�}tt�jjj���|_tjtjd����g|_�fd�}|j|��jj!|j#�d�|S)�6
        Test content received after a query.
        �r�iaSr�r�r��rr�c�t���j|jdjj�d�y�Nrr��rr�r��
dottedQuad�r�rs �r�cbz2DatagramProtocolTests.test_simpleQuery.<locals>.cb�+������V�^�^�A�.�6�6�A�A�C�Y�Or)r��queryr	r�rrt�liveMessages�keysru�next�iterrqr�r�r��addCallbackr�r�)r�drUrs`   r�test_simpleQueryz&DatagramProtocolTests.test_simpleQuery
s����
�J�J���1�C�I�I�f�4E�3F�G������T�Z�Z�4�4�9�9�;�<�a�@��K�K�M���D����0�0�5�5�7�8�9����\�\�#�,�,�y�*I�J�K��	�	P�	
�
�
�b���
�
�#�#�A�G�G�I�/C�D��rc��|jjdtjd�g�}|j	t|jj�d�|jjd�|j|tj�|j	t|jj�d�|S)�>
        Test that query timeouts after some seconds.
        rr�r�r>r�r�r
r	r�rrtrr��advance�
assertFailure�DNSQueryTimeoutError�rrs  r�test_queryTimeoutz'DatagramProtocolTests.test_queryTimeouts���
�J�J���1�C�I�I�f�4E�3F�G������T�Z�Z�4�4�5�q�9��
�
���2�����1�c�6�6�7�����T�Z�Z�4�4�5�q�9��rc���d�}||jj_|jjdt	j
d�g�}|j
|t�S)z�
        Exceptions raised by the transport's write method should be turned into
        C{Failure}s passed to errbacks of the C{Deferred} returned by
        L{DNSDatagramProtocol.query}.
        c��td���N�bar��RuntimeError)r�r�s  r�
writeErrorz9DatagramProtocolTests.test_writeError.<locals>.writeError-�
���u�%�%rrr��r�r�rsr
r	r�rr"�rr#rs   r�test_writeErrorz%DatagramProtocolTests.test_writeError&sQ��	&�&0��
�
���"��J�J���1�C�I�I�f�4E�3F�G���!�!�!�\�2�2rc���d�}||j_d|j_|jjdt	j
d�g�}|j
|t�S)z�
        Exception L{CannotListenError} raised by C{listenUDP} should be turned
        into a C{Failure} passed to errback of the C{Deferred} returned by
        L{DNSDatagramProtocol.query}.
        c��tddd��r�)rr,rr�startListeningErrorzCDatagramProtocolTests.test_listenError.<locals>.startListeningError<s��#�D�$��5�5rNrr�)r��startListeningr�r
r	r�rr)rr*rs   r�test_listenErrorz&DatagramProtocolTests.test_listenError5sX��	6�%8��
�
�!�#��
�
���J�J���1�C�I�I�f�4E�3F�G���!�!�!�%6�7�7rc�~�tj�}d|_tjtjd����g|_|jj|j�d�|j|jjddj�|j��y)	z�
        When receiving a message whose id is not in
        L{DNSDatagramProtocol.liveMessages} or L{DNSDatagramProtocol.resends},
        the message will be received by L{DNSDatagramProtocol.controller}.
        r�r�rr�r���rN)r	rurqr�r�r�r�r�r�rr�r�)rr�s  r�$test_receiveMessageNotInLiveMessagesz:DatagramProtocolTests.test_receiveMessageNotInLiveMessagesFs����+�+�-����
��<�<����Y�0O�P�Q����
�
�#�#�G�M�M�O�5I�J�������1�1�"�5�a�8�>�>�@�'�-�-�/�RrN)r)r*r+r4r�r�rrrr'r,r/r,rrr�r��s0���	4�7�7�(�"	�
3�8�"
Srr�c�"�eZdZdZd�Zd�Zd�Zy)�TestTCPControllera	
    Pretend to be a DNS query processor for a DNSProtocol.

    @ivar connections: A list of L{DNSProtocol} instances which have
        notified this controller that they are connected and have not
        yet notified it that their connection has been lost.
    c�<�tj|�g|_yr�)r�r��connectionsrs rr�zTestTCPController.__init__\s������%���rc�:�|jj|�yr�)r3r��rr�s  r�connectionMadez TestTCPController.connectionMade`���������&rc�:�|jj|�yr�)r3�remover5s  r�connectionLostz TestTCPController.connectionLostcr7rN)r)r*r+r4r�r6r:r,rrr1r1Ss����'�'rr1c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�DNSProtocolTestsz5
    Test various aspects of L{dns.DNSProtocol}.
    c�@�tj�|_t�|_tj|j�|_|jjtj��|jj|j_y)zI
        Create a L{dns.DNSProtocol} with a deterministic clock.
        N)rr�r�r1r�r	�DNSProtocolr�r�r
�StringTransportr�rs rr�zDNSProtocolTests.setUpls`���Z�Z�\��
�+�-����_�_�T�_�_�5��
��
�
�!�!�-�"?�"?�"A�B�#�z�z�3�3��
�
�rc��|j|jj|jg�|jj	tt
d���|j|jjg�y)z�
        L{dns.DNSProtocol} calls its controller's C{connectionMade}
        method with itself when it is connected to a transport and its
        controller's C{connectionLost} method when it is disconnected.
        zFake Connection DoneN)rr�r3r�r:r
rrs r�test_connectionTrackingz(DNSProtocolTests.test_connectionTrackingvs[��	
������4�4�t�z�z�l�C��
�
�!�!�'�.�9O�*P�"Q�R�������4�4�b�9rc��|jjtjd�g�}|j	t|jj�d�|jjd�|j|tj�|j	t|jj�d�|S)rr�r��<rrrs  rrz"DNSProtocolTests.test_queryTimeout�s���
�J�J���c�i�i��/�0�1������T�Z�Z�4�4�5�q�9��
�
���2�����1�c�6�6�7�����T�Z�Z�4�4�5�q�9��rc����jjtjd�g�}�j	t�jjj��d�tj�}tt�jjj���|_tjtjd����g|_�fd�}|j|�|j!�}t#j$dt|��|z}�jj'|�|S)rr�r�r�rr�c�t���j|jdjj�d�yrrr
s �rrz-DNSProtocolTests.test_simpleQuery.<locals>.cb�rr�!H)r�r
r	r�rrtrrrurrrqr�r�r�rr��struct�pack�dataReceived)rrrUrr�s`    rrz!DNSProtocolTests.test_simpleQuery�s����
�J�J���c�i�i��/�0�1������T�Z�Z�4�4�9�9�;�<�a�@��K�K�M���D����0�0�5�5�7�8�9����\�\�#�,�,�y�*I�J�K��	�	P�	
�
�
�b��
�G�G�I���K�K��c�!�f�%��)���
�
����"��rc���d�}||jj_|jjt	j
d�g�}|j
|t�S)z�
        Exceptions raised by the transport's write method should be turned into
        C{Failure}s passed to errbacks of the C{Deferred} returned by
        L{DNSProtocol.query}.
        c��td��rr!)r�s rr#z4DNSProtocolTests.test_writeError.<locals>.writeError�r$rr�r%r&s   rr'z DNSProtocolTests.test_writeError�sN��	&�&0��
�
���"��J�J���c�i�i��/�0�1���!�!�!�\�2�2rc���tj�}d|_tjtjd����g|_|j
�}tjdt|��|z}|jj|�|j|jjddj
�|j
��y)	z�
        When receiving a message whose id is not in L{DNSProtocol.liveMessages}
        the message will be received by L{DNSProtocol.controller}.
        r�r�rr�rFr.rN)r	rurqr�r�r�r�rGrHrtr�rIrr�r�)rr�r�s   rr/z5DNSProtocolTests.test_receiveMessageNotInLiveMessages�s���
�+�+�-����
��<�<����Y�0O�P�Q�����������T�3�v�;�/�&�8���
�
����'�������1�1�"�5�a�8�>�>�@�'�-�-�/�RrN)
r)r*r+r4r�rArrr'r/r,rrr<r<gs&���4�:�	��&
3�Srr<c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�	ReprTestszE
    Tests for the C{__repr__} implementation of record classes.
    c�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_NS} instance includes the name of the
        nameserver and the TTL of the record.
        r��z<NS name=example.com ttl=4321>N)rrdr	�	Record_NSrs r�test_nszReprTests.test_ns��(��
	
�������~�t�4�5�7W�	
rc�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_MD} instance includes the name of the
        mail destination and the TTL of the record.
        rrPz<MD name=example.com ttl=4321>N)rrdr	�	Record_MDrs r�test_mdzReprTests.test_md�rSrc�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_MF} instance includes the name of the
        mail forwarder and the TTL of the record.
        rrPz<MF name=example.com ttl=4321>N)rrdr	�	Record_MFrs r�test_mfzReprTests.test_mf�rSrc�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_CNAME} instance includes the name of the
        mail forwarder and the TTL of the record.
        rrPz!<CNAME name=example.com ttl=4321>N)rrdr	�Record_CNAMErs r�
test_cnamezReprTests.test_cname��*��
	
�����!�!�.�$�7�8�/�	
rc�b�|jttjdd��d�y)z}
        The repr of a L{dns.Record_MB} instance includes the name of the
        mailbox and the TTL of the record.
        rrPz<MB name=example.com ttl=4321>N)rrdr	�	Record_MBrs r�test_mbzReprTests.test_mb�rSrc�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_MG} instance includes the name of the
        mail group member and the TTL of the record.
        rrPz<MG name=example.com ttl=4321>N)rrdr	�	Record_MGrs r�test_mgzReprTests.test_mg�rSrc�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_MR} instance includes the name of the
        mail rename domain and the TTL of the record.
        rrPz<MR name=example.com ttl=4321>N)rrdr	�	Record_MRrs r�test_mrzReprTests.test_mr�rSrc�b�|jttjdd��d�y)z~
        The repr of a L{dns.Record_PTR} instance includes the name of the
        pointer and the TTL of the record.
        rrPz<PTR name=example.com ttl=4321>N)rrdr	�
Record_PTRrs r�test_ptrzReprTests.test_ptrs(��
	
���������5�6�-�	
rc�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_DNAME} instance includes the name of the
        non-terminal DNS name redirection and the TTL of the record.
        rrPz!<DNAME name=example.com ttl=4321>N)rrdr	�Record_DNAMErs r�
test_dnamezReprTests.test_dname
r]rc�b�|jttjdd��d�y)z�
        The repr of a L{dns.Record_A} instance includes the dotted-quad
        string representation of the address it is for and the TTL of the
        record.
        r�i7z<A address=1.2.3.4 ttl=567>N)rrdr	r�rs r�test_azReprTests.test_as(��	
�������i��-�.�0M�	
rc�p�|jttjdddddddd�	��d
�y)zh
        The repr of a L{dns.Record_SOA} instance includes all of the
        authority fields.
        smNamesrNamer^���r>rr�)r�r�r�r�r�r�r�r�zZ<SOA mname=mName rname=rName serial=123 refresh=456 retry=789 expire=10 minimum=11 ttl=12>N)rrdr	r�rs r�test_soazReprTests.test_soasC��
	
�������"�"�������	�
�
5�	
rc�b�|jttjdd��d�y)z
        The repr of a L{dns.Record_NULL} instance includes the repr of its
        payload and the TTL of the record.
        sabcdr^z<NULL payload='abcd' ttl=123>N)rrdr	r�rs r�	test_nullzReprTests.test_null4s(��
	
��������#�.�/�1P�	
rc	�f�|jttjddd���d�y)z�
        The repr of a L{dns.Record_WKS} instance includes the dotted-quad
        string representation of the address it is for, the IP protocol
        number it is for, and the TTL of the record.
        z2.3.4.5r|r�rz&<WKS address=2.3.4.5 protocol=7 ttl=8>N)rrdr	r�rs r�test_wkszReprTests.test_wks=s*��	
�������	�1�!�4�5�4�	
rc�d�|jttjdd���d�y)z�
        The repr of a L{dns.Record_AAAA} instance includes the colon-separated
        hex string representation of the address it is for and the TTL of the
        record.
        z
8765::1234r>rz <AAAA address=8765::1234 ttl=10>N)rrdr	r�rs r�	test_aaaazReprTests.test_aaaaHs(��	
��������2�6�7�.�	
rc
�h�|jttjdddd���d�y)z�
        The repr of a L{dns.Record_A6} instance includes the colon-separated
        hex string representation of the address it is for and the TTL of the
        record.
        rz
1234::5678r|r>rz,<A6 suffix=1234::5678 prefix=foo.bar ttl=10>N)rrdr	r�rs r�test_a6zReprTests.test_a6Ss,��	
�������q�,�
��C�D�:�	
rc�h�|jttjddddd��d�y)z�
        The repr of a L{dns.Record_SRV} instance includes the name and port of
        the target and the priority, weight, and TTL of the record.
        r�r�r�r�r�z9<SRV priority=1 weight=2 target=example.org port=3 ttl=4>N)rrdr	r�rs r�test_srvzReprTests.test_srv^s.��
	
��������1�a���;�<�G�	
rc	�p�tjddddddd�}|jt|�d�y	)
z�
        The repr of a L{dns.Record_NAPTR} instance includes the order,
        preference, flags, service, regular expression, replacement, and TTL of
        the record.
        r�r}�S�https
/foo/bar/i�bazr�zY<NAPTR order=5 preference=9 flags=S service=http regexp=/foo/bar/i replacement=baz ttl=3>N)r	rrrd�rr�s  r�
test_naptrzReprTests.test_naptrhs:���!�!�!�Q��g�}�f�a�P�������L�
7�	
rc	�d�|jttjddd��d�y)z{
        The repr of a L{dns.Record_AFSDB} instance includes the subtype,
        hostname, and TTL of the record.
        r�r�r�z,<AFSDB subtype=3 hostname=example.org ttl=5>N)rrdr	r rs r�
test_afsdbzReprTests.test_afsdbus,��
	
�����!�!�!�^�Q�7�8�:�	
rc	�d�|jttjddd��d�y)zw
        The repr of a L{dns.Record_RP} instance includes the mbox, txt, and TTL
        fields of the record.
        r#sadmin.example.comr�z7<RP mbox=alice.example.com txt=admin.example.com ttl=3>N)rrdr	r&rs r�test_rpzReprTests.test_rps,��
	
�������3�5I�1�M�N�E�	
rc	�d�|jttjddd��d�y)zx
        The repr of a L{dns.Record_HINFO} instance includes the cpu, os, and
        TTL fields of the record.
        ssparcsminixr�z%<HINFO cpu='sparc' os='minix' ttl=12>N)rrdr	r+rs r�
test_hinfozReprTests.test_hinfo�s,��
	
�����!�!�(�H�b�9�:�3�	
rc�h�tjddd�}|jt|�d�y)z�
        The repr of a L{dns.Record_MINFO} instance includes the rmailbx,
        emailbx, and TTL fields of the record.
        r#�bob.example.com�zF<MINFO responsibility=alice.example.com errors=bob.example.com ttl=15>N)r	r0rrdr�s  r�
test_minfozReprTests.test_minfo�s2��
�!�!�"6�8J�B�O�������L�W�	
rc	�d�|jttjddd��d�y)z~
        The repr of a L{dns.Record_MX} instance includes the preference, name,
        and TTL fields of the record.
        �
smx.example.comr�z,<MX preference=13 name=mx.example.com ttl=2>N)rrdr	r3rs r�test_mxzReprTests.test_mx�s+��
	
�������r�#4�a�8�9�:�	
rc	�f�|jttjddd���d�y)zr
        The repr of a L{dns.Record_TXT} instance includes the data and ttl
        fields of the record.
        r�r�r�rz <TXT data=['foo', 'bar'] ttl=15>N)rrdr	rErs r�test_txtzReprTests.test_txt��*��
	
���������B�7�8�.�	
rc	�f�|jttjddd���d�y)zr
        The repr of a L{dns.Record_SPF} instance includes the data and ttl
        fields of the record.
        r�r�r�rz <SPF data=['foo', 'bar'] ttl=15>N)rrdr	�
Record_SPFrs r�test_spfzReprTests.test_spf�r�rc�b�|jttjdd��d�y)zu
        The repr of a L{dns.UnknownRecord} instance includes the data and ttl
        fields of the record.
        sfoobarr�z"<UNKNOWN data='foo\x1fbar' ttl=12>N)rrdr	r�rs rr�zReprTests.test_unknown�s*��
	
�����"�"�=�"�5�6�1�	
rN)r)r*r+r4rRrVrYr\r`rcrfrirlrnrrrtrvrxrzr|r�r�r�r�r�r�r�r�r�r,rrrNrN�s����
�
�
�
�
�
�
�
�
�
�
�,
�	
�	
�	
�
�
�
�
�
�	
�
�
�
�
rrNc���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#y")#�
EqualityTestszM
    Tests for the equality and non-equality behavior of record classes.
    c�(�|j|||�Sr�)r�)r�
firstValueOne�secondValueOne�valueTwos    r�
_equalityTestzEqualityTests._equalityTest�s���6�6��>�8�
�	
rc��|jtjd�tjd�tjd��y)zt
        Two L{dns.Charstr} instances compare equal if and only if they have the
        same string value.
        �abc�defN)r�r	r�rs r�test_charstrzEqualityTests.test_charstr�s4��
	
����K�K������V�!4�c�k�k�&�6I�	
rc��|jtjd�tjd�tjd��y)zo
        Two L{dns.Name} instances compare equal if and only if they have the
        same name value.
        r�r�N)r�r	r'rs rr�zEqualityTests.test_name�s1��
	
���3�8�8�F�+�S�X�X�f�-=�s�x�x��?O�Prc��|j|dd�|dd�|dd��|j|dd�|dd�|dd��y)z�
        Assert that instances of C{cls} with the same attributes compare equal
        to each other and instances with different attributes compare as not
        equal.

        @param cls: A L{dns.SimpleRecord} subclass.
        rr^iAr�N)r�)rr~s  r�_simpleEqualityTestz!EqualityTests._simpleEqualityTest�s\��	
������$�c�.�#�&>��N�TW�@X�	
�	
������$�c�.�#�&>��N�TW�@X�	
rc���|jtjdtjd���tjdtjd���tjdtjd����|jtjdtjd���tjdtjd���tjdtjd����|jtjdtj�tjdtj�tjdtj
��|jtjdtjtjd���tjdtjtjd���tjdtjtjd����|jtjddtjd���tjddtjd���tjdd	tjd����|jtjdd
tjd���tjdd
tjd���tjddtjd����y
)z�
        Two L{dns.RRHeader} instances compare equal if and only if they have
        the same name, type, class, time to live, payload, and authoritative
        bit.
        rr�r�r��1.2.3.5)r~r�rC)r�r�rCr�)rhr�rN)r�r	r�r�r��MXr��CSrs r�
test_rrheaderzEqualityTests.test_rrheader�s��	
����L�L�����i�1H�I��L�L�����i�1H�I��L�L�����i�1H�I�	
�	
����L�L�����i�1H�I��L�L�����i�1H�I��L�L�����i�1H�I�	
�	
����L�L�����/��L�L�����/��L�L�����0�	
�	
����L�L��S�V�V�S�\�\�)�=T�U��L�L��S�V�V�S�\�\�)�=T�U��L�L��S�V�V�S�\�\�)�=T�U�	
�	
����L�L��R����i�9P�Q��L�L��R����i�9P�Q��L�L��S�#�,�,�y�:Q�R�	
�	
����L�L��a����i�9P�Q��L�L��a����i�9P�Q��L�L��a����i�9P�Q�	
rc�B�|jtj�y)zv
        Two L{dns.Record_NS} instances compare equal if and only if they have
        the same name and TTL.
        N)r�r	rQrs rrRzEqualityTests.test_ns#���
	
� � ����/rc�B�|jtj�y�zv
        Two L{dns.Record_MD} instances compare equal if and only if they have
        the same name and TTL.
        N)r�r	rUrs rrVzEqualityTests.test_md*r�rc�B�|jtj�y)zv
        Two L{dns.Record_MF} instances compare equal if and only if they have
        the same name and TTL.
        N)r�r	rXrs rrYzEqualityTests.test_mf1r�rc�B�|jtj�y)zy
        Two L{dns.Record_CNAME} instances compare equal if and only if they
        have the same name and TTL.
        N)r�r	r[rs rr\zEqualityTests.test_cname8���
	
� � ��!1�!1�2rc�B�|jtj�y)zv
        Two L{dns.Record_MB} instances compare equal if and only if they have
        the same name and TTL.
        N)r�r	r_rs rr`zEqualityTests.test_mb?r�rc�B�|jtj�y)zv
        Two L{dns.Record_MG} instances compare equal if and only if they have
        the same name and TTL.
        N)r�r	rbrs rrczEqualityTests.test_mgFr�rc�B�|jtj�y)zv
        Two L{dns.Record_MR} instances compare equal if and only if they have
        the same name and TTL.
        N)r�r	rers rrfzEqualityTests.test_mrMr�rc�B�|jtj�y)zw
        Two L{dns.Record_PTR} instances compare equal if and only if they have
        the same name and TTL.
        N)r�r	rhrs rrizEqualityTests.test_ptrTs��
	
� � ����0rc�B�|jtj�yr�)r�r	rkrs rrlzEqualityTests.test_dname[r�rc�@�|jtjdd�tjdd�tjdd��|jtjdd�tjdd�tjdd��y)zx
        Two L{dns.Record_A} instances compare equal if and only if they have
        the same address and TTL.
        r�r�rzr�N)r�r	r�rs rrnzEqualityTests.test_absv��	
����L�L��A�&��L�L��A�&��L�L��A�&�	
�	
����L�L��A�&��L�L��A�&��L�L��A�&�	
rc��|jtjdddddddd�tjdddddddd�tjd	ddddddd��|jtjdddddddd�tjdddddddd�tjdd	dddddd��|jtjdddddddd�tjdddddddd�tjddd
ddddd��|jtjdddddddd�tjdddddddd�tjdddd
dddd��|jtjdddddddd�tjdddddddd�tjddddd
ddd��|jtjdddddddd�tjdddddddd�tjdddddd
dd��|jtjdddddddd�tjdddddddd�tjddddddd
d��|jtjdddddddd�tjdddddddd�tjdd	dddddd
��y)z�
        Two L{dns.Record_SOA} instances compare equal if and only if they have
        the same mname, rname, serial, refresh, minimum, expire, retry, and
        ttl.
        smnamesrnamer^rprqr>r�rosxnamer�N)r�r	r�rs rrrzEqualityTests.test_soats���	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I�	
�	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I�	
�	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�q�#�s�B��B�G�	
�	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�A�s�B��B�G�	
�	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��B��B�G�	
�	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��a��R�H�	
�	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�!�R�H�	
�	
����N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�b�I��N�N�8�X�s�C��b�"�a�H�	
rc�@�|jtjdd�tjdd�tjdd��|jtjdd�tjdd�tjdd��y)z{
        Two L{dns.Record_NULL} instances compare equal if and only if they have
        the same payload and ttl.
        zfoo barr>zbar foorN)r�r	r�rs rrtzEqualityTests.test_null�sv��	
����O�O�I�r�*��O�O�I�r�*��O�O�I�r�*�	
�	
����O�O�I�r�*��O�O�I�r�*��O�O�I�s�+�	
rc
��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��y	)
z�
        Two L{dns.Record_WKS} instances compare equal if and only if they have
        the same address, protocol, map, and ttl.
        r�r��foor�r�rr ��N)r�r	r�rs rrvzEqualityTests.test_wks�s��	
����N�N�9�a���2��N�N�9�a���2��N�N�9�a���2�	
�	
����N�N�9�a���2��N�N�9�a���2��N�N�9�c�5�!�4�	
�	
����N�N�9�a���2��N�N�9�a���2��N�N�9�a���2�	
�	
����N�N�9�a���2��N�N�9�a���2��N�N�9�a���4�	
rc�@�|jtjdd�tjdd�tjdd��|jtjdd�tjdd�tjdd��y)z{
        Two L{dns.Record_AAAA} instances compare equal if and only if they have
        the same address and ttl.
        z1::2r�z2::1r>N)r�r	r�rs rrxzEqualityTests.test_aaaa�sv��	
����O�O�F�A�&��O�O�F�A�&��O�O�F�A�&�	
�	
����O�O�F�A�&��O�O�F�A�&��O�O�F�B�'�	
rc
��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��y	)
z�
        Two L{dns.Record_A6} instances compare equal if and only if they have
        the same prefix, prefix length, suffix, and ttl.
        r1z::abcdrr>r�z::abcd:0r�rN)r�r	r�rs rrzzEqualityTests.test_a6�s��	
����M�M�"�h���;��M�M�"�h���;��M�M�"�h���;�	
�	
����M�M�"�h���;��M�M�"�h���;��M�M�"�j�.�"�=�	
�	
����M�M�"�h���;��M�M�"�h���;��M�M�"�h���;�	
�	
����M�M�"�h���;��M�M�"�h���;��M�M�"�h���<�	
rc�t�|jtjddddd�tjddddd�tjddddd��|jtjddddd�tjddddd�tjddddd��|jtjddddd�tjddddd�tjddddd��|jtjddddd�tjddddd�tjdddd	d��|jtjddddd�tjddddd�tjddddd
��y)z�
        Two L{dns.Record_SRV} instances compare equal if and only if they have
        the same priority, weight, port, target, and ttl.
        r>r�rorrprr�i,r��N)r�r	r�rs rr|zEqualityTests.test_srvs~��	
����N�N�2�r�2�~�r�:��N�N�2�r�2�~�r�:��N�N�3��B���;�	
�	
����N�N�2�r�2�~�r�:��N�N�2�r�2�~�r�:��N�N�2�s�B���;�	
�	
����N�N�2�r�2�~�r�:��N�N�2�r�2�~�r�:��N�N�2�r�3���;�	
�	
����N�N�2�r�2�~�r�:��N�N�2�r�2�~�r�:��N�N�2�r�2�~�r�:�	
�	
����N�N�2�r�2�~�r�:��N�N�2�r�2�~�r�:��N�N�2�r�2�~�s�;�	
rc
��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��|jtjdddd�tjdddd�tjdddd��y)z�
        Two L{dns.Record_SSHFP} instances compare equal if and only if
        they have the same key type, fingerprint type, fingerprint, and ttl.
        r�r�shappydayrpshappxday�-N)r�r	rrs r�
test_sshfpzEqualityTests.test_sshfp2s2��	
������Q��;��3����Q��;��3����Q��;��3�	
�	
������Q��;��3����Q��;��3����Q��;��3�	
�	
������Q��;��3����Q��;��3����Q��;��3�	
�	
������Q��;��3����Q��;��3����Q��;��3�	
rc
�(�|jtjddddddd�tjddddddd�tjddddddd��|jtjddddddd�tjddddddd�tjddddddd��|jtjddddddd�tjddddddd�tjddd	dddd��|jtjddddddd�tjddddddd�tjdddd
ddd��|jtjddddddd�tjddddddd�tjddddddd��|jtjddddddd�tjddddddd�tjddddddd��|jtjddddddd�tjddddddd�tjddddddd
��y)z�
        Two L{dns.Record_NAPTR} instances compare equal if and only if they
        have the same order, preference, flags, service, regexp, replacement,
        and ttl.
        r�r�r
rs	/foo/bar/r�r�r��prs	/bar/foo/squuxr�N)r�r	rrs rr�zEqualityTests.test_naptrPs���	
������Q��4��\�6�2�N����Q��4��\�6�2�N����Q��4��\�6�2�N�	
�	
������Q��4��\�6�2�N����Q��4��\�6�2�N����Q��4��\�6�2�N�	
�	
������Q��4��\�6�2�N����Q��4��\�6�2�N����Q��4��\�6�2�N�	
�	
������Q��4��\�6�2�N����Q��4��\�6�2�N����Q��4��,���K�	
�	
������Q��4��\�6�2�N����Q��4��\�6�2�N����Q��4��\�6�2�N�	
�	
������Q��4��\�6�2�N����Q��4��\�6�2�N����Q��4��\�7�B�O�	
�	
������Q��4��\�6�2�N����Q��4��\�6�2�N����Q��4��\�6�1�M�	
rc	���|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��y)z�
        Two L{dns.Record_AFSDB} instances compare equal if and only if they
        have the same subtype, hostname, and ttl.
        r�rr�r�r�N)r�r	r rs rr�zEqualityTests.test_afsdb�s���	
������Q���2����Q���2����Q���2�	
�	
������Q���2����Q���2����Q���2�	
�	
������Q���2����Q���2����Q���2�	
rc	���|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��y)zx
        Two L{Record_RP} instances compare equal if and only if they have the
        same mbox, txt, and ttl.
        r#s
alice is nicer>r�salice is not nicerN)r�r	r&rs rr�zEqualityTests.test_rp�s���	
����M�M�.�0@�"�E��M�M�.�0@�"�E��M�M�,�.>��C�	
�	
����M�M�.�0@�"�E��M�M�.�0@�"�E��M�M�.�0D�b�I�	
�	
����M�M�.�0@�"�E��M�M�.�0@�"�E��M�M�.�0@�#�F�	
rc	���|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��y)z}
        Two L{dns.Record_HINFO} instances compare equal if and only if they
        have the same cpu, os, and ttl.
        zx86-64�plan9r>�i386�plan11rN)r�r	r+rs rr�zEqualityTests.test_hinfo�s���	
������X�w��3����X�w��3����V�W�b�1�	
�	
������X�w��3����X�w��3����X�x��4�	
�	
������X�w��3����X�w��3����X�w��4�	
rc	���|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��y)z�
        Two L{dns.Record_MINFO} instances compare equal if and only if they
        have the same rmailbx, emailbx, and ttl.
        srmailboxsemailboxr>s	someplaces	somethingrN)r�r	r0rs rr�zEqualityTests.test_minfo�s���	
������[�+�r�:����[�+�r�:����\�;��;�	
�	
������[�+�r�:����[�+�r�:����[�,��;�	
�	
������[�+�r�:����[�+�r�:����[�+�s�;�	
rc	���|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��|jtjddd�tjddd�tjddd��y)z�
        Two L{dns.Record_MX} instances compare equal if and only if they have
        the same preference, name, and ttl.
        r>r�r�rsexample.netr�N)r�r	r3rs rr�zEqualityTests.test_mx�s���	
����M�M�"�n�b�1��M�M�"�n�b�1��M�M�#�~�r�2�	
�	
����M�M�"�n�b�1��M�M�"�n�b�1��M�M�"�n�b�1�	
�	
����M�M�"�n�b�1��M�M�"�n�b�1��M�M�"�n�c�2�	
rc
��|jtjddd��tjddd��tjdddd���|jtjddd��tjddd��tjddd���|jtjddd��tjddd��tjddd���y)zw
        Two L{dns.Record_TXT} instances compare equal if and only if they have
        the same data and ttl.
        r�r r>r�bazrN)r�r	rErs rr�zEqualityTests.test_txt�����	
����N�N�5�%�R�0��N�N�5�%�R�0��N�N�5�%��B�7�	
�	
����N�N�5�%�R�0��N�N�5�%�R�0��N�N�5�%�R�0�	
�	
����N�N�5�%�R�0��N�N�5�%�R�0��N�N�5�%�S�1�	
rc
��|jtjddd��tjddd��tjdddd���|jtjddd��tjddd��tjddd���|jtjddd��tjddd��tjddd���y)zs
        L{dns.Record_SPF} instances compare equal if and only if they have the
        same data and ttl.
        r�r r>rr�rN)r�r	r�rs rr�zEqualityTests.test_spf	r�rc
�Z�dddddtjddd�}d	d
ddd
tjddd�}|j�D]f}|j	�}||||<|jtjdi|��tjdi|��tjdi|����hy)z�
        L{dns.Record_TSIG} instances compare equal if and only if they have the
        same RDATA (algorithm, timestamp, MAC, etc.) and ttl.
        zhmac-sha224r6r�s�crrp)rr8r:r;r9r=r>r�zhmac-sha512i�pUZrsi���r�Nr,)r	�OKr@r�copyr�r?)r�baseargs�altargs�kw�altereds     r�	test_tsigzEqualityTests.test_tsig)	s���'�$��*���V�V���	
��'�$��*���\�\�$��	
���-�-�/�	�B��m�m�o�G�!�"�+�G�B�K�������*�'�*����*�'�*����+�(�+�
�	rc���|jtjdd��tjdd��tjdd���|jtjdd��tjdd��tjdd���|jtjdd��tjdd��tjdd���y)zv
        L{dns.UnknownRecord} instances compare equal if and only if they have
        the same data and ttl.
        r�r>r�foobarr rN)r�r	r�rs rr�zEqualityTests.test_unknownK	s���	
������e��,����e��,����h�B�/�	
�	
������e��,����e��,����e��,�	
�	
������e��,����e��,����e��-�	
rN)$r)r*r+r4r�r�r�r�r�rRrVrYr\r`rcrfrirlrnrrrtrvrxrzr|r�r�r�r�r�r�r�r�r�r�r�r,rrr�r��s����
�

�Q�
�"/
�b0�0�0�3�0�0�0�1�3�
�$5
�n
�$
�<
�$
�B"
�H
�</
�b
�0
�0
�0
�0
�0
�0
�0 �D
rr�c�"�eZdZdZd�Zd�Zd�Zy)�
RRHeaderTestsz2
    Tests for L{twisted.names.dns.RRHeader}.
    c��|jttjdtjtj
dtjd��y)z�
        Attempting to create a L{dns.RRHeader} instance with a negative TTL
        causes L{ValueError} to be raised.
        rr.r�N�r%rUr	r�r�r�r�rs r�test_negativeTTLzRRHeaderTests.test_negativeTTLi	s<��
	
�����L�L���E�E��F�F���L�L��%�	
rc	���d}tjdtjtj|tjd��}|j|jt|��y)z<
        L{dns.RRHeader} converts TTLs to integers.
        g������^@rr�N)r	r�r�r�r�rr��int)r�
ttlAsFloat�headers   r�test_nonIntegralTTLz!RRHeaderTests.test_nonIntegralTTLx	sM���
�����3�5�5�#�&�&�*�c�l�l�;�6O�
��	
������S��_�5rc��|jttjdtjtj
dtjd��y)z�
        Attempting to create a L{dns.RRHeader} instance with a TTL
        that L{int} cannot convert to an integer raises a L{TypeError}.
        rzthis is not a numberr�Nr�rs r�!test_nonNumericTTLRaisesTypeErrorz/RRHeaderTests.test_nonNumericTTLRaisesTypeError�	s<��
	
�����L�L���E�E��F�F�"��L�L��%�	
rN)r)r*r+r4r�r�r�r,rrr�r�d	s���

�6�

rr�c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�NameToLabelsTestsz7
    Tests for L{twisted.names.dns._nameToLabels}.
    c�P�|jtjd�dg�y)zp
        L{dns._nameToLabels} returns a list containing a single
        empty label for an empty name.
        rN�rr	�
_nameToLabelsrs r�
test_emptyzNameToLabelsTests.test_empty�	s!��
	
����*�*�3�/�#��7rc�P�|jtjd�dg�y)z
        L{dns._nameToLabels} returns a list containing a single
        empty label for a name containing only a dot.
        �.rNr�rs r�test_onlyDotzNameToLabelsTests.test_onlyDot�	s!��
	
����*�*�4�0�3�%�8rc�R�|jtjd�ddg�y)z{
        L{dns._nameToLabels} returns a list ending with an empty
        label for a name without a trailing dot.
        �comrNr�rs r�test_withoutTrailingDotz)NameToLabelsTests.test_withoutTrailingDot�	s#��
	
����*�*�6�2�V�S�M�Brc�R�|jtjd�ddg�y)zx
        L{dns._nameToLabels} returns a list ending with an empty
        label for a name with a trailing dot.
        scom.r�rNr�rs r�test_withTrailingDotz&NameToLabelsTests.test_withTrailingDot�	s#��
	
����*�*�7�3�f�c�]�Crc�R�|jtjd�gd��y)zt
        L{dns._nameToLabels} returns a list containing entries
        for all labels in a subdomain name.
        sfoo.bar.baz.example.com.)r�r�r�sexampler�rNr�rs r�test_subdomainz NameToLabelsTests.test_subdomain�	s$��
	
������9�:�=�	
rc�R�|jtjd�gd��y)z`
        L{dns._nameToLabels} preserves the case of ascii
        characters in labels.
        �EXAMPLE.COM)sEXAMPLEsCOMrNr�rs r�test_casePreservationz'NameToLabelsTests.test_casePreservation�	s ��
	
����*�*�>�:�<U�VrN)
r)r*r+r4r�r�r�r�r�r�r,rrr�r��	s(���8�9�C�D�
�Wrr�c�Z�|jtj||�|�d|���y)a\
    Assert that C{descendant} *is* a subdomain of C{ancestor}.

    @type testCase: L{unittest.SynchronousTestCase}
    @param testCase: The test case on which to run the assertions.

    @type descendant: C{str}
    @param descendant: The subdomain name to test.

    @type ancestor: C{str}
    @param ancestor: The superdomain name to test.
    z is not a subdomain of N)r�r	�_isSubdomainOf��testCase�
descendant�ancestors   r�assertIsSubdomainOfr�	s1��
������:�x�0��.�/��|�<�rc�Z�|jtj||�|�d|���y)a`
    Assert that C{descendant} *is not* a subdomain of C{ancestor}.

    @type testCase: L{unittest.SynchronousTestCase}
    @param testCase: The test case on which to run the assertions.

    @type descendant: C{str}
    @param descendant: The subdomain name to test.

    @type ancestor: C{str}
    @param ancestor: The superdomain name to test.
    z is a subdomain of N)r�r	r�r�s   r�assertIsNotSubdomainOfr�	s1��
������:�x�0��.�+�H�<�8�rc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)�IsSubdomainOfTestsz8
    Tests for L{twisted.names.dns._isSubdomainOf}.
    c��t|dd�y)z[
        L{dns._isSubdomainOf} returns C{True} for identical
        domain names.
        rN�rrs r�test_identicalz!IsSubdomainOfTests.test_identical�	s��
	�D�.�.�Arc��t|dd�y)z�
        L{dns._isSubdomainOf} returns C{True} when the first
        name is an immediate descendant of the second name.
        rkrNrrs r�test_parentzIsSubdomainOfTests.test_parent�	s��
	�D�"4�n�Erc��t|dd�y)z
        L{dns._isSubdomainOf} returns C{True} when the first
        name is a distant descendant of the second name.
        sfoo.bar.baz.example.comr�Nrrs r�test_distantAncestorz'IsSubdomainOfTests.test_distantAncestor�	s��
	�D�"<�f�Erc��t|dd�y)zw
        L{dns._isSubdomainOf} returns C{False} when the first
        name is an ancestor of the second name.
        rrkN�rrs r�test_superdomainz#IsSubdomainOfTests.test_superdomain
s��
	�t�^�5G�Hrc��t|dd�y)zs
        L{dns._isSubdomainOf} returns C{False} if the first name
        is a sibling of the second name.
        rksbar.example.comNrrs r�test_siblingzIsSubdomainOfTests.test_sibling
s��
	�t�%7�9K�Lrc��t|dd�y)zx
        L{dns._isSubdomainOf} returns C{False} even when domain
        names happen to share a common suffix.
        sfoo.myexample.comrNrrs r�test_unrelatedCommonSuffixz-IsSubdomainOfTests.test_unrelatedCommonSuffix
s��
	�t�%9�>�Jrc��t|dd�y)z�
        L{dns._isSubdomainOf} returns C{True} if the first name
        is a subdomain of the second name but the first name has a
        trailing ".".
        �foo.example.com.rNrrs r�test_subdomainWithTrailingDotz0IsSubdomainOfTests.test_subdomainWithTrailingDot
s��	�D�"5�~�Frc��t|dd�y)z�
        L{dns._isSubdomainOf} returns C{True} if the first name
        is a subdomain of the second name but the second name has a
        trailing ".".
        rk�example.com.Nrrs r�test_superdomainWithTrailingDotz2IsSubdomainOfTests.test_superdomainWithTrailingDot"
s��	�D�"4�o�Frc��t|dd�y)z�
        L{dns._isSubdomainOf} returns C{True} if the first name
        is a subdomain of the second name and both names have a
        trailing ".".
        rrNrrs r�test_bothWithTrailingDotz+IsSubdomainOfTests.test_bothWithTrailingDot*
s��	�D�"5��Grc��t|dd�y)zw
        L{dns._isSubdomainOf} returns C{False} if the first name
        is empty and the second name is not.
        rrNrrs r�test_emptySubdomainz&IsSubdomainOfTests.test_emptySubdomain2
s��
	�t�S�.�9rc��t|dd�y)zv
        L{dns._isSubdomainOf} returns C{True} if the second name
        is empty and the first name is not.
        rkrNrrs r�test_emptySuperdomainz(IsSubdomainOfTests.test_emptySuperdomain9
s��
	�D�"4�c�:rc�8�t|dd�t|dd�y)z`
        L{dns._isSubdomainOf} does case-insensitive comparison
        of name labels.
        rkr�sFOO.EXAMPLE.COMrNrrs r�test_caseInsensitiveComparisonz1IsSubdomainOfTests.test_caseInsensitiveComparison@
s��
	�D�"4�n�E��D�"4�n�ErN)r)r*r+r4r	rr
rrrrrrrr r"r,rrrr�	sM���B�F�F�I�M�K�G�G�H�:�;�Frrc�2�eZdZdZedd��Zed��Zy)�OPTNonStandardAttributesz�
    Generate byte and instance representations of an L{dns._OPTHeader}
    where all attributes are set to non-default values.

    For testing whether attributes have really been read from the byte
    string during decoding.
    c��d}|rd}d|zS)aT
        Return L{bytes} representing an encoded OPT record.

        @param excludeName: A flag that controls whether to exclude
            the name field. This allows a non-standard name to be
            prepended during the test.
        @type excludeName: L{bool}

        @param excludeOptions: A flag that controls whether to exclude
            the RDLEN field. This allows encoded variable options to be
            appended during the test.
        @type excludeOptions: L{bool}

        @return: L{bytes} representing the encoded OPT record returned
            by L{object}.
        r�rs	)�r,)r~�excludeName�excludeOptions�rdlens    rrczOPTNonStandardAttributes.bytesS
s%��$����E�
�
��	rc�4�tjdddd��S)z�
        Return a new L{dns._OPTHeader} instance.

        @return: A L{dns._OPTHeader} instance with attributes that
            match the encoded record returned by L{bytes}.
        �r�r�T)�udpPayloadSize�
extendedRCODE�version�dnssecOK)r	�
_OPTHeader�r~s rr8zOPTNonStandardAttributes.objectr
s���~�~��a��T�
�	
rN)FF)r)r*r+r4�classmethodrcr8r,rrr$r$J
s/�������<�	
��	
rr$c���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"y!)"�OPTHeaderTestsz4
    Tests for L{twisted.names.dns._OPTHeader}.
    c�T�ttjtj�y)zA
        L{dns._OPTHeader} implements L{dns.IEncodable}.
        N)rr	�
IEncodabler/rs r�test_interfacezOPTHeaderTests.test_interface�
s��	�C�N�N�C�N�N�3rc��|jtj�jtjd��y)zq
        L{dns._OPTHeader.name} is an instance attribute whose value is
        fixed as the root domain
        rN)rr	r/rbr'rs rr�zOPTHeaderTests.test_name�
s)��
	
������)�.�.�����
�>rc	��tj�}|jtt|dtj
d��y)z5
        L{dns._OPTHeader.name} is readonly.
        rbrN)r	r/r%�AttributeError�setattrr'�r�hs  r�test_nameReadonlyz OPTHeaderTests.test_nameReadonly�
s/��
�N�N������.�'�1�f�c�h�h�~�>V�Wrc�`�|jtj�jd�y)z^
        L{dns._OPTHeader.type} is an instance attribute with fixed value
        41.
        �)N)rr	r/r}rs r�	test_typezOPTHeaderTests.test_type�
s!��
	
������)�.�.��3rc��tj�}|jtt|dtj
�y)z5
        L{dns._OPTHeader.type} is readonly.
        r}N)r	r/r%r9r:r�r;s  r�test_typeReadonlyz OPTHeaderTests.test_typeReadonly�
s*��
�N�N������.�'�1�f�c�e�e�Drc�`�|jtj�jd�y)zt
        L{dns._OPTHeader.udpPayloadSize} defaults to 4096 as
        recommended in rfc6891 section-6.2.5.
        �N�rr	r/r+rs r�test_udpPayloadSizez"OPTHeaderTests.test_udpPayloadSize�
s!��
	
������)�8�8�$�?rc�d�|jtjd��jd�y)z`
        L{dns._OPTHeader.udpPayloadSize} can be overridden in the
        constructor.
        r*�r+NrErs r�test_udpPayloadSizeOverridez*OPTHeaderTests.test_udpPayloadSizeOverride�
s#��
	
������s�;�J�J�C�Prc�`�|jtj�jd�y)z@
        L{dns._OPTHeader.extendedRCODE} defaults to 0.
        rN�rr	r/r,rs r�test_extendedRCODEz!OPTHeaderTests.test_extendedRCODE�
s!��	
������)�7�7��;rc�d�|jtjd��jd�y)z_
        L{dns._OPTHeader.extendedRCODE} can be overridden in the
        constructor.
        r��r,NrKrs r�test_extendedRCODEOverridez)OPTHeaderTests.test_extendedRCODEOverride�
s#��
	
������a�8�F�F��Jrc�`�|jtj�jd�y)z:
        L{dns._OPTHeader.version} defaults to 0.
        rN�rr	r/r-rs r�test_versionzOPTHeaderTests.test_version�
s!��	
������)�1�1�1�5rc�d�|jtjd��jd�y)zY
        L{dns._OPTHeader.version} can be overridden in the
        constructor.
        r��r-NrQrs r�test_versionOverridez#OPTHeaderTests.test_versionOverride�
s#��
	
�������2�:�:�A�>rc�^�|jtj�j�y)z?
        L{dns._OPTHeader.dnssecOK} defaults to False.
        N)r�r	r/r.rs r�
test_dnssecOKzOPTHeaderTests.test_dnssecOK�
s��	
������)�2�2�3rc�b�|jtjd��j�y)zZ
        L{dns._OPTHeader.dnssecOK} can be overridden in the
        constructor.
        T�r.N)r�r	r/r.rs r�test_dnssecOKOverridez$OPTHeaderTests.test_dnssecOKOverride�
s��
	
�������5�>�>�?rc�`�|jtj�jg�y)zC
        L{dns._OPTHeader.options} defaults to empty list.
        N)rr	r/�optionsrs r�test_optionszOPTHeaderTests.test_options�
s!��	
������)�1�1�2�6rc�l�tjdg��}|j|jdg�y)zY
        L{dns._OPTHeader.options} can be overridden in the
        constructor.
        )r�r���r\N)r	r/rr\r;s  r�test_optionsOverridez#OPTHeaderTests.test_optionsOverride�
s,��

�N�N�O�#4�5��������_�$5�6rc���t�}tj�j|�|j	|j�tj
��y)z�
        L{dns._OPTHeader.encode} packs the header fields and writes
        them to a file like object passed in as an argument.
        N)rr$r8rlrrmrc)r�bs  rrpzOPTHeaderTests.test_encode�
sB��

�I�� �'�'�)�0�0��3��������'?�'E�'E�'G�Hrc�2�tj�}tjdd�tjdd�g|_t�}|j
|�|j|j�tjd��dz�y)	z�
        L{dns._OPTHeader.options} is a list of L{dns._OPTVariableOption}
        instances which are packed into the rdata area of the header.
        r��	foobarbazr��quxT�r'�	foobarbazquxN)
r$r8r	�_OPTVariableOptionr\rrlrrmrc)rr<rcs   r�test_encodeWithOptionsz%OPTHeaderTests.test_encodeWithOptions�
s���

%�+�+�-���"�"�1�l�3��"�"�1�f�-�
��	�
�I��	��������
�J�J�L�$�*�*�$�*�?��	
�	
rc���tj�}|jttj���|j
|tj��y)z�
        L{dns._OPTHeader.decode} unpacks the header fields from a file
        like object and populates the attributes of an existing
        L{dns._OPTHeader} instance.
        N)r	r/rgrr$rcrr8)r�
decodedHeaders  rrizOPTHeaderTests.test_decodesG�����(�
����W�%=�%C�%C�%E�F�G�����(@�(G�(G�(I�Jrc��ttj��}tj�}|j|�|j
|j�t|j���y)zk
        L{dns._OPTHeader.decode} reads all the bytes of the record
        that is being decoded.
        N�
rr$rcr	r/rgrr�rtrm�rrcrls   r�test_decodeAllExpectedBytesz*OPTHeaderTests.test_decodeAllExpectedBytessS��
�,�2�2�4�5�����(�
����Q���������3�q�z�z�|�#4�5rc��ttj�dz�}tj�}|j|�|j
|j�t|j��td�z
�y)z�
        L{dns._OPTHeader.decode} reads only the bytes from the current
        file position to the end of the record that is being
        decoded. Trailing bytes are not consumed.
        sxxxxNrnros   r�test_decodeOnlyExpectedBytesz+OPTHeaderTests.test_decodeOnlyExpectedBytes&sa��
�,�2�2�4�w�>�?�����(�
����Q���������3�q�z�z�|�#4�s�7�|�#C�Drc���ttjd��dz�}tj�}|j|�|j
|jtjd��y)z�
        L{dns._OPTHeader.decode} discards the name which is encoded in
        the supplied bytes. The name attribute of the resulting
        L{dns._OPTHeader} instance will always be L{dns.Name(b'')}.
        T)r&rfrN)	rr$rcr	r/rgrrbr'�rrcr<s   r�test_decodeDiscardsNamez&OPTHeaderTests.test_decodeDiscardsName3sZ��
�$�*�*�t�*�<�?X�X�
��
�N�N���	��������������#��/rc��ttjd��dz�}tj�}|jt|j|�y)zj
        L{dns._OPTHeader.decode} raises an exception if the supplied
        RDLEN is too short.
        TrgsN�rr$rcr	r/r%r�rgrts   r�test_decodeRdlengthTooShortz*OPTHeaderTests.test_decodeRdlengthTooShortA�M��

�$�*�*�$�*�?��
�
��
�N�N������(�A�H�H�a�0rc��ttjd��dz�}tj�}|jt|j|�y)zi
        L{dns._OPTHeader.decode} raises an exception if the supplied
        RDLEN is too long.
        TrgsNrwrts   r�test_decodeRdlengthTooLongz)OPTHeaderTests.test_decodeRdlengthTooLongRryrc��ttjd��dz�}tj�}|j|�|j
|jtjdd�tjdd�g�y)	z�
        If the OPT bytes contain variable options,
        L{dns._OPTHeader.decode} will populate a list
        L{dns._OPTHeader.options} with L{dns._OPTVariableOption}
        instances.
        Trgrhr�rer�rfN)	rr$rcr	r/rgrr\rirts   r�test_decodeWithOptionsz%OPTHeaderTests.test_decodeWithOptionscs|��
�$�*�*�$�*�?��	
�
��
�N�N���	��������
�I�I��&�&�q�,�7��&�&�q�&�1�
�	
rc
�<�tjdtjddtjd���}tjj|�}tjddddtjdd	�
�g��}|j||�y)
z�
        L{_OPTHeader.fromRRHeader} accepts an L{RRHeader} instance and
        returns an L{_OPTHeader} instance whose attribute values have
        been derived from the C{cls}, C{ttl} and C{payload} attributes
        of the original header.
        rr<l�}s��abcr���Tr�)�code�data)r+r,r-r.r\N)r	r��OPTr�r/�fromRRHeaderrir)r�
genericHeader�decodedOptHeader�expectedOptHeaders    r�test_fromRRHeaderz OPTHeaderTests.test_fromRRHeader�s�����������5��%�%�&<�=�
�
��>�>�6�6�}�E���N�N�!�����+�+��f�E�F�
��	
���)�+<�=rc�^�|jttj��d�y)z�
        L{dns._OPTHeader.__repr__} displays the name and type and all
        the fixed and extended header values of the OPT record.
        zb<_OPTHeader name= type=41 udpPayloadSize=4096 extendedRCODE=0 version=0 dnssecOK=False options=[]>N)rrdr	r/rs r�	test_reprzOPTHeaderTests.test_repr�s&��
	
�������!�"�
�
	
rc��|jtjd��tjd��tjd���y)zh
        Two L{OPTHeader} instances compare equal if they have the same
        udpPayloadSize.
        r*rHrDN�r�r	r/rs r�test_equalityUdpPayloadSizez*OPTHeaderTests.test_equalityUdpPayloadSize�s6��
	
�/�/��N�N�#�.��N�N�#�.��N�N�$�/�	
rc��|jtjd��tjd��tjd���y)zg
        Two L{OPTHeader} instances compare equal if they have the same
        extendedRCODE.
        r�rNr�Nr�rs r�test_equalityExtendedRCODEz)OPTHeaderTests.test_equalityExtendedRCODE�s6��
	
�/�/��N�N��+��N�N��+��N�N��+�	
rc��|jtjd��tjd��tjd���y)za
        Two L{OPTHeader} instances compare equal if they have the same
        version.
        r�rTr�Nr�rs r�test_equalityVersionz#OPTHeaderTests.test_equalityVersion�s6��
	
�/�/��N�N�1�%��N�N�1�%��N�N�1�%�	
rc��|jtjd��tjd��tjd���y)zh
        Two L{OPTHeader} instances compare equal if they have the same
        dnssecOK flags.
        TrYFNr�rs r�test_equalityDnssecOKz$OPTHeaderTests.test_equalityDnssecOK�s6��
	
�/�/��N�N�D�)��N�N�D�)��N�N�E�*�	
rc
� �|jtjtjdd�g��tjtjdd�g��tjtjdd�g���y)za
        Two L{OPTHeader} instances compare equal if they have the same
        options.
        r��xr`r��yN)r�r	r/rirs r�test_equalityOptionsz#OPTHeaderTests.test_equalityOptions�sf��
	
�/�/��N�N�C�$:�$:�1�d�$C�#D�E��N�N�C�$:�$:�1�d�$C�#D�E��N�N�C�$:�$:�1�d�$C�#D�E�	
rN)#r)r*r+r4r6r�r=r@rBrFrIrLrOrRrUrWrZr]rarprjrirprrrurxr{r}r�r�r�r�r�r�r�r,rrr3r3
s����4�?�X�4�E�@�Q�<�K�6�?�4�@�7�7�I�
�6	K�6�E�0�1�"1�"
�>>�6
�"	
�	
�	
�	
�	
rr3c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�OPTVariableOptionTestsz.
    Tests for L{dns._OPTVariableOption}.
    c�T�ttjtj�y)zI
        L{dns._OPTVariableOption} implements L{dns.IEncodable}.
        N)rr	r5rirs rr6z%OPTVariableOptionTests.test_interface�s��	�C�N�N�C�$:�$:�;rc��tjdd�}|j|jd�|j|jd�y)z�
        L{dns._OPTVariableOption.__init__} requires code and data
        arguments which are saved as public instance attributes.
        r�r�N)r	rirr�r�r;s  r�test_constructorArgumentsz0OPTVariableOptionTests.test_constructorArguments�s>��

�"�"�1�d�+���������#��������&rc�b�|jttjdd��d�y)zf
        L{dns._OPTVariableOption.__repr__} displays the code and data
        of the option.
        r�r�z"<_OPTVariableOption code=1 data=x>N)rrdr	rirs rr�z OPTVariableOptionTests.test_repr�s*��
	
�����'�'��4�0�1�9�	
rc�@�|jtjdd�tjdd�tjdd��|jtjdd�tjdd�tjdd��y)zs
        Two OPTVariableOption instances compare equal if they have the same
        code and data values.
        r�r�r�r�N)r�r	rirs rr�z$OPTVariableOptionTests.test_equalitys���
	
�/�/��"�"�1�d�+��"�"�1�d�+��"�"�1�d�+�	
�	
�/�/��"�"�1�d�+��"�"�1�d�+��"�"�1�d�+�	
rc��tjdd�}t�}|j|�|j	|j�d�y)z�
        L{dns._OPTVariableOption.encode} encodes the code and data
        instance attributes to a byte string which also includes the
        data length.
        r��foobar�
foobarN)r	rirrlrrm)r�orcs   rrpz"OPTVariableOptionTests.test_encodesD��
�"�"�1�i�0���I��	��������
�J�J�L�
�	
rc���td�}tj�}|j|�|j	|j
d�|j	|jd�y)z�
        L{dns._OPTVariableOption.decode} is a classmethod that decodes
        a byte string and returns a L{dns._OPTVariableOption} instance.
        r�r�r�N)rr	rirgrr�r�)rrcr�s   rriz"OPTVariableOptionTests.test_decode%sV��

�
�
��
�"�"�$��	������������#��������+rN)
r)r*r+r4r6r�r�r�rprir,rrr�r��s%���<�'�
�
�"
� ,rr�c��eZdZdZd�Zy)�
RaisedArgszp
    An exception which can be raised by fakes to test that the fake is called
    with expected arguments.
    c� �||_||_y)z�
        Store the positional and keyword arguments as attributes.

        @param args: The positional args.
        @param kwargs: The keyword args.
        N�r�r��rr�r�s   rr�zRaisedArgs.__init__<s����	���rN)r)r*r+r4r�r,rrr�r�6s���
rr�c�0�eZdZdZed��Zed��Zy)�MessageEmptyz^
    Generate byte string and constructor arguments for an empty
    L{dns._EDNSMessage}.
    c��	y)��
        Bytes which are expected when encoding an instance constructed using
        C{kwargs} and which are expected to result in an identical instance when
        decoded.

        @return: The L{bytes} of a wire encoded message.
        s��r,r0s rrczMessageEmpty.bytesM���
�	
rc�F�tddtjdddddd��	S)��
        Keyword constructor arguments which are expected to result in an
        instance which returns C{bytes} when encoded.

        @return: A L{dict} of keyword arguments.
        r�Tr�N�	rqrgrrrhrirjrkrs�ednsVersion)�dictr	�	OP_STATUSr0s rr�zMessageEmpty.kwargs`s0������=�=�������

�
	
rN�r)r*r+r4r1rcr�r,rrr�r�Gs/���
�
��
�$�
��
rr�c�0�eZdZdZed��Zed��Zy)�MessageTruncatedz=
    An empty response message whose TR bit is set to 1.
    c��	y)r�s�r,r0s rrczMessageTruncated.byteszr�rc�*�tddddddddd��	S)r�r�r�rNr�)r�r0s rr�zMessageTruncated.kwargs�s,������������

�
	
rNr�r,rrr�r�us/����
��
�$�
��
rr�c�0�eZdZdZed��Zed��Zy)�MessageNonAuthoritativez.
    A minimal non-authoritative message.
    c��	y)r�sr,r0s rrczMessageNonAuthoritative.bytes����

 �	
rc�x�tdddtjdtjdd��d��g�	�S)
r�r�rNrr�rF�r�rh�rqrhr�r��r�r	r�r�r0s rr�zMessageNonAuthoritative.kwargs�s:���������S�#�,�,�y�a�*H�u�U��	
�	
rNr�r,rrr�r���/����
��
�2�
��
rr�c�0�eZdZdZed��Zed��Zy)�MessageAuthoritativez*
    A minimal authoritative message.
    c��	y)r�sr,r0s rrczMessageAuthoritative.bytes�r�rc�x�tdddtjdtjdd��d�	�g�
�S)r�r�r�Nrr�rrTr�r�r�r0s rr�zMessageAuthoritative.kwargs�s:���������S�#�,�,�y�a�*H�t�T��	
�	
rNr�r,rrr�r��r�rr�c�0�eZdZdZed��Zed��Zy)�MessageCompletez�
    An example of a fully populated non-edns response message.

    Contains name compression, answers, authority, and additional records.
    c��	y)r�sn��examplecom�����'ns1�
hostmaster������������������������)�)����r,r0s rrczMessageComplete.bytes
s��%
 �'	
rc��tddtjdddddtjdtj�gtj
dtjddtjddd	d
ddd
d����gtj
dtjddtjdd����gtj
dtjddtjdd����g��S)r�r�r�r�Nr���T�ns1.example.com�hostmaster.example.com�������������r�r�r�r�r�r�r�r��r}r�rhr��ns1.example.comr�5.6.7.8)rqrgrrrhrjrkrsr�r�r�r�r��r�r	r�r�r�r�r��NSrQr�r�r0s rr�zMessageComplete.kwargs=
s�������=�=�������Y�Y�~�s�w�w�7�8����"����"���N�N�&�0�7�)� *�(�)� *�	���&���"����"���M�M�*;��L������&����"���L�L��
�C���K.
�.	
rNr�r,rrr�r�
s0����/
��/
�b�5
��5
rr�c�0�eZdZdZed��Zed��Zy)�MessageEDNSQueryz'
    A minimal EDNS query message.
    c��	y)r�s,wwwexamplecom)r,r0s rrczMessageEDNSQuery.bytes{
s��
�	
rc��tddtjddddddtjdtj�gg��S)r�rr�Fswww.example.com)rqrgrrrhrjrkrsr�r.r�r�)r�r	r�r�r�r0s rr�zMessageEDNSQuery.kwargs�
sI������<�<��������Y�Y�1�3�5�5�9�:��
�	
rNr�r,rrr�r�v
s/����
��
�<�
��
rr�c�0�eZdZdZed��Zed��Zy)�MessageEDNSCompletez�
    An example of a fully populated edns response message.

    Contains name compression, answers, authority, and additional records.
    c��	y)r�sy��examplecom�����'ns1�
hostmaster������������������������)�)����)�r,r0s rrczMessageEDNSComplete.bytes�
s��-
�/	
rc�P�td'idd�dd�dtj�dd�dd�d	d�d
d�dd�d
d�dd�dd�dd�dd�dtjdtj�g�dtj
dtjddtjdddddddd� ��!�g�d"tj
dtjddtjd#d�$��!�g�d%tj
dtjddtjd&d�$��!�g��S)(r�rqr�rgr�rrrhrirrjrkrsr�r�r�r.TrKrYrt�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r,r�r0s rr�zMessageEDNSComplete.kwargs�
sl���3
��3
��3
��=�=�3
��	3
�
�3
��
3
��3
��3
��3
��3
��3
�"�3
��3
��Y�Y�~�s�w�w�7�8�3
� ���"����"���N�N�&�0�7�)� *�(�)� *�	���3
�D���"����"���M�M�*;��L���C3
�V���&����"���L�L��
�C���U3
�3	
rNr�r,rrr�r��
s0����7
��7
�r�:
��:
rr�c�0�eZdZdZed��Zed��Zy)�MessageEDNSExtendedRCODEz?
    An example of an EDNS message with an extended RCODE.
    c��	y)r�s)�r,r0s rrczMessageEDNSExtendedRCODE.bytes5s��
�	
rc�R�tddtjddddddddgggg��S)r�rFi�
rD)rqrgrrrhrirjrkrsr�r.rtr�r�r�r�)r�r	r�r0s rr�zMessageEDNSExtendedRCODE.kwargsPsB������<�<�������������
�	
rNr�r,rrr�r�0s/����
��
�4�
��
rr�c�$�eZdZdZdxZZd�Zd�Zy)�MessageComparablez�
    A wrapper around L{dns.Message} which is comparable so that it can be tested
    using some of the L{dns._EDNSMessage} tests.
    )rqrgrrrhrirjrkrsr�r�r�r�c��||_yr�)�original)rr�s  rr�zMessageComparable.__init__�s	�� ��
rc�.�t|j|�Sr�)�getattrr�)r�keys  r�__getattr__zMessageComparable.__getattr__�s���t�}�}�c�*�*rN)r)r*r+r4�showAttributes�compareAttributesr�r�r,rrr�r�ks ���

*�
�N�&�!�+rr�c��|�|}i}||d�}|�}t||�|d<|di||i��}t||�|d<|j||�y)a�
    Verify that an attribute has the expected default value and that a
    corresponding argument passed to a constructor is assigned to that
    attribute.

    @param testCase: The L{TestCase} whose assert methods will be
        called.
    @type testCase: L{unittest.TestCase}

    @param cls: The constructor under test.
    @type cls: L{type}

    @param argName: The name of the constructor argument under test.
    @type argName: L{str}

    @param defaultVal: The expected default value of C{attrName} /
        C{argName}
    @type defaultVal: L{object}

    @param altVal: A value which is different from the default. Used to
        test that supplied constructor arguments are actually assigned to the
        correct attribute.
    @type altVal: L{object}

    @param attrName: The name of the attribute under test if different
        from C{argName}. Defaults to C{argName}
    @type attrName: L{str}
    N��
defaultVal�altValr�r�r,)r�r)	r�r~�argNamer�r��attrName�actualryr�s	         r�verifyConstructorArgumentr��si��>����
�F�(�F�;�H���A�"�1�h�/�F�<��� �w��� �A��q�(�+�F�8������6�*rc��eZdZdZd�Zd�Zy)�ConstructorTestsMixinzl
    Helper methods for verifying default attribute values and corresponding
    constructor arguments.
    c�8�t||j|||��y)a�
        Wrap L{verifyConstructorArgument} to provide simpler interface for
        testing Message and _EDNSMessage constructor arguments.

        @param argName: The name of the constructor argument.
        @param defaultVal: The expected default value.
        @param altVal: An alternative value which is expected to be assigned to
            a correspondingly named attribute.
        �r�r~r�r�r�N�r�r�)rr�r�r�s    r�_verifyConstructorArgumentz0ConstructorTestsMixin._verifyConstructorArgument�s!��	"���#�#��!��	
rc�F�|dvsJ�t||j|||��y)a

        Wrap L{verifyConstructorArgument} to provide simpler interface for
        testing  _EDNSMessage constructor flags.

        @param argName: The name of the constructor flag argument
        @param defaultVal: The expected default value of the flag
        )TFr�Nr�)rr�r�s   r�_verifyConstructorFlagz,ConstructorTestsMixin._verifyConstructorFlag�s1���]�*�*�*�!���#�#��!�!�>�	
rN)r)r*r+r4r�r�r,rrr�r��s���

�$
rr�c�^�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�CommonConstructorTestsMixina�
    Tests for constructor arguments and their associated attributes that are
    common to both L{twisted.names.dns._EDNSMessage} and L{dns.Message}.

    TestCase classes that use this mixin must provide a C{messageFactory} method
    which accepts any argment supported by L{dns.Message.__init__}.

    TestCases must also mixin ConstructorTestsMixin which provides some custom
    assertions for testing constructor arguments.
    c�,�|jddd��y)zk
        L{dns._EDNSMessage.id} defaults to C{0} and can be overridden in
        the constructor.
        rqrr�r�N�r�rs rr�z#CommonConstructorTestsMixin.test_id�s��
	
�'�'���1�'�Erc�*�|jdd��y)zs
        L{dns._EDNSMessage.answer} defaults to C{False} and can be overridden in
        the constructor.
        rgF�r�N�r�rs rr�z'CommonConstructorTestsMixin.test_answer����
	
�#�#�H��#�?rc�d�|jdtjtj��y)zz
        L{dns._EDNSMessage.opCode} defaults to L{dns.OP_QUERY} and can be
        overridden in the constructor.
        rrr�N)r�r	r�r�rs rr�z'CommonConstructorTestsMixin.test_opCode�s&��
	
�'�'�����c�m�m�	(�	
rc�*�|jdd��y)zq
        L{dns._EDNSMessage.auth} defaults to C{False} and can be overridden in
        the constructor.
        rhFrNrrs rr�z%CommonConstructorTestsMixin.test_auths��
	
�#�#�F�u�#�=rc�*�|jdd��y)zr
        L{dns._EDNSMessage.trunc} defaults to C{False} and can be overridden in
        the constructor.
        riFrNrrs rr�z&CommonConstructorTestsMixin.test_trunc	���
	
�#�#�G��#�>rc�*�|jdd��y)zs
        L{dns._EDNSMessage.recDes} defaults to C{False} and can be overridden in
        the constructor.
        rjFrNrrs rr�z'CommonConstructorTestsMixin.test_recDesrrc�*�|jdd��y)zr
        L{dns._EDNSMessage.recAv} defaults to C{False} and can be overridden in
        the constructor.
        rkFrNrrs rr�z&CommonConstructorTestsMixin.test_recAvr
rc�,�|jddd��y)zn
        L{dns._EDNSMessage.rCode} defaults to C{0} and can be overridden in the
        constructor.
        rsrr^r�Nrrs rr�z&CommonConstructorTestsMixin.test_rCodes��
	
�'�'��A�c�'�Jrc�,�|jddd��y)zr
        L{dns._EDNSMessage.maxSize} defaults to C{512} and can be overridden in
        the constructor.
        rtr*r�r�Nrrs rr�z(CommonConstructorTestsMixin.test_maxSize%s��
	
�'�'�	�c�$�'�Orc�X�|j|j�jg�y)z@
        L{dns._EDNSMessage.queries} defaults to C{[]}.
        N)rr�r�rs rr�z(CommonConstructorTestsMixin.test_queries,�#��	
����,�,�.�6�6��;rc�X�|j|j�jg�y)z@
        L{dns._EDNSMessage.answers} defaults to C{[]}.
        N)rr�r�rs rr�z(CommonConstructorTestsMixin.test_answers2rrc�X�|j|j�jg�y)zB
        L{dns._EDNSMessage.authority} defaults to C{[]}.
        N)rr�r�rs rr�z*CommonConstructorTestsMixin.test_authority8s#��	
����,�,�.�8�8�"�=rc�X�|j|j�jg�y)zC
        L{dns._EDNSMessage.additional} defaults to C{[]}.
        N)rr�r�rs rr�z+CommonConstructorTestsMixin.test_additional>s#��	
����,�,�.�9�9�2�>rN)r)r*r+r4r�r�r�r�r�r�r�r�r�r�r�r�r�r,rrrr�sM��	�F�@�
�>�?�@�?�K�P�<�<�>�?rrc�(�eZdZdZej
Zy)�EDNSMessageConstructorTestszt
    Tests for L{twisted.names.dns._EDNSMessage} constructor arguments that are
    shared with L{dns.Message}.
    N�r)r*r+r4r	�_EDNSMessager�r,rrrrE����
�%�%�Nrrc�(�eZdZdZej
Zy)�MessageConstructorTestszt
    Tests for L{twisted.names.dns.Message} constructor arguments that are shared
    with L{dns._EDNSMessage}.
    N)r)r*r+r4r	rur�r,rrrrPs���
�[�[�Nrrc��eZdZdZej
Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zy)�EDNSMessageSpecificsTestsz�
    Tests for L{dns._EDNSMessage}.

    These tests are for L{dns._EDNSMessage} APIs which are not shared with
    L{dns.Message}.
    c�,�|jddd��y)zt
        L{dns._EDNSMessage.ednsVersion} defaults to C{0} and can be overridden
        in the constructor.
        r�rNr�rrs r�test_ednsVersionz*EDNSMessageSpecificsTests.test_ednsVersiones��
	
�'�'�
�!�D�'�Qrc�*�|jdd��y)zu
        L{dns._EDNSMessage.dnssecOK} defaults to C{False} and can be overridden
        in the constructor.
        r.FrNrrs rrWz'EDNSMessageSpecificsTests.test_dnssecOKls��
	
�#�#�J�5�#�Arc�*�|jdd��y)zz
        L{dns._EDNSMessage.authenticData} defaults to C{False} and can be
        overridden in the constructor.
        rKFrNrrs rr�z,EDNSMessageSpecificsTests.test_authenticDatass��
	
�#�#�O��#�Frc�*�|jdd��y)z}
        L{dns._EDNSMessage.checkingDisabled} defaults to C{False} and can be
        overridden in the constructor.
        rYFrNrrs rr�z/EDNSMessageSpecificsTests.test_checkingDisabledzs��
	
�#�#�$6�5�#�Irc��|jtjd�g��}|j|jtjd�g�y)zS
        L{dns._EDNSMessage.queries} can be overridden in the constructor.
        rr�N)r�r	r�rr�r�s  r�test_queriesOverridez.EDNSMessageSpecificsTests.test_queriesOverride�sC���!�!�3�9�9�^�+D�*E�!�F��������s�y�y��'@�&A�Brc	��|jtjdtjd���g��}|j	|j
tjdtjd���g�y)zS
        L{dns._EDNSMessage.answers} can be overridden in the constructor.
        rr�r�r�N)r�r	r�r�rr�r�s  r�test_answersOverridez.EDNSMessageSpecificsTests.test_answersOverride�sc���!�!��\�\�.�#�,�,�y�:Q�R�S�"�
��	
����K�K�#�,�,�~�s�|�|�I�?V�W�X�	
rc	�<�|jtjdtjtj���g��}|j|jtjdtjtj���g�y)�U
        L{dns._EDNSMessage.authority} can be overridden in the constructor.
        rr�r�N)r�r	r�r�r�rr�r�s  r�test_authorityOverridez0EDNSMessageSpecificsTests.test_authorityOverride�sn���!�!����^�#�'�'�3�>�>�CS�T��"�
��	
����M�M�
�\�\�.�s�w�w����@P�
Q�R�	
rc	��|jtjdtjd���g��}|j	|j
tjdtjd���g�y)r'rr�r�r�N)r�r	r�r�rr�r�s  r�test_additionalOverridez1EDNSMessageSpecificsTests.test_additionalOverride�sd���!�!����^�S�\�\�)�=T�U�V�"�
��	
����N�N�
�\�\�.�#�,�,�y�2I�
J�K�	
rc�V�|jdt|j���y)z�
        L{dns._EDNSMessage.__repr__} omits field values and sections which are
        identical to their defaults. The id field value is always shown.
        z<_EDNSMessage id=0>N�rrdr�rs rrez+EDNSMessageSpecificsTests.test_reprDefaults�s#��
	
���.��T�5H�5H�5J�0K�Lrc
�l�|jdddddddd��}|jdt|��y)zR
        L{dns._EDNSMessage.__repr__} displays flags if they are L{True}.
        T)rgrhrirjrkrKrYr.z`<_EDNSMessage id=0 flags=answer,auth,trunc,recDes,recAv,authenticData,checkingDisabled,dnssecOK>N�r�rrdrTs  rrmz-EDNSMessageSpecificsTests.test_reprFlagsIfSet�sO��
���������!��
 �	
��	
���
�

��G�
	
rc�f�|jddddd��}|jdt|��y)	zp
        L{dns._EDNSMessage.__repr__} displays field values if they differ from
        their defaults.
        r>r�rorpr)rqrrrsrtr�zA<_EDNSMessage id=10 opCode=20 rCode=30 maxSize=40 ednsVersion=50>Nr.rTs  rruz2EDNSMessageSpecificsTests.test_reprNonDefautFields�s<��

���2�b��B�TV��W�����
�
��G�		
rc��|j�}gd�|_gd�|_gd�|_gd�|_|jdt
|��y)rwrxryr{r~zc<_EDNSMessage id=0 queries=[1, 2, 3] answers=[4, 5, 6] authority=[7, 8, 9] additional=[10, 11, 12]>N)r�r�r�r�r�rrdrTs  rr�z5EDNSMessageSpecificsTests.test_reprNonDefaultSections�sJ��

���!����	���	����#������
�
��G�		
rc��Gd�d�}tj�}||_t�}|j	t
|j|�}|j|fif|j|jf�y)z�
        L{dns._EDNSMessage.fromString} calls L{dns._EDNSMessage._messageFactory}
        to create a new L{dns.Message} instance which is used to decode the
        supplied bytes.
        c��eZdZdZd�Zy)�UEDNSMessageSpecificsTests.test_fromStrCallsMessageFactory.<locals>.FakeMessageFactory�/
            Fake message factory.
            c��t||��)z�
                Fake fromStr method which raises the arguments it was passed.

                @param args: positional arguments
                @param kwargs: keyword arguments
                �r�r�s   rr�z]EDNSMessageSpecificsTests.test_fromStrCallsMessageFactory.<locals>.FakeMessageFactory.fromStrs��!��v�.�.rN�r)r*r+r4r�r,rr�FakeMessageFactoryr3�s��
�
/rr8N)
r	r�_messageFactoryr8r%r�r�rr�r�)rr8rU�
dummyBytesrs     r�test_fromStrCallsMessageFactoryz9EDNSMessageSpecificsTests.test_fromStrCallsMessageFactory�sg��	/�	/�
�����.����X�
����j�!�)�)�Z�@�����:�-��,�q�v�v�q�x�x�.@�Arc���tj�}Gd�d�}|���fd�|_d�}||_|j	t
|jd�}|j�fif|j|jf�y)z~
        L{dns._EDNSMessage.fromString} calls L{dns._EDNSMessage._fromMessage}
        with a L{dns.Message} instance
        c��eZdZdZd�Zy)�REDNSMessageSpecificsTests.test_fromStrCallsFromMessage.<locals>.FakeMessageFactoryr4c��y)zw
                A noop fake version of fromStr

                @param bytes: the bytes to be decoded
                Nr,)rrcs  rr�zZEDNSMessageSpecificsTests.test_fromStrCallsFromMessage.<locals>.FakeMessageFactory.fromStrs�rNr7r,rrr8r>s��
�
rr8c����Sr�r,)�fakeMessages�r�<lambda>zHEDNSMessageSpecificsTests.test_fromStrCallsFromMessage.<locals>.<lambda>$s���K�rc��t||��r�r6r�s  r�fakeFromMessagezOEDNSMessageSpecificsTests.test_fromStrCallsFromMessage.<locals>.fakeFromMessage&����T�6�*�*rrN)
r	rr9�_fromMessager%r�r�rr�r�)rrUr8rDrrAs     @r�test_fromStrCallsFromMessagez6EDNSMessageSpecificsTests.test_fromStrCallsFromMessagesy���

�����
	�
	�)�*��/���	+�)������j�!�)�)�S�9�����;�.�"�-�������/A�Brc���tj�}d�}||_|jt|j
�}|j
dif|j|jf�y)zP
        L{dns._EDNSMessage.toStr} calls L{dns._EDNSMessage._toMessage}
        c��t||��r�r6r�s  r�
fakeToMessagezIEDNSMessageSpecificsTests.test_toStrCallsToMessage.<locals>.fakeToMessage3rErr,N)	r	r�
_toMessager%r�r�rr�r�)rrUrJrs    r�test_toStrCallsToMessagez2EDNSMessageSpecificsTests.test_toStrCallsToMessage-sW��
�����	+�%������j�!�'�'�2�����"�b��A�F�F�A�H�H�#5�6rc����tj�}t��G�fd�d���fd�}||_|j	�|j��y)z}
        L{dns._EDNSMessage.toStr} calls C{toStr} on the message returned by
        L{dns._EDNSMessage._toMessage}.
        c���eZdZdZ�fd�Zy)�LEDNSMessageSpecificsTests.test_toStrCallsToMessageToStr.<locals>.FakeMessagez&
            Fake Message
            c����S)zk
                Fake toStr which returns dummyBytes.

                @return: dummyBytes
                r,)rr:s �rr�zREDNSMessageSpecificsTests.test_toStrCallsToMessageToStr.<locals>.FakeMessage.toStrGs���"�!rN)r)r*r+r4r�)r:s�r�FakeMessagerOBs
���
�
"rrQc�����Sr�r,)r�r�rQs  �rrJzNEDNSMessageSpecificsTests.test_toStrCallsToMessageToStr.<locals>.fakeToMessageOs����=� rN)r	rr8rKrr�)rrUrJrQr:s   @@r�test_toStrCallsToMessageToStrz7EDNSMessageSpecificsTests.test_toStrCallsToMessageToStr:sH���

������X�
�	"�	"�	!�%�������Q�W�W�Y�/rN)r)r*r+r4r	rr�rrWr�r�r#r%r(r*rermrur�r;rGrLrSr,rrrr[sl����%�%�N�R�B�G�J�C�

�

�
�M�
�.
�"
�*B�6C�:7�0rrc��eZdZdZej
Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zy)�EDNSMessageEqualityTestsz�
    Tests for equality between L{dns._EDNSMessage} instances.

    These tests will not work with L{dns.Message} because it does not use
    L{twisted.python.util.FancyEqMixin}.
    c��|j|jd��|jd��|jd���y)zc
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        id.
        r�r�r�Nr�rs rr�z EDNSMessageEqualityTests.test_idasE��
	
�/�/����1��%����1��%����1��%�	
rc��|j|jd��|jd��|jd���y)zl
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        answer flag.
        Tr�FNr�rs rr�z$EDNSMessageEqualityTests.test_answerl�E��
	
�/�/����t��,����t��,����u��-�	
rc���|j|jtj��|jtj��|jtj���y)zg
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        opCode.
        r�N)r�r�r	r��
OP_INVERSErs rr�z$EDNSMessageEqualityTests.test_opCodewsQ��
	
�/�/����s�}�}��5����s�}�}��5����s�~�~��6�	
rc��|j|jd��|jd��|jd���y)zj
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        auth flag.
        Tr�FNr�rs rr�z"EDNSMessageEqualityTests.test_auth�sE��
	
�/�/����T��*����T��*����U��+�	
rc��|j|jd��|jd��|jd���y)zk
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        trunc flag.
        Tr�FNr�rs rr�z#EDNSMessageEqualityTests.test_trunc��E��
	
�/�/����d��+����d��+����e��,�	
rc��|j|jd��|jd��|jd���y)zl
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        recDes flag.
        Tr�FNr�rs rr�z$EDNSMessageEqualityTests.test_recDes�rXrc��|j|jd��|jd��|jd���y)zk
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        recAv flag.
        Tr�FNr�rs rr�z#EDNSMessageEqualityTests.test_recAv�r]rc��|j|jd��|jd��|jd���y)zf
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        rCode.
        r1r�r�Nr�rs rr�z#EDNSMessageEqualityTests.test_rCode�r�rc��|j|jd��|jd��|jd���y)zl
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        ednsVersion.
        r��r�Nr�rs rrz)EDNSMessageEqualityTests.test_ednsVersion�sE��
	
�/�/����A��.����A��.����D��1�	
rc��|j|jd��|jd��|jd���y)zi
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        dnssecOK.
        TrYFNr�rs rrWz&EDNSMessageEqualityTests.test_dnssecOK�sE��
	
�/�/������.������.������/�	
rc��|j|jd��|jd��|jd���y)zt
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        authenticData flags.
        TrNFNr�rs rr�z+EDNSMessageEqualityTests.test_authenticData�sE��
	
�/�/����d��3����d��3����e��4�	
rc��|j|jd��|jd��|jd���y)zw
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        checkingDisabled flags.
        Tr\FNr�rs rr�z.EDNSMessageEqualityTests.test_checkingDisabled�sE��
	
�/�/������6������6������7�	
rc��|j|jd��|jd��|jd���y)zh
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        maxSize.
        ir�r�Nr�rs rr�z%EDNSMessageEqualityTests.test_maxSize�sE��
	
�/�/������-������-������-�	
rc	��|j|jtjd�g��|jtjd�g��|jtjd�g���y)zh
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        queries.
        rr�r�Nr�rs rr�z%EDNSMessageEqualityTests.test_queries�r�rc��|j|jtjdtjd���g��|jtjdtjd���g��|jtjdtjd���g���y)zh
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        answers.
        rr�r�r�r�r�Nr�rs rr�z%EDNSMessageEqualityTests.test_answers�r�rc���|j|jtjdtjtj
���g��|jtjdtjtj
���g��|jtjdtjtj
���g���y)zr
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        authority records.
        rr�r�r�Nr�rs rr�z'EDNSMessageEqualityTests.test_authorityr�rc��|j|jtjdtjd���g��|jtjdtjd���g��|jtjdtjd���g���y)zs
        Two L{dns._EDNSMessage} instances compare equal if they have the same
        additional records.
        rr�r�r�r�Nr�rs rr�z(EDNSMessageEqualityTests.test_additional#r�rN)r)r*r+r4r	rr�r�r�r�r�r�r�r�r�rrWr�r�r�r�r�r�r�r,rrrUrUWsi����%�%�N�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�
�"
�.
rrUc�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�StandardEncodingTestsMixina�
    Tests for the encoding and decoding of various standard (not EDNS) messages.

    These tests should work with both L{dns._EDNSMessage} and L{dns.Message}.

    TestCase classes that use this mixin must provide a C{messageFactory} method
    which accepts any argment supported by L{dns._EDNSMessage.__init__}.

    EDNS specific arguments may be discarded if not supported by the message
    class under construction.
    c��|j|jditj���j	�tj��y)z2
        An empty message can be encoded.
        Nr,)rr�r�r�r�rcrs r�test_emptyMessageEncodez2StandardEncodingTestsMixin.test_emptyMessageEncodeHsB��	
����D���8�,�"5�"5�"7�8�>�>�@�,�BT�BT�BV�	
rc	���|j�}|jtj��|j	||jditj����y)z@
        An empty message byte sequence can be decoded.
        Nr,)r�r�r�rcrr�rTs  r�test_emptyMessageDecodez2StandardEncodingTestsMixin.test_emptyMessageDecodePsQ��
���!��	�	�	�,�$�$�&�'�����/�D�/�/�H�,�2E�2E�2G�H�Irc��|j|jditj���j	�tj��y)zA
        A fully populated query message can be encoded.
        Nr,)rr�r�r�r�rcrs r�test_completeQueryEncodez3StandardEncodingTestsMixin.test_completeQueryEncodeYsC��	
����D���;�/�"8�"8�":�;�A�A�C��!�!�#�	
rc	���|j�}|jtj��f|j	||jditj����y)zG
        A fully populated message byte string can be decoded.
        Nr,)r�r�r�rcrr�rTs  r�test_completeQueryDecodez3StandardEncodingTestsMixin.test_completeQueryDecodebsT��
���!��	�	�	�/�'�'�)�*�+�����/�D�/�/�K�/�2H�2H�2J�K�Lrc��djtd�D�cgc]}tj|���c}�}tj|�}tj
dtj|��}|j�}|jj|�|j�}|j�}|j|�|j|jdjtj�|j|jdjj|�ycc}w)zu
        A I{NULL} record with an arbitrary payload can be encoded and decoded as
        part of a message.
        rr�r�r�rN)r�r�r	r2r�r�r�r�r�r�r�r�rar�rr�s        rr�z$StandardEncodingTestsMixin.test_NULLks���
���U�3�Z�@��#�.�.��+�@�A���o�o�e�$��
�\�\�+�s�x�x��
=���"�"�$�������B���J�J�L���"�"�$�����Q�����d�l�l�1�o�5�5�s���G�������a��0�0�8�8�%�@��As�D>c��|j|jditj���j	�tj��y)zv
        If the message C{authoritative} attribute is set to 0, the encoded bytes
        will have AA bit 0.
        Nr,)rr�r�r�r�rcrs r�"test_nonAuthoritativeMessageEncodez=StandardEncodingTestsMixin.test_nonAuthoritativeMessageEncode}sD��
	
����D���C�"9�"@�"@�"B�C�I�I�K�#�)�)�+�	
rc	���|j�}|jtj��|j	||jditj����y)z�
        The L{dns.RRHeader} instances created by a message from a
        non-authoritative message byte string are marked as not authoritative.
        Nr,)r�r�r�rcrr�rTs  r�"test_nonAuthoritativeMessageDecodez=StandardEncodingTestsMixin.test_nonAuthoritativeMessageDecode�sS��

���!��	�	�	�)�/�/�1�2�����/�D�/�/�S�2I�2P�2P�2R�S�Trc��|j|jditj���j	�tj��y)zv
        If the message C{authoritative} attribute is set to 1, the encoded bytes
        will have AA bit 1.
        Nr,)rr�r�r�r�rcrs r�test_authoritativeMessageEncodez:StandardEncodingTestsMixin.test_authoritativeMessageEncode�sD��
	
����D���@�"6�"=�"=�"?�@�F�F�H� �&�&�(�	
rc	���|j�}|jtj��|j	||jditj����y)z�
        The message and its L{dns.RRHeader} instances created by C{decode} from
        an authoritative message byte string, are marked as authoritative.
        Nr,)r�r�r�rcrr�rTs  r�test_authoritativeMessageDecodez:StandardEncodingTestsMixin.test_authoritativeMessageDecode�sS��

���!��	�	�	�&�,�,�.�/�����/�D�/�/�P�2F�2M�2M�2O�P�Qrc��|j|jditj���j	�tj��y)zm
        If the message C{trunc} attribute is set to 1 the encoded bytes will
        have TR bit 1.
        Nr,)rr�r�r�r�rcrs r�test_truncatedMessageEncodez6StandardEncodingTestsMixin.test_truncatedMessageEncode�sD��
	
����D���<�"2�"9�"9�";�<�B�B�D��"�"�$�	
rc	���|j�}|jtj��|j	||jditj����y)zn
        The message instance created by decoding a truncated message is marked
        as truncated.
        Nr,)r�r�r�rcrr�rTs  r�test_truncatedMessageDecodez6StandardEncodingTestsMixin.test_truncatedMessageDecode�sS��

���!��	�	�	�"�(�(�*�+�����/�D�/�/�L�2B�2I�2I�2K�L�MrN)r)r*r+r4rnrprrrtr�rwryr{r}rr�r,rrrlrl;sD��
�
�J�
�M�A�$
�U�
�R�
�Nrrlc�(�eZdZdZej
Zy)� EDNSMessageStandardEncodingTestszq
    Tests for the encoding and decoding of various standard (non-EDNS) messages
    by L{dns._EDNSMessage}.
    Nrr,rrr�r��rrr�c� �eZdZdZed��Zy)�MessageStandardEncodingTestszl
    Tests for the encoding and decoding of various standard (non-EDNS) messages
    by L{dns.Message}.
    c�.�|jdg�}|jdg�}|jdg�}|jdg�}|jdd�tjdi|��}||_||_||_||_t|�S)a�
        This function adapts constructor arguments expected by
        _EDNSMessage.__init__ to arguments suitable for use with the
        Message.__init__.

        Also handles the fact that unlike L{dns._EDNSMessage},
        L{dns.Message.__init__} does not accept queries, answers etc as
        arguments.

        Also removes any L{dns._EDNSMessage} specific arguments.

        @param args: The positional arguments which will be passed to
            L{dns.Message.__init__}.

        @param kwargs: The keyword arguments which will be stripped of EDNS
            specific arguments before being passed to L{dns.Message.__init__}.

        @return: An L{dns.Message} instance.
        r�r�r�r�r�Nr,)r�r	rur�r�r�r�r�)r�r�r�r�r�rUs      rr�z+MessageStandardEncodingTests.messageFactory�s���*�*�*�Y��+���*�*�Y��+���J�J�{�B�/�	��Z�Z��b�1�
��
�
�=�$�'��K�K�!�&�!����	���	����!��� ��#�#rN)r)r*r+r4�staticmethodr�r,rrr�r��s���
� $�� $rr�c�d�eZdZdZej
Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zy)
�EDNSMessageEDNSEncodingTestszz
    Tests for the encoding and decoding of various EDNS messages.

    These test will not work with L{dns.Message}.
    c��|j�}|jtj��|j	|j
g�y)z�
        The L(_EDNSMessage} instance created by L{dns._EDNSMessage.decode} from
        an EDNS query never includes OPT records in the additional section.
        N)r�r�r�rcrr�rTs  r�&test_ednsMessageDecodeStripsOptRecordszCEDNSMessageEDNSEncodingTests.test_ednsMessageDecodeStripsOptRecords�s<��

���!��	�	�	�"�(�(�*�+�������r�*rc�*�tj�}tjd��tjd��g|_tj�}|j|j
��|j|j�y)a
        An L(_EDNSMessage} instance created from a byte string containing
        multiple I{OPT} records will discard all the C{OPT} records.

        C{ednsVersion} will be set to L{None}.

        @see: U{https://tools.ietf.org/html/rfc6891#section-6.1.1}
        r�rTr�N)	r	rur/r�rr�r��assertIsNoner�)rrU�ednsMessages   r�(test_ednsMessageDecodeMultipleOptRecordszEEDNSMessageEDNSEncodingTests.test_ednsMessageDecodeMultipleOptRecordssc��
�K�K�M�����q�1�3�>�>�!�3L�M����&�&�(�����A�G�G�I�&����+�1�1�2rc�D�tj�}|jtj	��tj
j
|�}g}dD],}t||�t||�us�|j|��.|r|jd|���yy)z�
        L{dns._EDNSMessage._fromMessage} returns an L{_EDNSMessage} instance
        whose queries, answers, authority and additional lists are copies (not
        references to) the original message lists.
        )r�r�r�r�zZMessage and _EDNSMessage shared references to the following section lists after decoding: N)
r	rur�r�rcrrFr�r��fail)r�standardMessager��
duplicatesr�s     r�test_fromMessageCopiesSectionsz;EDNSMessageEDNSEncodingTests.test_fromMessageCopiesSectionss����+�+�-����� 0� 6� 6� 8�9��&�&�3�3�O�D���
�I�	,�H����1�W�[�(�5S�S��!�!�(�+�	,���I�I�6@�C�
�rc��tjd��}|j�|j|jg�y)zf
        L{dns._EDNSMessage.toStr} makes no in place changes to the message
        instance.
        r�rbN)r	rr�rr�)rr�s  r�test_toMessageCopiesSectionsz9EDNSMessageEDNSEncodingTests.test_toMessageCopiesSections+s6��
�&�&�1�5����������/�/��4rc��t�}tjd��}|j|�tj�}|jd�|j
|�tj�}|g|_g}|jtjj|�j�|jjtjtj���|jtjj|�j�|jjdtjtj���|jtjj|�j�|jdgdz|�y)a
        L{dns._EDNSMessage} can decode OPT records, regardless of their position
        in the additional records section.

        "The OPT RR MAY be placed anywhere within the additional data section."

        @see: U{https://tools.ietf.org/html/rfc6891#section-6.1.1}
        r�rTr)r}r�N)rr	r/rlr�r�rgrur�r�rrFr�r��insertr)rrc�	optRecord�optRRHeaderrU�actualMessagess      r�test_optHeaderPositionz3EDNSMessageEDNSEncodingTests.test_optHeaderPosition4s)��
�I���N�N�1�-�	�������l�l�n��	���q�	����1���K�K�M��#�}��������c�.�.�;�;�A�>�J�J�K�	�����C�L�L�c�e�e�4�5����c�.�.�;�;�A�>�J�J�K�	�����A�s�|�|����7�8����c�.�.�;�;�A�>�J�J�K����!��q��.�1rc	���|j�}|jtj��|j	||jditj����y)z�
        The L(_EDNSMessage} instance created by L{dns._EDNSMessage.fromStr}
        derives its edns specific values (C{ednsVersion}, etc) from the supplied
        OPT record.
        Nr,)r�r�r�rcrr�rTs  r�test_ednsDecodez,EDNSMessageEDNSEncodingTests.test_ednsDecodeRsS��
���!��	�	�	�%�+�+�-�.�����/�D�/�/�O�2E�2L�2L�2N�O�Prc��|j|jditj���j	�tj��y)z�
        The L(_EDNSMessage} instance created by L{dns._EDNSMessage.toStr}
        encodes its edns specific values (C{ednsVersion}, etc) into an OPT
        record added to the additional section.
        Nr,)rr�r�r�r�rcrs r�test_ednsEncodez,EDNSMessageEDNSEncodingTests.test_ednsEncode]sD��	
����D���?�"5�"<�"<�">�?�E�E�G��%�%�'�	
rc��|j|jditj���j	�tj��y)z�
        The L(_EDNSMessage.toStr} encodes the extended I{RCODE} (>=16) by
        assigning the lower 4bits to the message RCODE field and the upper 4bits
        to the OPT pseudo record.
        Nr,)rr�r�r�r�rcrs r�test_extendedRcodeEncodez5EDNSMessageEDNSEncodingTests.test_extendedRcodeEncodehsD��	
����D���D�":�"A�"A�"C�D�J�J�L�$�*�*�,�	
rc	���|j�}|jtj��|j	||jditj����y)z�
        The L(_EDNSMessage} instance created by L{dns._EDNSMessage.fromStr}
        derives RCODE from the supplied OPT record.
        Nr,)r�r�r�rcrr�rTs  r�test_extendedRcodeDecodez5EDNSMessageEDNSEncodingTests.test_extendedRcodeDecodessS��

���!��	�	�	�*�0�0�2�3�����/�D�/�/�T�2J�2Q�2Q�2S�T�Urc��|jdd��}|j�}|jd|j|jdj
f�y)z�
        Note that EXTENDED-RCODE value 0 indicates that an unextended RCODE is
        in use (values 0 through 15).

        https://tools.ietf.org/html/rfc6891#section-6.1.3
        r�r)rsr�)r�rN)r�rKrrsr�r,)rr�r�s   r�test_extendedRcodeZeroz3EDNSMessageEDNSEncodingTests.test_extendedRcodeZero}sW���)�)���)�B��%�0�0�2������
�
"�
"�O�$>�$>�q�$A�$O�$O�P�	
rN)r)r*r+r4r	rr�r�r�r�r�r�r�r�r�r�r�r,rrr�r��sH����%�%�N�+�3�"�,5�2�<	Q�	
�	
�V�

rr�c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�ResponseFromMessageTestsz0
    Tests for L{dns._responseFromMessage}.
    c��tj�}tjtj|��}|j||�y)z�
        L{dns.Message._responseFromMessage} is a constructor function which
        generates a new I{answer} message from an existing L{dns.Message} like
        instance.
        ��responseConstructorr�N)r	ru�_responseFromMessage�assertIsNot�r�request�responses   r�$test_responseFromMessageResponseTypez=ResponseFromMessageTests.test_responseFromMessageResponseType�s:���+�+�-���+�+� #���W�
��	
����(�+rc��Gd�d�}tj}|jtj||���|�y)zN
        L{dns._responseFromMessage} returns a new instance of C{cls}
        c��eZdZdZgZy)�AResponseFromMessageTests.test_responseType.<locals>.SuppliedClassr�N)r)r*r+rqr�r,rr�
SuppliedClassr��s���B��Grr�r�N)r	rurar�)rr��
expectedClasss   r�test_responseTypez*ResponseFromMessageTests.test_responseType�s?��
	�	����
�����$�$�$1�=�?�
�
�		
rc	��|jdtjtjtjd����j�y)zi
        L{dns._responseFromMessage} copies the C{id} attribute of the original
        message.
        i�r�r�N)rr	r�rurqrs r�test_responseIdz(ResponseFromMessageTests.test_responseId�s:��
	
�����$�$�$'�K�K�����9M�
��b�		
rc���tj�}tjtj|��}|jd|j|jf�y)zP
        L{dns._responseFromMessage} sets the C{answer} flag to L{True}
        r�)FTN)r	rur�rrgr�s   r�test_responseAnswerz,ResponseFromMessageTests.test_responseAnswer�sG���+�+�-���+�+� #���W�
��	
����������(I�Jrc��tj�}t�t�t�g}|dd|_|j	|tj
tj|��j�y)zn
        L{dns._responseFromMessage} copies the C{queries} attribute of the
        original message.
        Nr�)r	rur8r�rr�)rr��expectedQueriess   r�test_responseQueriesz-ResponseFromMessageTests.test_responseQueries�sZ��
�+�+�-��!�8�V�X�v�x�8��)�!�,��������$�$�$'�K�K��
��g�		
rc��|jdtjtjtj�d��j�y)z�
        L{dns._responseFromMessage} accepts other C{kwargs} which are assigned
        to the new message before it is returned.
        r^)r�r�rsN)rr	r�rursrs r�test_responseKwargsz,ResponseFromMessageTests.test_responseKwargs�s9��
	
�����$�$�$'�K�K�����c�
��e�		
rN)
r)r*r+r4r�r�r�r�r�r�r,rrr�r��s&���
,�
�$

�K�
� 

rr�c�0�eZdZdZ						dd�Zdefd�Zy)�Fooz�
    An example class for use in L{dns._compactRepr} tests.
    It follows the pattern of initialiser settable flags, fields and sections
    found in L{dns.Message} and L{dns._EDNSMessage}.
    Nc�`�||_||_||_||_||_|�g}||_y)zK
        Set some flags, fields and sections as public attributes.
        N)�field1�field2�alwaysShowField�flagTrue�	flagFalse�section1)rr�r�r�r�r�r�s       rr�zFoo.__init__�s:��������.��� ��
�"������H� ��
rrZc��tj|dj�dj�dj�dj���S)zO
        Call L{dns._compactRepr} to generate a string representation.
        r�zfield1 field2 alwaysShowFieldzflagTrue flagFalsezsection1 section2)�
alwaysShow�
fieldNames�	flagNames�sectionNames)r	�_compactRepr�splitrs r�__repr__zFoo.__repr__sJ������(�.�.�0�6�<�<�>�*�0�0�2�,�2�2�4�
�	
r)r�r��ASTFN)r)r*r+r4r��strr�r,rrr�r��s,���������!�,

�#�

rr�c�,�eZdZdZeZd�Zd�Zd�Zd�Z	y)�CompactReprTestsz(
    Tests for L{dns._compactRepr}.
    c�V�|jdt|j���y)z�
        L{dns._compactRepr} omits field values and sections which have the
        default value. Flags which are True are always shown.
        z)<Foo alwaysShowField='AS' flags=flagTrue>Nr,rs r�
test_defaultszCompactReprTests.test_defaultss%��
	
���7��d�>Q�>Q�>S�9T�	
rc�`�|jdd��}|jdt|��y)zV
        L{dns._compactRepr} displays flags if they have a non-default value.
        T)r�r�z3<Foo alwaysShowField='AS' flags=flagTrue,flagFalse>Nr.rTs  r�test_flagsIfSetz CompactReprTests.test_flagsIfSets1��
������>�����J���G�	
rc�`�|jdd��}|jdt|��y)zg
        L{dns._compactRepr} displays field values if they differ from their
        defaults.
        r>r�)r�r�z=<Foo field1=10 field2=20 alwaysShowField='AS' flags=flagTrue>Nr.rTs  r�test_nonDefautFieldsz%CompactReprTests.test_nonDefautFields's5��

���r�"��5�����
�
��G�	
rc�~�|j�}gd�|_gd�|_|jdt	|��y)zY
        L{dns._compactRepr} displays sections which differ from their defaults.
        )r�r�r�)r�r�r�zO<Foo alwaysShowField='AS' flags=flagTrue section1=[1, 1, 1] section2=[2, 2, 2]>N)r�r��section2rrdrTs  r�test_nonDefaultSectionsz(CompactReprTests.test_nonDefaultSections7s<��
���!����
���
����
�
��G�	
rN)
r)r*r+r4r�r�r�r�r�r�r,rrr�r�
s"����N�
�
�
� 
rr�r�)fr4rG�ior�zope.interface.verifyr�twisted.internetrr�twisted.internet.errorrr�
twisted.namesr	�twisted.python.failurer
�twisted.python.utilrr�twisted.testr
�twisted.test.testutilsr�
twisted.trialrrQrUrXr[r_rbrerhrkr�r�r�r�r�r r&r+r0r3rEr�r�rrr?r�r��SynchronousTestCaser�TestCaser.r6r\r�rQr_rHr�r�r�r1r<rNr�r�r�rrrr$r3r��	Exceptionr�r�r�r�r�r�r�r�r�r�r�r�rrrrrUrlr�r�r�r�r�r�r,rr�<module>r�s��
�
��-�*�D��*�;�&�7�"��M�M��M�M��M�M�����M�M��M�M��M�M��N�N�����L�L��N�N��O�O��N�N��N�N�����M�M��������M�M��N�N��O�O��M�M��������O�O����5��<"P��4�4�"P�J
8�H�%�%�
8�A:�H�%�%�A:�HJ*��!�!�J*�Z_B��)�)�_B�F��� �q1�8�/�/�q1�ha
�1�8�3O�3O�a
�H1�1�*rS�H�-�-�rS�j'��'�(QS�x�(�(�QS�hI
��!�!�I
�XZ

�(�(�*;�*;�Z

�z+
�H�%�%�+
�\0W��4�4�0W�f�&�&\F��5�5�\F�~2
�2
�jd
�)�8�+<�+<�d
�NM,�1�8�3D�3D�M,�`���"+
�+
�\*
�*
�Z.
�.
�b.
�.
�bo
�o
�d8
�8
�v|
�|
�~8
�8
�v+��m�+�::>�++�\'
�'
�Tc?�c?�L&��6��8T�8T�&�!��6��8T�8T�!�y0� 5�x�7S�7S�y0�xa
�3�X�5Q�5Q�a
�H|N�|N�~&��� <� <�&�)$��� <� <�)$�XY
�8�#?�#?�Y
�xS
�x�;�;�S
�l'
�'
�T9
�x�3�3�9
r

Zerion Mini Shell 1.0