Hmm... so I pulled Gustavo's sample pylons auth app: http://wiki.pylonshq.com/display/pylonscookbook/Authorization+with+repoze.what
I added: identity = request.environ.get('repoze.who.identity') c.user = identity.get('user').user_name to the index action of the PanelController (protected with the in_group predicate) and came up with the same error (only in testing): AttributeError: 'NoneType' object has no attribute 'get' Not running a nosetest, the context variable resolves in the template. Is it wrong to define the user name, from the session credentials, in the controller to the template context like this? What am I missing? I have to be wrong, right? wouldn't others be getting the same problem? P.S. the nosetests pass as they were before the addition...and that was testing On Aug 16, 3:48 pm, Gustavo Narea <m...@gustavonarea.net> wrote: > Hello, Wojtek. > > I've had a quick look at the "auth_repozepylons" template in Shabti and I > think I've found the problem. > > The test case TestController doesn't seem to be setting "skip_authentication". > Can you please modify it to make it look like this: > """ > class TestController(TestModel): > > # Protected areas should be tested with authentication disabled: > application_under_test = 'main' > > def __init__(self, *args, **kwargs): > conf_dir = config['here'] > wsgiapp = loadapp('config:test.ini#%s' % self.application_under_test, > relative_to=conf_dir) > self.app = TestApp(wsgiapp) > url._push_object(URLGenerator(config['routes.map'], environ)) > TestCase.__init__(self, *args, **kwargs) > """ > > Then go to tests/functional/test_auth_login.py and add the > application_under_test attribute to TestLoginController, like this: > """ > class TestLoginController(TestController): > application_under_test = 'main_without_authn' > > ... > """ > > Does it work now? If so, can you please report the bug > onhttps://bitbucket.org/gjhiggins/shabti/issues?status=new > > Cheers. > > - Gustavo. > > Wojtek said: > > > > > Thanks for reply, Gustavo. > > I did check that, though I'm using the *shabti* templates and they are up > > to par. > > I guess my problem isn't with authentication so much as with > > identification, maybe?: > > > In my controller I have *request.environ.get('repoze.who.identity')['user'] > > *and its just keeps coming up as 'None' on my tests (only)... > > > <sigh> > > > I've been at it for a couple of days now. I even went as far as doing > > another virtualenv and creating a new app and it persists. > > > I really appreciate the help. > > > On Sun, Aug 15, 2010 at 3:45 PM, Gustavo Narea <m...@gustavonarea.net> > > wrote: > > > Hello, > > > > Setting REMOTE_USER is the preferred method. It should make everything > > > work with no additional code. > > > > If it doesn't work, the only reason I can think of would be that > > > "skip_authentication" is not set during the tests: > > >http://code.gustavonarea.net/repoze.who-testutil/HowTo/Reconfiguring.... > > > > HTH. > > > > - Gustavo. > > > > Chris said: > > > > > Greetings, > > > > > > I'm using the shabti paster templates for a repoze auth'n'auth set up > > > > > on Pylons. > > > > > The templates preconfigure the set up with repoze.who_testutil. > > > > > > I've been struggling trying to get these tests to run. > > > > > The instructions for the testutil show that I just need to pass in > > > > > the REMOTE_USER dictionary in the enviorn: > > > > > response = self.app.get(url(controller='mycontroller', > > > > > action='index', extra_environ={'REMOTE_USER':'tester'})) > > > > > > Someone else on the Pylons bored told me to just create a > > > > > repoze.what.credentials dictionary with userid, groups, and > > > > > premissions keys. > > > > > > I'm chocking here... > > > > > On my controller I use the helper get_user to get a user instance > > > > > which keeps showing as None in the error stack... > > > > -- > > > Gustavo Narea <xri://=Gustavo>. > > > > | Tech blog: =Gustavo/(+blog)/tech ~ About me: =Gustavo/about | > > -- > Gustavo Narea <xri://=Gustavo>. > | Tech blog: =Gustavo/(+blog)/tech ~ About me: =Gustavo/about | > _______________________________________________ > Repoze-dev mailing list > repoze-...@lists.repoze.orghttp://lists.repoze.org/listinfo/repoze-dev _______________________________________________ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev