Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #891 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

[PATCH] Identity and unit testing

Reported by: Joost Owned by: anonymous
Priority: normal Milestone: 1.0b1
Component: CherryPy Version: 0.9a5
Severity: normal Keywords:
Cc:

Description

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 dtitle? == '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.

Attachments

891.patch Download (343 bytes) - added by anonymous 13 years ago.

Change History

Changed 13 years ago by anonymous

comment:1 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone set to 1.0b1

committed in [1849]. Thanks!

Note: See TracTickets for help on using tickets.