Skip to content

Commit

Permalink
[FIX] auth_oauth_multi_token: Apply token version for being validated…
Browse files Browse the repository at this point in the history
… in tests
  • Loading branch information
dnplkndll authored and kobros-tech committed Feb 4, 2025
1 parent b14b991 commit ca2abb9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions auth_oauth_multi_token/tests/test_multi_token.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2017 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

import base64
import json

from odoo import exceptions
Expand All @@ -26,8 +27,12 @@ def setUpClass(cls):
)

def _fake_params(self, **kw):
# in version 18.0 tokens should follow version check
# based on verify_hash_signed method
fake_token = b"\x01" + b"FAKE_TOKEN"
encoded_token = base64.urlsafe_b64encode(fake_token).rstrip(b"=").decode()
params = {
"state": json.dumps({"t": "FAKE_TOKEN"}),
"state": json.dumps({"t": encoded_token}),
"access_token": "FAKE_ACCESS_TOKEN",
}
params.update(kw)
Expand All @@ -38,14 +43,10 @@ def test_no_provider_no_access(self):
"user_id": "oauth_uid_no_one",
}
params = self._fake_params()
try:
with self.assertRaises(exceptions.AccessDenied):
self.user_model._auth_oauth_signin(
self.provider_google.id, validation, params
)
# In version 18.0 AccessDenied exception is raising ValueError exception
except ValueError as e:
self.assertEqual(str(e), "Unknown token version")
with self.assertRaises(exceptions.AccessDenied):
self.user_model._auth_oauth_signin(
self.provider_google.id, validation, params
)

def _test_one_token(self):
validation = {
Expand Down

0 comments on commit ca2abb9

Please sign in to comment.