Skip to content

Commit

Permalink
[DON'T MERGE] test-requirements.txt
Browse files Browse the repository at this point in the history
[IMP] Renaming module name

[IMP] Readme

[IMP] Tests

[IMP] Tests

[ADD] Tests

[ADD]Tests

[IMP] Enable recaptcha by default

[IMP] Do not enable recaptcha by default

[IMP] pre-commit
  • Loading branch information
edescalona committed Dec 3, 2024
1 parent c151e59 commit a3d27a4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
odoo-addon-website_recaptcha_v2 @ git+https://github.com/OCA/website.git@refs/pull/1032/head#subdirectory=setup/website_recaptcha_v2
10 changes: 1 addition & 9 deletions website_recaptcha_v2_login/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ Website reCAPTCHA v2

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to use reCAPTCHA v2 on website forms.

It is a helper module that only provides the widget and the validation logic
which can be used by other modules to actually display it on website forms and
check whether the user entry is valid.

This module originally comes from ``website_recaptcha_reloaded`` from Tech
Receptives, which itself comes from ``website_recaptcha`` from Elico Corp.
This module allows you to use reCAPTCHA v2 in the login form.

**Table of contents**

Expand Down Expand Up @@ -70,7 +63,6 @@ Authors
Contributors
~~~~~~~~~~~~

* Edilio Escalona Almira
* `Binhex <https://www.binhex.cloud/>`_:

Maintainers
Expand Down
2 changes: 1 addition & 1 deletion website_recaptcha_v2_login/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "BINHEX: Website reCAPTCHA v2",
"name": "Website reCAPTCHA v2 login",
"version": "16.0.1.0.0",
"category": "Website",
"depends": ["web", "website_recaptcha_v2"],
Expand Down
1 change: 1 addition & 0 deletions website_recaptcha_v2_login/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_recaptcha
34 changes: 34 additions & 0 deletions website_recaptcha_v2_login/tests/test_recaptcha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from unittest import mock

from odoo.exceptions import AccessDenied
from odoo.tests import common

imp_requests = "odoo.addons.website_recaptcha_v2.models.website.requests"


class TestModule(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.website = cls.env.ref("website.default_website")
cls.website.write(
{
"recaptcha_v2_enabled": True,
"recaptcha_v2_site_key": "test-site",
"recaptcha_v2_secret_key": "test-secret",
}
)

@mock.patch(imp_requests)
def test_captcha_valid(self, requests_mock):
requests_mock.post().json.return_value = {"success": True}
result = self.website.valid_recaptcha(
{"g-recaptcha-response": "dummy_response"}
)
self.assertTrue(result)

@mock.patch(imp_requests)
def test_captcha_not_valid(self, requests_mock):
requests_mock.post().json.return_value = {"success": False}
with self.assertRaises(AccessDenied):
self.website.valid_recaptcha({"g-recaptcha-response": ""})

0 comments on commit a3d27a4

Please sign in to comment.