From 72febff7071caf8921177304051108aef664c627 Mon Sep 17 00:00:00 2001 From: fw-bot Date: Tue, 29 Oct 2019 11:13:45 +0000 Subject: [PATCH] [FIX] tests: ensure that previous user is logged off in authenticate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some case, a browser_js test with login "None" following a browser_js test with a defined login could result in the second test being executed with the previous user. This was caused by a race condition, a request response comming back to chrome just after browser clear, restoring the old cookie. (All odoo request have the set_cookie flag set in order to refresh cookie timeout) The solution here is to check one more time for cookie in authenticate, but also to remove HTTPCase session from session_store. This will only be effective when calling browser_js without login in the same HTTPCase . closes odoo/odoo#39525 X-original-commit: 218db53b9da1573dc18610678de3b7f763531c60 Signed-off-by: Xavier Dollé (xdo) --- odoo/tests/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 287586d31a7..5944b8820dc 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -811,7 +811,7 @@ class ChromeBrowser(): params = {kw:kwargs[kw] for kw in kwargs if kw in ['url', 'domain', 'path']} params.update({'name': name}) _id = self._websocket_send('Network.deleteCookies', params=params) - return self._websocket_wait_id(_id) + return self._websocket_wait_id(_id) def _wait_ready(self, ready_code, timeout=60): self._logger.info('Evaluate ready code "%s"', ready_code) @@ -1000,6 +1000,9 @@ class HttpCase(TransactionCase): def authenticate(self, user, password): # stay non-authenticated if user is None: + if self.session: + odoo.http.root.session_store.delete(self.session) + self.browser.delete_cookie('session_id', domain=HOST) return db = get_db_name()