#891: [PATCH] Identity and unit testing
----------------------+-----------------------------------------------------
 Reporter:  Joost     |       Owner:  anonymous
     Type:  defect    |      Status:  new      
 Priority:  normal    |   Milestone:           
Component:  CherryPy  |     Version:  0.9a5    
 Severity:  normal    |    Keywords:           
----------------------+-----------------------------------------------------
 Hi, I'm having some trouble writing unit tests for a secured object.
 The controller code is as follows:

 foo= Foo()
 foo = identity.SecureObject(foo,
 
identity.from_any_host(cherrypy.config.get("identity.allowed_hosts",["127.0.0.1"])))

 Next i'm trying to test this controller as described in the docs:

 def test_index():
     cherrypy.root = Root()
     d = testutil.call(cherrypy.root.index)
     assert d['title'] == 'A greate title'

 Yet this raises IdentityFailure.

 Digging into identity and testutil it appears that the allowed_hosts
 predicate uses cherrypy.request.remoteHost which isn't set in the
 DummyRequest used by testutils.call(). I have attached a patch which
 sets this attribute to '127.0.0.1'. Yet i'm not sure if this is the
 best way to go about.

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/891>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to