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
merged 1 commit into from Mar 5, 2013

Conversation

Projects
None yet
2 participants

brisssou commented Nov 6, 2012

Hello,
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

@require_basic_auth('Authrealm',
                    ldapauth.auth_user_ldap,
                    not AM_I_TESTING.am_i)
class SomeHandler(tornado.web.RequestHandler):
    pass

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):
    pass

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.

Brice.

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

@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
8038673

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

Owner

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