Skip to content

Commit

Permalink
[IMP] ODOO-297 Disable web tests in production.
Browse files Browse the repository at this point in the history
  • Loading branch information
amh-mw committed Dec 8, 2022
1 parent 9f92494 commit 19ffde4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/web/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,7 @@
},
'bootstrap': True, # load translations for login screen,
'license': 'LGPL-3',
'demo': [
'demo/demo.xml',
],
}
6 changes: 6 additions & 0 deletions addons/web/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,14 +1025,20 @@ def version_info(self):

@http.route('/web/tests', type='http', auth="user")
def test_suite(self, mod=None, **kwargs):
if not request.env['ir.config_parameter'].sudo().get_param('web.enable_test'):
raise werkzeug.exceptions.Forbidden(_("Tests disabled"))
return request.render('web.qunit_suite')

@http.route('/web/tests/mobile', type='http', auth="none")
def test_mobile_suite(self, mod=None, **kwargs):
if not request.env['ir.config_parameter'].sudo().get_param('web.enable_test'):
raise werkzeug.exceptions.Forbidden(_("Tests disabled"))
return request.render('web.qunit_mobile_suite')

@http.route('/web/benchmarks', type='http', auth="none")
def benchmarks(self, mod=None, **kwargs):
if not request.env['ir.config_parameter'].sudo().get_param('web.enable_test'):
raise werkzeug.exceptions.Forbidden(_("Tests disabled"))
return request.render('web.benchmark_suite')


Expand Down
4 changes: 4 additions & 0 deletions addons/web/demo/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<function model="ir.config_parameter" name="set_param" eval="('web.enable_test', True)"/>
</odoo>

0 comments on commit 19ffde4

Please sign in to comment.