a }|g@sdZddlZddlZddlZddlmZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddlmmZejedZGdd d ejZGd d d eZGd d d eZGdddejZedkreeejdde gdS)z Tests for certbot._internal.eff.N)mock)messages)account) constantszrsa512_key.pemcs eZdZdZfddZZS)SubscriptionTestz&Abstract class for subscription tests.csbttjtjdtddttjjdt j ddddddt j d d d |_d |j _ d|j _dS) Nhi)ZuribodyZnew_authzr_uriztest.certbot.orgi )Ztzinfo)Z creation_hostZ creation_dt)Zregrkeymetacertbot@example.org)supersetUprZAccountrZRegistrationResourceZ Registration_KEYZMetadatetimepytzZUTCconfigemail eff_emailself __class__D/usr/lib/python3.9/site-packages/certbot/_internal/tests/eff_test.pyrs   zSubscriptionTest.setUp)__name__ __module__ __qualname____doc__r __classcell__rrrrrsrc@seZdZdZddZeedddZ eddZ ed d Z ed d Z ed dZ ddZddZdS)PrepareSubscriptionTestz5Tests for certbot._internal.eff.prepare_subscription.cCsddlm}||j|jdS)Nr)prepare_subscription)certbot._internal.effr$rr)rr$rrr_call's zPrepareSubscriptionTest._call)certbot._internal.eff.display_util.notifycCsLd|j_d|j_||jdd}d}||vs6J|jjjdusHJdS)NTrz,because you didn't provide an e-mail address)rrrr& call_argsrrregister_to_eff)r mock_notifymock_get_utilityactual expected_partrrr test_failure+s z$PrepareSubscriptionTest.test_failurecCs0d|j_||||jjjdus,JdSNF)rrr&_assert_no_get_utility_callsrrr)rr+rrr&test_will_not_subscribe_with_no_prompt6s z>PrepareSubscriptionTest.test_will_not_subscribe_with_no_promptcCs4d|j_||||jjj|jjks0JdSNT)rrr&r0rrr)rr1rrr"test_will_subscribe_with_no_prompt=s z:PrepareSubscriptionTest.test_will_subscribe_with_no_promptcCs@d|j_||jjr J|||jjjdusrTrrrrQs    zSubscribeTest._check_post_callcCs.d|jd<||}d}||vs*JdS)NFrJz2because your e-mail address appears to be invalid.)rLr&_get_reported_messagerr,r-rrrtest_bad_statuss  zSubscribeTest.test_bad_statuscCs:d|j_tjj|jj_||}d}||vs6JdS)NFZbecause) rMrKrequests exceptionsZ HTTPErrorZraise_for_status side_effectr&rU)rr,Zunexpected_partrrr test_not_oks zSubscribeTest.test_not_okcCs0t|jj_||}d}||vs,JdSNZproblem) ValueErrorrMrLrZr&rUrVrrrtest_response_not_jsons  z$SubscribeTest.test_response_not_jsoncCs.|j||}d}||vs*JdSr\)rLclearr&rUrVrrr)test_response_json_missing_status_elements  z7SubscribeTest.test_response_json_missing_status_elementcCs|jjs J|jjddS)Nr)r*r8r(rrrrrUs z#SubscribeTest._get_reported_messagecCs||jdusJdSr/rDr1rrrrHszSubscribeTest.test_subscribeN)rrr r!rrrAr&rQrWr[r^r`rUr?r@rHrrrrrIts   rI__main__rS)!r!rsysZunittestrZjosepyZpytestrrXZacmerZcertbot._internalrrZcertbot.tests.utilZtestsutilr?ZJWKRSAloadZ load_vectorrZConfigTestCaserr#rBZTestCaserIrexitmainargv__file__rrrrs&    <C