Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,13 @@ def update_req(self, site_item: "SiteItem", parent_srv: "Server | None" = None):
site_item.custom_subscription_email_enabled
).lower()
if site_item.custom_subscription_email is not None:
site_element.attrib["customSubscriptionEmail"] = str(site_item.custom_subscription_email).lower()
site_element.attrib["customSubscriptionEmail"] = str(site_item.custom_subscription_email)
if site_item.custom_subscription_footer_enabled is not None:
site_element.attrib["customSubscriptionFooterEnabled"] = str(
site_item.custom_subscription_footer_enabled
).lower()
if site_item.custom_subscription_footer is not None:
site_element.attrib["customSubscriptionFooter"] = str(site_item.custom_subscription_footer).lower()
site_element.attrib["customSubscriptionFooter"] = str(site_item.custom_subscription_footer)
if site_item.ask_data_mode is not None:
site_element.attrib["askDataMode"] = str(site_item.ask_data_mode)
if site_item.named_sharing_enabled is not None:
Expand Down Expand Up @@ -837,13 +837,13 @@ def create_req(self, site_item: "SiteItem", parent_srv: "Server | None" = None):
site_item.custom_subscription_email_enabled
).lower()
if site_item.custom_subscription_email is not None:
site_element.attrib["customSubscriptionEmail"] = str(site_item.custom_subscription_email).lower()
site_element.attrib["customSubscriptionEmail"] = str(site_item.custom_subscription_email)
if site_item.custom_subscription_footer_enabled is not None:
site_element.attrib["customSubscriptionFooterEnabled"] = str(
site_item.custom_subscription_footer_enabled
).lower()
if site_item.custom_subscription_footer is not None:
site_element.attrib["customSubscriptionFooter"] = str(site_item.custom_subscription_footer).lower()
site_element.attrib["customSubscriptionFooter"] = str(site_item.custom_subscription_footer)
if site_item.ask_data_mode is not None:
site_element.attrib["askDataMode"] = str(site_item.ask_data_mode)
if site_item.named_sharing_enabled is not None:
Expand Down
30 changes: 30 additions & 0 deletions test/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,36 @@ def test_update_missing_id(server: TSC.Server) -> None:
server.sites.update(single_site)


def test_update_subscription_email_and_footer_preserve_case() -> None:
# Regression for #1849: RequestFactory used to .lower() customSubscriptionEmail
# and customSubscriptionFooter, silently mangling caller intent. Footer
# especially, since it is displayed verbatim in outgoing subscription emails.
site = TSC.SiteItem(name="X", content_url="x")
site.custom_subscription_email = "Sales@Company.com"
site.custom_subscription_footer = "Sent by Tableau -- Confidential. See https://Example.com/Legal"

xml_bytes = RequestFactory.Site.update_req(site)
xml_text = xml_bytes.decode("utf-8")

assert 'customSubscriptionEmail="Sales@Company.com"' in xml_text, xml_text
assert (
'customSubscriptionFooter="Sent by Tableau -- Confidential. See https://Example.com/Legal"' in xml_text
), xml_text

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in abb41b2. Refactored both tests to parse with defusedxml and assert on the parsed site element attributes, matching the pattern in test_encoding_attr_capture (line 361). Still catches the load-bearing regression (.lower() applied to caller input) but survives serialization-format changes like quoting or entity escaping.



def test_create_subscription_email_and_footer_preserve_case() -> None:
# Same regression for the create-site path.
site = TSC.SiteItem(name="X", content_url="x")
site.custom_subscription_email = "Support@Company.com"
site.custom_subscription_footer = "COMPANY, Inc. -- All Rights Reserved."

xml_bytes = RequestFactory.Site.create_req(site)
xml_text = xml_bytes.decode("utf-8")

assert 'customSubscriptionEmail="Support@Company.com"' in xml_text, xml_text
assert 'customSubscriptionFooter="COMPANY, Inc. -- All Rights Reserved."' in xml_text, xml_text


def test_null_site_quota(server: TSC.Server) -> None:
test_site = TSC.SiteItem("testname", "testcontenturl", tier_explorer_capacity=1, user_quota=None)
assert test_site.tier_explorer_capacity == 1
Expand Down
Loading