Skip to content

Commit a4d0eca

Browse files
committed
[MIG] auth_api_key: Migration to 19.0
1 parent 48dca0d commit a4d0eca

File tree

5 files changed

+37
-28
lines changed

5 files changed

+37
-28
lines changed

auth_api_key/README.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ 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%2Fserver--auth-lightgray.png?logo=github
24-
:target: https://github.com/OCA/server-auth/tree/18.0/auth_api_key
24+
:target: https://github.com/OCA/server-auth/tree/19.0/auth_api_key
2525
:alt: OCA/server-auth
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-auth_api_key
27+
:target: https://translation.odoo-community.org/projects/server-auth-19-0/server-auth-19-0-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/server-auth&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -49,11 +49,11 @@ Odoo allows users to authenticate ``XMLRPC/JSONRPC`` calls using their
4949
API key instead of a password by native API keys (``res.users.apikey``).
5050
However, ``auth_api_key`` has some special features of its own such as:
5151

52-
- API keys remain usable even when the user is inactive, if enabled via
53-
settings (e.g., for system users in a shopinvader case).
54-
- Supports dual authentication via Basic Auth and API_KEY in separate
55-
HTTP headers.
56-
- Admins can manage API keys for all users
52+
- API keys remain usable even when the user is inactive, if enabled via
53+
settings (e.g., for system users in a shopinvader case).
54+
- Supports dual authentication via Basic Auth and API_KEY in separate
55+
HTTP headers.
56+
- Admins can manage API keys for all users
5757

5858
Given these advantages, particularly in use case like system user
5959
authentication, we have decided to keep the ``auth_api_key`` module
@@ -94,7 +94,7 @@ Bug Tracker
9494
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
9595
In case of trouble, please check there if your issue has already been reported.
9696
If you spotted it first, help us to smash it by providing a detailed and welcomed
97-
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
97+
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
9898

9999
Do not contact contributors directly about support or help with technical issues.
100100

@@ -109,12 +109,12 @@ Authors
109109
Contributors
110110
------------
111111

112-
- Denis Robinet <denis.robinet@acsone.eu>
113-
- Laurent Mignon <laurent.mignon@acsone.eu>
114-
- Quentin Groulard <quentin.groulard@acsone.eu>
115-
- Sébastien Beau <sebastien.beau@akretion.com>
116-
- Chafique Delli <chafique.delli@akretion.com>
117-
- Thien Vo Hong <thienvh@trobz.com>
112+
- Denis Robinet <denis.robinet@acsone.eu>
113+
- Laurent Mignon <laurent.mignon@acsone.eu>
114+
- Quentin Groulard <quentin.groulard@acsone.eu>
115+
- Sébastien Beau <sebastien.beau@akretion.com>
116+
- Chafique Delli <chafique.delli@akretion.com>
117+
- Thien Vo Hong <thienvh@trobz.com>
118118

119119
Other credits
120120
-------------
@@ -135,6 +135,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
135135
mission is to support the collaborative development of Odoo features and
136136
promote its widespread use.
137137

138-
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/18.0/auth_api_key>`_ project on GitHub.
138+
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/19.0/auth_api_key>`_ project on GitHub.
139139

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

auth_api_key/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Auth Api Key",
66
"summary": """
77
Authenticate http requests from an API key""",
8-
"version": "18.0.1.0.1",
8+
"version": "19.0.1.0.1",
99
"license": "LGPL-3",
1010
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/server-auth",

auth_api_key/models/auth_api_key.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AuthApiKey(models.Model):
2929
compute="_compute_active", readonly=False, store=True, default=True
3030
)
3131

32-
_sql_constraints = [("name_uniq", "unique(name)", "Api Key name must be unique.")]
32+
_name_uniq = models.Constraint("unique(name)", "Api Key name must be unique.")
3333

3434
@api.model
3535
def _retrieve_api_key(self, key):
@@ -43,9 +43,7 @@ def _retrieve_api_key_id(self, key):
4343
for api_key in self.search([], limit=None):
4444
if api_key.key and consteq(key, api_key.key):
4545
return api_key.id
46-
raise ValidationError(
47-
self.env._("The key {key} is not allowed").format(key=key)
48-
)
46+
raise ValidationError(self.env._("The key '%s is not allowed", key))
4947

5048
@api.model
5149
@tools.ormcache("key")

auth_api_key/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Auth Api Key</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:78e3946b0dbb81bb6fbf6c434aaf5214faec00449a765c2f41e321b65024ba05
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/server-auth/tree/18.0/auth_api_key"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-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/server-auth&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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/server-auth/tree/19.0/auth_api_key"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-19-0/server-auth-19-0-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/server-auth&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>Authenticate http requests from an API key.</p>
379379
<p>API keys are codes passed in (in the http header API-KEY) by programs
380380
calling an API in order to identify -in this case- the calling program’s
@@ -437,7 +437,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
437437
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-auth/issues">GitHub Issues</a>.
438438
In case of trouble, please check there if your issue has already been reported.
439439
If you spotted it first, help us to smash it by providing a detailed and welcomed
440-
<a class="reference external" href="https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
440+
<a class="reference external" href="https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
441441
<p>Do not contact contributors directly about support or help with technical issues.</p>
442442
</div>
443443
<div class="section" id="credits">
@@ -473,7 +473,7 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
473473
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
474474
mission is to support the collaborative development of Odoo features and
475475
promote its widespread use.</p>
476-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-auth/tree/18.0/auth_api_key">OCA/server-auth</a> project on GitHub.</p>
476+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-auth/tree/19.0/auth_api_key">OCA/server-auth</a> project on GitHub.</p>
477477
<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>
478478
</div>
479479
</div>

auth_api_key/tests/test_auth_api_key.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@ class TestAuthApiKey(TransactionCase):
99
def setUpClass(cls, *args, **kwargs):
1010
super().setUpClass(*args, **kwargs)
1111
cls.AuthApiKey = cls.env["auth.api.key"]
12-
cls.demo_user = cls.env.ref("base.user_demo")
12+
cls.partner_demo = cls.env["res.partner"].create(
13+
{
14+
"name": "Demo Partner",
15+
}
16+
)
17+
cls.demo_user = cls.env["res.users"].create(
18+
{
19+
"partner_id": cls.partner_demo.id,
20+
"login": "demotest",
21+
"password": "demotest",
22+
}
23+
)
1324
cls.api_key_good = cls.AuthApiKey.create(
1425
{"name": "good", "user_id": cls.demo_user.id, "key": "api_key"}
1526
)
1627

1728
def test_lookup_key_from_db(self):
18-
demo_user = self.env.ref("base.user_demo")
29+
demo_user = self.demo_user
1930
self.assertEqual(
2031
self.env["auth.api.key"]._retrieve_uid_from_api_key("api_key"), demo_user.id
2132
)
@@ -46,7 +57,7 @@ def test_cache_invalidation(self):
4657

4758
def test_user_archived_unarchived_with_option_on(self):
4859
self.env.company.archived_user_disable_auth_api_key = True
49-
demo_user = self.env.ref("base.user_demo")
60+
demo_user = self.demo_user
5061
self.assertEqual(
5162
self.env["auth.api.key"]._retrieve_uid_from_api_key("api_key"), demo_user.id
5263
)
@@ -60,7 +71,7 @@ def test_user_archived_unarchived_with_option_on(self):
6071

6172
def test_user_archived_unarchived_with_option_off(self):
6273
self.env.company.archived_user_disable_auth_api_key = False
63-
demo_user = self.env.ref("base.user_demo")
74+
demo_user = self.demo_user
6475
self.assertEqual(
6576
self.env["auth.api.key"]._retrieve_uid_from_api_key("api_key"), demo_user.id
6677
)

0 commit comments

Comments
 (0)