JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/certbot/plugins/__pycache__/dns_test_common_lexicon.cpython-39.pyc

a

}|�gd=�@s*dZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lm
Z
ddlmZddlZddlZddlmZdd
lmZddlmZddlmZddlmZddlmZe���*ejde d�ddl!m"Z"Wd�n1�s0Yddl#m$Z$ddl%m&Z'dZ(ej)�*e'�+d��Z,e-d�Z.eZ/ede�d�Z0ede�d�Z1Gdd�de$e
�Z2Gdd �d e
�Z3Gd!d"�d"ej4�Z5Gd#d$�d$�Z6Gd%d&�d&e$e
�Z7Gd'd(�d(ej4�Z8ej9eeeefddfd)�d*d+��Z:Gd,d-�d-�Z;eee;ej<e=��ej<e=<dS).z8Base test class for DNS authenticators built on Lexicon.�N)�
ModuleType)�Any)�cast)�	Generator)�List)�Protocol)�Tuple)�mock)�	MagicMock)�Response)�	HTTPError)�RequestException)�errors)�AnnotatedChallenge)�dns_test_common�ignore)�category)�
LexiconClient)�_AuthenticatorCallableTestCase)�utilzexample.comzrsa512_key.pemzNo domain foundz400 Client Error: ...)Zresponsez500 Surprise! Error: ...c@s"eZdZUdZeed<eed<dS)�%_AuthenticatorCallableLexiconTestCasezq
    Protocol describing a TestCase suitable to test challenges against
    a mocked LexiconClient instance.
    �mock_client�achallN)�__name__�
__module__�__qualname__�__doc__r
�__annotations__r�rr�K/usr/lib/python3.9/site-packages/certbot/plugins/dns_test_common_lexicon.pyr(s
rc@sjeZdZUdZeed<eed<eed<eed<eed<eed<eed<eed	<eed
<e	dd�d
d�Z
dS)�_LexiconAwareTestCasezX
    Protocol describing a TestCase suitable to test a real LexiconClient instance.
    �client�
provider_mock�
record_prefix�record_name�record_content�DOMAIN_NOT_FOUND�
GENERIC_ERROR�LOGIN_ERROR�UNKNOWN_LOGIN_ERRORN)�unused_args�returncGsdS)zl
        See
        https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises
        Nr)�selfr*rrr�assertRaisesAsz"_LexiconAwareTestCase.assertRaises)rrrrrrr
�str�	Exceptionrr-rrrrr 1s
r c@s6eZdZe��eedd�dd��Zedd�dd�ZdS)�BaseLexiconAuthenticatorTestN)r,�unused_mock_get_utilityr+cCs<|j�|jg�tj�tdttj�g}|�||j	j
�dS)N�_acme-challenge.)�auth�performrr	�call�add_txt_record�DOMAIN�ANY�assertEqualr�
mock_calls)r,r1�expectedrrr�test_performMsz)BaseLexiconAuthenticatorTest.test_perform�r,r+cCsDd|j_|j�|jg�tj�tdttj�g}|�	||j
j�dS)NTr2)r3�_attempt_cleanup�cleanuprr	r5�del_txt_recordr7r8r9rr:)r,r;rrr�test_cleanupUsz)BaseLexiconAuthenticatorTest.test_cleanup)	rrr�	test_util�patch_display_utilrrr<rArrrrr0Ks
�r0c@seZdZeZeZeZeZdZedeZ	dZ
edd�dd�Zedd�dd	�Z
edd�d
d�Zedd�dd
�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�ZdS) �BaseLexiconClientTestz_acme-challenge�.ZbarNr=cCs0|j�t|j|j�|jjjd|j|jd�dS�N�TXT�Zrtype�nameZcontent)r!r6r7r$r%r"�
create_record�assert_called_with�r,rrr�test_add_txt_recordgs

�z)BaseLexiconClientTest.test_add_txt_recordcCs@|jdg|jj_|j�t|j|j�|jj	j
d|j|jd�dS)N�rGrH)r&r"�authenticate�side_effectr!r6r7r$r%rJrKrLrrr�,test_add_txt_record_try_twice_to_find_domainns
�zBBaseLexiconClientTest.test_add_txt_record_try_twice_to_find_domaincCs6|j|j|jg|jj_|�tj|jjt	|j
|j�dS�N)r&r"rOrPr-r�PluginErrorr!r6r7r$r%rLrrr�'test_add_txt_record_fail_to_find_domainws�

�z=BaseLexiconClientTest.test_add_txt_record_fail_to_find_domaincCs,|j|jj_|�tj|jjt	|j
|j�dSrR)r(r"rOrPr-rrSr!r6r7r$r%rLrrr�(test_add_txt_record_fail_to_authenticate�s

�z>BaseLexiconClientTest.test_add_txt_record_fail_to_authenticatecCs,|j|jj_|�tj|jjt	|j
|j�dSrR)r)r"rOrPr-rrSr!r6r7r$r%rLrrr�;test_add_txt_record_fail_to_authenticate_with_unknown_error�s

�zQBaseLexiconClientTest.test_add_txt_record_fail_to_authenticate_with_unknown_errorcCs,|j|jj_|�tj|jjt	|j
|j�dSrR)r'r"rOrPr-rrSr!r6r7r$r%rLrrr�(test_add_txt_record_error_finding_domain�s

�z>BaseLexiconClientTest.test_add_txt_record_error_finding_domaincCs,|j|jj_|�tj|jjt	|j
|j�dSrR)r'r"rJrPr-rrSr!r6r7r$r%rLrrr�'test_add_txt_record_error_adding_record�s

�z=BaseLexiconClientTest.test_add_txt_record_error_adding_recordcCs0|j�t|j|j�|jjjd|j|jd�dSrF)r!r@r7r$r%r"�
delete_recordrKrLrrr�test_del_txt_record�s

�z)BaseLexiconClientTest.test_del_txt_recordcCs.|j|j|jg|jj_|j�t|j|j�dSrR)	r&r"rOrPr!r@r7r$r%rLrrr�'test_del_txt_record_fail_to_find_domain�s
�
z=BaseLexiconClientTest.test_del_txt_record_fail_to_find_domaincCs$|j|jj_|j�t|j|j�dSrR)	r(r"rOrPr!r@r7r$r%rLrrr�(test_del_txt_record_fail_to_authenticate�sz>BaseLexiconClientTest.test_del_txt_record_fail_to_authenticatecCs$|j|jj_|j�t|j|j�dSrR)	r)r"rOrPr!r@r7r$r%rLrrr�;test_del_txt_record_fail_to_authenticate_with_unknown_error�szQBaseLexiconClientTest.test_del_txt_record_fail_to_authenticate_with_unknown_errorcCs$|j|jj_|j�t|j|j�dSrR)	r'r"rOrPr!r@r7r$r%rLrrr�(test_del_txt_record_error_finding_domain�sz>BaseLexiconClientTest.test_del_txt_record_error_finding_domaincCs$|j|jj_|j�t|j|j�dSrR)	r'r"rYrPr!r@r7r$r%rLrrr�)test_del_txt_record_error_deleting_record�sz?BaseLexiconClientTest.test_del_txt_record_error_deleting_record)rrrr&r'r(r)r#r7r$r%r rMrQrTrUrVrWrXrZr[r\r]r^r_rrrrrD]s,		��rDc@s:eZdZUdZeed<eed<eed<eed<eed<dS)�%_BaseLexiconDNSAuthenticatorTestProtoz6Protocol for BaseLexiconDNSAuthenticatorTest instancesr&r'r(r)rN)rrrrr/rrrrrrr`�s
r`c@s�eZdZeZeZeZeZedd�dd�Zedd�dd�Z	edd�dd�Z
edd�d	d
�Zedd�dd�Zedd�d
d�Z
edd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�Zedd�dd�ZdS)�BaseLexiconDNSAuthenticatorTestNr=c	Cs�t���Jt��$\}}|j�|jg�Wd�n1s:0YWd�n1sX0Y|��|jdd}|�t	|�
d��|jjddt	��t
jd�dS)Nr�lexicon:domainrGr2rH)rBrC�_patch_lexicon_clientr3r4r�
assert_called�	call_argsr9r7�resolverJrKr	r8�r,r�mock_operationsZconfigrrr�test_perform_succeed�s
L�z4BaseLexiconDNSAuthenticatorTest.test_perform_succeedc	Csxt���\t��6\}}|j||g|jj_|j�|j	g�Wd�n1sL0YWd�n1sj0YdSrR)
rBrCrcr&�return_value�	__enter__rPr3r4r)r,rrhrrr�7test_perform_with_one_domain_resolution_failure_succeed�s
�
zWBaseLexiconDNSAuthenticatorTest.test_perform_with_one_domain_resolution_failure_succeedc	Cszt���^t��8\}}|j|jj_|�tj	|j
j|jg�Wd�n1sN0YWd�n1sl0YdSrR)
rBrCrcr&rjrkrPr-rrSr3r4r�r,r�_rrr�6test_perform_with_two_domain_resolution_failures_raise�s
�zVBaseLexiconDNSAuthenticatorTest.test_perform_with_two_domain_resolution_failures_raisec	Cszt���^t��8\}}|j|jj_|�tj	|j
j|jg�Wd�n1sN0YWd�n1sl0YdSrR)
rBrCrcr'rjrkrPr-rrSr3r4rrmrrr�9test_perform_with_domain_resolution_general_failure_raise�s
�zYBaseLexiconDNSAuthenticatorTest.test_perform_with_domain_resolution_general_failure_raisec	Csvt���Zt��4\}}|j|_|�tj|jj	|j
g�Wd�n1sJ0YWd�n1sh0YdSrR)rBrCrcr(rPr-rrSr3r4rrmrrr�$test_perform_with_auth_failure_raise�s
�zDBaseLexiconDNSAuthenticatorTest.test_perform_with_auth_failure_raisec	Csvt���Zt��4\}}|j|_|�tj|jj	|j
g�Wd�n1sJ0YWd�n1sh0YdSrR)rBrCrcr)rPr-rrSr3r4rrmrrr�,test_perform_with_unknown_auth_failure_raises
�zLBaseLexiconDNSAuthenticatorTest.test_perform_with_unknown_auth_failure_raisec	Csxt���\t��6\}}|j|j_|�tj|j	j
|jg�Wd�n1sL0YWd�n1sj0YdSrR)rBrCrcr'rJrPr-rrSr3r4r�r,rnrhrrr�-test_perform_with_create_record_failure_raises

�zMBaseLexiconDNSAuthenticatorTest.test_perform_with_create_record_failure_raisecCs�d|j_t��$\}}|j�|jg�Wd�n1s80Y|��|jdd}|�t|�	d��|j
jddt��tj
d�dS)NTrrbrGr2rH)r3r>rcr?rrdrer9r7rfrYrKr	r8rgrrr�test_cleanup_successs.�z4BaseLexiconDNSAuthenticatorTest.test_cleanup_successcCsFt��,\}}|j|_|j�|jg�Wd�n1s80YdSrR�rcr(rPr3r?rrmrrr�%test_cleanup_with_auth_failure_ignore!szEBaseLexiconDNSAuthenticatorTest.test_cleanup_with_auth_failure_ignorecCsFt��,\}}|j|_|j�|jg�Wd�n1s80YdSrRrvrmrrr�-test_cleanup_with_unknown_auth_failure_ignore&szMBaseLexiconDNSAuthenticatorTest.test_cleanup_with_unknown_auth_failure_ignorecCsJt��0\}}|j|jj_|j�|jg�Wd�n1s<0YdSrR)rcr&rjrkrPr3r?rrmrrr�2test_cleanup_with_domain_resolution_failure_ignore,szRBaseLexiconDNSAuthenticatorTest.test_cleanup_with_domain_resolution_failure_ignorecCsJt��0\}}|j|jj_|j�|jg�Wd�n1s<0YdSrR)rcr'rjrkrPr3r?rrmrrr�:test_cleanup_with_domain_resolution_general_failure_ignore2szZBaseLexiconDNSAuthenticatorTest.test_cleanup_with_domain_resolution_general_failure_ignorecCsHt��.\}}|j|j_|j�|jg�Wd�n1s:0YdSrR)rcr'rJrPr3r?rrsrrr�.test_cleanup_with_delete_record_failure_ignore8s
zNBaseLexiconDNSAuthenticatorTest.test_cleanup_with_delete_record_failure_ignore)rrrr&r'r(r)r`rirlrorprqrrrtrurwrxryrzr{rrrrra�s4
��
�		�
�	����ra�r+ccsHt�d��*}t�}||jj_||fVWd�n1s:0YdS)Nz)certbot.plugins.dns_common_lexicon.Client)r	Zpatchr
rjrk)rrhrrrrc?s
rcc@sbeZdZdZed�dd�Zeed�dd�Zeedd	�d
d�Z	eed�dd
�Z
eed�dd�ZdS)�_DeprecationModulez�
    Internal class delegating to a module, and displaying warnings when attributes
    related to deprecated attributes in the current module.
    )�modulecCs||jd<dS�N�_module)�__dict__)r,r~rrr�__init__Osz_DeprecationModule.__init__)�attrr+cCs0|dvr$tj|�dt�d�tdd�t|j|�S)N)r0rDz attribute in z/ module is deprecated and will be removed soon.�)�
stacklevel)�warnings�warnr�DeprecationWarning�getattrr��r,r�rrr�__getattr__Rs
�z_DeprecationModule.__getattr__N)r��valuer+cCst|j||�dSrR)�setattrr�)r,r�r�rrr�__setattr__Ysz_DeprecationModule.__setattr__cCst|j|�dSrR)�delattrr�r�rrr�__delattr__\sz_DeprecationModule.__delattr__r|cCsdgt|j�Sr)�dirr�rLrrr�__dir___sz_DeprecationModule.__dir__)
rrrrrr�r.rr�r�r�rr�rrrrr}Jsr})>r�
contextlib�sys�typesr�typingrrrrrrZunittestr	Z
unittest.mockr
r�ZjosepyZjoseZrequestsrZrequests.exceptionsrr
ZcertbotrZcertbot.achallengesrZcertbot.pluginsr�catch_warnings�filterwarningsr�Z"certbot.plugins.dns_common_lexiconrZcertbot.plugins.dns_test_commonrZ
certbot.testsrrBr7ZJWKRSA�loadZload_vectorZKEYr/r&r'r(r)rr ZBaseAuthenticatorTestr0rDr`ra�contextmanagerrcr}�modulesrrrrr�<module>sP
,	d
t"

Back to Directory  nL+D550H?Mx ,D"v]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