From a177db910de2edffec8c86429b881038abf9f18a Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 9 Jun 2022 08:39:33 +0000 Subject: [PATCH] [IMP] website: unit test to cover invalid IP V6 URL This is a unit test to cover the fix in revision bfdd54e815334dbfd0f65ec6559a711b4973a6eb closes odoo/odoo#93170 Signed-off-by: Denis Ledoux (dle) --- addons/website/tests/test_lang_url.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/addons/website/tests/test_lang_url.py b/addons/website/tests/test_lang_url.py index a6b97d93e03..6ae29b49310 100644 --- a/addons/website/tests/test_lang_url.py +++ b/addons/website/tests/test_lang_url.py @@ -80,6 +80,24 @@ class TestLangUrl(HttpCase): doc = lxml.html.document_fromstring(r.text) self.assertEqual(doc.get('lang'), 'fr-FR', "Ensure contactus did not soft crash + loaded in correct lang") + def test_05_invalid_ipv6_url(self): + view = self.env['ir.ui.view'].create({ + 'name': 'Base', + 'type': 'qweb', + 'arch': 'Invalid IP V6', + 'key': 'test.invalid_ipv6_view', + }) + + self.env['website.page'].create({ + 'view_id': view.id, + 'url': '/page_invalid_ipv6_url', + 'is_published': True, + }) + r = self.url_open('/page_invalid_ipv6_url') + self.assertEqual(r.status_code, 200, 'The page must still load despite the invalid link') + doc = lxml.html.document_fromstring(r.text) + [anchor] = doc.xpath('//a[@id="foo"]') + self.assertEqual(anchor.get('href'), 'http://]', 'The invalid IP URL must be left untouched') @tagged('-at_install', 'post_install')