Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Testing require_basic_auth-wrapped handlers #5

merged 1 commit into from Mar 5, 2013


None yet
2 participants

brisssou commented Nov 6, 2012

I added a parameter in the require_basic_auth wrapper.
This way, you can use the wrapper and still be able to test your handler:

from tinman.auth import AM_I_TESTING
from tinman.auth.basic import require_basic_auth
import tornado.web
import ldapauth

                    not AM_I_TESTING.am_i)
class SomeHandler(tornado.web.RequestHandler):

And then you test case may look like this:

from tinman.auth import AM_I_TESTING
AM_I_TESTING.am_i = True
#More imports

class Test(AsyncHTTPTestCase):

The first tow lines really have to be those ones, and the wrapper will not wrap the handler, so you can test the code, with no need of authentication, or mock authentication.

I'm not really happy with the names of the function/class/parameter or the way it's used, but it does the work, and I can now test a wrapped Handler.


blaurencin * added a parameter in the wrapper and a runtime class, both help tes…
…ting a require_basic_auth-wrapped handler.

@gmr gmr pushed a commit that referenced this pull request Mar 5, 2013

Gavin M. Roy Merge pull request #5 from tomslabs/master
Testing require_basic_auth-wrapped handlers

@gmr gmr merged commit 8038673 into gmr:master Mar 5, 2013


gmr commented Mar 5, 2013

Thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment