Your IP : 216.73.216.172


Current Path : /lib/python3/dist-packages/zope/component/tests/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/zope/component/tests/__pycache__/test_security.cpython-38.pyc

U

,�W�$�@srdZddlZGdd�dej�ZGdd�dej�ZGdd�dej�ZGd	d
�d
ej�ZGdd�dej�Zd
d�ZdS)zPure-Python hookable tests
�Nc@s$eZdZdd�Zdd�Zdd�ZdS)�PermissionProxyTestscCsddlm}|S)Nr)�PermissionProxy)�zope.component.securityr)�selfr�r�D/usr/lib/python3/dist-packages/zope/component/tests/test_security.py�_getTargetClasssz$PermissionProxyTests._getTargetClasscCs|��|�S�N)r)r�wrappedrrr�_makeOneszPermissionProxyTests._makeOnecCstddlm}ddlm}ddlm}Gdd�d|�}||�Gdd�dt��}|�}|�|�}|�||�||��dS)	Nr��	Interface)�implementer)�
providedByc@seZdZdS)zGPermissionProxyTests.test_proxy_delegates___provided_by__.<locals>.IFooN��__name__�
__module__�__qualname__rrrr�IFoo src@seZdZdS)zFPermissionProxyTests.test_proxy_delegates___provided_by__.<locals>.FooNrrrrr�Foo"sr)�zope.interfacer
rr�objectr�assertEqual)rr
rrrr�foo�proxyrrr�$test_proxy_delegates___provided_by__s
z9PermissionProxyTests.test_proxy_delegates___provided_by__N)rrrrrrrrrrrsrc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
Test__checkercOsddlm}|||�S)Nr)�_checker)rr)r�args�kwrrrr�_callFUT,szTest__checker._callFUTcCs@ddlm}|�t�ddd�}|�|jd|i�|�|j�dS)Nr��
CheckerPublic�zope.Publicr�__call__)�zope.security.checkerr"r rr�get_permissions�assertFalse�set_permissions)rr"�checkerrrr�0test_no_allowed_attributes_no_allowed_interfaces0sz>Test__checker.test_no_allowed_attributes_no_allowed_interfacescCshddlm}Gdd�d|�}Gdd�d|�}|�t�d||fd�}|�|jdddd	��|�|j�dS)
Nrrc@seZdZdd�Zdd�ZdS)z5Test__checker.test_w_allowed_interfaces.<locals>.IFoocSsdSr	r�rrrr�bar9sz9Test__checker.test_w_allowed_interfaces.<locals>.IFoo.barcSsdSr	rr+rrr�baz;sz9Test__checker.test_w_allowed_interfaces.<locals>.IFoo.bazN)rrrr,r-rrrrr8src@seZdZdd�ZdS)z6Test__checker.test_w_allowed_interfaces.<locals>.ISpamcSsdSr	rr+rrr�qux>sz:Test__checker.test_w_allowed_interfaces.<locals>.ISpam.quxN)rrrr.rrrr�ISpam=sr/�testingr)r,r-r.)rr
r rrr&r'r()rr
rr/r)rrr�test_w_allowed_interfaces6s
�z'Test__checker.test_w_allowed_interfacescCs6|�t�ddd�}|�|jddd��|�|j�dS)Nr0r)rr,)r rrr&r'r()rr)rrr�test_w_allowed_attributesEs
�z'Test__checker.test_w_allowed_attributesN)rrrr r*r1r2rrrrr*src@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�Test_proxifycOsddlm}|||�S)Nr)�proxify)rr4)rrrr4rrrr NszTest_proxify._callFUTcCsGdd�dt�}|�S)Nc@seZdZdd�ZdS)z+Test_proxify._makeContext.<locals>._ContextcSsdSr	rr+rrrr,Tsz/Test_proxify._makeContext.<locals>._Context.barN�rrrr,rrrr�_ContextSsr6)r)rr6rrr�_makeContextRszTest_proxify._makeContextcCs |��}|jt|j|dd�dS)Nr0)�
permission)r7�assertRaises�
ValueErrorr )r�ctxrrr�test_no_checker_no_providesXsz(Test_proxify.test_no_checker_no_providescCs<ddlm}Gdd�d|�}|��}|jt|j||d�dS)Nrrc@seZdZdd�ZdS)z8Test_proxify.test_no_checker_no_permission.<locals>.IFoocSsdSr	rr+rrrr,_sz<Test_proxify.test_no_checker_no_permission.<locals>.IFoo.barNr5rrrrr^sr)�provides)rr
r7r9r:r )rr
rr;rrr�test_no_checker_no_permission\sz*Test_proxify.test_no_checker_no_permissioncCs�ddlm}ddlm}ddlm}Gdd�d|�}|��}|j||dd�}|�||�|k�|j	}|�
|jd	|i�|�|j
�dS)
Nrrr!��getProxiedObjectc@seZdZdd�ZdS)zKTest_proxify.test_no_checker_w_provides_and_permission_public.<locals>.IFoocSsdSr	rr+rrrr,iszOTest_proxify.test_no_checker_w_provides_and_permission_public.<locals>.IFoo.barNr5rrrrrhsrr#�r=r8r,)rr
r%r"�
zope.proxyr@r7r �
assertTrue�__Security_checker__rr&r'r()rr
r"r@rr;rr)rrr�0test_no_checker_w_provides_and_permission_publicdsz=Test_proxify.test_no_checker_w_provides_and_permission_publiccCszddlm}ddlm}Gdd�d|�}|��}|j||dd�}|�||�|k�|j}|�|j	ddi�|�
|j�dS)	Nrrr?c@seZdZdd�ZdS)zNTest_proxify.test_no_checker_w_provides_and_permission_protected.<locals>.IFoocSsdSr	rr+rrrr,vszRTest_proxify.test_no_checker_w_provides_and_permission_protected.<locals>.IFoo.barNr5rrrrrusrr0rAr,)rr
rBr@r7r rCrDrr&r'r()rr
r@rr;rr)rrr�3test_no_checker_w_provides_and_permission_protectedrsz@Test_proxify.test_no_checker_w_provides_and_permission_protectedcCsLddlm}t�}|��}|�||�}|�||�|k�|�|j|k�dS)Nrr?)rBr@rr7r rCrD)rr@Z_CHECKERr;rrrr�test_w_checkerszTest_proxify.test_w_checkerN)
rrrr r7r<r>rErFrGrrrrr3Ls
r3c@s$eZdZdd�Zdd�Zdd�ZdS)�Test_protectedFactorycOsddlm}|||�S)Nr)�protectedFactory)rrI)rrrrIrrrr �szTest_protectedFactory._callFUTcCstddlm}ddlm}Gdd�d|�}Gdd�dt�}|�||d�}|�|j|k�|�}|�|j	j
d	|i�dS)
Nrrr!c@seZdZdd�ZdS)zCTest_protectedFactory.test_public_not_already_proxied.<locals>.IFoocSsdSr	rr+rrrr,�szGTest_protectedFactory.test_public_not_already_proxied.<locals>.IFoo.barNr5rrrrr�src@seZdZdd�ZdS)zGTest_protectedFactory.test_public_not_already_proxied.<locals>._FactorycSsdSr	rr+rrrr,�szKTest_protectedFactory.test_public_not_already_proxied.<locals>._Factory.barNr5rrrr�_Factory�srJr#r,)rr
r%r"rr rC�factoryrrDr&)rr
r"rrJ�	protectedrrrr�test_public_not_already_proxied�s
�z5Test_protectedFactory.test_public_not_already_proxiedcCsrddlm}ddlm}Gdd�d|�}Gdd�dt�}|�||d�}|�|j|k�|�}|�||�d	g�dS)
Nrr)�getTestProxyItemsc@seZdZdd�ZdS)zBTest_protectedFactory.test_nonpublic_already_proxied.<locals>.IFoocSsdSr	rr+rrrr,�szFTest_protectedFactory.test_nonpublic_already_proxied.<locals>.IFoo.barNr5rrrrr�src@seZdZdZdd�ZdS)zFTest_protectedFactory.test_nonpublic_already_proxied.<locals>._Factory)ZonecSsdSr	rr+rrrr,�szJTest_protectedFactory.test_nonpublic_already_proxied.<locals>._Factory.barN)rrr�	__slots__r,rrrrrJ�srJr0)r,r0)	rr
Zzope.security.proxyrNrr rCrKr)rr
rNrrJrLrrrr�test_nonpublic_already_proxied�sz4Test_protectedFactory.test_nonpublic_already_proxiedN)rrrr rMrPrrrrrH�srHc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�Test_securityAdapterFactorycOsddlm}|||�S)Nr)�securityAdapterFactory)rrR)rrrrRrrrr �sz$Test_securityAdapterFactory._callFUTcCs.Gdd�dt�}|�|�|ddd�|k�dS)Nc@seZdZdS)zVTest_securityAdapterFactory.test_no_permission_untrusted_no_location.<locals>._FactoryNrrrrrrJ�srJF�rrCr �rrJrrr�(test_no_permission_untrusted_no_location�s�zDTest_securityAdapterFactory.test_no_permission_untrusted_no_locationcCs.Gdd�dt�}|�|�|ddd�|k�dS)Nc@seZdZdS)zOTest_securityAdapterFactory.test_public_untrusted_no_location.<locals>._FactoryNrrrrrrJ�srJr#FrSrTrrr�!test_public_untrusted_no_location�s�z=Test_securityAdapterFactory.test_public_untrusted_no_locationcCs:ddlm}Gdd�dt�}|�|�||dd�|k�dS)Nrr!c@seZdZdS)zVTest_securityAdapterFactory.test_CheckerPublic_untrusted_no_location.<locals>._FactoryNrrrrrrJ�srJF)r%r"rrCr )rr"rJrrr�(test_CheckerPublic_untrusted_no_location�s
�zDTest_securityAdapterFactory.test_CheckerPublic_untrusted_no_locationcCs@ddlm}Gdd�dt�}|�|ddd�}|�t||��dS)Nr)�LocatingUntrustedAdapterFactoryc@seZdZdS)zRTest_securityAdapterFactory.test_protected_untrusted_no_location.<locals>._FactoryNrrrrrrJ�srJr0F)�zope.security.adapterrXrr rC�
isinstance)rrXrJrrrr�$test_protected_untrusted_no_location�sz@Test_securityAdapterFactory.test_protected_untrusted_no_locationcCs@ddlm}Gdd�dt�}|�|ddd�}|�t||��dS)Nr��LocatingTrustedAdapterFactoryc@seZdZdS)zTTest_securityAdapterFactory.test_no_permission_trusted_no_location.<locals>._FactoryNrrrrrrJ�srJFT�rYr]rr rCrZ�rr]rJrrrr�&test_no_permission_trusted_no_location�szBTest_securityAdapterFactory.test_no_permission_trusted_no_locationcCs@ddlm}Gdd�dt�}|�|ddd�}|�t||��dS)Nrr\c@seZdZdS)zMTest_securityAdapterFactory.test_public_trusted_no_location.<locals>._FactoryNrrrrrrJ�srJr#FTr^r_rrr�test_public_trusted_no_location�sz;Test_securityAdapterFactory.test_public_trusted_no_locationcCsLddlm}ddlm}Gdd�dt�}|�||dd�}|�t||��dS)Nrr\r!c@seZdZdS)zTTest_securityAdapterFactory.test_CheckerPublic_trusted_no_location.<locals>._FactoryNrrrrrrJ�srJFT)rYr]r%r"rr rCrZ)rr]r"rJrrrr�&test_CheckerPublic_trusted_no_location�s
zBTest_securityAdapterFactory.test_CheckerPublic_trusted_no_locationcCs@ddlm}Gdd�dt�}|�|ddd�}|�t||��dS)Nrr\c@seZdZdS)zPTest_securityAdapterFactory.test_protected_trusted_no_location.<locals>._FactoryNrrrrrrJ�srJr0FTr^r_rrr�"test_protected_trusted_no_location�sz>Test_securityAdapterFactory.test_protected_trusted_no_locationcCs@ddlm}Gdd�dt�}|�|ddd�}|�t||��dS)Nrr\c@seZdZdS)zOTest_securityAdapterFactory.test_protected_trusted_w_location.<locals>._FactoryNrrrrrrJ�srJr0Tr^r_rrr�!test_protected_trusted_w_location�sz=Test_securityAdapterFactory.test_protected_trusted_w_locationN)
rrrr rUrVrWr[r`rarbrcrdrrrrrQ�srQc	Cs2t�t�t�t�t�t�t�t�t�t�t�f�Sr	)�unittestZ	TestSuiteZ	makeSuiterrr3rHrQrrrr�
test_suite�s�rf)	�__doc__reZTestCaserrr3rHrQrfrrrr�<module>s"<%E