Skip to content

Commit 903ed7d

Browse files
committed
[MIG] endpoint_auth_api_key: Migration to 19.0
1 parent 7d0e322 commit 903ed7d

9 files changed

Lines changed: 107 additions & 57 deletions

File tree

endpoint_auth_api_key/README.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Endpoint Auth API key
2121
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
2222
:alt: License: LGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb--api-lightgray.png?logo=github
24-
:target: https://github.com/OCA/web-api/tree/18.0/endpoint_auth_api_key
24+
:target: https://github.com/OCA/web-api/tree/19.0/endpoint_auth_api_key
2525
:alt: OCA/web-api
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/web-api-18-0/web-api-18-0-endpoint_auth_api_key
27+
:target: https://translation.odoo-community.org/projects/web-api-19-0/web-api-19-0-endpoint_auth_api_key
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/web-api&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web-api&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -50,7 +50,7 @@ Bug Tracker
5050
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web-api/issues>`_.
5151
In case of trouble, please check there if your issue has already been reported.
5252
If you spotted it first, help us to smash it by providing a detailed and welcomed
53-
`feedback <https://github.com/OCA/web-api/issues/new?body=module:%20endpoint_auth_api_key%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
`feedback <https://github.com/OCA/web-api/issues/new?body=module:%20endpoint_auth_api_key%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5454

5555
Do not contact contributors directly about support or help with technical issues.
5656

@@ -74,8 +74,7 @@ Contributors
7474
Other credits
7575
-------------
7676

77-
The migration of this module from 14.0 to 16.0 was financially supported
78-
by Camptocamp
77+
7978

8079
Maintainers
8180
-----------
@@ -98,6 +97,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
9897

9998
|maintainer-simahawk|
10099

101-
This module is part of the `OCA/web-api <https://github.com/OCA/web-api/tree/18.0/endpoint_auth_api_key>`_ project on GitHub.
100+
This module is part of the `OCA/web-api <https://github.com/OCA/web-api/tree/19.0/endpoint_auth_api_key>`_ project on GitHub.
102101

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

endpoint_auth_api_key/__manifest__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
{
55
"name": "Endpoint Auth API key",
66
"summary": """Provide API key auth for endpoints.""",
7-
"version": "18.0.1.0.1",
7+
"version": "19.0.1.0.0",
88
"license": "LGPL-3",
99
"development_status": "Alpha",
1010
"author": "Camptocamp, Odoo Community Association (OCA)",
1111
"maintainers": ["simahawk"],
1212
"website": "https://github.com/OCA/web-api",
1313
"depends": ["endpoint", "auth_api_key_group"],
14-
"demo": ["demo/api_key_demo.xml", "demo/endpoint_demo.xml"],
1514
"data": ["views/endpoint_view.xml"],
1615
}

endpoint_auth_api_key/demo/api_key_demo.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

endpoint_auth_api_key/demo/endpoint_demo.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
The migration of this module from 14.0 to 16.0 was financially supported
2-
by Camptocamp

endpoint_auth_api_key/static/description/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Endpoint Auth API key</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:cfd515c9f4adfa18204af3865093c9d6d00f92e79b06ce7d7e6ca353a4fc6934
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web-api/tree/18.0/endpoint_auth_api_key"><img alt="OCA/web-api" src="https://img.shields.io/badge/github-OCA%2Fweb--api-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-api-18-0/web-api-18-0-endpoint_auth_api_key"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web-api&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web-api/tree/19.0/endpoint_auth_api_key"><img alt="OCA/web-api" src="https://img.shields.io/badge/github-OCA%2Fweb--api-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-api-19-0/web-api-19-0-endpoint_auth_api_key"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web-api&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>Provide API key auth for endpoints.</p>
379379
<div class="admonition important">
380380
<p class="first admonition-title">Important</p>
@@ -400,7 +400,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
400400
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web-api/issues">GitHub Issues</a>.
401401
In case of trouble, please check there if your issue has already been reported.
402402
If you spotted it first, help us to smash it by providing a detailed and welcomed
403-
<a class="reference external" href="https://github.com/OCA/web-api/issues/new?body=module:%20endpoint_auth_api_key%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
403+
<a class="reference external" href="https://github.com/OCA/web-api/issues/new?body=module:%20endpoint_auth_api_key%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
404404
<p>Do not contact contributors directly about support or help with technical issues.</p>
405405
</div>
406406
<div class="section" id="credits">
@@ -427,8 +427,6 @@ <h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
427427
</div>
428428
<div class="section" id="other-credits">
429429
<h3><a class="toc-backref" href="#toc-entry-5">Other credits</a></h3>
430-
<p>The migration of this module from 14.0 to 16.0 was financially supported
431-
by Camptocamp</p>
432430
</div>
433431
<div class="section" id="maintainers">
434432
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
@@ -441,7 +439,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
441439
promote its widespread use.</p>
442440
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
443441
<p><a class="reference external image-reference" href="https://github.com/simahawk"><img alt="simahawk" src="https://github.com/simahawk.png?size=40px" /></a></p>
444-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web-api/tree/18.0/endpoint_auth_api_key">OCA/web-api</a> project on GitHub.</p>
442+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web-api/tree/19.0/endpoint_auth_api_key">OCA/web-api</a> project on GitHub.</p>
445443
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
446444
</div>
447445
</div>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright 2026 Camptocamp SA
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3+
4+
from odoo import Command
5+
from odoo.tests import TransactionCase, tagged
6+
7+
8+
def _setup_demo_api_keys(env, demo_user):
9+
"""Create demo API keys for tests."""
10+
api_key_model = env["auth.api.key"]
11+
12+
api_key_1 = api_key_model.create(
13+
{
14+
"name": "Endpoint API key demo",
15+
"key": "cZ6dF2UQwNcm",
16+
"user_id": demo_user.id,
17+
}
18+
)
19+
api_key_2 = api_key_model.create(
20+
{
21+
"name": "Endpoint API key demo 2",
22+
"key": "kV47QyOTC5mS",
23+
"user_id": demo_user.id,
24+
}
25+
)
26+
return api_key_1, api_key_2
27+
28+
29+
def _setup_demo_api_key_group(env, api_keys):
30+
"""Create demo API key group for tests."""
31+
return env["auth.api.key.group"].create(
32+
{
33+
"name": "Demo Group 1",
34+
"code": "demo_group1",
35+
"auth_api_key_ids": [Command.set(api_keys.ids)],
36+
}
37+
)
38+
39+
40+
def _setup_demo_endpoint(env, api_key_group):
41+
"""Create demo endpoint for tests."""
42+
return env["endpoint.endpoint"].create(
43+
{
44+
"name": "Demo Endpoint - auth api key",
45+
"route": "/demo/api/key",
46+
"request_method": "GET",
47+
"auth_type": "api_key",
48+
"auth_api_key_group_ids": [Command.set(api_key_group.ids)],
49+
"exec_mode": "code",
50+
"code_snippet": 'result = {"response": Response("ok")}',
51+
}
52+
)
53+
54+
55+
@tagged("-at_install", "post_install")
56+
class CommonEndpointAuthAPIKey(TransactionCase):
57+
@classmethod
58+
def setUpClass(cls):
59+
super().setUpClass()
60+
cls._setup_env()
61+
cls._setup_records()
62+
63+
@classmethod
64+
def _setup_env(cls):
65+
cls.env = cls.env(context=cls._setup_context())
66+
67+
@classmethod
68+
def _setup_context(cls):
69+
return dict(
70+
cls.env.context,
71+
tracking_disable=True,
72+
)
73+
74+
@classmethod
75+
def _setup_records(cls):
76+
cls.demo_user = cls.env.ref("base.user_demo")
77+
78+
cls.api_key, cls.api_key2 = _setup_demo_api_keys(
79+
cls.env,
80+
cls.demo_user,
81+
)
82+
cls.api_keys = cls.api_key | cls.api_key2
83+
84+
cls.api_key_group = _setup_demo_api_key_group(
85+
cls.env,
86+
cls.api_keys,
87+
)
88+
cls.endpoint = _setup_demo_endpoint(
89+
cls.env,
90+
cls.api_key_group,
91+
)

endpoint_auth_api_key/tests/test_endpoint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
from odoo.addons.endpoint.tests.common import CommonEndpoint
1111

12+
from .common import CommonEndpointAuthAPIKey
1213

13-
class TestEndpoint(CommonEndpoint):
14+
15+
class TestEndpoint(CommonEndpoint, CommonEndpointAuthAPIKey):
1416
@classmethod
1517
def _setup_records(cls):
1618
super()._setup_records()

endpoint_auth_api_key/tests/test_endpoint_controller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
from odoo.tests.common import HttpCase
1212
from odoo.tools.misc import mute_logger
1313

14+
from .common import CommonEndpointAuthAPIKey
15+
1416

1517
@unittest.skipIf(os.getenv("SKIP_HTTP_CASE"), "EndpoinAuthApikeytHttpCase skipped")
16-
class EndpoinAuthApikeytHttpCase(HttpCase):
18+
class EndpoinAuthApikeytHttpCase(HttpCase, CommonEndpointAuthAPIKey):
1719
@classmethod
1820
def setUpClass(cls):
1921
super().setUpClass()
20-
cls.api_key = cls.env.ref("endpoint_auth_api_key.auth_api_key_demo")
21-
cls.api_key2 = cls.env.ref("endpoint_auth_api_key.auth_api_key_demo2")
2222
# force sync for demo records
2323
cls.env["endpoint.endpoint"].search([])._handle_registry_sync()
2424

0 commit comments

Comments
 (0)