Skip to content

Commit

Permalink
[FIX] add newline at end of file oca_dependencies.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
chafique-delli committed Oct 26, 2020
1 parent 83f1467 commit 6f075cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion auth_api_key/models/auth_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class AuthApiKey(models.Model):
the api key""",
)

_sql_constraints = [("name_uniq", "unique(name)", "Api Key name must be unique.")]
_sql_constraints = [("name_uniq", "unique(name)",
"Api Key name must be unique.")]

def _server_env_section_name(self):
"""Name of the section in the configuration files
Expand Down
3 changes: 2 additions & 1 deletion auth_api_key/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def _auth_method_api_key(cls):
api_key = headers.get("HTTP_API_KEY")
if api_key:
request.uid = 1
auth_api_key = request.env["auth.api.key"]._retrieve_api_key(api_key)
auth_api_key = request.env["auth.api.key"]._retrieve_api_key(
api_key)
if auth_api_key:
# reset _env on the request since we change the uid...
# the next call to env will instantiate an new
Expand Down
7 changes: 4 additions & 3 deletions auth_api_key/tests/test_auth_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ def setUpClass(cls, *args, **kwargs):
def test_lookup_key_from_db(self):
demo_user = self.env.ref("base.user_demo")
self.assertEqual(
self.env["auth.api.key"]._retrieve_uid_from_api_key("api_key"), demo_user.id
)
self.env["auth.api.key"]._retrieve_uid_from_api_key("api_key"),
demo_user.id)

def test_lookup_key_from_env(self):
self.assertEqual(
self.env["auth.api.key"]._retrieve_uid_from_api_key("api_key_from_env"),
self.env["auth.api.key"]._retrieve_uid_from_api_key(
"api_key_from_env"),
self.demo_user.id,
)
with self.assertRaises(ValidationError):
Expand Down
3 changes: 2 additions & 1 deletion oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
server-env
# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt
server-env

0 comments on commit 6f075cb

Please sign in to comment.