a }|g@sdZddlZddlZddlZddlmZddlZddlmZddlm Z ddl m Z ddl m Z ddl mZdd l mZGd d d ejZed kreeejd degdS)z*Tests for certbot._internal.plugins.manualN)mock) challenges)errors) filesystem)os) acme_util)utilcsheZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ZS)AuthenticatorTestz9Tests for certbot._internal.plugins.manual.Authenticator.cstt}||_||jtj |_ tj |_ tj |_|j |j |jg|_dD]}ttj|j|qVtjdddddtj|jdtj|jdtj|jdtj|jdtj|jdd |_dd lm}||jd d |_dS) N) config_dirwork_dirZ in_progressrFr r backup_dirtemp_checkpoint_dirZ in_progess) Z http01_portmanual_auth_hookmanual_cleanup_hooknoninteractive_modevalidate_hooksr r r r Zin_progress_dir) AuthenticatorZmanual)name)supersetUp test_utilZpatch_display_utilstartmock_get_displayZ addCleanupstoprZHTTP01_A http_achallZDNS01_A dns_achallZ DNS01_A_2Z dns_achall_2achallsrmkdirrpathjoinZtempdirrZ MagicMockconfigZ certbot._internal.plugins.manualrauth)selfZget_display_patchdr __class__O/usr/lib/python3.9/site-packages/certbot/_internal/tests/plugins/manual_test.pyrs.    zAuthenticatorTest.setUpcCsBd|j_ttj|jWdn1s40YdSNT)r rpytestraisesrZ PluginErrorr!preparer"r&r&r'#test_prepare_no_hook_noninteractive0sz5AuthenticatorTest.test_prepare_no_hook_noninteractivecCsTtjtj|j_d|j_tt j |j Wdn1sF0YdSr() rrabspathsepr rrr)r*rZHookCommandNotFoundr!r+r,r&r&r'test_prepare_bad_hook5sz'AuthenticatorTest.test_prepare_bad_hookcCsdSNr&r,r&r&r'test_more_info;sz AuthenticatorTest.test_more_infocCsdSr1r&r,r&r&r'test_get_chall_pref>sz%AuthenticatorTest.test_get_chall_prefc Csdtj|j_d|jjd|j|jjd dd|j Dt |j |j |jd}d|j j|j jd|j |j jd d d|j Dt |j |j |j d}t|jjD]*\}\}}t|jj|j |d d }qdS) Na {0} -c "from certbot.compat import os;print(os.environ.get('CERTBOT_DOMAIN'));print(os.environ.get('CERTBOT_TOKEN', 'notoken'));print(os.environ.get('CERTBOT_VALIDATION', 'novalidation'));print(os.environ.get('CERTBOT_ALL_DOMAINS'));print(os.environ.get('CERTBOT_REMAINING_CHALLENGES'));"z{0} {1} {2} {3} {4}Znotoken,css|] }|jVqdSr1domain.0achallr&r&r' Oz8AuthenticatorTest.test_script_perform..tokencss|] }|jVqdSr1r5r7r&r&r'r:Tr;ZCERTBOT_AUTH_OUTPUT )formatsys executabler rrr6Z validationZ account_keyrrlenindexrchallencode enumerater notificationcall_args_listtextwrapindentr!env)r"Z dns_expectedZ http_expectediargs_Zneedler&r&r'test_script_performBs& z%AuthenticatorTest.test_script_performcCs,t|jjD]\}\}}|j|}qdSr1)rFrrGrHr)r"rLrMkwargsr9r&r&r'test_manual_performds z%AuthenticatorTest.test_manual_performcCshdtj|j_d|j_|j|j|jD]6}|j |gt |j t j t jfrRt |j t j r,q,q,dS)Nz,{0} -c "import sys; sys.stdout.write('foo')"z # cleanup)r?r@rAr rrr!ZperformrZcleanup isinstancerDrZHTTP01ZDNS01)r"r9r&r&r' test_cleanupns zAuthenticatorTest.test_cleanupcCs d|j_dS)Nz /bin/true)r rr,r&r&r'test_auth_hint_hooksz%AuthenticatorTest.test_auth_hint_hookcCsdSr1r&r,r&r&r'test_auth_hint_no_hooksz(AuthenticatorTest.test_auth_hint_no_hook)__name__ __module__ __qualname____doc__rr-r0r2r3rOrQrSrTrU __classcell__r&r&r$r'r s "  r __main__r<)rYr@rIZunittestrr)ZacmerZcertbotrZcertbot.compatrrZ certbot.testsrrrZTempDirTestCaser rVexitmainargv__file__r&r&r&r's