Ñò ˆ_‚Jc@s_dZddklZddklZddklZddkZddkl Z ddk l Z ddk l Z lZdd klZdd klZlZdd klZlZlZlZdd klZlZlZddkZdd klZddkl Z ddk!l"Z"l#Z#ddk$l%Z%l&Z&ddk'l(Z(ddk)l*Z*ddk+l,Z,l-Z-l.Z.dZ/ei0i1ei0i2e3ƒƒZ4ei0i5e4dƒZ6ee6de7ƒhd„Z8d„Z9defd„ƒYZ:defd„ƒYZ;defd„ƒYZ<ee.ƒƒe<ƒZ<defd „ƒYZ=d!efd"„ƒYZ>d#efd$„ƒYZ?ee-d%ƒƒe?ƒZ?d&efd'„ƒYZ@d(e@fd)„ƒYZAd*e@fd+„ƒYZBd,e@fd-„ƒYZCd.e@fd/„ƒYZDd0e@fd1„ƒYZEd2e@fd3„ƒYZFd4e@fd5„ƒYZGd6e@fd7„ƒYZHd8e@fd9„ƒYZIdS(:s0 repoze.what & repoze.what-pylons **integration** tests. Note that it is not necessary to have integration tests for the other auth* software in this package. They must be in tg.devtools, specifically in the test suite of the quickstarted applications (and there's where they are, as of this writing). iÿÿÿÿ(tTestCase(trmtree(tunquoteN(thttpexceptions(tRegistryManager(tResponsetRequest(tTestApp(tCacheMiddlewaretSessionMiddleware(tresponsetexposetrequiret allow_only(t TGControllertWSGIAppControllertRestController(t tmpl_context(tabort(t ContextObjt PylonsContext(tControllerWraptSetupCacheGlobal(tAuthTktCookiePlugin(t setup_auth(tNottis_usert not_anonymouss-The current user must have been authenticatedtsessiont ignore_errorsc CsÙt|ƒ}t||dtdtƒ}t|ƒ}t|hdtƒ}t|hdtii t dƒƒ}d }d }t ddƒ}d|fg}t |||d|d gd gd tƒ}ti|ƒ}t|ƒS( sCreates a ``TestApp`` instance.t setup_cachet setup_sessiontdata_dirtcachetsecrettauthtkttcookiet identifierstauthenticatorst challengerstskip_authenticationN(RRtTrueRR t session_dirRtostpathtjoinR tNoneRRRtmake_middlewareR(tcontroller_klasstenvirontapptgroups_adapterstpermissions_adaptersR$R%((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pytmake_app.s  $ cCs3t|ƒ}td|i|iƒ}|||ƒS(sMock WSGI applications Hello from %s(RRt script_namet path_info(R1tstart_responsetreqtresp((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pytwsgi_appJs tDaRestControllercBs,eZdZedƒZeƒd„ƒZRS(sMock REST controllertgustavocCsdS(Nsnew here((tself((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pytnewVs(t__name__t __module__t__doc__RR R R?(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR<Qs tHRManagementControllercBs>eZdZedƒZeƒd„ƒZeƒd„ƒZRS(s=Mock TG2 protected controller using the .allow_only attributeshiring-managercCsdS(Nsyou can manage Human Resources((R>((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pytindex`scCsd|S(Ns%s was just hired((R>t person_name((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pythireds(R@RARBRR R RDRF(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRC[s t ControlPanelcBsMeZdZeƒZeƒd„ƒZeƒeedƒƒd„ƒƒZ RS(s9Mock TG2 protected controller using @allow_only directly.cCsdS(Nsyou are in the panel((R>((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRDnstadmincCsd|S(Ns%s was just registered((R>t user_name((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pytadd_userrs( R@RARBRCthrR RDR RRJ(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRGis  tRootControllercBsheZeƒZeƒZeededƒƒZ e ƒd„ƒZ e ƒe edƒƒd„ƒƒZ RS(R R=cCsdS(Nsyou're in the main page((R>((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRD‚st developercCsdS(Nsyou can commit((R>((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pytcommit†s(R@RARGtcpR<trestRR;Rt mounted_appR RDR RN(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRLzs   t5ControllerWithAllowOnlyAttributeAndAuthzDenialHandlercBs;eZdZedƒZeƒd„ƒZed„ƒZRS(s=Mock TG2 protected controller using the .allow_only attributetfoobarcCsdS(NsWelcome back, foobar!((R>((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRD‘scCstdƒdS(Ni’(R(R>treason((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt_failed_authorization•s( R@RARBRR R RDt classmethodRU(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRRŒs t5ControllerWithAllowOnlyDecoratorAndAuthzDenialHandlercBs/eZdZeƒd„ƒZed„ƒZRS(su Mock TG2 protected controller using the @allow_only decorator, but also using ._failed_authorization() cCsdS(NsWelcome back, foobar!((R>((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRD¢scCstdƒdS(Ni’(R(R>RT((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRU¦s(R@RARBR RDRVRU(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRW›sRStBaseIntegrationTestscBs/eZdZeZd„Zd„Zd„ZRS(s(Base test case for the integration testscCs•tiitƒptitƒntƒ}tƒ}||_d|_ |_ ht ddƒd6|d6}t ii |ƒt|i|ƒ|_dS(NtactionRDspylons.routes_dicts pylons.pylons(R+R,texistsR*tmakedirsRRtcR.trequestR tdicttpylonst _push_objectR5t controllerR2(R>R\tpy_objR1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pytsetUp·s    cCstiƒttdtƒdS(NR(Rt _pop_objectRR*R)(R>((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyttearDownÆs cGsmd|ijp td‚t|idƒ}x9|D]1}d|}||jptd||f‚q4WdS(sW Check that ``expected_messages`` are defined in the WebFlash cookie. twebflashsSuch no WebFlash cookies"%s"sMessage %s not in flash: %sN(t cookies_settAssertionErrorR(R>R texpected_messagestflashtmsg((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt _check_flashËs  (R@RARBRLRaRcReRl(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRX²s   t TestRequirecBs2eZdZd„Zd„Zd„Zd„ZRS(s$Test case for the @require decoratorcCsBhdd6}|iidd|ddƒ}|id|iƒdS(NRMt REMOTE_USERs/committ extra_environtstatusiÈsyou can commit(R2tgett assertEqualtbody(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt%test_authz_granted_in_root_controllerÚs cCs•|iidddƒ}d|ijpt‚|i|dƒhdd6}|iidd|dd ƒ}d|ijpt‚|i|dƒdS( Ns/commitRpi‘syou can commits&The current user must be \"developer\"RSRnRoi“(R2RqRsRhRl(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt$test_authz_denied_in_root_controllerßs cCsBhdd6}|iidd|ddƒ}|id|iƒdS(NRHRns/cp/add_user/fooRoRpiÈsfoo was just registered(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt$test_authz_granted_in_sub_controllerês  cCs•|iidddƒ}d|ijpt‚|i|tƒhdd6}|iidd|ddƒ}d|ijpt‚|i|d ƒdS( Ns/cp/add_user/fooRpi‘swas just registeredRSRnRoi“s"The current user must be \"admin\"(R2RqRsRhRltNOT_AUTHENTICATED(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt#test_authz_denied_in_sub_controllerðs  (R@RARBRtRuRvRx(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRm×s   t%TestAllowOnlyDecoratorInSubControllercBs2eZdZd„Zd„Zd„Zd„ZRS(s;Test case for the @allow_only decorator in a sub-controllercCsBhdd6}|iidd|ddƒ}|id|iƒdS(NtsomeoneRns/cp/RoRpiÈsyou are in the panel(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt"test_authz_granted_without_requires cCsC|iidddƒ}d|ijpt‚|i|tƒdS(Ns/cp/Rpi‘syou are in the panel(R2RqRsRhRlRw(R>R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt!test_authz_denied_without_requirescCsBhdd6}|iidd|ddƒ}|id|iƒdS(NRHRns/cp/add_user/fooRoRpiÈsfoo was just registered(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyttest_authz_granted_with_require s  cCsC|iidddƒ}d|ijpt‚|i|tƒdS(Ns/cp/add_user/fooRpi‘swas just registered(R2RqRsRhRlRw(R>R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyttest_authz_denied_with_requires(R@RARBR{R|R}R~(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRyýs    t2TestAllowOnlyDecoratorAndDefaultAuthzDenialHandlercBs&eZdZeZd„Zd„ZRS(s{ Test case for the @allow_only decorator in a controller using _failed_authorization() as its denial handler. cCsBhdd6}|iidd|ddƒ}|id|iƒdS(NRSRnt/RoRpiÈsWelcome back, foobar!(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyttest_authz_granteds cCs3|iidddƒ}d|ijpt‚dS(NR€Rpi’s Welcome back(R2RqRsRh(R>R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyttest_authz_denied$s(R@RARBRWRaRR‚(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRs t%TestAllowOnlyAttributeInSubControllercBs8eZdZeZd„Zd„Zd„Zd„ZRS(s;Test case for the .allow_only attribute in a sub-controllercCsBhdd6}|iidd|ddƒ}|id|iƒdS(Nshiring-managerRns/hr/RoRpiÈsyou can manage Human Resources(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR{.s cCs•|iidddƒ}d|ijpt‚|i|dƒhdd6}|iidd|dd ƒ}d|ijpt‚|i|dƒdS( Ns/hr/Rpi‘syou can manage Human Resourcess+The current user must be \"hiring-manager\"RzRnRoi“(R2RqRsRhRl(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR|3s cCsBhdd6}|iidd|ddƒ}|id|iƒdS(Nshiring-managerRns/hr/hire/gustavoRoRpiÈsgustavo was just hired(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR}>s  cCs•|iidddƒ}d|ijpt‚|i|dƒhdd6}|iidd|dd ƒ}d|ijpt‚|i|dƒdS( Ns/hr/hire/gustavoRpi‘swas just hireds+The current user must be \"hiring-manager\"RzRnRoi“(R2RqRsRhRl(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR~Ds ( R@RARBRGRaR{R|R}R~(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRƒ)s   t2TestAllowOnlyAttributeAndDefaultAuthzDenialHandlercBs&eZdZeZd„Zd„ZRS(s{ Test case for the .allow_only attribute in a controller using _failed_authorization() as its denial handler. cCsBhdd6}|iidd|ddƒ}|id|iƒdS(NRSRnR€RoRpiÈsWelcome back, foobar!(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRYs cCs3|iidddƒ}d|ijpt‚dS(NR€Rpi’s Welcome back(R2RqRsRh(R>R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR‚^s(R@RARBRRRaRR‚(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR„Ps t&TestAppWideAuthzWithAllowOnlyDecoratorcBs8eZdZeZd„Zd„Zd„Zd„ZRS(sCTest case for application-wide authz with the @allow_only decoratorcCsBhdd6}|iidd|ddƒ}|id|iƒdS(NRzRnR€RoRpiÈsyou are in the panel(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR{hs cCsC|iidddƒ}d|ijpt‚|i|tƒdS(NR€Rpi‘syou are in the panel(R2RqRsRhRlRw(R>R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR|mscCsBhdd6}|iidd|ddƒ}|id|iƒdS(NRHRns /add_user/fooRoRpiÈsfoo was just registered(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR}rs  cCsC|iidddƒ}d|ijpt‚|i|tƒdS(Ns /add_user/fooRpi‘swas just registered(R2RqRsRhRlRw(R>R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR~xs( R@RARBRGRaR{R|R}R~(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR…cs    t&TestAppWideAuthzWithAllowOnlyAttributecBs8eZdZeZd„Zd„Zd„Zd„ZRS(sCTest case for application-wide authz with the .allow_only attributecCsGhdd6}|iidd|ddƒ}|GH|id|iƒdS(Nshiring-managerRnR€RoRpiÈsyou can manage Human Resources(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR{ƒs cCs•|iidddƒ}d|ijpt‚|i|dƒhdd6}|iidd|dd ƒ}d|ijpt‚|i|dƒdS( NR€Rpi‘syou can manage Human Resourcess+The current user must be \"hiring-manager\"RzRnRoi“(R2RqRsRhRl(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR|‰s cCsBhdd6}|iidd|ddƒ}|id|iƒdS(Nshiring-managerRns /hire/gustavoRoRpiÈsgustavo was just hired(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR}”s  cCs|iidddƒ}d|ijpt‚|iGH|i|dƒhdd6}|iidd|dd ƒ}d|ijpt‚|i|dƒdS( Ns /hire/gustavoRpi‘swas just hireds+The current user must be \"hiring-manager\"RzRnRoi“(R2RqRsRhRl(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR~šs ( R@RARBRCRaR{R|R}R~(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR†~s   tTestProtectedRESTContollercBs eZdZd„Zd„ZRS(s(Test case for protected REST controllerscCsBhdd6}|iidd|ddƒ}|id|iƒdS(NR=Rns /rest/newRoRpiÈsnew here(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRªs  cCs•|iidddƒ}d|ijpt‚|i|dƒhdd6}|iidd|dd ƒ}d|ijpt‚|i|dƒdS( Ns /rest/newRpi‘snew heres$The current user must be \"gustavo\"s non-gustavoRnRoi“(R2RqRsRhRl(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR‚°s (R@RARBRR‚(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR‡§s tTestProtectedWSGIApplicationcBs eZdZd„Zd„ZRS(sCTest case for protected WSGI applications mounted on the controllercCsBhdd6}|iidd|ddƒ}|id|iƒdS(NR=Rns/mounted_app/da-pathRoRpiÈsHello from /mounted_app/da-path(R2RqRrRs(R>R1R:((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR¿s  cCs•|iidddƒ}d|ijpt‚|i|dƒhdd6}|iidd|dd ƒ}d|ijpt‚|i|dƒdS( Ns/mounted_app/da-pathRpi‘sHello from /mounted_app/s$The current user must be \"gustavo\"s non-gustavoRnRoi“(R2RqRsRhRl(R>R:R1((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyR‚Ås  (R@RARBRR‚(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyRˆ¼s (JRBtunittestRtshutilRturllibRR+tpasteRtpaste.registryRtwebobRRtwebtestRtbeaker.middlewareRR ttgR R R R ttg.controllersRRRR_Rtpylons.controllers.utilRt pylons.utilRRtpylons.testutilRRtrepoze.who.plugins.auth_tktRtrepoze.what.middlewareRtrepoze.what.predicatesRRRRwR,tdirnametabspatht__file__R R-R*R)R5R;R<RCRGRLRRRWRXRmRyRRƒR„R…R†R‡Rˆ(((s</usr/lib/python2.6/site-packages/tg/test_stack/test_authz.pyt sX "    %&')