diff options
| author | Jeremy Kersten <jke@odoo.com> | 2019-10-07 08:56:02 +0000 |
|---|---|---|
| committer | fw-bot <otis@odoo.com> | 2019-10-17 15:35:11 +0000 |
| commit | 3a7033463ea98def2e3fb85333c4f00f7c7d6925 (patch) | |
| tree | 87f8f5c707c4925b30d77d4fa9c2ce7eeaf2cd61 /addons/test_website | |
| parent | 734f0af61f4cc642f30083eb013c56bba1f82d83 (diff) | |
[FIX] website: allow authenticate in json multidb
Before this commit launch a server with --db-filter that match at least 2 dbs name
Try to authenticate
You will have an error request is unbound when you try to access request.env
Now we retrieve the user from self instead of the request.
New test to ensure rpc authentication is tested.
Related to commit 245ef4b1
closes odoo/odoo#38969
X-original-commit: 4b3400c430bec7539aada0619fd203978daca2d8
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/test_website')
| -rw-r--r-- | addons/test_website/controllers/main.py | 8 | ||||
| -rw-r--r-- | addons/test_website/static/tests/tours/json_auth.js | 26 | ||||
| -rw-r--r-- | addons/test_website/tests/__init__.py | 1 | ||||
| -rw-r--r-- | addons/test_website/tests/test_session.py | 9 | ||||
| -rw-r--r-- | addons/test_website/views/templates.xml | 1 |
5 files changed, 45 insertions, 0 deletions
diff --git a/addons/test_website/controllers/main.py b/addons/test_website/controllers/main.py index ec94cbc3aee..1fc9f8e54e6 100644 --- a/addons/test_website/controllers/main.py +++ b/addons/test_website/controllers/main.py @@ -44,6 +44,14 @@ class WebsiteTest(Home): def test_company_context(self): return request.make_response(json.dumps(request.context.get('allowed_company_ids'))) + # Test Session + + @http.route('/test_get_dbname', type='json', auth='public', website=True) + def test_get_dbname(self, **kwargs): + return request.env.cr.dbname + + # Test Error + @http.route('/test_error_view', type='http', auth='public', website=True) def test_error_view(self, **kwargs): return request.render('test_website.test_error_view') diff --git a/addons/test_website/static/tests/tours/json_auth.js b/addons/test_website/static/tests/tours/json_auth.js new file mode 100644 index 00000000000..6c4df8e26de --- /dev/null +++ b/addons/test_website/static/tests/tours/json_auth.js @@ -0,0 +1,26 @@ +odoo.define('test_website.json_auth', function (require) { +'use strict'; + +var tour = require('web_tour.tour'); +var session = require('web.session') + +tour.register('test_json_auth', { + test: true, +}, [{ + trigger: 'body', + run: async function () { + await session.rpc('/test_get_dbname').then( function (result){ + return session.rpc("/web/session/authenticate", { + db: result, + login: 'admin', + password: 'admin' + }); + }); + window.location.href = window.location.origin; + }, +}, { + trigger: 'span:contains(Mitchell Admin)', + run: function () {}, +} +]); +}); diff --git a/addons/test_website/tests/__init__.py b/addons/test_website/tests/__init__.py index 8b8ec3e4e44..4fab1ec9b68 100644 --- a/addons/test_website/tests/__init__.py +++ b/addons/test_website/tests/__init__.py @@ -6,3 +6,4 @@ from . import test_reset_views from . import test_error from . import test_views_during_module_operation from . import test_multi_company +from . import test_session diff --git a/addons/test_website/tests/test_session.py b/addons/test_website/tests/test_session.py new file mode 100644 index 00000000000..22975ebdda4 --- /dev/null +++ b/addons/test_website/tests/test_session.py @@ -0,0 +1,9 @@ +import odoo.tests +from odoo.tools import mute_logger + + +@odoo.tests.common.tagged('post_install', '-at_install') +class TestWebsiteSession(odoo.tests.HttpCase): + + def test_01_run_test(self): + self.start_tour('/', 'test_json_auth') diff --git a/addons/test_website/views/templates.xml b/addons/test_website/views/templates.xml index ee6b500c5ca..23e71565a55 100644 --- a/addons/test_website/views/templates.xml +++ b/addons/test_website/views/templates.xml @@ -10,6 +10,7 @@ <xpath expr="." position="inside"> <script type="text/javascript" src="/test_website/static/tests/tours/reset_views.js"></script> <script type="text/javascript" src="/test_website/static/tests/tours/error_views.js"></script> + <script type="text/javascript" src="/test_website/static/tests/tours/json_auth.js"></script> </xpath> </template> </odoo> |
