From fc9a602cbc9c24d11a2483063f0adc9fef1d84ce Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Fri, 7 Aug 2026 07:52:12 +0200 Subject: [PATCH 1/2] [IMP] dbfilter_from_header: tests --- dbfilter_from_header/tests/__init__.py | 1 + .../tests/test_dbfilter_from_header.py | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 dbfilter_from_header/tests/__init__.py create mode 100644 dbfilter_from_header/tests/test_dbfilter_from_header.py diff --git a/dbfilter_from_header/tests/__init__.py b/dbfilter_from_header/tests/__init__.py new file mode 100644 index 00000000000..4fbe3d58e9f --- /dev/null +++ b/dbfilter_from_header/tests/__init__.py @@ -0,0 +1 @@ +from . import test_dbfilter_from_header diff --git a/dbfilter_from_header/tests/test_dbfilter_from_header.py b/dbfilter_from_header/tests/test_dbfilter_from_header.py new file mode 100644 index 00000000000..1a98c41c379 --- /dev/null +++ b/dbfilter_from_header/tests/test_dbfilter_from_header.py @@ -0,0 +1,58 @@ +import importlib + +from odoo import http +from odoo.tests.common import TransactionCase +from odoo.tools import config + +from odoo.addons.http_routing.tests.common import MockRequest + +from .. import override + + +class TestDbfilterFromHeader(TransactionCase): + def setUp(self): + super().setUp() + self.config_org = {} + for key in ("proxy_mode", "server_wide_modules", "dbfilter", "db_name"): + self.config_org[key] = config[key] + self.db_filter_org = http.db_filter + config["dbfilter"] = "^db1|db2$" + config["proxy_mode"] = True + config["server_wide_modules"] = "dbfilter_from_header" + importlib.reload(override) + + def test_dbfilter_with_header(self): + """ + Test that with a dbfilter set in config, it restricts what is selectable + via the header + """ + with MockRequest(self.env) as mock_request: + mock_request.httprequest.environ["HTTP_X_ODOO_DBFILTER"] = "^db2|db3$" + filtered_dbs = http.db_filter(["db1", "db2", "db3"]) + self.assertEqual(filtered_dbs, ["db2"]) + + def test_dbfilter_without_header(self): + """ + Test that with a dbfilter set in config and no header added, standard behavior + is applied + """ + with MockRequest(self.env): + filtered_dbs = http.db_filter(["db1", "db2", "db3"]) + self.assertEqual(filtered_dbs, ["db1", "db2"]) + + def test_no_dbfilter_with_header(self): + """ + Test that with no dbfilter set in config, filter from header is unrestricted + """ + config["dbfilter"] = "" + config["db_name"] = "" + with MockRequest(self.env) as mock_request: + mock_request.httprequest.environ["HTTP_X_ODOO_DBFILTER"] = "^db2|db3$" + filtered_dbs = http.db_filter(["db1", "db2", "db3"]) + self.assertEqual(filtered_dbs, ["db2", "db3"]) + + def tearDown(self): + super().tearDown() + for key, value in self.config_org.items(): + config[key] = value + http.db_filter = self.db_filter_org From 396d0793bceb983b6c802ea8438ed1c7c9da2101 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Fri, 7 Aug 2026 07:53:35 +0200 Subject: [PATCH 2/2] [UPD] dbfilter_from_header: make hbrunn maintainer --- dbfilter_from_header/README.rst | 8 ++++++++ dbfilter_from_header/__manifest__.py | 1 + dbfilter_from_header/static/description/index.html | 2 ++ 3 files changed, 11 insertions(+) diff --git a/dbfilter_from_header/README.rst b/dbfilter_from_header/README.rst index 5f68e057816..50900d0376d 100644 --- a/dbfilter_from_header/README.rst +++ b/dbfilter_from_header/README.rst @@ -132,6 +132,14 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px + :target: https://github.com/hbrunn + :alt: hbrunn + +Current `maintainer `__: + +|maintainer-hbrunn| + This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/dbfilter_from_header/__manifest__.py b/dbfilter_from_header/__manifest__.py index f09bb6f556c..a9ebc12faf4 100644 --- a/dbfilter_from_header/__manifest__.py +++ b/dbfilter_from_header/__manifest__.py @@ -12,6 +12,7 @@ "license": "AGPL-3", "category": "Tools", "depends": ["web"], + "maintainers": ["hbrunn"], "auto_install": False, "installable": True, } diff --git a/dbfilter_from_header/static/description/index.html b/dbfilter_from_header/static/description/index.html index 172bb15734c..2ff223ea109 100644 --- a/dbfilter_from_header/static/description/index.html +++ b/dbfilter_from_header/static/description/index.html @@ -471,6 +471,8 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

+

Current maintainer:

+

hbrunn

This module is part of the OCA/server-tools project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.