|
| 1 | +# Copyright 2024 Simone Rubino - Aion Tech |
| 2 | +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). |
| 3 | + |
1 | 4 | from odoo.tests import HttpCase
|
2 | 5 |
|
3 | 6 |
|
@@ -35,3 +38,35 @@ def test_dispatch_authorized(self):
|
35 | 38 | 200,
|
36 | 39 | "Expected the response status code to be 200 which means no redirection",
|
37 | 40 | )
|
| 41 | + |
| 42 | + def test_authorize_everything(self): |
| 43 | + """Requiring "/" for authorization always redirects to login page.""" |
| 44 | + # Arrange |
| 45 | + self.env["website.auth.url"].unlink() |
| 46 | + root_path = "/" |
| 47 | + self.env["website.auth.url"].create( |
| 48 | + {"website_id": self.website.id, "path": root_path} |
| 49 | + ) |
| 50 | + self.env["ir.qweb"]._pregenerate_assets_bundles() |
| 51 | + asset_attachment = self.env["ir.attachment"].search( |
| 52 | + [ |
| 53 | + ("url", "like", "/web/assets/%"), |
| 54 | + ], |
| 55 | + limit=1, |
| 56 | + ) |
| 57 | + |
| 58 | + redirection_path_map = { |
| 59 | + "/": "/web/login?redirect=/", |
| 60 | + "/contactus": "/web/login?redirect=/contactus", |
| 61 | + asset_attachment.url: asset_attachment.url, |
| 62 | + "/web/login": "/web/login", |
| 63 | + } |
| 64 | + |
| 65 | + # Assert |
| 66 | + for requested_path, expected_redirected_path in redirection_path_map.items(): |
| 67 | + response = self.url_open(requested_path) |
| 68 | + self.assertEqual( |
| 69 | + response.status_code, |
| 70 | + 200, |
| 71 | + ) |
| 72 | + self.assertTrue(response.url.endswith(expected_redirected_path)) |
0 commit comments