Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips
System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : fdshops ( 1003)
PHP Version : 8.2.21
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/certbot/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/certbot/tests/util.pyo
�
���_c@s}dZddlZddlmZddlmZddlZddlZddlZddlZddl	m
Z
ddlmZddl
ZyddlZWn!ek
r�ddlmZnXddlZddlZddlZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlm Z dd
l!mZ"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*e+d�Z,dd�Z-ddd�Z/de0fd��YZ1d�Z2d �Z3d!�Z4d"ej5fd#��YZ6d$e6fd%��YZ7d&�Z8d'�Z9d(�Z:d)�Z;dS(*sTest utilities.i����N(tEvent(tProcess(tdefault_backend(t
serialization(tmock(t
reload_module(t
interfaces(tutil(t
configuration(t	constants(tlock(tstorage(t
filesystem(toscGstjttjjd|��S(sPath to a test vector.ttestdata(t
pkg_resourcestresource_filenamet__name__R
tpathtjoin(tnames((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytvector_path!scGsZtjttjjd|��}y |j�jdd�j�SWnt	k
rU|SXdS(sLoad contents of a test vector.Rs
s
N(
Rtresource_stringRR
RRtdecodetreplacetencodet
ValueError(Rtdata((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytload_vector's 
cCsTtjj|�\}}|j�dkr.|S|j�dkrD|Std��dS(Ns.pems.ders1Loader could not be recognized based on extension(R
RtsplitexttlowerR(tfilenamet
loader_pemt
loader_dert_text((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt
_guess_loader5scGs;t|dtjjtjj�}tjj|t|��S(sLoad certificate.i����(R$tOpenSSLtcryptotFILETYPE_PEMt
FILETYPE_ASN1tload_certificateR(Rtloader((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt	load_cert>scGs;t|dtjjtjj�}tjj|t|��S(sLoad certificate request.i����(R$R%R&R'R(tload_certificate_requestR(RR*((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytload_csrEscGstjt|��S(s(Load ComparableX509 certificate request.(tjosetComparableX509R-(R((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytload_comparable_csrLscGsDt|dtjtj�}tj|t|�dddt���S(sLoad RSA private key.i����tpasswordtbackendN(	R$Rtload_pem_private_keytload_der_private_keyR.tComparableRSAKeyRtNoneR(RR*((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytload_rsa_private_keyQs	cGs;t|dtjjtjj�}tjj|t|��S(sLoad pyOpenSSL private key.i����(R$R%R&R'R(tload_privatekeyR(RR*((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytload_pyopenssl_private_keyYsc
s�|td� }tjj�tj�}tjj�tj|�}tjj�tj|�}x9|||fD](}tjj|�sot	j
|�qoqoWtdj|r�dnd��}xEtj
|�D]4}	tjtjj||	�tjj||	��q�WxQtjD]F}	tjtjj|dj|	��tjj|dj|	���qWtjj�||�}
tt|���<}t|
d��$}|j�fd�|D��Wd	QXWd	QX|
S(
spCreates a lineage defined by testfile.

    This creates the archive, live, and renewal directories if
    necessary and creates a simple lineage.

    :param str config_dir: path to the configuration directory
    :param str testfile: configuration file to base the lineage on

    :returns: path to the renewal conf file for the created lineage
    :rtype: str

    s.confssample-archive{}s-ects{0}1.pems{0}.pemtwc3s!|]}|jd��VqdS(tMAGICDIRN(R(t.0tline(t
config_dir(s6/usr/lib/python2.7/site-packages/certbot/tests/util.pys	<genexpr>�sN(tlenR
RRR	tRENEWAL_CONFIGS_DIRtARCHIVE_DIRtLIVE_DIRtexistsRtmakedirsRtformattlistdirtshutiltcopyfileRtALL_FOURtsymlinktopent
writelines(
R?ttestfiletectlineage_nametconf_dirtarchive_dirtlive_dirt	directorytsample_archivetkindt	conf_pathtsrctdst((R?s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytmake_lineage`s.
			!!##szope.component.getUtilitycCstj|dt�S(s;Patch zope.component.getUtility to use a special mock IDisplay.

    The mock IDisplay works like a regular mock object, except it also
    also asserts that methods are called with valid arguments.

    :param str target: path to patch

    :returns: mock zope.component.getUtility
    :rtype: mock.MagicMock

    tnew_callable(Rtpatcht_create_get_utility_mock(ttarget((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytpatch_get_utility�scCs7|r|n	tj�}t|�}tj|d|�S(sPatch zope.component.getUtility to use a special mock IDisplay.

    The mock IDisplay works like a regular mock object, except it also
    also asserts that methods are called with valid arguments.

    The `message` argument passed to the IDisplay methods is passed to
    stdout's write method.

    :param str target: path to patch
    :param object stdout: object to write standard output to; it is
        expected to have a `write` method

    :returns: mock zope.component.getUtility
    :rtype: mock.MagicMock

    tnew(tsixtStringIOt$_create_get_utility_mock_with_stdoutRR\(R^tstdouttfreezable_mock((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytpatch_get_utility_with_stdout�st
FreezableMockcBsJeZdZedejjd�Zd�Z	d�Z
d�Zd�ZRS(s�Mock object with the ability to freeze attributes.

    This class works like a regular mock.MagicMock object, except
    attributes and behavior set before the object is frozen cannot
    be changed during tests.

    If a func argument is provided to the constructor, this function
    is called first when an instance of FreezableMock is called,
    followed by the usual behavior defined by MagicMock. The return
    value of func is ignored.

    cCs^|rt�ndh|_||_tj�|_|tjjkrQ||_n||_	dS(Ntfreeze(
tsett_frozen_sett_funcRt	MagicMockt_mocktsentineltDEFAULTtreturn_valuet_frozen(tselftfrozentfuncRp((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt__init__�s	cCs
t|_dS(s)Freeze object preventing further changes.N(tTrueRq(Rr((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyRh�scOs2|jdk	r"|j||�n|j||�S(N(RkR6Rm(Rrtargstkwargs((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt__call__�scCs�|dkr8ytj||�SWq�tk
r4tSXni|dkr]ttj|d�|�S|dksx||jkr�tj||�Sttj|d�|�SdS(NRqRptside_effectRmRj(sreturn_valueRz(tobjectt__getattribute__tAttributeErrortFalsetgetattrRj(Rrtname((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyR|�s
cCs�|jr>||jkr+td|��nt|j||�S|dkr]|jj|�n|dkr|t|j||�Stj|||�S(s� Before it is frozen, attributes are set on the FreezableMock
        instance and added to the _frozen_set. Attributes in the _frozen_set
        cannot be changed after the FreezableMock is frozen. In this case,
        they are set on the underlying _mock.

        In cases of return_value and side_effect, these attributes are always
        passed through to the instance's _mock and added to the _frozen_set
        before the object is frozen.

        sCannot change frozen attribute RjRpRz(sreturn_valuesside_effect(RqRjR}tsetattrRmtaddR{t__setattr__(RrR�tvalue((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyR��s	N(
Rt
__module__t__doc__R~R6RRnRoRuRhRyR|R�(((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyRg�s			
cCstt�}xKtjj�D]:}|dkrtdtdt�}t|||�qqW|j�tdtd|�S(NtnotificationRsRtRp(RgRtIDisplayRRvt_assert_valid_callR�Rh(tdisplayR�tfrozen_mock((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyR]�s	
cs��fd���fd�}t�}xptjj�D]_}|dkrqtdtd��}t|||�q7tdtd|�}t|||�q7W|j�tdtd|�S(Ncs|r�j|�ndS(s$Write to message to stdout.
        N(twrite(tmessagetunused_argst
unused_kwargs(Rd(s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt
_write_msgscst||��||�dS(s5
        Mock function for IDisplay methods.
        N(R�(RwRx(R�(s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytmock_method	s
R�RsRtRp(RgRR�RRvR�Rh(RdR�R�R�R�((R�Rds6/usr/lib/python2.7/site-packages/certbot/tests/util.pyRcs			
cOsy|r|dn|dg}i}|jdd�|d<|jdd�|d<|jdt�|d<tj||�dS(NiR�tdefaulttcli_flagtforce_interactive(tgetR6R~tdisplay_utiltassert_valid_call(RwRxtassert_argst
assert_kwargs((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyR�!stTempDirTestCasecBs eZdZd�Zd�ZRS(sBBase test class which sets up and tears down a temporary directorycCstj�|_dS(sExecute before testN(ttempfiletmkdtempttempdir(Rr((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytsetUp/scCs7tj�gtj�_tj�tj|j�dS(sExecute after testN(	tloggingtshutdownt	getLoggerthandlersRt_release_locksRHtrmtreeR�(Rr((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyttearDown3s

(RR�R�R�R�(((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyR�,s	tConfigTestCasecBseZdZd�ZRS(s2Test class which sets up a NamespaceConfig object.cCs�tt|�j�tjtjtj��|_	d|j	_
tjj
|jd�|j	_tjj
|jd�|j	_tjj
|jd�|j	_tjd|j	_tjd|j	_tjd|j	_d|j	_dS(Ntcertonlytconfigtworktlogstauth_cert_pathtauth_chain_pathshttps://example.com(tsuperR�R�RtNamespaceConfigRRlR	tCLI_DEFAULTSR�tverbR
RRR�R?twork_dirtlogs_dirt	cert_pathtfullchain_patht
chain_pathtserver(Rr((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyR�Ds(RR�R�R�(((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyR�BscCsStjj|�r$tj|�}ntj|�}z|j�Wd|j�XdS(s�
    Acquire a file lock on given path, then wait to release it. This worker is coordinated
    using events to signal when the lock should be acquired and released.
    :param multiprocessing.Event event_in: event object to signal when to release the lock
    :param multiprocessing.Event event_out: event object to signal when the lock is acquired
    :param path: the path to lock
    N(R
RtisdirR
tlock_dirtLockFileRitrelease(tevent_int	event_outRtmy_lock((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt_handle_lockSs
cCsitt�t�}t�}tdtd|||f�}|j�|�|j�|jdd�dS(s�
    Grab a lock on path_to_lock from a foreign process then execute the callback.
    :param callable callback: object to call after acquiring the lock
    :param str path_to_lock: path to file or directory to lock
    R^Rwttimeouti
N(RRRRR�tstartRiR(tcallbacktpath_to_lockt
emit_eventt
receive_eventtprocess((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt
lock_and_callfs
		

cs�fd�}|S(sFDecorator to skip permanently a test on Windows. A reason is required.cstjtjdk��|�S(sWrapped versiontwin32(tunittesttskipIftsystplatform(tfunction(treason(s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytwrapper�s((R�R�((R�s6/usr/lib/python2.7/site-packages/certbot/tests/util.pytskip_on_windows�scCstjjtj�|�S(s�
    Return the given path joined to the tempdir path for the current platform
    Eg.: 'cert' => /tmp/cert (Linux) or 'C:\Users\currentuser\AppData\Temp\cert' (Windows)
    (R
RRR�t
gettempdir(R((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt	temp_join�s(<R�R�tmultiprocessingRRRHR�R�R�tcryptography.hazmat.backendsRtcryptography.hazmat.primitivesRtjosepyR.RtImportErrorR%RRat	six.movesRtcertbotRRtcertbot._internalRR	R
Rtcertbot.compatRR
tcertbot.displayR�RRR$R+R-R0R7R9R~RZR_R6RfR{RgR]RcR�tTestCaseR�R�R�R�R�R�(((s6/usr/lib/python2.7/site-packages/certbot/tests/util.pyt<module>sb
									,D						

Spamworldpro Mini