3 ,W$@srdZddlZGdddejZGdddejZGdddejZGd d d ejZGd d d ejZd dZdS)zPure-Python hookable tests Nc@s$eZdZddZddZddZdS)PermissionProxyTestscCsddlm}|S)Nr)PermissionProxy)zope.component.securityr)selfrr#/usr/lib/python3.6/test_security.py_getTargetClasss z$PermissionProxyTests._getTargetClasscCs |j|S)N)r)rwrappedrrr_makeOneszPermissionProxyTests._makeOnecCstddlm}ddlm}ddlm}Gddd|}||Gdddt}|}|j|}|j||||dS) Nr) Interface) implementer) providedByc@s eZdZdS)zGPermissionProxyTests.test_proxy_delegates___provided_by__..IFooN)__name__ __module__ __qualname__rrrrIFoo src@s eZdZdS)zFPermissionProxyTests.test_proxy_delegates___provided_by__..FooN)rrrrrrrFoo"sr)zope.interfacer r r objectr assertEqual)rr r r rrfooproxyrrr$test_proxy_delegates___provided_by__s    z9PermissionProxyTests.test_proxy_delegates___provided_by__N)rrrrr rrrrrrsrc@s,eZdZddZddZddZddZd S) Test__checkercOsddlm}|||S)Nr)_checker)rr)rargskwrrrr_callFUT,s zTest__checker._callFUTcCs@ddlm}|jtdff}|j|jd|i|j|jdS)Nr) CheckerPublicz zope.Public__call__)zope.security.checkerrrrrget_permissions assertFalseset_permissions)rrcheckerrrr0test_no_allowed_attributes_no_allowed_interfaces0s z>Test__checker.test_no_allowed_attributes_no_allowed_interfacescCshddlm}Gddd|}Gddd|}|jtd||ff}|j|jdddd|j|jdS) Nr)r c@seZdZddZddZdS)z5Test__checker.test_w_allowed_interfaces..IFoocSsdS)Nr)rrrrbar9sz9Test__checker.test_w_allowed_interfaces..IFoo.barcSsdS)Nr)rrrrbaz;sz9Test__checker.test_w_allowed_interfaces..IFoo.bazN)rrrr&r'rrrrr8src@seZdZddZdS)z6Test__checker.test_w_allowed_interfaces..ISpamcSsdS)Nr)rrrrqux>sz:Test__checker.test_w_allowed_interfaces..ISpam.quxN)rrrr(rrrrISpam=sr)testing)r&r'r()rr rrrr!r"r#)rr rr)r$rrrtest_w_allowed_interfaces6s z'Test__checker.test_w_allowed_interfacescCs6|jtdfd}|j|jddd|j|jdS)Nr*rr&)rr&)rr&)rrrr!r"r#)rr$rrrtest_w_allowed_attributesEs z'Test__checker.test_w_allowed_attributesN)rrrrr%r+r,rrrrr*src@sDeZdZddZddZddZddZd d Zd d Zd dZ dS) Test_proxifycOsddlm}|||S)Nr)proxify)rr.)rrrr.rrrrNs zTest_proxify._callFUTcCsGdddt}|S)Nc@seZdZddZdS)z+Test_proxify._makeContext.._ContextcSsdS)Nr)rrrrr&Tsz/Test_proxify._makeContext.._Context.barN)rrrr&rrrr_ContextSsr/)r)rr/rrr _makeContextRszTest_proxify._makeContextcCs |j}|jt|j|dddS)Nr*) permission)r0 assertRaises ValueErrorr)rctxrrrtest_no_checker_no_providesXsz(Test_proxify.test_no_checker_no_providescCs<ddlm}Gddd|}|j}|jt|j||ddS)Nr)r c@seZdZddZdS)z8Test_proxify.test_no_checker_no_permission..IFoocSsdS)Nr)rrrrr&_sz.IFoo.barN)rrrr&rrrrr^sr)provides)rr r0r2r3r)rr rr4rrrtest_no_checker_no_permission\s z*Test_proxify.test_no_checker_no_permissioncCsddlm}ddlm}ddlm}Gddd|}|j}|j||dd}|j|||k|j }|j |j d |i|j |j dS) Nr)r )r)getProxiedObjectc@seZdZddZdS)zKTest_proxify.test_no_checker_w_provides_and_permission_public..IFoocSsdS)Nr)rrrrr&iszOTest_proxify.test_no_checker_w_provides_and_permission_public..IFoo.barN)rrrr&rrrrrhsrz zope.Public)r6r1r&)rr r r zope.proxyr8r0r assertTrue__Security_checker__rr!r"r#)rr rr8rr4rr$rrr0test_no_checker_w_provides_and_permission_publicds   z=Test_proxify.test_no_checker_w_provides_and_permission_publiccCszddlm}ddlm}Gddd|}|j}|j||dd}|j|||k|j}|j|j ddi|j |j dS) Nr)r )r8c@seZdZddZdS)zNTest_proxify.test_no_checker_w_provides_and_permission_protected..IFoocSsdS)Nr)rrrrr&vszRTest_proxify.test_no_checker_w_provides_and_permission_protected..IFoo.barN)rrrr&rrrrrusrr*)r6r1r&) rr r9r8r0rr:r;rr!r"r#)rr r8rr4rr$rrr3test_no_checker_w_provides_and_permission_protectedrs  z@Test_proxify.test_no_checker_w_provides_and_permission_protectedcCsLddlm}t}|j}|j||}|j|||k|j|j|kdS)Nr)r8)r9r8rr0rr:r;)rr8Z_CHECKERr4rrrrtest_w_checkers   zTest_proxify.test_w_checkerN) rrrrr0r5r7r<r=r>rrrrr-Ls r-c@s$eZdZddZddZddZdS)Test_protectedFactorycOsddlm}|||S)Nr)protectedFactory)rr@)rrrr@rrrrs zTest_protectedFactory._callFUTcCstddlm}ddlm}Gddd|}Gdddt}|j||d}|j|j|k|}|j|j j d |idS) Nr)r )rc@seZdZddZdS)zCTest_protectedFactory.test_public_not_already_proxied..IFoocSsdS)Nr)rrrrr&szGTest_protectedFactory.test_public_not_already_proxied..IFoo.barN)rrrr&rrrrrsrc@seZdZddZdS)zGTest_protectedFactory.test_public_not_already_proxied.._FactorycSsdS)Nr)rrrrr&szKTest_protectedFactory.test_public_not_already_proxied.._Factory.barN)rrrr&rrrr_FactorysrAz zope.Publicr&) rr r rrrr:factoryrr;r!)rr rrrA protectedrrrrtest_public_not_already_proxieds   z5Test_protectedFactory.test_public_not_already_proxiedcCsrddlm}ddlm}Gddd|}Gdddt}|j||d}|j|j|k|}|j||d gdS) Nr)r )getTestProxyItemsc@seZdZddZdS)zBTest_protectedFactory.test_nonpublic_already_proxied..IFoocSsdS)Nr)rrrrr&szFTest_protectedFactory.test_nonpublic_already_proxied..IFoo.barN)rrrr&rrrrrsrc@seZdZdZddZdS)zFTest_protectedFactory.test_nonpublic_already_proxied.._FactoryonecSsdS)Nr)rrrrr&szJTest_protectedFactory.test_nonpublic_already_proxied.._Factory.barN)rF)rrr __slots__r&rrrrrAsrAr*r&)r&r*) rr Zzope.security.proxyrErrr:rBr)rr rErrArCrrrrtest_nonpublic_already_proxieds  z4Test_protectedFactory.test_nonpublic_already_proxiedN)rrrrrDrHrrrrr?sr?c@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)Test_securityAdapterFactorycOsddlm}|||S)Nr)securityAdapterFactory)rrJ)rrrrJrrrrs z$Test_securityAdapterFactory._callFUTcCs.Gdddt}|j|j|ddd|kdS)Nc@s eZdZdS)zVTest_securityAdapterFactory.test_no_permission_untrusted_no_location.._FactoryN)rrrrrrrrAsrAF)rr:r)rrArrr(test_no_permission_untrusted_no_locationszDTest_securityAdapterFactory.test_no_permission_untrusted_no_locationcCs.Gdddt}|j|j|ddd|kdS)Nc@s eZdZdS)zOTest_securityAdapterFactory.test_public_untrusted_no_location.._FactoryN)rrrrrrrrAsrAz zope.PublicF)rr:r)rrArrr!test_public_untrusted_no_locationsz=Test_securityAdapterFactory.test_public_untrusted_no_locationcCs:ddlm}Gdddt}|j|j||dd|kdS)Nr)rc@s eZdZdS)zVTest_securityAdapterFactory.test_CheckerPublic_untrusted_no_location.._FactoryN)rrrrrrrrAsrAF)r rrr:r)rrrArrr(test_CheckerPublic_untrusted_no_locations zDTest_securityAdapterFactory.test_CheckerPublic_untrusted_no_locationcCs@ddlm}Gdddt}|j|ddd}|jt||dS)Nr)LocatingUntrustedAdapterFactoryc@s eZdZdS)zRTest_securityAdapterFactory.test_protected_untrusted_no_location.._FactoryN)rrrrrrrrAsrAr*F)zope.security.adapterrNrrr: isinstance)rrNrArrrr$test_protected_untrusted_no_locations z@Test_securityAdapterFactory.test_protected_untrusted_no_locationcCs@ddlm}Gdddt}|j|ddd}|jt||dS)Nr)LocatingTrustedAdapterFactoryc@s eZdZdS)zTTest_securityAdapterFactory.test_no_permission_trusted_no_location.._FactoryN)rrrrrrrrAsrAFT)rOrRrrr:rP)rrRrArrrr&test_no_permission_trusted_no_locations zBTest_securityAdapterFactory.test_no_permission_trusted_no_locationcCs@ddlm}Gdddt}|j|ddd}|jt||dS)Nr)rRc@s eZdZdS)zMTest_securityAdapterFactory.test_public_trusted_no_location.._FactoryN)rrrrrrrrAsrAz zope.PublicFT)rOrRrrr:rP)rrRrArrrrtest_public_trusted_no_locations z;Test_securityAdapterFactory.test_public_trusted_no_locationcCsLddlm}ddlm}Gdddt}|j||dd}|jt||dS)Nr)rR)rc@s eZdZdS)zTTest_securityAdapterFactory.test_CheckerPublic_trusted_no_location.._FactoryN)rrrrrrrrAsrAFT)rOrRr rrrr:rP)rrRrrArrrr&test_CheckerPublic_trusted_no_locations   zBTest_securityAdapterFactory.test_CheckerPublic_trusted_no_locationcCs@ddlm}Gdddt}|j|ddd}|jt||dS)Nr)rRc@s eZdZdS)zPTest_securityAdapterFactory.test_protected_trusted_no_location.._FactoryN)rrrrrrrrAsrAr*FT)rOrRrrr:rP)rrRrArrrr"test_protected_trusted_no_locations z>Test_securityAdapterFactory.test_protected_trusted_no_locationcCs@ddlm}Gdddt}|j|ddd}|jt||dS)Nr)rRc@s eZdZdS)zOTest_securityAdapterFactory.test_protected_trusted_w_location.._FactoryN)rrrrrrrrAsrAr*T)rOrRrrr:rP)rrRrArrrr!test_protected_trusted_w_locations z=Test_securityAdapterFactory.test_protected_trusted_w_locationN) rrrrrKrLrMrQrSrTrUrVrWrrrrrIsrIcCs2tjtjttjttjttjttjtfS)N)unittestZ TestSuiteZ makeSuiterrr-r?rIrrrr test_suites rY) __doc__rXZTestCaserrr-r?rIrYrrrrs"<%E