On Mon, Jan 5, 2009 at 9:25 AM, aubry-yves <[email protected]> wrote:
>
>
> Hello,
> I write unit tests for an application TG2.
> I followed these docs:
> http://docs.turbogears.org/2.0/RoughDocs/AppTesting
> http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing
>
> But I do not know how to test the pages with authenticated based on
> repoze.who
>
> There is an example here, to assign a value to REMOTE_USER:
> http://pythonpaste.org/webtest/#modifying-the-environment-simulating-authentication
>
> But it makes no difference.
Hi, I have been wanting to document this for some time, we had the
same trouble on an application I'm working on.
The short answer is that you need to call login on each request, one
way of solving this is by using the following base webtest class.
This is a modification of your /tests/__init__.py in fact it just adds
line 40, of course you will need to add that user/pass to your
websetup.py for everything to work.
35 class TestController(object):
36
37 def __init__(self, *args, **kwargs):
38 wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
39 self.app = webtest.TestApp(wsgiapp)
40 response =
self.app.get('/login_handler?login=jorge&password=jorge')
The long answer is that the way repoze.who works it honors REMOTE_USER
and bails out (assumes auth has been done by another wsgi component)
which makes repoze.what fail as it has no presence of a "real auth".
I'm not 100% sure if this is a bug (repoze.what shouldn't assume
repoze.who authenticated) or simply a bad use case that should be
documented.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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?hl=en
-~----------~----~----~----~------~----~------~--~---