Files
odoo_source/odoo/addons/base/tests/test_config_parameter.py
T
Om Rabara 52a204f3da [FIX] base: handle database.secret parameter while deletion
An error occurs when the user attempts to delete the 'database.secret' record,
either by following these steps:
- Enable developer mode.
- Go to Settings > Technical > System Parameters.
- Select the 'database.secret' record and attempt to delete it.

Or when the user tries to update the key for the 'database.secret' record using
the following steps:
- Open the 'database.secret' record.
- Update the value of the key field.
-  Save the record.
- The server will stop running and not be accessible.

Error: ValueError: CSRF protection requires a configured database secret

sentry - 4291267997

closes odoo/odoo#131460

X-original-commit: fe694e5b8285ceed99b321c22af534eee25cf282
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-08-10 17:02:15 +02:00

22 lines
846 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.base.models.ir_config_parameter import _default_parameters
from odoo.exceptions import ValidationError
from odoo.tests.common import TransactionCase
class TestIrConfigParameter(TransactionCase):
def test_default_parameters(self):
""" Check the behavior of _default_parameters
when updating keys and deleting records. """
for key in _default_parameters:
config_parameter = self.env['ir.config_parameter'].search([('key', '=', key)], limit=1)
with self.assertRaises(ValidationError):
config_parameter.unlink()
new_key = f"{key}_updated"
with self.assertRaises(ValidationError):
config_parameter.write({'key': new_key})