[18.0][MIG] auth_oauth_autologin: Migration to 18.0#868
[18.0][MIG] auth_oauth_autologin: Migration to 18.0#868
Conversation
…of the URI fragment to redirect to
895538c to
c637c01
Compare
|
Hi @sbidoul , I have refactored the module to use a pure backend redirect v18-autologin.mp4 |
|
I have some doubts with the redirect implementation, in particular when the user is already logged in . Could you pick-up the tests from #821 ? The implementation in #821 is a bit different, as is the original implementation in f25f5d4 which calls super first. I don't know which approach is better in 18.0. |
|
Can you also remove the old icon so the bot will generate a new one after merge? |
c637c01 to
8c3d84e
Compare
8c3d84e to
7376795
Compare
|
Hi @sbidoul , I've removed the icon and added the tests |
|
Hello, The logic looks good, however I find the tests very hard to read. In the original version they looked like this and at first sight this gives the same test coverage while being more compact and in my view easier to understand: from odoo.tests import common
class TestAuthMethod(common.HttpCase):
def _assert_no_autologin(self, query=""):
r = self.url_open(f"/web/login{query}", allow_redirects=False)
self.assertNotEqual(r.status_code, 303)
self.assertTrue(r.ok)
def test_end_to_end_default_providers(self):
# by default no provider is configured
providers = self.env["auth.oauth.provider"].search(
[("enabled", "=", True), ("autologin", "=", True)]
)
self.assertFalse(providers)
self._assert_no_autologin()
def test_end_to_end_one_provider(self):
provider = self.env["auth.oauth.provider"].search(
[("enabled", "=", True), ("autologin", "=", False)],
limit=1,
)
self.assertTrue(provider)
provider.autologin = True
# some query parameters disable autologin
self._assert_no_autologin(query="?no_autologin=1")
self._assert_no_autologin(query="?error=...")
self._assert_no_autologin(query="?oauth_error=...")
# test autologin redirect
r = self.url_open("/web/login", allow_redirects=False)
self.assertEqual(r.status_code, 303)
self.assertTrue(r.headers["Location"].startswith(provider.auth_endpoint)) |
No description provided.