From 3629c6eeaf32fbd275745e60c5b57b28280d5786 Mon Sep 17 00:00:00 2001 From: Nils Coenen <74965194+NICO-SOLUTIONS@users.noreply.github.com> Date: Sat, 17 Jun 2023 14:54:47 +0200 Subject: [PATCH] [MIG] website_require_login: Migration to 15.0 --- website_require_login/__manifest__.py | 2 +- website_require_login/readme/CONTRIBUTORS.rst | 1 + website_require_login/tests/test_ir_http.py | 29 ++++++++++--------- .../views/website_auth_url.xml | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/website_require_login/__manifest__.py b/website_require_login/__manifest__.py index 7dc343fb3e..0bb2fe40fe 100644 --- a/website_require_login/__manifest__.py +++ b/website_require_login/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Website Login Required", "category": "Website", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "author": "Advitus MB, Ooops, Odoo Community Association (OCA)", "website": "https://github.com/OCA/website", "license": "LGPL-3", diff --git a/website_require_login/readme/CONTRIBUTORS.rst b/website_require_login/readme/CONTRIBUTORS.rst index b5f195b844..f07b76cdb6 100644 --- a/website_require_login/readme/CONTRIBUTORS.rst +++ b/website_require_login/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Ooops404 +* Nils Coenen diff --git a/website_require_login/tests/test_ir_http.py b/website_require_login/tests/test_ir_http.py index 23d31cf2ed..9a01b46482 100644 --- a/website_require_login/tests/test_ir_http.py +++ b/website_require_login/tests/test_ir_http.py @@ -2,34 +2,35 @@ class TestIrHttp(HttpCase): - def setUp(self): - super().setUp() - self.website = self.env["website"].sudo().get_current_website() - self.auth_url = self.env["website.auth.url"].create( - {"website_id": self.website.id, "path": "/contactus"} + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.website = cls.env["website"].sudo().get_current_website() + cls.auth_url = cls.env["website.auth.url"].create( + {"website_id": cls.website.id, "path": "/contactus"} ) - self.user = self.env["res.users"].create( + cls.user = cls.env["res.users"].create( {"name": "Test User", "login": "test_user", "password": "12345"} ) - self.path = "/contactus" - self.expected_path = "/web/login?redirect=%s" % self.path + cls.path = "/contactus" + cls.expected_path = "/web/login?redirect=%s" % cls.path def test_dispatch_unauthorized(self): - # Test that an unauthorized user cannot access "/auth_path + # Test that a public user cannot access "/auth_path self.authenticate(None, None) - response = self.url_open(self.path, allow_redirects=False) + response = self.url_open(self.__class__.path, allow_redirects=False) self.assertEqual( response.status_code, - 302, - "Expected the response status code to be 302 indicating a redirect", + 303, + "Expected the response status code to be 303 indicating a redirect", ) - self.assertIn(self.expected_path, response.headers["Location"]) + self.assertIn(self.__class__.expected_path, response.headers["Location"]) def test_dispatch_authorized(self): # Test that an authorized user can access "/auth_path self.authenticate(user="test_user", password="12345") - response = self.url_open(self.path) + response = self.url_open(self.__class__.path) self.assertEqual( response.status_code, 200, diff --git a/website_require_login/views/website_auth_url.xml b/website_require_login/views/website_auth_url.xml index c60e9e218b..2e354a1621 100644 --- a/website_require_login/views/website_auth_url.xml +++ b/website_require_login/views/website_auth_url.xml @@ -5,7 +5,7 @@ website.auth.url website.auth.url - +