Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore RECAPTCHA_TESTING mechanism #5

Open
lenarother opened this issue Aug 22, 2016 · 3 comments
Open

Restore RECAPTCHA_TESTING mechanism #5

lenarother opened this issue Aug 22, 2016 · 3 comments

Comments

@lenarother
Copy link
Contributor

Hallo!

To make testing easier testing mechanism from django-recaptcha could be restored:

settings:
RECAPTCHA_TESTING = True
form data:
data['g-recaptcha-response'] = 'PASSED'

Currently it is necessary to mock verifying function
nobot.client.HumanCaptchaClient.verify

@EnTeQuAk
Copy link
Owner

EnTeQuAk commented Aug 22, 2016

Thanks for the report!

I believe that RECAPTCHA_TESTING was a bad design choice and mocking together with proper documentation (which doesn't exist unfortunately) is a more correct approach particularly since there are multiple ways in which the verification can fail.

Another idea would be to write a testing related client implementation that can be used in the fields accordingly, e.g something like

class TestingCaptchaClient(ReCaptchaClient):
    def verify(self, challenge, response, remote_ip):
        return return RecaptchaResponse(is_valid=True, error_code=None)

Not sure yet what feels right, I'll look into it a bit more later this or next week.

@lenarother
Copy link
Contributor Author

Thank you!

@lenarother
Copy link
Contributor Author

How would you change client in test then? Should there be settings variable for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants