Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

realm: Fix extra_data for REALM_SUBDOMAIN_CHANGED audit log entries.

Sahil Batra4dbc9bd281da
diff --git a/zerver/actions/create_realm.py b/zerver/actions/create_realm.py
index 11774e59047..fd479a26cdd 100644
--- a/zerver/actions/create_realm.py
+++ b/zerver/actions/create_realm.py
@@ -70,7 +70,12 @@ def do_change_realm_subdomain(
event_type=AuditLogEventType.REALM_SUBDOMAIN_CHANGED,
event_time=timezone_now(),
acting_user=acting_user,
- extra_data={"old_subdomain": old_subdomain, "new_subdomain": new_subdomain},
+ # Old RealmAuditLog entries for this used "old_subdomain" and
+ # "new_subdomain" keys to store this data.
+ extra_data={
+ RealmAuditLog.OLD_VALUE: old_subdomain,
+ RealmAuditLog.NEW_VALUE: new_subdomain,
+ },
)
# If a realm if being renamed multiple times, we should find all the placeholder
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 81dd2f23aa7..d308fce98f9 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -402,7 +402,10 @@ class RealmTest(ZulipTestCase):
event_type=AuditLogEventType.REALM_SUBDOMAIN_CHANGED, acting_user=iago
).last()
assert realm_audit_log is not None
- expected_extra_data = {"old_subdomain": "zulip", "new_subdomain": "newzulip"}
+ expected_extra_data = {
+ RealmAuditLog.OLD_VALUE: "zulip",
+ RealmAuditLog.NEW_VALUE: "newzulip",
+ }
self.assertEqual(realm_audit_log.extra_data, expected_extra_data)
self.assertEqual(realm_audit_log.acting_user, iago)