Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add deepcoopy when updating CONFIG_STRUCTURE for AdminEmailPlugin (#15813)

Krzysztof Kwaśniakc5bc3ef90074
diff --git a/saleor/plugins/admin_email/plugin.py b/saleor/plugins/admin_email/plugin.py
index a13fa41194..9b3aef5608 100644
--- a/saleor/plugins/admin_email/plugin.py
+++ b/saleor/plugins/admin_email/plugin.py
@@ -1,4 +1,5 @@
import logging
+from copy import deepcopy
from dataclasses import asdict
from typing import Union
@@ -143,7 +144,7 @@ class AdminEmailPlugin(BasePlugin):
"label": "CSV export failed template",
},
}
- CONFIG_STRUCTURE.update(DEFAULT_EMAIL_CONFIG_STRUCTURE)
+ CONFIG_STRUCTURE.update(deepcopy(DEFAULT_EMAIL_CONFIG_STRUCTURE))
CONFIG_STRUCTURE["host"]["help_text"] += (
" Leave it blank if you want to use system environment - EMAIL_HOST."
)
diff --git a/saleor/plugins/admin_email/tests/test_plugin.py b/saleor/plugins/admin_email/tests/test_plugin.py
index 8f97196058..8d35df6035 100644
--- a/saleor/plugins/admin_email/tests/test_plugin.py
+++ b/saleor/plugins/admin_email/tests/test_plugin.py
@@ -8,7 +8,11 @@ from django.core.mail.backends.smtp import EmailBackend
from ....core.notify_events import NotifyEventType
from ....graphql.tests.utils import get_graphql_content
-from ...email_common import DEFAULT_EMAIL_VALUE, get_email_template
+from ...email_common import (
+ DEFAULT_EMAIL_CONFIG_STRUCTURE,
+ DEFAULT_EMAIL_VALUE,
+ get_email_template,
+)
from ...manager import get_plugins_manager
from ...models import PluginConfiguration
from ..constants import (
@@ -24,7 +28,7 @@ from ..notify_events import (
send_staff_order_confirmation,
send_staff_reset_password,
)
-from ..plugin import get_admin_event_map
+from ..plugin import AdminEmailPlugin, get_admin_event_map
def test_event_map():
@@ -293,3 +297,30 @@ def test_plugin_manager_doesnt_load_email_templates_from_db(
# email template from DB but returns default email value.
assert email_config_item
assert email_config_item["value"] == DEFAULT_EMAIL_VALUE
+
+
+def test_plugin_dont_change_default_help_text_config_value():
+ assert (
+ AdminEmailPlugin.CONFIG_STRUCTURE["host"]["help_text"]
+ != DEFAULT_EMAIL_CONFIG_STRUCTURE["host"]["help_text"]
+ )
+ assert (
+ AdminEmailPlugin.CONFIG_STRUCTURE["port"]["help_text"]
+ != DEFAULT_EMAIL_CONFIG_STRUCTURE["port"]["help_text"]
+ )
+ assert (
+ AdminEmailPlugin.CONFIG_STRUCTURE["username"]["help_text"]
+ != DEFAULT_EMAIL_CONFIG_STRUCTURE["username"]["help_text"]
+ )
+ assert (
+ AdminEmailPlugin.CONFIG_STRUCTURE["password"]["help_text"]
+ != DEFAULT_EMAIL_CONFIG_STRUCTURE["password"]["help_text"]
+ )
+ assert (
+ AdminEmailPlugin.CONFIG_STRUCTURE["use_tls"]["help_text"]
+ != DEFAULT_EMAIL_CONFIG_STRUCTURE["use_tls"]["help_text"]
+ )
+ assert (
+ AdminEmailPlugin.CONFIG_STRUCTURE["use_ssl"]["help_text"]
+ != DEFAULT_EMAIL_CONFIG_STRUCTURE["use_ssl"]["help_text"]
+ )