a }|g&@sdZddlZddlmZddlZddlmZddlZddlmZddlm Z ddl m Z ddl mZdd lmZdd lmZGd d d ejZGd d d ejZGdddejZGdddejZGdddejZedkreeejddegdS)z'Tests for letsencrypt.plugins.selectionN)List)mock)errors) interfaces)obj)PluginsRegistry)utilc@s0eZdZdZddZddZddZdd Zd S) ConveniencePickPluginTestz5Tests for certbot._internal.plugins.selection.pick_*.cCs^t}t}t}td}d|_Wdn1s>0Y||||d|dS)Nz/certbot._internal.plugins.selection.pick_pluginfoo Question?)rMockpatch return_valueassert_called_once_with)selfZfunifacesconfigdefaultpluginsZmock_prR/usr/lib/python3.9/site-packages/certbot/_internal/tests/plugins/selection_test.py_tests  zConveniencePickPluginTest._testcCs ddlm}||tjfdS)Nr)pick_authenticator)#certbot._internal.plugins.selectionrrr Authenticator)rrrrrtest_authenticators z,ConveniencePickPluginTest.test_authenticatorcCs ddlm}||tjfdS)Nr)pick_installer)rrrr Installer)rrrrrtest_installer#s z(ConveniencePickPluginTest.test_installercCs$ddlm}||tjtjfdS)Nr)pick_configurator)rrrrrr)rrrrrtest_configurator's  z+ConveniencePickPluginTest.test_configuratorN)__name__ __module__ __qualname____doc__rrrr rrrrr s  r c@s`eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ dS)PickPluginTestz:Tests for certbot._internal.plugins.selection.pick_plugin.cCs.tjdd|_d|_t|_d|_g|_dS)NF)Znoninteractive_moder )rr rr MagicMockregquestionrrrrrsetUp0s  zPickPluginTest.setUpcCs&ddlm}||j|j|j|j|jS)Nr) pick_plugin)rr+rrr'r(r)rr+rrr_call7s zPickPluginTest._callcCsd|_|dSNr )rr,r)rrrtest_default_provided<sz$PickPluginTest.test_default_providedcCs |dSN)r,r)rrrtest_no_defaultAszPickPluginTest.test_no_defaultcCsdSr/rr)rrrtest_no_candidateEsz PickPluginTest.test_no_candidatecCs0t}d|j_d|_d|i|jj_dS)Nr Fbar rr&initr misconfiguredr'visibler availabler plugin_eprrr test_singleHs zPickPluginTest.test_singlecCs0t}d|j_d|_d|i|jj_dS)Nr Tr2r3r8rrrtest_single_misconfiguredQs z(PickPluginTest.test_single_misconfiguredcCsnt}d|j_||d|jj_td}||_Wdn1sN0Y| ||g|j dS)Nr r2Zbaz1certbot._internal.plugins.selection.choose_plugin) rr&r4rr'r6rr7r rr()rr9 mock_chooserrr test_multipleZs  zPickPluginTest.test_multiplecCsLddd|jj_td}d|_Wdn1s>0YdS)Nr<r=)r'r6rr7rrr )rr>rrrtest_choose_plugin_nonegs  z&PickPluginTest.test_choose_plugin_nonecCs$d|_t}||jj_|dSr-)rrr&r'filterrr,)rZfilteredrrrtest_default_must_be_filteredqs  z,PickPluginTest.test_default_must_be_filteredN)r!r"r#r$r*r,r.r0r1r:r;r?r@rBrrrrr%-s    r%c@sPeZdZdZddZddZeddZedd Z ed d Z d S) ChoosePluginTestzz2GetUnpreparedInstallerTest.setUp..rFcSs|dkSNrFrrYrrrrZr[)rWrF) superr*rr mock_apache_fail_ep check_nameZmock_apache_epr&Zmock_apache_pluginr4rrrr) __class__rrr*s     z GetUnpreparedInstallerTest.setUpcCsddlm}||j|jS)Nr)get_unprepared_installer)rrbrr)rrbrrrr,s z GetUnpreparedInstallerTest._callcCs d|j_dSr/)r configuratorr)rrrtest_no_installer_definedsz4GetUnpreparedInstallerTest.test_no_installer_definedcCsJd|j_ti|_ttj|Wdn1s<0YdSr\) rrcrrpytestraisesrPluginSelectionErrorr,r)rrrtest_no_available_installerss z7GetUnpreparedInstallerTest.test_no_available_installerscCsd|j_|}dSr\)rrcr,)rZ installerrrrtest_get_pluginsz*GetUnpreparedInstallerTest.test_get_plugincCsLd|j_dd|j_ttj|Wdn1s>0YdS)NrFcSs|dkSr\rrYrrrrZr[zNGetUnpreparedInstallerTest.test_multiple_installers_returned..) rrcr^r_rerfrrgr,r)rrr!test_multiple_installers_returneds z.F)rr r_r&rKr4rr5)rrKZmock_epZ mock_pluginrrYr_setupMockPluginsz.TestChooseConfiguratorPlugins._setupMockPlugincCs*ddlm}ddlm}||j|S)Nr) configuration)cli)certbotroZcertbot._internalrpZprepare_and_parse_argsrsplit)rargsrorprrr _parseArgss  z(TestChooseConfiguratorPlugins._parseArgscCs(t|d|d|dd|_dS)NnginxrFmanual)rurFrv)rrnrr)rrrr*s z#TestChooseConfiguratorPlugins.setUpcCs ddlm}||||jdS)Nr)choose_configurator_pluginsZcertonly)rrwrtr)rrsrwrrr _runWithArgss z*TestChooseConfiguratorPlugins._runWithArgscCs |d\}}|d\}}dS)Nzcertonly --nginxzcertonly --apacherxrinstZauthrrr test_noninteractive_configuratorsz>TestChooseConfiguratorPlugins.test_noninteractive_configuratorcCsX|d\}}|d\}}|d\}}|d\}}|d\}}|d\}}dS)Nzcertonly -a nginx -i nginxzcertonly -a apache -i apachezcertonly -a nginxzcertonly -a nginx -i nonezcertonly -a apachezcertonly -a apache -i noneryrzrrrtest_noninteractive_inst_argsz:TestChooseConfiguratorPlugins.test_noninteractive_inst_argN) r!r"r#r$rnrtr*rxr|r}rrrrrls  rl__main__rM) r$rItypingrZunittestrrerqrrZcertbot._internal.displayrrHZcertbot._internal.plugins.discorZcertbot.displayrrOZ certbot.testsrUZTestCaser r%rCZConfigTestCaserVrlr!exitmainargv__file__rrrrs$        M*-B