[FIX] payment_*: tests when running with a non-default port
For payment_buckaroo and payment_sips (at least) running with a non-standard port is an issue to the `test_redirect_form_value` tests: while the form and test will use respectively the base_url and the configuration port, both check a response signature which is predicated upon a base url of `http://127.0.0.1:8069`. This means the test does not pass when run with a different port, and may not pass if the database was installed with a different port either (because this may have caused the `web.base_url` to be set to the installation port). The other payment modules don't seem to have such signature verification and thus apparently don't mind running with non-default port. Update in 15.2: `test_webhook_notification_confirms_transaction` also broke but differently, because the payment utils would fetch (and use) the `web.base.url` they get confused if a db is installed using one port then the tests are run using an other (or something along those lines), despite `HttpCase` trying to set the `web.base.url` (could be an ordering thing). Anyway a working solution seems to be to *remove* the bespoke code from `PaymentTestUtils` and fix `HttpCase.base_url()` so it uses the right port (apparently that'd never been fixed). This does require adapting the patch being forward-ported as `base_url` is now a callable, not an attribute. Also re-remove the attractive nuisance of the odoo.tests.common.PORT constant which does not work: it is evaluated before the configuration has been loaded and is thus always set to the default (8069). closes odoo/odoo#86068 X-original-commit: c28c99f7399da91e1a6176d6f97d4fc947013cae Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
@@ -12,13 +12,6 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PaymentTestUtils(AccountTestInvoicingCommon):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls, chart_template_ref=None):
|
||||
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||
|
||||
cls.icp_base_url = cls.env['ir.config_parameter'].get_param('web.base.url')
|
||||
|
||||
def _generate_test_access_token(self, *values):
|
||||
""" Generate an access token based on the provided values for testing purposes.
|
||||
|
||||
@@ -37,7 +30,7 @@ class PaymentTestUtils(AccountTestInvoicingCommon):
|
||||
return access_token
|
||||
|
||||
def _build_url(self, route):
|
||||
return urls.url_join(self.icp_base_url, route)
|
||||
return urls.url_join(self.base_url(), route)
|
||||
|
||||
def _extract_values_from_html_form(self, html_form):
|
||||
""" Extract the transaction rendering values from an HTML form.
|
||||
|
||||
@@ -16,6 +16,9 @@ from odoo.addons.payment_buckaroo.tests.common import BuckarooCommon
|
||||
class BuckarooTest(BuckarooCommon, PaymentHttpCommon):
|
||||
|
||||
def test_redirect_form_values(self):
|
||||
self.patch(self, 'base_url', lambda: 'http://127.0.0.1:8069')
|
||||
self.patch(type(self.env['base']), 'get_base_url', lambda _: 'http://127.0.0.1:8069')
|
||||
|
||||
return_url = self._build_url(BuckarooController._return_url)
|
||||
expected_values = {
|
||||
'Brq_websitekey': self.buckaroo.buckaroo_website_key,
|
||||
|
||||
@@ -45,6 +45,9 @@ class SipsTest(SipsCommon, PaymentHttpCommon):
|
||||
"Payulatam: transaction reference wasn't correctly singularized.")
|
||||
|
||||
def test_redirect_form_values(self):
|
||||
self.patch(self, 'base_url', lambda: 'http://127.0.0.1:8069')
|
||||
self.patch(type(self.env['base']), 'get_base_url', lambda _: 'http://127.0.0.1:8069')
|
||||
|
||||
tx = self.create_transaction(flow="redirect")
|
||||
|
||||
with mute_logger('odoo.addons.payment.models.payment_transaction'):
|
||||
|
||||
@@ -71,7 +71,6 @@ _logger = logging.getLogger(__name__)
|
||||
# The odoo library is supposed already configured.
|
||||
ADDONS_PATH = odoo.tools.config['addons_path']
|
||||
HOST = '127.0.0.1'
|
||||
PORT = odoo.tools.config['http_port']
|
||||
# Useless constant, tests are aware of the content of demo data
|
||||
ADMIN_USER_ID = odoo.SUPERUSER_ID
|
||||
|
||||
@@ -1670,7 +1669,7 @@ class HttpCase(TransactionCase):
|
||||
|
||||
@classmethod
|
||||
def base_url(cls):
|
||||
return f"http://{HOST}:{PORT}"
|
||||
return f"http://{HOST}:{odoo.tools.config['http_port']}"
|
||||
|
||||
def start_tour(self, url_path, tour_name, step_delay=None, **kwargs):
|
||||
"""Wrapper for `browser_js` to start the given `tour_name` with the
|
||||
|
||||
Reference in New Issue
Block a user