%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_client.cpython-312.pyc

�

Ϫ�f����dZddlZddlmZmZddlmZddlmZm	Z	ddl
mZddlm
Z
ddlmZdd	lmZmZmZmZmZdd
lmZddlmZddlmZdd
lmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'e#jP�sdZ)ndZ)Gd�de�Z*Gd�d�Z+Gd�d�Z,Gd�de'jZ�Z.Gd�de'jZe�Z/Gd�de'jZ�Z0Gd �d!e'jZ�Z1Gd"�d#e'jZ�Z2Gd$�d%�Z3Gd&�d'e'jZ�Z4Gd(�d)e'jZ�Z5y)*z)
Test cases for L{twisted.names.client}.
�N)�verifyClass�verifyObject)�defer)�CannotListenError�ConnectionRefusedError)�	IResolver)�Clock)�AlternateReactor)�cache�client�dns�error�hosts)�ResolverBase)�DNSQueryTimeoutError)�	test_util)�GoodTempPathMixin)�failure)�FilePath)�platform)�
proto_helpers)�unittestz:These tests need more work before they'll work on Windows.c��eZdZd�Zy)�FakeResolverc
��|dk(r>tj|tj|dtjdd����}ntj|||d��}|g}g}g}t	j
|||f�S)z�
        The getHostByNameTest does a different type of query that requires it
        return an A record from an ALL_RECORDS lookup, so we accommodate that
        here.
        �getHostByNameTest�<�	127.0.0.1)�address�ttl)�name�type�clsr �payload)r!r"r#r )r
�RRHeader�A�Record_Ar�succeed)	�selfr!r#�qtype�timeout�rr�results�	authority�
additionals	         �@/usr/lib/python3/dist-packages/twisted/names/test/test_client.py�_lookupzFakeResolver._lookup$sv���'�'������U�U������[�b�A��B����4�e��"�E�B��$���	��
��}�}�g�y�*�=�>�>�N)�__name__�
__module__�__qualname__r1�r2r0rr#s��?r2rc��eZdZdZdZd�Zy)�StubPortz�
    A partial implementation of L{IListeningPort} which only keeps track of
    whether it has been stopped.

    @ivar disconnected: A C{bool} which is C{False} until C{stopListening} is
        called, C{True} afterwards.
    Fc��d|_y)NT)�disconnected�r)s r0�
stopListeningzStubPort.stopListeningFs
�� ��r2N)r3r4r5�__doc__r:r<r6r2r0r8r8;s����L�!r2r8c��eZdZdZd�Zdd�Zy)�StubDNSDatagramProtocolz�
    L{dns.DNSDatagramProtocol}-alike.

    @ivar queries: A C{list} of tuples giving the arguments passed to
        C{query} along with the L{defer.Deferred} which was returned from
        the call.
    c�0�g|_t�|_y�N��queriesr8�	transportr;s r0�__init__z StubDNSDatagramProtocol.__init__S������!���r2Nc�n�tj�}|jj|||||f�|S)zv
        Record the given arguments and return a Deferred which will not be
        called back by this code.
        )r�DeferredrC�append)r)rrCr+�id�results      r0�queryzStubDNSDatagramProtocol.queryWs2��
���!�������W�g�w��F�C�D��
r2��
N)r3r4r5r=rErLr6r2r0r?r?Js���$�r2r?c� �eZdZdZeZd�Zd�Zy)�GetResolverTestsz*
    Tests for L{client.getResolver}.
    c��tt��5tj�}ddd�|j	tt��y#1swY�)xYw)zQ
        L{client.getResolver} returns an object providing L{IResolver}.
        N)r
r	r�getResolver�
assertTruerr�r)�resolvers  r0�test_interfacezGetResolverTests.test_interfacehsD���e�g�
&�	,��)�)�+�H�	,�����Y��9�:�	,�	,�s�A�Ac���tt��5tj�}tj�}ddd�|j	�y#1swY�xYw)zn
        Multiple calls to L{client.getResolver} return the same L{IResolver}
        implementation.
        N)r
r	rrR�assertIs)r)�a�bs   r0�test_idempotentz GetResolverTests.test_idempotentpsO��
�e�g�
&�	%��"�"�$�A��"�"�$�A�	%�	
�
�
�a���	%�	%�s�)A�A!N)r3r4r5r=�windowsSkip�skiprVr[r6r2r0rPrPas����D�;�r2rPc�P�eZdZdZeZd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zy)
�CreateResolverTestsz-
    Tests for L{client.createResolver}.
    c���|jD�cgc]}t|tj�s�|��!}}|j	dt|��|j	|dj|�ycc}w)N�r)�	resolvers�
isinstancer�Resolver�assertEqual�len�file�r)rU�filename�r�ress     r0�
_hostsTestzCreateResolverTests._hostsTest�sZ��"�,�,�N�Q�
�1�e�n�n�0M�q�N��N�����C��H�%�����Q����h�/��O�
�A0�A0c��tt��5tj�}ddd�|j	d�y#1swY�xYw)z�
        L{client.createResolver} returns a L{resolve.ResolverChain} including a
        L{hosts.Resolver} using I{/etc/hosts} if no alternate hosts file is
        specified.
        Ns
/etc/hosts�r
r	r�createResolverrlrTs  r0�test_defaultHostsz%CreateResolverTests.test_defaultHosts�s?���e�g�
&�	/��,�,�.�H�	/�����-�0�	/�	/���A�A
c��tt��5tjd��}ddd�|j	d�y#1swY�xYw)z�
        The I{hosts} parameter to L{client.createResolver} overrides the hosts
        file used by the L{hosts.Resolver} in the L{resolve.ResolverChain} it
        returns.
        �/foo/bar)rNrorTs  r0�test_overrideHostsz&CreateResolverTests.test_overrideHosts�sE���e�g�
&�	@��,�,�;�?�H�	@�����+�.�	@�	@���A�Ac���|jD�cgc]}t|tj�s�|��!}}|j	dt|��|j	|dj|�ycc}w)z|
        Verify that C{resolver} has a L{client.Resolver} with a configuration
        filename set to C{filename}.
        rarN)rbrcrrdrerf�resolvrhs     r0�_resolvConfTestz#CreateResolverTests._resolvConfTest�s\��
#�,�,�O�Q�
�1�f�o�o�0N�q�O��O�����C��H�%�����Q�����1��Prmc�f�t�}t|�5tj�}ddd�jD�cgc]}t|tj�s�|��!}}|jdt|��|j||dj�y#1swY�xxYwcc}w)z�
        The L{client.Resolver} included in the L{resolve.ResolverChain} returned
        by L{client.createResolver} uses the global reactor.
        Nrar)r	r
rrprbrcrdrerfrX�_reactor)r)�reactorrUrjrks     r0�test_reactorz CreateResolverTests.test_reactor�s���
�'��
�g�
&�	/��,�,�.�H�	/�"�,�,�O�Q�
�1�f�o�o�0N�q�O��O�����C��H�%��
�
�g�s�1�v���/�		/�	/��Os�B"�B.�!B.�"B+c��tt��5tj�}ddd�|j	d�y#1swY�xYw)z�
        L{client.createResolver} returns a L{resolve.ResolverChain} including a
        L{client.Resolver} using I{/etc/resolv.conf} if no alternate resolver
        configuration file is specified.
        Ns/etc/resolv.conf�r
r	rrpryrTs  r0�test_defaultResolvConfz*CreateResolverTests.test_defaultResolvConf�sB���e�g�
&�	/��,�,�.�H�	/����X�':�;�	/�	/�rrc��tt��5tjd��}ddd�|j	d�y#1swY�xYw)z�
        The I{resolvconf} parameter to L{client.createResolver} overrides the
        resolver configuration file used by the L{client.Resolver} in the
        L{resolve.ResolverChain} it returns.
        rt��
resolvconfNrrTs  r0�test_overrideResolvConfz+CreateResolverTests.test_overrideResolvConf�sG���e�g�
&�	E��,�,��D�H�	E����X�{�3�	E�	E�rvc��|j�}|jd�tt��5t	j
|j��}ddd�jD�cgc]}t|tj�s�|��!}}|jdt|��|jg|dj�|jdg|dj�y#1swY��xYwcc}w)z�
        If no servers are given, addresses are taken from the file given by the
        I{resolvconf} parameter to L{client.createResolver}.
        �nameserver 127.1.2.3
r�Nrar�z	127.1.2.3�5�
�path�
setContentr
r	rrprbrcrdrerf�servers�
dynServers�r)r�rUrjrks     r0�test_defaultServersz'CreateResolverTests.test_defaultServers�s���
�Y�Y�[�
����7�8�
�e�g�
&�	I��,�,�
���H�H�	I�"�,�,�O�Q�
�1�f�o�o�0N�q�O��O�����C��H�%�����S��V�^�^�,����+�,�c�!�f�.?�.?�@�	I�	I��Os�!C-�,C9�C9�-C6c��|j�}|jd�tt��5t	j
dg|j��}ddd�jD�cgc]}t|tj�s�|��!}}|jdt|��|jdg|dj�|jdg|dj�y#1swY��xYwcc}w)z�
        Servers passed to L{client.createResolver} are used in addition to any
        found in the file given by the I{resolvconf} parameter.
        r�)z	127.3.2.1r�)r�r�Nrarr�r�r�s     r0�test_overrideServersz(CreateResolverTests.test_overrideServers�s���
�Y�Y�[�
����7�8�
�e�g�
&�	��,�,�*�+�
����H�	�#�,�,�O�Q�
�1�f�o�o�0N�q�O��O�����C��H�%����+�,�c�!�f�n�n�=����+�,�c�!�f�.?�.?�@�	�	��Ps�#C0�.C<�C<�0C9c�$�tt��5tj�}ddd�jD�cgc]}t|tj�s�|��!}}|jdt|��y#1swY�YxYwcc}w)zy
        L{client.createResolver} returns a L{resolve.ResolverChain} including a
        L{cache.CacheResolver}.
        Nra)
r
r	rrprbrcr�
CacheResolverrerf)r)rUrjrks    r0�
test_cachezCreateResolverTests.test_cache�so��
�e�g�
&�	/��,�,�.�H�	/�"�,�,�S�Q�
�1�e�>Q�>Q�0R�q�S��S�����C��H�%�	/�	/��Ss�B�B
�B
�B
N)r3r4r5r=r\r]rlrqruryr}r�r�r�r�r�r6r2r0r_r_{sB����D�0�
1�/�2�
0�<�4�A�A� &r2r_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�Zy)�
ResolverTestsz'
    Tests for L{client.Resolver}.
    c�,�ttt�y)z]
        L{client} provides L{IResolver} through a series of free
        functions.
        N)rrrr;s r0�test_clientProvidesIResolverz*ResolverTests.test_clientProvidesIResolver�s��
	�Y��'r2c�@�tttj�y)z;
        L{client.Resolver} provides L{IResolver}.
        N)rrrrdr;s r0�$test_clientResolverProvidesIResolverz2ResolverTests.test_clientResolverProvidesIResolver�s��	�I�v���/r2c�L�|jttj�y)z�
        L{client.Resolver} raises L{ValueError} if constructed with neither
        servers nor a nameserver configuration file.
        N)�assertRaises�
ValueErrorrrdr;s r0�test_noServerszResolverTests.test_noServers�s��
	
���*�f�o�o�6r2c��tj|j�t���}|j	dg|j
�y)z�
        A missing nameserver configuration file results in no server information
        being loaded from it (ie, not an exception) and a default server being
        provided.
        �rxr|�rr�N)rrd�mktempr	rer�rTs  r0�test_missingConfigurationz'ResolverTests.test_missingConfigurations6���?�?�$�+�+�-���I�����+�,�h�.A�.A�Br2c����t|j��}|jd���G�fd�dtj�}|ddgdt���|j
�j�y	)
z�
        As part of its constructor, C{StubResolver} opens C{/etc/resolv.conf};
        then, explicitly closes it and does not count on the GC to do so for
        it.
        zw+)�modec���eZdZ�fd�Zy)�9ResolverTests.test_closesResolvConf.<locals>.StubResolverc����SrAr6)r)r!�
resolvConfs  �r0�	_openFilezCResolverTests.test_closesResolvConf.<locals>.StubResolver._openFiles	���!�!r2N)r3r4r5r�)r�s�r0�StubResolverr�s���
"r2r��example.comr�z/etc/resolv.conf)r�rxr|N)rr��openrrdr	rS�closed)r)�handler�r�s   @r0�test_closesResolvConfz#ResolverTests.test_closesResolvConfsb����$�+�+�-�(���[�[�d�[�+�
�	"�6�?�?�	"�	�"�B�'�0B�E�G�	
�	
���
�)�)�*r2c��tjdg��}|jdg�|jd|j�y)z�
        L{client.Resolver.parseConfig} treats a I{domain} line without an
        argument as indicating a domain of C{b""}.
        r��r�sdomain
r2N)rrd�parseConfigre�domainrTs  r0�test_domainEmptyArgumentz&ResolverTests.test_domainEmptyArgument!s:��
�?�?�,=�+>�?�����k�]�+�����h�o�o�.r2c��tjdg��}|jdg�|jg|j�y)z�
        L{client.Resolver.parseConfig} treats a I{search} line without an
        argument as indicating an empty search suffix.
        r�r�ssearch
N)rrdr�re�searchrTs  r0�test_searchEmptyArgumentz&ResolverTests.test_searchEmptyArgument*s:��
�?�?�,=�+>�?�����k�]�+�����X�_�_�-r2c�v��t��ddg}ddg}tj|��}||_�fd�|_t�}|j
d�}|j|j|�|jt�j�d�|j�jd	d	|d	��jd	d
jtd	��|jt�j�d�|j�jdd	|d��jdd
jtd��|jt�j�d�|j�jdd	|d	��jdd
jtd��|jt�j�d
�|j�jdd	|d��jdd
j|�|S)a

        L{client.Resolver.queryUDP} should issue queries to its
        L{dns.DNSDatagramProtocol} with server addresses taken from its own
        C{servers} and C{dynServers} lists, proceeding through them in order
        as L{DNSQueryTimeoutError}s occur.
        �z::1r�)z::2r�)z::3r�)z::4r�r�c����SrAr6)�	interface�protocols �r0�<lambda>z=ResolverTests.test_datagramQueryServerOrder.<locals>.<lambda>@s����r2Nrar������)r?rrdr��_connectedProtocol�object�queryUDP�addCallbackrerfrCrX�errbackr�callback)r)r�r�rU�expectedResult�queryResultr�s      @r0�test_datagramQueryServerOrderz+ResolverTests.test_datagramQueryServerOrder3s����+�,����,��!�;�/�
��?�?�7�3��(���&@��#�����'�'��-������ 0� 0�.�A�����X�-�-�.��2��
�
�h�&�&�q�)�!�,�g�a�j�9������B��'�'�(<�Q�(?�@�����X�-�-�.��2��
�
�h�&�&�q�)�!�,�g�a�j�9������B��'�'�(<�Q�(?�@�����X�-�-�.��2��
�
�h�&�&�q�)�!�,�j��m�<������B��'�'�(<�Q�(?�@�����X�-�-�.��2��
�
�h�&�&�q�)�!�,�j��m�<������B��(�(��8��r2c���	�
�t��
tjdg��}�
fd�|_�
j}tjdt
jt
j�}|j|�}�jt|�d�|j|�}�jt|�d�t��	tj�}|jj�	�|j!�dj#|�t%j&||g�}�	�fd�}|j)|�|S)z�
        L{client.Resolver.query} only issues one request at a time per query.
        Subsequent requests made before responses to prior ones are received
        are queued and given the same response as is given to the first one.
        �r�r�r�c����SrAr6�r�s�r0r�z<ResolverTests.test_singleConcurrentRequest.<locals>.<lambda>]����h�r2�foo.example.comrar�c�h��|\}}�j|�gggf��j|�gggf�yrA�re)�	responses�
firstResponse�secondResponse�answerr)s   ��r0�
cbFinishedz>ResolverTests.test_singleConcurrentRequest.<locals>.cbFinishedrs?���,5�)�M�>����]�f�X�r�2�,>�?����^�v�h��B�-?�@r2)r?rrdr�rCr
�Queryr&�INrLrerfr��Message�answersrI�popr�r�
gatherResultsr�)r)rUrCrL�firstResult�secondResult�response�dr�r�r�s`        @@r0�test_singleConcurrentRequestz*ResolverTests.test_singleConcurrentRequestUs���+�,���?�?�,?�+@�A��&6��#��"�"���	�	�,�c�e�e�S�V�V�<���n�n�U�+������W��q�)� �~�~�e�,������W��q�)�����;�;�=��������'����
�b��"�"�8�,�����l� ;�<��	A�
	
�
�
�j�!��r2c�T��t��tjdg��}�fd�|_�j}tjdt
j�}|j|�|jt|�d�tjdt
j�}|j|�|jt|�d�tjdt
j�}|j|�|jt|�d�y	)
zh
        L{client.Resolver.query} issues a request for each different concurrent
        query.
        r�r�c����SrAr6r�s�r0r�z?ResolverTests.test_multipleConcurrentRequests.<locals>.<lambda>�r�r2r�ra�bar.example.comr�r�N)r?rrdr�rCr
r�r&rLrerf�A6)r)rUrC�
firstQuery�secondQuery�
thirdQueryr�s      @r0�test_multipleConcurrentRequestsz-ResolverTests.test_multipleConcurrentRequestszs����
+�,���?�?�,?�+@�A��&6��#��"�"���Y�Y�1�3�5�5�9�
����z�"�����W��q�)��i�i� 2�C�E�E�:�����{�#�����W��q�)��Y�Y�1�3�6�6�:�
����z�"�����W��q�)r2c����t��tjdg��}�fd�|_�j}tjdt
j�}|j|�|jt|�d�|j�djtj��|j|�|jt|�d�y)z�
        After a response is received to a query issued with
        L{client.Resolver.query}, another query with the same parameters
        results in a new network request.
        r�r�c����SrAr6r�s�r0r�z?ResolverTests.test_multipleSequentialRequests.<locals>.<lambda>�r�r2r�rar�N)r?rrdr�rCr
r�r&rLrerfr�r�r�)r)rUrCrLr�s    @r0�test_multipleSequentialRequestsz-ResolverTests.test_multipleSequentialRequests�s����+�,���?�?�,?�+@�A��&6��#��"�"���	�	�,�c�e�e�4��	���u������W��q�)�	���
�b��"�"�3�;�;�=�1�	���u������W��q�)r2c���t��tjdg��}�fd�|_�j}tjdt
j�}|j|�}|j|�}Gd�dt�}|j�djtj|���tj|j!||�|j!||�g�S)z�
        If the result of a request is an error response, the Deferreds for all
        concurrently issued requests associated with that result fire with the
        L{Failure}.
        r�r�c����SrAr6r�s�r0r�z>ResolverTests.test_multipleConcurrentFailure.<locals>.<lambda>�r�r2r�c��eZdZy)�GResolverTests.test_multipleConcurrentFailure.<locals>.ExpectedExceptionN�r3r4r5r6r2r0�ExpectedExceptionr�����r2r�r�)r?rrdr�rCr
r�r&rL�	Exceptionr�r�r�Failurerr��
assertFailure)r)rUrCrLr�r�r�r�s       @r0�test_multipleConcurrentFailurez,ResolverTests.test_multipleConcurrentFailure�s����+�,���?�?�,?�+@�A��&6��#��"�"���	�	�,�c�e�e�4���n�n�U�+���~�~�e�,��	�	�	�	���
�b��!�!�'�/�/�2C�2E�"F�G��"�"��"�"�;�0A�B��"�"�<�1B�C�
�
�	
r2c�R�tjdg��}|j�}|j�}|j|j�|j|j�|j|jj
�j|jj
�j�tjtj|jj�tj|jj�g�S)z�
        L{client.Resolver._connectedProtocol} returns a new
        L{DNSDatagramProtocol} connected to a new address with a
        cryptographically secure random port number.
        r�r�)rrdr��assertIsNotNonerD�assertNotEqual�getHost�portrr��
maybeDeferredr<)r)rU�
firstProto�secondProtos    r0�test_connectedProtocolz$ResolverTests.test_connectedProtocol�s����?�?�,?�+@�A���0�0�2�
��1�1�3�����Z�1�1�2����[�2�2�3����� � �(�(�*�/�/��1F�1F�1N�1N�1P�1U�1U�	
��"�"��#�#�J�$8�$8�$F�$F�G��#�#�K�$9�$9�$G�$G�H�
�
�	
r2c���tj�}tj|j	�|��}|j�}|j
|j|�y)z�
        If a reactor instance is supplied to L{client.Resolver}
        L{client.Resolver._connectedProtocol} should pass that reactor
        to L{twisted.names.dns.DNSDatagramProtocol}.
        r�N)r�
MemoryReactorrrdr�r�rXr{)r)r|rU�protos    r0�)test_resolverUsesOnlyParameterizedReactorz7ResolverTests.test_resolverUsesOnlyParameterizedReactor�sH���)�)�+���?�?�$�+�+�-��I���+�+�-���
�
�e�n�n�g�.r2c�6��tjdg��}g�G�fd�d�}||_|jt	j
d��|jt	j
d��|j
tt���d�y)	z�
        L{client.Resolver._connectedProtocol} is called once each time a UDP
        request needs to be issued and the resulting protocol instance is used
        for that request.
        r�r�c� ��eZdZd�Zd�fd�	Zy)�:ResolverTests.test_differentProtocol.<locals>.FakeProtocolc�"�t�|_yrA�r8rDr;s r0rEzCResolverTests.test_differentProtocol.<locals>.FakeProtocol.__init__����!)���r2Nc�t���j|�tjtj��SrA)rIrr(r
r�)r)rrLr+rJ�	protocolss     �r0rLz@ResolverTests.test_differentProtocol.<locals>.FakeProtocol.query�s&���� � ��&��}�}�S�[�[�]�3�3r2rM�r3r4r5rErL)rs�r0�FakeProtocolr	�s
���
,�
4r2rr�r�r�N)	rrdr�rLr
r�rerf�set)r)rUrrs   @r0�test_differentProtocolz$ResolverTests.test_differentProtocol�su����?�?�,?�+@�A���	�	4�	4�'3��#����s�y�y�!3�4�5����s�y�y�!3�4�5�����S��^�,�a�0r2c�:�tj�}tjdg|��}|j	tjd��|jj�\\}}|j�j}|jd|�y)z<
        If the resolver is ipv6, open a ipv6 port.
        r��r�r|r�z::N)rrrrdrLr
r��udpPorts�itemsr��hostre)r)�fakerUrrDr�s      r0�test_ipv6ResolverzResolverTests.test_ipv6Resolversx��
�&�&�(���?�?�K�=�$�G�����s�y�y�!3�4�5�#�}�}�2�2�4��	�%���%�%�'�,�,�	�����y�)r2c����g�G�fd�d�}tjdg��}|�|_|j�|j	tt
���d�y)z�
        If a port number is initially selected which cannot be bound, the
        L{CannotListenError} is handled and another port number is attempted.
        c���eZdZ�fd�Zy)�6ResolverTests.test_disallowedPort.<locals>.FakeReactorc�^���j|�t��dk(r
td|d��y)Nra)rIrfr�r)r��args�kwargs�portss    �r0�	listenUDPz@ResolverTests.test_disallowedPort.<locals>.FakeReactor.listenUDPs.������T�"��u�:��?�+�D�$��=�=�#r2N�r3r4r5r"�r!s�r0�FakeReactorrs���
>r2r%r�r�r�N)rrdr{r�rerfr�r)r%rUr!s   @r0�test_disallowedPortz!ResolverTests.test_disallowedPortsV���
��	>�	>��?�?�,?�+@�A��'�M����#�#�%�����S��Z��!�,r2c����g�G�fd�d�}tjdg��}|�|_|jt|j
�|j
t��d�y)z�
        If port numbers that cannot be bound are repeatedly selected,
        L{resolver._connectedProtocol} will give up eventually.
        c���eZdZ�fd�Zy)�@ResolverTests.test_disallowedPortRepeatedly.<locals>.FakeReactorc�@���j|�td|d��rA)rIrrs    �r0r"zJResolverTests.test_disallowedPortRepeatedly.<locals>.FakeReactor.listenUDP's������T�"�'��d�D�9�9r2Nr#r$s�r0r%r*&s���
:r2r%r�r�i�N)rrdr{r�rr�rerfr&s   @r0�test_disallowedPortRepeatedlyz+ResolverTests.test_disallowedPortRepeatedlys]���
��	:�	:�
�?�?�,?�+@�A��'�M������+�X�-H�-H�I�����U��T�*r2c�F��g�G�fd�d�}tjdg��}|�|_|jt|j
�}|j
|jjtj�|j
t��d�y)zf
        If the process is out of files, L{Resolver._connectedProtocol}
        will give up.
        c���eZdZ�fd�Zy)�5ResolverTests.test_runOutOfFiles.<locals>.FakeReactorc�t���j|�ttjd�}t	d||��)NzOut of files :()rI�OSError�errno�EMFILEr)r)r�rr �errr!s     �r0r"z?ResolverTests.test_runOutOfFiles.<locals>.FakeReactor.listenUDP:s/������T�"��e�l�l�,=�>��'��d�C�8�8r2Nr#r$s�r0r%r/9s���
9r2r%r�r�raN)rrdr{r�rr�re�socketErrorr2r3rf)r)r%rU�excr!s    @r0�test_runOutOfFilesz ResolverTests.test_runOutOfFiles2s���
��	9�	9��?�?�,?�+@�A��'�M������ 1�8�3N�3N�O��	
������.�.����=�����U��Q�'r2c����tjdg��}g�tjt	j
t
d���tjtj��g�G��fd�d�}||_
|jtjd��|jtt���d�y)z|
        When a query issued by L{client.Resolver.query} times out, the retry
        uses a new protocol instance.
        r�r�Nc�"��eZdZd�Zd��fd�	Zy)�FResolverTests.test_differentProtocolAfterTimeout.<locals>.FakeProtocolc�"�t�|_yrArr;s r0rEzOResolverTests.test_differentProtocolAfterTimeout.<locals>.FakeProtocol.__init__Urr2Nc�H���j|��jd�S�Nr�rIr��r)rrLr+rJrr-s     ��r0rLzLResolverTests.test_differentProtocolAfterTimeout.<locals>.FakeProtocol.queryX����� � ��&��{�{�1�~�%r2rMr�rr-s��r0rr:T�
���
,�
&r2rr�r�)rrdr�failrr�rr(r
r�r�rLr�rerfr)r)rUrrr-s   @@r0�"test_differentProtocolAfterTimeoutz0ResolverTests.test_differentProtocolAfterTimeoutHs����
�?�?�,?�+@�A���	��J�J�w���';�D�'A�B�C��M�M�#�+�+�-�(�
��
	&�	&�'3��#����s�y�y�!3�4�5�����S��^�,�a�0r2c����tjdg��}g�tj��G��fd�d�}||_|jt
jd��|j�djj��jt
j��|j�djj�y)z�
        After the L{Deferred} returned by L{DNSDatagramProtocol.query} is
        called back, the L{DNSDatagramProtocol} is disconnected from its
        transport.
        r�r�c�"��eZdZd�Zd��fd�	Zy)�9ResolverTests.test_protocolShutDown.<locals>.FakeProtocolc�"�t�|_yrArr;s r0rEzBResolverTests.test_protocolShutDown.<locals>.FakeProtocol.__init__krr2Nc�*���j|��SrA�rI�r)rrLr+rJrrKs     ��r0rLz?ResolverTests.test_protocolShutDown.<locals>.FakeProtocol.queryn����� � ��&��
r2rMr�rrKs��r0rrGj�
���
,�
r2rr�rN)rrdrrHr�rLr
r��assertFalserDr:r�r�rS)r)rUrrrKs   @@r0�test_protocolShutDownz#ResolverTests.test_protocolShutDown`s�����?�?�,?�+@�A���	����!��	�	�'3��#����s�y�y�!3�4�5�����1��/�/�<�<�=�������
�&����	�!��.�.�;�;�<r2c����tjdg��}g�tj�}tjtjtd���|g�G��fd�d�}||_|jtjd��|j�djj�|jtj ��|j#�djj�y)z�
        The L{DNSDatagramProtocol} created when an interim timeout occurs is
        also disconnected from its transport after the Deferred returned by its
        query method completes.
        r�r�Nc�"��eZdZd�Zd��fd�	Zy)�EResolverTests.test_protocolShutDownAfterTimeout.<locals>.FakeProtocolc�"�t�|_yrArr;s r0rEzNResolverTests.test_protocolShutDownAfterTimeout.<locals>.FakeProtocol.__init__�rr2Nc�H���j|��jd�Sr=r>r?s     ��r0rLzKResolverTests.test_protocolShutDownAfterTimeout.<locals>.FakeProtocol.query�r@r2rMrrAs��r0rrS�rBr2rr�ra)rrdrrHrCrr�rr�rLr
r�rOrDr:r�r�rS)r)rUrKrrr-s    @@r0�!test_protocolShutDownAfterTimeoutz/ResolverTests.test_protocolShutDownAfterTimeoutys�����?�?�,?�+@�A���	����!���:�:�g�o�o�.B�4�.H�I�J�F�S��	&�	&�'3��#����s�y�y�!3�4�5�����1��/�/�<�<�=�������
�&����	�!��.�.�;�;�<r2c����Gd�dt�}tjdg��}g�tj��G��fd�d�}||_|j
tjd��}|j�djj��jtj|���|j�djj�|j!||�S)	z�
        If the L{Deferred} returned by L{DNSDatagramProtocol.query} fires with
        a failure, the L{DNSDatagramProtocol} is still disconnected from its
        transport.
        c��eZdZy)�JResolverTests.test_protocolShutDownAfterFailure.<locals>.ExpectedExceptionNr�r6r2r0r�rY�r�r2r�r�r�c�"��eZdZd�Zd��fd�	Zy)�EResolverTests.test_protocolShutDownAfterFailure.<locals>.FakeProtocolc�"�t�|_yrArr;s r0rEzNResolverTests.test_protocolShutDownAfterFailure.<locals>.FakeProtocol.__init__�rr2Nc�*���j|��SrArJrKs     ��r0rLzKResolverTests.test_protocolShutDownAfterFailure.<locals>.FakeProtocol.query�rLr2rMrrMs��r0rr[�rNr2rr�r)r�rrdrrHr�rLr
r�rOrDr:r�rr�rSr�)r)r�rUrr�rrKs     @@r0�!test_protocolShutDownAfterFailurez/ResolverTests.test_protocolShutDownAfterFailure�s����	�	�	��?�?�,?�+@�A���	����!��	�	�'3��#��n�n�S�Y�Y�/A�%B�C������1��/�/�<�<�=����w���'8�':�;�<����	�!��.�.�;�;�<��!�!�+�/@�A�Ar2c��tjdg��}|jjd�}|j	d�|j||j�|jd�|j||j�y)z�
        When a TCP DNS protocol associated with a Resolver disconnects, it is
        removed from the Resolver's connection list.
        r�r�N)	rrd�factory�
buildProtocol�makeConnection�assertIn�connections�connectionLost�assertNotIn)r)rUr�s   r0�(test_tcpDisconnectRemovesFromConnectionsz6ResolverTests.test_tcpDisconnectRemovesFromConnections�st��
�?�?�,?�+@�A���#�#�1�1�$�7������%��
�
�h�� 4� 4�5�	����%�����8�#7�#7�8r2c�~�tj�}tjdg|��}|j	tjd��}|jd\}}}}}Gd�dt�}	|j|jdtj|	���|j||	�y)z�
        The deferred returned by L{client.Resolver.queryTCP} will
        errback when the TCP connection attempt fails. The reason for
        the connection failure is passed as the argument to errback.
        �z192.0.2.100r�rr�rc��eZdZy)�VResolverTests.test_singleTCPQueryErrbackOnConnectionFailure.<locals>.SentinelExceptionNr�r6r2r0�SentinelExceptionrk�r�r2rlN)rrrrd�queryTCPr
r��
tcpClientsr��clientConnectionFailed�
connectorsrr��failureResultOf)
r)r|rUr�rr�r`r+�bindAddressrls
          r0�-test_singleTCPQueryErrbackOnConnectionFailurez;ResolverTests.test_singleTCPQueryErrbackOnConnectionFailure�s��� �-�-�/���?�?�,?�+@�'�R�����c�i�i�
�6�7��4;�4F�4F�q�4I�1��d�G�W�k�	�	�	�	�&�&����q�!�7�?�?�3D�3F�#G�	
�	
���Q� 1�2r2c��tj�}tjdg|��}|j	tjd��}|j	tjd��}|jd\}}}}}	Gd�dt�}
|j|jdtj|
���|j||
�}|j||
�}|j||�y)	z�
        All pending L{resolver.queryTCP} C{deferred}s will C{errback}
        with the same C{Failure} if the connection attempt fails.
        rirr�zexample.netrc��eZdZy)�XResolverTests.test_multipleTCPQueryErrbackOnConnectionFailure.<locals>.SentinelExceptionNr�r6r2r0rlrv�r�r2rlN)rrrrdrmr
r�rnr�rorprr�rqrX)
r)r|rU�d1�d2rr�r`r+rrrl�f1�f2s
             r0�/test_multipleTCPQueryErrbackOnConnectionFailurez=ResolverTests.test_multipleTCPQueryErrbackOnConnectionFailure�s���
 �-�-�/���?�?�,?�+@�'�R��
�
�
�s�y�y��7�
8��
�
�
�s�y�y��7�
8��4;�4F�4F�q�4I�1��d�G�W�k�	�	�	�	�&�&����q�!�7�?�?�3D�3F�#G�	
��
!�
!�"�&7�
8��
�
!�
!�"�&7�
8���
�
�b�"�r2c���
�tj�}tjdg|���
t	j
d���
j
��}��
fd�}|j|�|jt|j�d�|jt|j�d�|jd\}}}}}tjt��}	|j|jd|	�|jt|j�d�|jt|j�d�|j!|�tjt��}
|j|jd|
�|j#|t�}|j%||
�y)	z{
        An errback on the deferred returned by
        L{client.Resolver.queryTCP} may trigger another TCP query.
        )riE'rr�c�P��|jt��j��SrA)�traprrm)�e�qrUs ��r0�reissuezOResolverTests.test_reentrantTCPQueryErrbackOnConnectionFailure.<locals>.reissue�s!���
�F�F�)�*��$�$�Q�'�'r2rarr�N)rrrrdr
r�rm�
addErrbackrerfrnrprr�rro�assertNoResultrqrX)r)r|r�r�rr�r`r+rrryrz�fr�rUs            @@r0�0test_reentrantTCPQueryErrbackOnConnectionFailurez>ResolverTests.test_reentrantTCPQueryErrbackOnConnectionFailure�sr���
 �-�-�/���?�?�,@�+A�7�S���I�I�m�$��
���a� ��	(�	
���W������W�/�/�0�!�4�����W�/�/�0�!�4�4;�4F�4F�q�4I�1��d�G�W�k��_�_�3�5�
6���&�&�w�'9�'9�!�'<�b�A�	
����W�/�/�0�!�4�����W�/�/�0�!�4����A���_�_�3�5�
6���&�&�w�'9�'9�!�'<�b�A�
� � ��$:�;���
�
�a��r2c�:�tj�}tjdg|��}|j	tjd��}|jd\}}}}}|j}	|jt|	�d�Gd�dt�}
|j|jdtj|
���|j!||
�|j#|j|	�|jt|	�d�y)	z�
        When the TCP connection attempt fails, the
        L{client.Resolver.pending} list is emptied in place. It is not
        replaced with a new empty list.
        rirr�rrac��eZdZy)�JResolverTests.test_pendingEmptiedInPlaceOnError.<locals>.SentinelExceptionNr�r6r2r0rlr�'r�r2rlN)rrrrdrmr
r�rn�pendingrerfr�rorprr�rqrX)r)r|rUr�rr�r`r+rr�
prePendingrls           r0�!test_pendingEmptiedInPlaceOnErrorz/ResolverTests.test_pendingEmptiedInPlaceOnErrors��� �-�-�/���?�?�,?�+@�'�R�����c�i�i�
�6�7��4;�4F�4F�q�4I�1��d�G�W�k��%�%�
�����Z��!�,�	�	�	�	�&�&����q�!�7�?�?�3D�3F�#G�	
�	
���Q� 1�2��
�
�h�&�&�
�3�����Z��!�,r2N) r3r4r5r=r�r�r�r�r�r�r�r�r�r�r�r�rrrrr'r,r7rDrPrVr^rgrsr{r�r�r6r2r0r�r��s����(�0�7�C�+�$/�.� �D#�J*�6*�0
�6
�.	/�1�,
*�-�&+�&(�,1�0=�2=�4B�>9�3�*�.)�V-r2r�c��eZdZd�Zd�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�Zy)�ClientTestsc�F�t�t_d|_d|_y)z:
        Replace the resolver with a FakeResolver
        �example.comrN)rr�theResolver�hostname�hostnameForGetHostByNamer;s r0�setUpzClientTests.setUp4s��*�^���&��
�(<��%r2c��dt_y)zp
        By setting the resolver to None, it will be recreated next time a name
        lookup is done.
        N)rr�r;s r0�tearDownzClientTests.tearDown<s��
"��r2c��|\}}}|d}|j|jj|j�|j|j|�y)zT
        Verify that the result is the same query type as what is expected.
        rN)rer!r�r")r)r-r*r�r.r/rKs       r0�checkResultzClientTests.checkResultCsK��*1�&���J�����������)�)�4�=�=�9�������e�,r2c�(�|j|d�y)zR
        Test that the getHostByName query returns the 127.0.0.1 address.
        rNr��r)rKs  r0�checkGetHostByNamezClientTests.checkGetHostByNameLs��	
�����-r2c�z�tj|j�}|j|j�|S)zM
        do a getHostByName of a value that should return 127.0.0.1.
        )r�
getHostByNamer�r�r��r)r�s  r0�test_getHostByNamezClientTests.test_getHostByNameRs1��
� � ��!>�!>�?��	�
�
�d�-�-�.��r2c��tj|j�}|j|jt
j�|S)z�
        Do a lookup and test that the resolver will issue the correct type of
        query type. We do this by checking that FakeResolver returns a result
        record with the same query type as what we issued.
        )r�
lookupAddressr�r�r�r
r&r�s  r0�test_lookupAddresszClientTests.test_lookupAddressZs5��
� � ����/��	�
�
�d�&�&����.��r2c��tj|j�}|j|jt
j�|S�z+
        See L{test_lookupAddress}
        )r�lookupIPV6Addressr�r�r�r
�AAAAr�s  r0�test_lookupIPV6Addressz"ClientTests.test_lookupIPV6Addressds5��
�$�$�T�]�]�3��	�
�
�d�&�&����1��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupAddress6r�r�r�r
r�r�s  r0�test_lookupAddress6zClientTests.test_lookupAddress6ls5��
�!�!�$�-�-�0��	�
�
�d�&�&����/��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupNameserversr�r�r�r
�NSr�s  r0�test_lookupNameserversz"ClientTests.test_lookupNameserversts5��
�$�$�T�]�]�3��	�
�
�d�&�&����/��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupCanonicalNamer�r�r�r
�CNAMEr�s  r0�test_lookupCanonicalNamez$ClientTests.test_lookupCanonicalName|s5��
�&�&�t�}�}�5��	�
�
�d�&�&��	�	�2��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupAuthorityr�r�r�r
�SOAr�s  r0�test_lookupAuthorityz ClientTests.test_lookupAuthority�s5��
�"�"�4�=�=�1��	�
�
�d�&�&����0��r2c��tj|j�}|j|jt
j�|Sr�)r�
lookupMailBoxr�r�r�r
�MBr�s  r0�test_lookupMailBoxzClientTests.test_lookupMailBox�s5��
� � ����/��	�
�
�d�&�&����/��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupMailGroupr�r�r�r
�MGr�s  r0�test_lookupMailGroupz ClientTests.test_lookupMailGroup�s5��
�"�"�4�=�=�1��	�
�
�d�&�&����/��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupMailRenamer�r�r�r
�MRr�s  r0�test_lookupMailRenamez!ClientTests.test_lookupMailRename�s5��
�#�#�D�M�M�2��	�
�
�d�&�&����/��r2c��tj|j�}|j|jt
j�|Sr�)r�
lookupNullr�r�r�r
�NULLr�s  r0�test_lookupNullzClientTests.test_lookupNull��5��
���d�m�m�,��	�
�
�d�&�&����1��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupWellKnownServicesr�r�r�r
�WKSr�s  r0�test_lookupWellKnownServicesz(ClientTests.test_lookupWellKnownServices�s5��
�*�*�4�=�=�9��	�
�
�d�&�&����0��r2c��tj|j�}|j|jt
j�|Sr�)r�
lookupPointerr�r�r�r
�PTRr�s  r0�test_lookupPointerzClientTests.test_lookupPointer��5��
� � ����/��	�
�
�d�&�&����0��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupHostInfor�r�r�r
�HINFOr�s  r0�test_lookupHostInfozClientTests.test_lookupHostInfo�s5��
�!�!�$�-�-�0��	�
�
�d�&�&��	�	�2��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupMailboxInfor�r�r�r
�MINFOr�s  r0�test_lookupMailboxInfoz"ClientTests.test_lookupMailboxInfo��5��
�$�$�T�]�]�3��	�
�
�d�&�&��	�	�2��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupMailExchanger�r�r�r
�MXr�s  r0�test_lookupMailExchangez#ClientTests.test_lookupMailExchange�s5��
�%�%�d�m�m�4��	�
�
�d�&�&����/��r2c��tj|j�}|j|jt
j�|Sr�)r�
lookupTextr�r�r�r
�TXTr�s  r0�test_lookupTextzClientTests.test_lookupText�s5��
���d�m�m�,��	�
�
�d�&�&����0��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupSenderPolicyr�r�r�r
�SPFr�s  r0�test_lookupSenderPolicyz#ClientTests.test_lookupSenderPolicy�s5��
�%�%�d�m�m�4��	�
�
�d�&�&����0��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupResponsibilityr�r�r�r
�RPr�s  r0�test_lookupResponsibilityz%ClientTests.test_lookupResponsibility�s5��
�'�'��
�
�6��	�
�
�d�&�&����/��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupAFSDatabaser�r�r�r
�AFSDBr�s  r0�test_lookupAFSDatabasez"ClientTests.test_lookupAFSDatabase�r�r2c��tj|j�}|j|jt
j�|Sr�)r�
lookupServicer�r�r�r
�SRVr�s  r0�test_lookupServicezClientTests.test_lookupService�r�r2c��tj|j�}|j|jt
j�|Sr�)r�
lookupZoner�r�r�r
�AXFRr�s  r0�test_lookupZonezClientTests.test_lookupZone�r�r2c��tj|j�}|j|jt
j�|Sr�)r�lookupAllRecordsr�r�r�r
�ALL_RECORDSr�s  r0�test_lookupAllRecordsz!ClientTests.test_lookupAllRecordss5��
�#�#�D�M�M�2��	�
�
�d�&�&����8��r2c��tj|j�}|j|jt
j�|Sr�)r�lookupNamingAuthorityPointerr�r�r�r
�NAPTRr�s  r0�!test_lookupNamingAuthorityPointerz-ClientTests.test_lookupNamingAuthorityPointers5��
�/�/��
�
�>��	�
�
�d�&�&��	�	�2��r2c���tj|jtj�}t	j
|�}|j
|jtj�|S)a
        L{client.query} accepts a L{dns.Query} instance and dispatches
        it to L{client.theResolver}.C{query}, which in turn dispatches
        to an appropriate C{lookup*} method of L{client.theResolver},
        based on the L{dns.Query} type.
        )r
r�r�r&rrLr�r�)r)r�r�s   r0�
test_queryzClientTests.test_querysF��
�I�I�d�m�m�S�U�U�+���L�L��O��	�
�
�d�&�&����.��r2N) r3r4r5r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r6r2r0r�r�3s���=�"�-�.�������������������������
r2r�c�F�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�FilterAnswersTestsz|
    Test L{twisted.names.client.Resolver.filterAnswers}'s handling of various
    error conditions it might encounter.
    c�<�tjdg��|_y)N)z0.0.0.0rr�)rrdrUr;s r0r�zFilterAnswersTests.setUp's������0@�A��
r2c����tjd����jd���fd�}|�j_�jj��}|j
�jdgdgdgf�|S)zf
        Test that a truncated message results in an equivalent request made via
        TCP.
        T)�truncr�c����j|�j�tj�}dg|_dg|_dg|_tj|�S)Nr�r.r/)	rerCr
r�r�r.r/rr()rCr��mr)s  ��r0rmz:FilterAnswersTests.test_truncatedMessage.<locals>.queryTCP4sO������W�a�i�i�0��{�{�}�H� (�z�H��"-��H��#/�.�H���=�=��*�*r2r�r.r/)r
r��addQueryrUrm�
filterAnswersr�re)r)rmr�rs`  @r0�test_truncatedMessagez(FilterAnswersTests.test_truncatedMessage,sl���

�K�K�d�#��	�
�
�>�"�	+�"*��
�
���M�M�'�'��*��	�
�
�d�&�&�(��k�]�\�N�(S�T��r2c��tj|��}|jj|�}|j	|�y)N)�rCode)r
r�rUrr~)r)�rcoder6rr4s     r0�
_rcodeTestzFilterAnswersTests._rcodeTestAs/���K�K�e�$���m�m�)�)�!�,������
r2c�^�|jtjtj�S)z�
        Test that a message with a result code of C{EFORMAT} results in a
        failure wrapped around L{DNSFormatError}.
        )rr
�EFORMATr�DNSFormatErrorr;s r0�test_formatErrorz#FilterAnswersTests.test_formatErrorFs��
���s�{�{�E�,@�,@�A�Ar2c�^�|jtjtj�S)zP
        Like L{test_formatError} but for C{ESERVER}/L{DNSServerError}.
        )rr
�ESERVERr�DNSServerErrorr;s r0�test_serverErrorz#FilterAnswersTests.test_serverErrorMs�����s�{�{�E�,@�,@�A�Ar2c�^�|jtjtj�S)zL
        Like L{test_formatError} but for C{ENAME}/L{DNSNameError}.
        )rr
�ENAMEr�DNSNameErrorr;s r0�test_nameErrorz!FilterAnswersTests.test_nameErrorSs�����s�y�y�%�*<�*<�=�=r2c�^�|jtjtj�S)zX
        Like L{test_formatError} but for C{ENOTIMP}/L{DNSNotImplementedError}.
        )rr
�ENOTIMPr�DNSNotImplementedErrorr;s r0�test_notImplementedErrorz+FilterAnswersTests.test_notImplementedErrorYs�����s�{�{�E�,H�,H�I�Ir2c�^�|jtjtj�S)zW
        Like L{test_formatError} but for C{EREFUSED}/L{DNSQueryRefusedError}.
        )rr
�EREFUSEDr�DNSQueryRefusedErrorr;s r0�test_refusedErrorz$FilterAnswersTests.test_refusedError_s�����s�|�|�U�-G�-G�H�Hr2c�d�|jtjdztj�S)zm
        Like L{test_formatError} but for an unrecognized error code and
        L{DNSUnknownError}.
        ra)rr
rr�DNSUnknownErrorr;s r0�test_refusedErrorUnknownz+FilterAnswersTests.test_refusedErrorUnknownes$��
���s�|�|�a�/��1F�1F�G�Gr2N)
r3r4r5r=r�rrrrrrr r#r6r2r0rr!s:���
B�
�*�
B�B�>�J�I�Hr2rc� �eZdZd�Zdd�Zd�Zy)�FakeDNSDatagramProtocolc�0�g|_t�|_yrArBr;s r0rEz FakeDNSDatagramProtocol.__init__nrFr2Nc��|jj||||f�tjt	j
|��SrA)rCrIrrCrr)r)rrCr+rJs     r0rLzFakeDNSDatagramProtocol.queryrs7�������W�g�w��;�<��z�z�%�4�4�W�=�>�>r2c��yrAr6)r)rJs  r0�removeResendz$FakeDNSDatagramProtocol.removeResendvs��r2rM)r3r4r5rErLr)r6r2r0r%r%ms��$�?�
r2r%c�*�eZdZdZgd�Zd�Zd�Zd�Zy)�RetryLogicTestszE
    Tests for query retrying implemented by L{client.Resolver}.
    )z1.2.3.4z4.3.2.1za.b.c.dzz.y.x.wc�"��|jD�cgc]}|df��}}tjd|��}t���fd�|_|jd�j
|j�j|j��Scc}w)a
        When timeouts occur waiting for responses to queries, the next
        configured server is issued the query.  When the query has been issued
        to all configured servers, the timeout is increased and the process
        begins again at the beginning.
        r�N)rxr�c����SrAr6)rs�r0r�z8RetryLogicTests.test_roundRobinBackoff.<locals>.<lambda>�s���u�r2r�)
�testServersrrdr%r�r�r��_cbRoundRobinBackoffr��_ebRoundRobinBackoff)r)�x�addrsrjrs    @r0�test_roundRobinBackoffz&RetryLogicTests.test_roundRobinBackoff�s{���#'�"2�"2�3�Q�!�R��3��3��O�O�4��7��'�)��,���
�O�O�.�/�
�[��2�2�
3�
�Z��1�1�5�
9�	
��	4s�Bc�&�|jd�y)Nz/Lookup address succeeded, should have timed out)rCr�s  r0r/z$RetryLogicTests._cbRoundRobinBackoff�s���	�	�C�Dr2c��|jtj�dD]�}|jdt	|j
�}|jdt	|j
��=|j
�t|j
�}|j
�t||�D]0\\}}}}	}
|j||
df�|j||��2��|j|j�y)N)rar���-r�)r~r�TimeoutErrorrCrfr.�sort�list�ziprerO)r)r�	fakeProto�t�tries�expected�addrrLr+rJ�expectedAddrs           r0r0z$RetryLogicTests._ebRoundRobinBackoff�s�������U�'�'�(�
 �
	-�A��%�%�&=��D�,<�,<�(=�>�E��!�!�"9�C��(8�(8�$9�"9�:��J�J�L��D�,�,�-�H��M�M�O�<?��x�<P�
-�8�*��u�g�r�L�� � ���b�'9�:�� � ��!�,�
-�
	-�	
����*�*�+r2N)r3r4r5r=r.r3r/r0r6r2r0r+r+{s���?�K�
�"E�,r2r+c��eZdZdZd�Zy)�ThreadedResolverTestsz/
    Tests for L{client.ThreadedResolver}.
    c��tj�|j|jg��}|j	|ddd�|j	|ddt
�|j	t
|�d�y)z�
        L{client.ThreadedResolver} is deprecated.  Instantiating it emits a
        deprecation warning pointing at the code that does the instantiation.
        )�offendingFunctionsr�messagezztwisted.names.client.ThreadedResolver is deprecated since Twisted 9.0, use twisted.internet.base.ThreadedResolver instead.�categoryraN)r�ThreadedResolver�
flushWarnings�test_deprecatedre�DeprecationWarningrf)r)�warningss  r0rJz%ThreadedResolverTests.test_deprecated�s{��
	���!��%�%�$�:N�:N�9O�%�P������Q�K�	�"�
�	
�	
����!��Z�0�2D�E�����X���*r2N)r3r4r5r=rJr6r2r0rCrC�s���+r2rC)6r=r2�zope.interface.verifyrr�twisted.internetr�twisted.internet.errorrr�twisted.internet.interfacesr�twisted.internet.taskr	�#twisted.internet.test.modulehelpersr
�
twisted.namesrrr
rr�twisted.names.commonr�twisted.names.errorr�twisted.names.testr�twisted.names.test.test_hostsr�twisted.pythonr�twisted.python.filepathr�twisted.python.runtimer�twisted.testr�
twisted.trialr�	isWindowsr\rr8r?�TestCaserPr_r�r�rr%r+rCr6r2r0�<module>r_s���

�;�"�L�1�'�@�:�:�-�4�(�;�"�,�+�&�"��x�����K�N�K�?�<�?�0!�!���.�x�(�(��4o&�(�+�+�->�o&�dC	-�H�%�%�C	-�Lk�(�#�#�k�\IH��*�*�IH�X
�
�-,�h�'�'�-,�`+�H�-�-�+r2

Zerion Mini Shell 1.0