-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/15/2014 05:22 AM, pyramidX wrote:

> I have the following test method, where I add a test user to the
> database, then with a DummyRequest I call my login view, then I assert
> the authenticated_userid is what I think it should be. However it
> returns None.
> 
> def test_login(self): self.config = testing.setUp() 
> self.config.include('mymodule') self.config.add_route('home', '/')
> 
> user = UserFactory.build(id='testid', post__password='testpassword') 
> DBSession.add(user) self._transaction.commit()
> 
> request = testing.DummyRequest(post={'id': 'testid', 'password': 
> 'testpassword'}) view = views.login(request)
> 
> assert authenticated_userid(request) is 'testid'  # FAILS, returning
> None instead of 'testid'
> 
> The last lines of my views.login function are here.
> 
> print(user.id)  # Prints 'testid' as expected, so the user is being
> retrieved correctly from the database headers = remember(request,
> user.id) return HTTPFound(location=next, headers=headers)
> 
> In my module's includeme function I have:
> 
> def includeme(config): authz_policy = ACLAuthorizationPolicy() 
> config.set_authorization_policy(authz_policy) authn_policy =
> AuthTktAuthenticationPolicy('....', hashalg='sha512') 
> config.set_authentication_policy(authn_policy)
> 
> Any idea what I'm doing wrong?

'remember' doesn't mutate the current request:  it just computes headers
passed to the response (so that the user will be authenticated on the
*next* request).


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlSO8aIACgkQ+gerLs4ltQ6+IQCfRoXc6qAMYr/B6/Db0z32I5EB
T7YAn3nbnDSXUyID7IMu+7JM6IvzelUt
=JwAs
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to