HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/twisted/names/test/__pycache__/test_tap.cpython-310.pyc
o

�b��@s�dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZdd	lmZdd
lmZGdd�de�Zd
S)z!
Tests for L{twisted.names.tap}.
�)�ThreadedResolver)�Resolver)�PORT)�
ResolverChain)�SecondaryAuthorityService)�Options�_buildResolvers)�platform)�
UsageError)�SynchronousTestCasec@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�OptionsTestszf
    Tests for L{Options}, defining how command line arguments for the DNS server
    are parsed.
    cCsZt�}|�t|jddg�|�t|jddg�|�t|jddg�|�t|jddg�dS)z�
        If the value supplied for an I{--secondary} option does not provide a
        server IP address, optional port number, and domain name,
        L{Options.parseOptions} raises L{UsageError}.
        �--secondary��1.2.3.4z
1.2.3.4:helloz1.2.3.4:hello/example.comN)r�assertRaisesr
�parseOptions��self�options�r�=/usr/lib/python3/dist-packages/twisted/names/test/test_tap.py�test_malformedSecondarys��z$OptionsTests.test_malformedSecondarycCs2t�}|�ddg�|�dtfdgfg|j�dS)z�
        An argument of the form C{"ip/domain"} is parsed by L{Options} for the
        I{--secondary} option and added to its list of secondaries, using the
        default DNS port number.
        r
z1.2.3.4/example.comr�example.comN)rr�assertEqualr�secondariesrrrr�test_secondary+szOptionsTests.test_secondarycCs.t�}|�ddg�|�ddgfg|j�dS)z�
        An argument of the form C{"ip:port/domain"} can be used to specify an
        alternate port number for which to act as a secondary.
        r
�1.2.3.4:5353/example.com)r��rN)rrrrrrrr�test_secondaryExplicitPort5sz'OptionsTests.test_secondaryExplicitPortcCs�t�}|�gd��|�t|j�d�|jd}|�|jdt�|�|jd�|�|jd�|jd}|�|jdt�|�|jd�|�|jd�d	S)
z�
        After parsing I{--secondary} options, L{Options} constructs a
        L{SecondaryAuthorityService} instance for each configured secondary.
        )r
rr
z1.2.3.5:5354/example.com�rrr�z1.2.3.5i�N)	rrr�len�svcs�assertIsInstancer�primary�_port)rr�	secondaryrrr�test_secondaryAuthorityServices>s�

z,OptionsTests.test_secondaryAuthorityServicescCs�t�}|�gd��t|�\}}|D]}t|t�r(|jd}t|t�r(|j��qt	�
�dkrHddlm}|j
D]}|�|jjtj�|��q8|�|dt�dS)z�
        Recursive DNS lookups, if enabled, should be a last-resort option.
        Any other lookup method (cache, local lookup, etc.) should take
        precedence over recursive lookups
        )z--hosts-filez	hosts.txtz--recursive����posixr)�reactorN)rrr�
isinstancer�	resolversr�
_parseCall�cancelr	�getType�twisted.internetr*�_newTimedCallsr�func�__func__r�_cleanupr#)rr�ca�cl�x�recurserr*rrr�test_recursiveConfigurationVs



�

z(OptionsTests.test_recursiveConfigurationN)	�__name__�
__module__�__qualname__�__doc__rrrr'r9rrrrrs
	rN)r=�twisted.internet.baser�twisted.names.clientr�twisted.names.dnsr�twisted.names.resolver�twisted.names.secondaryr�twisted.names.taprr�twisted.python.runtimer	�twisted.python.usager
�twisted.trial.unittestrrrrrr�<module>s