tags:

views:

20

answers:

1

I'm implementing a custom log-in screen for a django site I am working on and users will be presented with a CAPTCHA challenge every time they log on. (Sounds like overkill I know but for a whole bunch of complex reasons it is impossible to set a decent password policy which leaves the log in open to brute force attacks)

I want to be able to tell from within the view if it is being called by the django test client so that, in that specific case, it can ignore the captcha answer.

Is there a way to do this? (Preferably one which doesn't rely on any unique request headers which may be set by the client as these could be spoofed)

Thanks!

+1  A: 

I wouldn't base it on being called by the test client, I'd have a setting that indicates the system is under test. When you run the Django tests, you can give it a different settings file which sets TESTING=True, and then imports your original settings. Then you can check settings.TESTING to decide whether to show the captcha.

Ned Batchelder
Yes, that makes much more sense than the approach I was going to take!
Andy