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/samba/tests/__pycache__/dns_wildcard.cpython-310.pyc
o

�/a�3�@sdddlZddlmZddlmZmZddlmZddlm	Z	m
Z
ddlmZmZddl
mZddlmZddlZe�d�Ze�e�Ze�e�ejd	d
ddd
�e�e�Ze�e�e	e�Ze�e�e��\ZZe��a e�!t �a"ej#a#e$e�dkr�e�%�e�&d�edZ'eda(t"�)ej*�dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2Gdd�de�Z3e
e4ed�dS)�N)�credentials)�dns�	dnsserver)�record_from_string)�SubunitOptions�TestProgram)�werror�WERRORError)�DNSTestz3dns_wildcard.py <server name> <server ip> [options]z	--timeout�int�timeoutz Specify timeout for DNS requests)�type�dest�help��z1.1.1.1z*.wildcardtestz1.1.1.2zexact.wildcardtestz1.1.1.3z*.level2.wildcardtestz1.1.1.4zexact.level2.wildcardtestcs|eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�TestWildCardQueriescs�tt|���t|_t|_t|_t|_t|_t	j
dt|��ft
ft	j
dt|��ftft	j
dt|��ftft	j
dt|��ftfg|_|��}|jD]
\}}}|�||||�qLdS)N�%s.%s)�superr�setUp�server_name�server�	server_ip�lp�credsrr�DNS_QTYPE_A�WILDCARD�get_dns_domain�WILDCARD_IP�EXACT�EXACT_IP�LEVEL2_WILDCARD�LEVEL2_WILDCARD_IP�LEVEL2_EXACT�LEVEL2_EXACT_IP�dns_records�dns_connect�
add_record��self�c�typ�name�data��	__class__��:/usr/lib/python3/dist-packages/samba/tests/dns_wildcard.pyrNsB��������zTestWildCardQueries.setUpcCs.|��}|jD]
\}}}|�||||�qdS)N)r&r%�
delete_recordr(r0r0r1�tearDownms�zTestWildCardQueries.tearDowncCsd|j}t�||j|j�S)Nzncacn_ip_tcp:%s[sign])rrrr)r)�binding_strr0r0r1r&rs
zTestWildCardQueries.dns_connectc
Csxt||�}t��}||_z|�tjd|j|��|d|�WdSty;}z|j	dt
jkr0|�WYd}~dSd}~ww�Nr)rr�DNS_RPC_RECORD_BUF�rec�DnssrvUpdateRecord2�DNS_CLIENT_VERSION_LONGHORNrrr	�argsr�"WERR_DNS_ERROR_NAME_DOES_NOT_EXIST)r)�dns_connr+r,r-r7�del_rec_buf�er0r0r1r2vs$

����z!TestWildCardQueries.delete_recordc
CsZt||�}t��}||_z|�tjd|j|��||d�WdSty,}z|�d}~wwr5)	rrr6r7r8r9rrr	)r)r<r+r,r-r7�add_rec_bufr>r0r0r1r'�s 

���zTestWildCardQueries.add_recordcC�|�tj�}g}d|��}|�|tjtj�}|�|�|�||�|j	||j
d�\}}|�|tj�|�
|tj�|�|jd�|�|jdjtj�|�|jdjt�dS)z2Query an A record, should match the wildcard entryzmiss.wildcardtest.%s��hostrrN��make_name_packetr�DNS_OPCODE_QUERYr�make_name_questionr�
DNS_QCLASS_IN�append�finish_name_packet�dns_transaction_udpr�assert_dns_rcode_equals�DNS_RCODE_OK�assert_dns_opcode_equals�assertEqual�ancount�answers�rr_type�rdatar�r)�p�	questionsr,�q�response�response_packetr0r0r1�test_one_a_query_match_wildcard�� �
�z3TestWildCardQueries.test_one_a_query_match_wildcardcCr@)z~ Query an A record, should match the wild card entry
            have two labels to the left of the wild card target.
        zlabel2.label1.wildcardtest.%srArrNrCrSr0r0r1�(test_one_a_query_match_wildcard_2_labels�� �
�z<TestWildCardQueries.test_one_a_query_match_wildcard_2_labelscC�|�tj�}g}dt|��f}|�|tjtj�}|�|�|�	||�|j
||jd�\}}|�|tj
�|�|tj�|�|jd�|�|jdjtj�|�|jdjt�dS)zQuery the wildcard entryrrArrN)rDrrErrrFrrGrHrIrJrrKrLrMrNrOrPrQrRrrSr0r0r1�test_one_a_query_wildcard_entry�� �
�z3TestWildCardQueries.test_one_a_query_wildcard_entrycCr]�z\Query an entry that matches the wild card but has an exact match as
         well.
         rrArrN)rDrrErrrFrrGrHrIrJrrKrLrMrNrOrPrQrRr rSr0r0r1�test_one_a_query_exact_match�� �
�z0TestWildCardQueries.test_one_a_query_exact_matchcCr@)z:Query an A record, should match the level 2 wildcard entryzmiss.level2.wildcardtest.%srArrN�rDrrErrFrrGrHrIrJrrKrLrMrNrOrPrQrRr"rSr0r0r1�"test_one_a_query_match_wildcard_l2�rZz6TestWildCardQueries.test_one_a_query_match_wildcard_l2cCr@)z�Query an A record, should match the level 2 wild card entry
           have two labels to the left of the wild card target
        z$label1.label2.level2.wildcardtest.%srArrNrcrSr0r0r1�+test_one_a_query_match_wildcard_l2_2_labels
r\z?TestWildCardQueries.test_one_a_query_match_wildcard_l2_2_labelscCr]r`)rDrrEr#rrFrrGrHrIrJrrKrLrMrNrOrPrQrRr$rSr0r0r1�test_one_a_query_exact_match_l2"rbz3TestWildCardQueries.test_one_a_query_exact_match_l2cCr])z Query the level 2 wildcard entryrrArrN)rDrrEr!rrFrrGrHrIrJrrKrLrMrNrOrPrQrRr"rSr0r0r1�"test_one_a_query_wildcard_entry_l29r_z6TestWildCardQueries.test_one_a_query_wildcard_entry_l2)�__name__�
__module__�__qualname__rr3r&r2r'rYr[r^rardrerfrg�
__classcell__r0r0r.r1rLsr)�module�opts)5�sys�sambar�samba.dcerpcrr�samba.dnsserverr�samba.tests.subunitrunrrrr	�samba.tests.dns_baser
�samba.getopt�getopt�options�optparse�OptionParser�parser�SambaOptions�	sambaopts�add_option_group�
add_option�CredentialsOptions�credopts�subunitopts�
parse_argsrmr:�get_loadparmr�get_credentialsrr�len�print_usage�exitrr�set_krb_forwardable�NO_KRB_FORWARDABLErrr rr"r!r$r#rrhr0r0r0r1�<module>sV�


�