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_*.cCstt}t}t}td,}d|_d||||dks@JWdn1sT0Y||||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 4 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._callcCs$d|_|d|jjjks JdSNr )rr,r'filter call_countr)rrrtest_default_provided<sz$PickPluginTest.test_default_providedcCs"|d|jjjksJdSNr.)r,r'visiblerr0r)rrrtest_no_defaultAszPickPluginTest.test_no_defaultcCs|dusJdSN)r,r)rrrtest_no_candidateEsz PickPluginTest.test_no_candidatecCs@t}d|j_d|_d|i|jj_d| ksr?rCrDrErrrrr%-s    r%c@sPeZdZdZddZddZeddZedd Z ed d Z d S) ChoosePluginTestzJdS)Nrr.) display_utilOKmenu side_effectrOr,Z notificationr0rZ mock_utilrrrtest_selections  zChoosePluginTest.test_selectioncCs(tjdfg|j_|j|ks$JdSr2)rQrRrSrTrOr,rUrrrtest_more_infos zChoosePluginTest.test_more_infocCs$tjdf|j_|dus JdS)Nr)rQZCANCELrSrr,rUrrrtest_no_choiceszChoosePluginTest.test_no_choiceN) r!r"r#r$r*r, test_utilZpatch_display_utilrVrWrXrrrrrFzs  rFcsHeZdZdZfddZddZddZdd Zd d Zd d Z Z S)GetUnpreparedInstallerTestzGTests for certbot._internal.plugins.selection.get_unprepared_installer.cslttjdd|_dd|j_tjdd|_dd|j_t|_|j|jj _ t |j|jd|_ dS)NafailrHcSs|dkS)Nr[rrNrrrz2GetUnpreparedInstallerTest.setUp..rIcSs|dkSNrIrr]rrrr^r_)r[rI) superr*rr mock_apache_fail_ep check_nameZmock_apache_epr&mock_apache_pluginr9rrrr) __class__rrr*s     z GetUnpreparedInstallerTest.setUpcCsddlm}||j|jS)Nr)get_unprepared_installer)rrgrr)rrgrrrr,s z GetUnpreparedInstallerTest._callcCsd|j_|dusJdSr5)r configuratorr,r)rrrtest_no_installer_definedsz4GetUnpreparedInstallerTest.test_no_installer_definedcCsJd|j_ti|_ttj|Wdn1s<0YdSr`) rrhrrpytestraisesrPluginSelectionErrorr,r)rrrtest_no_available_installerss z7GetUnpreparedInstallerTest.test_no_available_installerscCs"d|j_|}||jusJdSr`)rrhr,rd)rZ installerrrrtest_get_pluginsz*GetUnpreparedInstallerTest.test_get_plugincCsLd|j_dd|j_ttj|Wdn1s>0YdS)NrIcSs|dkSr`rr]rrrr^r_zNGetUnpreparedInstallerTest.test_multiple_installers_returned..) rrhrbrcrjrkrrlr,r)rrr!test_multiple_installers_returneds z.F)rr rcr&rNr9rr:)rrNZmock_epZ mock_pluginrr]r_setupMockPluginsz.TestChooseConfiguratorPlugins._setupMockPlugincCs*ddlm}ddlm}||j|S)Nr) configuration)cli)certbotrtZcertbot._internalruZprepare_and_parse_argsrsplit)rargsrtrurrr _parseArgss  z(TestChooseConfiguratorPlugins._parseArgscCs(t|d|d|dd|_dS)NnginxrImanual)rzrIr{)rrsrr)rrrr*s z#TestChooseConfiguratorPlugins.setUpcCs ddlm}||||jdS)Nr)choose_configurator_pluginsZcertonly)rr|ryr)rrxr|rrr _runWithArgss z*TestChooseConfiguratorPlugins._runWithArgscCsX|d\}}|jdksJ|jdks*J|d\}}|jdksFJ|jdksTJdS)Nzcertonly --nginxrzzcertonly --apacherIr}rNrinstZauthrrr test_noninteractive_configurators z>TestChooseConfiguratorPlugins.test_noninteractive_configuratorcCs|d\}}|jdksJ|jdks*J|d\}}|jdksFJ|jdksTJ|d\}}|dusnJ|jdks|J|d\}}|dusJ|jdksJ|d\}}|dusJ|jdksJ|d\}}|dusJ|jdksJdS) Nzcertonly -a nginx -i nginxrzzcertonly -a apache -i apacherIzcertonly -a nginxzcertonly -a nginx -i nonezcertonly -a apachezcertonly -a apache -i noner~rrrrtest_noninteractive_inst_args$    z:TestChooseConfiguratorPlugins.test_noninteractive_inst_argN) r!r"r#r$rsryr*r}rrrrrrrqs  rq__main__r.) r$rLtypingrZunittestrrjrvrrZcertbot._internal.displayrrKZcertbot._internal.plugins.discorZcertbot.displayrrQZ certbot.testsrYZTestCaser r%rFZConfigTestCaserZrqr!exitmainargv__file__rrrrs$        M*-B