Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
odoo-addon-webservice @ git+https://github.com/OCA/web-api.git@refs/pull/143/head#subdirectory=webservice
odoo-addon-webservice_server_env @ git+https://github.com/OCA/web-api.git@refs/pull/143/head#subdirectory=webservice_server_env
7 changes: 7 additions & 0 deletions webservice/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ HTTP call returns by default the content of the response. A context
.. contents::
:local:

Configuration
=============

When a database is neutralized, stored webservice backend credentials
(username, password, API key, OAuth2 client id/secret/token, custom
OAuth2 auth header value) are cleared.

Bug Tracker
===========

Expand Down
9 changes: 9 additions & 0 deletions webservice/data/neutralize.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- remove webservice backend credentials
UPDATE webservice_backend
SET username = NULL,
password = NULL,
api_key = NULL,
oauth2_clientid = NULL,
oauth2_client_secret = NULL,
Comment thread
yankinmax marked this conversation as resolved.
oauth2_client_auth_value = NULL,
oauth2_token = NULL;
3 changes: 3 additions & 0 deletions webservice/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When a database is neutralized, stored webservice backend credentials
(username, password, API key, OAuth2 client id/secret/token, custom
OAuth2 auth header value) are cleared.
27 changes: 17 additions & 10 deletions webservice/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,41 +382,48 @@ <h1>WebService</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>When a database is neutralized, stored webservice backend credentials
(username, password, API key, OAuth2 client id/secret/token, custom
OAuth2 auth header value) are cleared.</p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web-api/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web-api/issues/new?body=module:%20webservice%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<ul class="simple">
<li>Creu Blanca</li>
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<ul class="simple">
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li>
<li>Alexandre Fayolle &lt;<a class="reference external" href="mailto:alexandre.fayolle&#64;camptocamp.com">alexandre.fayolle&#64;camptocamp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
1 change: 1 addition & 0 deletions webservice/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import test_oauth2
from . import test_webservice
from . import test_utils
from . import test_neutralize
49 changes: 49 additions & 0 deletions webservice/tests/test_neutralize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.modules import neutralize
from odoo.tests import tagged

from .common import CommonWebService


@tagged("neutralize")
class TestWebserviceNeutralize(CommonWebService):
@classmethod
def _setup_records(cls):
res = super()._setup_records()
# `auth_type="none"` skips the `_check_auth_type` constraint so all
# credential fields can be populated at once regardless of which
# auth method would normally require them.
cls.backend = cls.env["webservice.backend"].create(
{
"name": "Neutralize WebService",
"protocol": "http",
"url": "https://localhost.demo.odoo/",
"tech_name": "neutralize_ws",
"auth_type": "none",
"username": "secret-user",
"password": "secret-password",
"api_key": "secret-api-key",
"oauth2_clientid": "secret-client-id",
"oauth2_client_secret": "secret-client-secret",
"oauth2_client_auth_value": "secret-header-value",
"oauth2_token": '{"access_token": "secret-token"}',
}
)
return res

def test_neutralize_removes_webservice_credentials(self):
"""Test database neutralization clears stored webservice backend credentials."""
installed_modules = neutralize.get_installed_modules(self.cr)
queries = neutralize.get_neutralization_queries(installed_modules)
for query in queries:
self.cr.execute(query)
self.backend.invalidate_recordset()
self.assertFalse(self.backend.username)
self.assertFalse(self.backend.password)
self.assertFalse(self.backend.api_key)
self.assertFalse(self.backend.oauth2_clientid)
self.assertFalse(self.backend.oauth2_client_secret)
self.assertFalse(self.backend.oauth2_client_auth_value)
self.assertFalse(self.backend.oauth2_token)
8 changes: 8 additions & 0 deletions webservice_server_env/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Webservice addon.
.. contents::
:local:

Configuration
=============

When a database is neutralized, webservice backend credentials
(username, password, API key, OAuth2 client id/secret, custom OAuth2
auth header value) stored as server environment defaults are cleared as
well.

Bug Tracker
===========

Expand Down
16 changes: 16 additions & 0 deletions webservice_server_env/data/neutralize.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- remove webservice backend credentials stored as server environment defaults
-- (this module turns username/password/api_key/oauth2_clientid/oauth2_client_secret
-- into non-stored fields backed by the server_env_defaults JSON column
-- this neutralization is needed if both webservice and server_environment are installed,
-- so the plain columns nulled by webservice/data/neutralize.sql can be properly cleared)
UPDATE webservice_backend
Comment thread
yankinmax marked this conversation as resolved.
SET server_env_defaults = (
server_env_defaults::jsonb
- 'x_username_env_default'
- 'x_password_env_default'
- 'x_api_key_env_default'
- 'x_oauth2_clientid_env_default'
- 'x_oauth2_client_secret_env_default'
- 'x_oauth2_client_auth_value_env_default'
)::text
WHERE server_env_defaults IS NOT NULL;
3 changes: 3 additions & 0 deletions webservice_server_env/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When a database is neutralized, webservice backend credentials (username,
password, API key, OAuth2 client id/secret, custom OAuth2 auth header
value) stored as server environment defaults are cleared as well.
28 changes: 18 additions & 10 deletions webservice_server_env/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,41 +380,49 @@ <h1>WebService Server Environment</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>When a database is neutralized, webservice backend credentials
(username, password, API key, OAuth2 client id/secret, custom OAuth2
auth header value) stored as server environment defaults are cleared as
well.</p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web-api/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web-api/issues/new?body=module:%20webservice_server_env%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<ul class="simple">
<li>Creu Blanca</li>
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<ul class="simple">
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li>
<li>Daniel Reis &lt;<a class="reference external" href="mailto:dreis&#64;opensourceintegrators.com">dreis&#64;opensourceintegrators.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
1 change: 1 addition & 0 deletions webservice_server_env/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import test_oauth2
from . import test_neutralize
47 changes: 47 additions & 0 deletions webservice_server_env/tests/test_neutralize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.modules import neutralize
from odoo.tests import tagged

from odoo.addons.webservice.tests.common import CommonWebService


@tagged("neutralize")
class TestWebserviceServerEnvNeutralize(CommonWebService):
@classmethod
def _setup_records(cls):
res = super()._setup_records()
# No `SERVER_ENV_CONFIG` section is defined for this tech_name, so
# these credentials are stored as env-default values inside
# `server_env_defaults` instead of the (now unused) plain columns.
cls.backend = cls.env["webservice.backend"].create(
{
"name": "Neutralize WebService Server Env",
"protocol": "http",
"url": "https://localhost.demo.odoo/",
"tech_name": "neutralize_server_env_ws",
"auth_type": "none",
"username": "secret-user",
"password": "secret-password",
"api_key": "secret-api-key",
"oauth2_clientid": "secret-client-id",
"oauth2_client_secret": "secret-client-secret",
"oauth2_client_auth_value": "secret-header-value",
}
)
return res

def test_neutralize_removes_server_env_default_credentials(self):
"""Test neutralization clears credentials stored as server-env defaults."""
installed_modules = neutralize.get_installed_modules(self.cr)
queries = neutralize.get_neutralization_queries(installed_modules)
for query in queries:
self.cr.execute(query)
self.backend.invalidate_recordset()
self.assertFalse(self.backend.username)
self.assertFalse(self.backend.password)
self.assertFalse(self.backend.api_key)
self.assertFalse(self.backend.oauth2_clientid)
self.assertFalse(self.backend.oauth2_client_secret)
self.assertFalse(self.backend.oauth2_client_auth_value)
Loading