I\'m using the GAE testbed service and when I run users.get_current_user()
I get None
i.e.
>>> import sys
>>> sys
After some experimentation the following worked for me:
>>> os.environ['USER_EMAIL'] = 'a@b.c'
>>> os.environ['USER_ID'] = '123'
>>> users.get_current_user()
users.User(email='a@b.c',_user_id='123')
I hope this is a good solution, and this answer helps the next person to run into this issue.
To avoid /google/appengine/api/users.py:115 - AssertionError: assert _auth_domain
>>> os.environ['AUTH_DOMAIN'] = 'testbed'
Per Elliot de Vries comment, for an administrative user:
>>> os.environ['USER_IS_ADMIN'] = '1'
To simulate a sign in of an admin user, you can call anywhere in your test function:
self.testbed.setup_env(
USER_EMAIL = 'test@example.com',
USER_ID = '123',
USER_IS_ADMIN = '1',
overwrite = True)
Note that you need to use the overwrite=True
parameter!