diff --git a/addons/bus/controllers/main.py b/addons/bus/controllers/main.py index 99fcc82ed81..f1d45920e9c 100644 --- a/addons/bus/controllers/main.py +++ b/addons/bus/controllers/main.py @@ -1,4 +1,6 @@ -# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import json from odoo import exceptions, _ from odoo.http import Controller, request, route @@ -42,3 +44,12 @@ class BusController(Controller): @route('/longpolling/im_status', type="json", auth="user") def im_status(self, partner_ids): return request.env['res.partner'].with_context(active_test=False).search([('id', 'in', partner_ids)]).read(['im_status']) + + @route('/longpolling/health', type='http', auth='none', save_session=False) + def health(self): + data = json.dumps({ + 'status': 'pass', + }) + headers = [('Content-Type', 'application/json'), + ('Cache-Control', 'no-store')] + return request.make_response(data, headers) diff --git a/addons/bus/tests/__init__.py b/addons/bus/tests/__init__.py index 06c6ab0e440..7cd3a9d428b 100644 --- a/addons/bus/tests/__init__.py +++ b/addons/bus/tests/__init__.py @@ -1 +1,2 @@ from . import test_assetsbundle +from . import test_health diff --git a/addons/bus/tests/test_health.py b/addons/bus/tests/test_health.py new file mode 100644 index 00000000000..906ddc98806 --- /dev/null +++ b/addons/bus/tests/test_health.py @@ -0,0 +1,12 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests import HttpCase + + +class TestBusController(HttpCase): + def test_health(self): + response = self.url_open('/longpolling/health') + self.assertEqual(response.status_code, 200) + payload = response.json() + self.assertEqual(payload['status'], 'pass') + self.assertNotIn('session_id', response.cookies) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index b5938d136d7..78bc5117a8f 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -903,6 +903,16 @@ class Home(http.Controller): return request.redirect(self._login_redirect(uid)) + @http.route('/web/health', type='http', auth='none', save_session=False) + def health(self): + data = json.dumps({ + 'status': 'pass', + }) + headers = [('Content-Type', 'application/json'), + ('Cache-Control', 'no-store')] + return request.make_response(data, headers) + + class WebClient(http.Controller): @http.route('/web/webclient/locale/', type='http', auth="none") diff --git a/addons/web/tests/__init__.py b/addons/web/tests/__init__.py index 157ef045f1b..62810336e66 100644 --- a/addons/web/tests/__init__.py +++ b/addons/web/tests/__init__.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import test_health from . import test_image from . import test_js from . import test_menu diff --git a/addons/web/tests/test_health.py b/addons/web/tests/test_health.py new file mode 100644 index 00000000000..cec042b12d0 --- /dev/null +++ b/addons/web/tests/test_health.py @@ -0,0 +1,12 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests import HttpCase + + +class TestWebController(HttpCase): + def test_health(self): + response = self.url_open('/web/health') + self.assertEqual(response.status_code, 200) + payload = response.json() + self.assertEqual(payload['status'], 'pass') + self.assertNotIn('session_id', response.cookies)