mirror of https://github.com/zulip/zulip.git
audit-log: Move remote realm event types to AuditLogEventType enum.
Event types moved: REMOTE_REALM_VALUE_UPDATED, REMOTE_PLAN_TRANSFERRED_SERVER_TO_REALM, REMOTE_REALM_LOCALLY_DELETED REMOTE_REALM_LOCALLY_DELETED_RESTORED
This commit is contained in:
parent
aad93e149e
commit
00ecd4c8f0
|
@ -120,6 +120,14 @@ class AuditLogEventType(IntEnum):
|
||||||
REMOTE_SERVER_SPONSORSHIP_PENDING_STATUS_CHANGED = 10213
|
REMOTE_SERVER_SPONSORSHIP_PENDING_STATUS_CHANGED = 10213
|
||||||
REMOTE_SERVER_CREATED = 10215
|
REMOTE_SERVER_CREATED = 10215
|
||||||
|
|
||||||
|
# This value is for RemoteRealmAuditLog entries tracking changes to the
|
||||||
|
# RemoteRealm model resulting from modified realm information sent to us
|
||||||
|
# via send_server_data_to_push_bouncer.
|
||||||
|
REMOTE_REALM_VALUE_UPDATED = 20001
|
||||||
|
REMOTE_PLAN_TRANSFERRED_SERVER_TO_REALM = 20002
|
||||||
|
REMOTE_REALM_LOCALLY_DELETED = 20003
|
||||||
|
REMOTE_REALM_LOCALLY_DELETED_RESTORED = 20004
|
||||||
|
|
||||||
|
|
||||||
class AbstractRealmAuditLog(models.Model):
|
class AbstractRealmAuditLog(models.Model):
|
||||||
"""Defines fields common to RealmAuditLog and RemoteRealmAuditLog."""
|
"""Defines fields common to RealmAuditLog and RemoteRealmAuditLog."""
|
||||||
|
@ -139,16 +147,7 @@ class AbstractRealmAuditLog(models.Model):
|
||||||
|
|
||||||
extra_data = models.JSONField(default=dict, encoder=DjangoJSONEncoder)
|
extra_data = models.JSONField(default=dict, encoder=DjangoJSONEncoder)
|
||||||
|
|
||||||
# Event types
|
# See AuditLogEventType class above.
|
||||||
|
|
||||||
# This value is for RemoteRealmAuditLog entries tracking changes to the
|
|
||||||
# RemoteRealm model resulting from modified realm information sent to us
|
|
||||||
# via send_server_data_to_push_bouncer.
|
|
||||||
REMOTE_REALM_VALUE_UPDATED = 20001
|
|
||||||
REMOTE_PLAN_TRANSFERRED_SERVER_TO_REALM = 20002
|
|
||||||
REMOTE_REALM_LOCALLY_DELETED = 20003
|
|
||||||
REMOTE_REALM_LOCALLY_DELETED_RESTORED = 20004
|
|
||||||
|
|
||||||
event_type = models.PositiveSmallIntegerField()
|
event_type = models.PositiveSmallIntegerField()
|
||||||
|
|
||||||
# event_types synced from on-prem installations to Zulip Cloud when
|
# event_types synced from on-prem installations to Zulip Cloud when
|
||||||
|
|
|
@ -1729,7 +1729,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
# Verify the RemoteRealmAuditLog entries created.
|
# Verify the RemoteRealmAuditLog entries created.
|
||||||
remote_audit_logs = (
|
remote_audit_logs = (
|
||||||
RemoteRealmAuditLog.objects.filter(
|
RemoteRealmAuditLog.objects.filter(
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_VALUE_UPDATED,
|
event_type=AuditLogEventType.REMOTE_REALM_VALUE_UPDATED,
|
||||||
remote_realm=zephyr_remote_realm,
|
remote_realm=zephyr_remote_realm,
|
||||||
)
|
)
|
||||||
.order_by("id")
|
.order_by("id")
|
||||||
|
@ -1740,7 +1740,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
list(remote_audit_logs),
|
list(remote_audit_logs),
|
||||||
[
|
[
|
||||||
dict(
|
dict(
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_VALUE_UPDATED,
|
event_type=AuditLogEventType.REMOTE_REALM_VALUE_UPDATED,
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
realm_id=zephyr_realm.id,
|
realm_id=zephyr_realm.id,
|
||||||
extra_data={
|
extra_data={
|
||||||
|
@ -1750,7 +1750,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_VALUE_UPDATED,
|
event_type=AuditLogEventType.REMOTE_REALM_VALUE_UPDATED,
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
realm_id=zephyr_realm.id,
|
realm_id=zephyr_realm.id,
|
||||||
extra_data={
|
extra_data={
|
||||||
|
@ -1760,7 +1760,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_VALUE_UPDATED,
|
event_type=AuditLogEventType.REMOTE_REALM_VALUE_UPDATED,
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
realm_id=zephyr_realm.id,
|
realm_id=zephyr_realm.id,
|
||||||
extra_data={
|
extra_data={
|
||||||
|
@ -1770,7 +1770,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_VALUE_UPDATED,
|
event_type=AuditLogEventType.REMOTE_REALM_VALUE_UPDATED,
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
realm_id=zephyr_realm.id,
|
realm_id=zephyr_realm.id,
|
||||||
extra_data={
|
extra_data={
|
||||||
|
@ -1780,7 +1780,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_VALUE_UPDATED,
|
event_type=AuditLogEventType.REMOTE_REALM_VALUE_UPDATED,
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
realm_id=zephyr_realm.id,
|
realm_id=zephyr_realm.id,
|
||||||
extra_data={
|
extra_data={
|
||||||
|
@ -2719,7 +2719,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
self.assertEqual(analytics_logger.output, ["WARNING:zulip.analytics:Dummy warning"])
|
self.assertEqual(analytics_logger.output, ["WARNING:zulip.analytics:Dummy warning"])
|
||||||
|
|
||||||
audit_log = RemoteRealmAuditLog.objects.latest("id")
|
audit_log = RemoteRealmAuditLog.objects.latest("id")
|
||||||
self.assertEqual(audit_log.event_type, RemoteRealmAuditLog.REMOTE_REALM_LOCALLY_DELETED)
|
self.assertEqual(audit_log.event_type, AuditLogEventType.REMOTE_REALM_LOCALLY_DELETED)
|
||||||
self.assertEqual(audit_log.remote_realm, remote_realm_for_deleted_realm)
|
self.assertEqual(audit_log.remote_realm, remote_realm_for_deleted_realm)
|
||||||
|
|
||||||
from django.core.mail import outbox
|
from django.core.mail import outbox
|
||||||
|
@ -2758,7 +2758,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||||
|
|
||||||
audit_log = RemoteRealmAuditLog.objects.latest("id")
|
audit_log = RemoteRealmAuditLog.objects.latest("id")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
audit_log.event_type, RemoteRealmAuditLog.REMOTE_REALM_LOCALLY_DELETED_RESTORED
|
audit_log.event_type, AuditLogEventType.REMOTE_REALM_LOCALLY_DELETED_RESTORED
|
||||||
)
|
)
|
||||||
self.assertEqual(audit_log.remote_realm, remote_realm_for_deleted_realm)
|
self.assertEqual(audit_log.remote_realm, remote_realm_for_deleted_realm)
|
||||||
|
|
||||||
|
|
|
@ -917,7 +917,7 @@ def update_remote_realm_data_for_server(
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
remote_realm=remote_realm,
|
remote_realm=remote_realm,
|
||||||
realm_id=realm.id,
|
realm_id=realm.id,
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_VALUE_UPDATED,
|
event_type=AuditLogEventType.REMOTE_REALM_VALUE_UPDATED,
|
||||||
event_time=now,
|
event_time=now,
|
||||||
extra_data={
|
extra_data={
|
||||||
"attr_name": remote_realm_attr,
|
"attr_name": remote_realm_attr,
|
||||||
|
@ -936,7 +936,7 @@ def update_remote_realm_data_for_server(
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
remote_realm=remote_realm,
|
remote_realm=remote_realm,
|
||||||
realm_id=uuid_to_realm_dict[str(remote_realm.uuid)].id,
|
realm_id=uuid_to_realm_dict[str(remote_realm.uuid)].id,
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_LOCALLY_DELETED_RESTORED,
|
event_type=AuditLogEventType.REMOTE_REALM_LOCALLY_DELETED_RESTORED,
|
||||||
event_time=now,
|
event_time=now,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -977,7 +977,7 @@ def update_remote_realm_data_for_server(
|
||||||
remote_id=None,
|
remote_id=None,
|
||||||
remote_realm=remote_realm,
|
remote_realm=remote_realm,
|
||||||
realm_id=None,
|
realm_id=None,
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_REALM_LOCALLY_DELETED,
|
event_type=AuditLogEventType.REMOTE_REALM_LOCALLY_DELETED,
|
||||||
event_time=now,
|
event_time=now,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1133,7 +1133,7 @@ def handle_customer_migration_from_server_to_realm(
|
||||||
RemoteRealmAuditLog(
|
RemoteRealmAuditLog(
|
||||||
server=server,
|
server=server,
|
||||||
remote_realm=remote_realm,
|
remote_realm=remote_realm,
|
||||||
event_type=RemoteRealmAuditLog.REMOTE_PLAN_TRANSFERRED_SERVER_TO_REALM,
|
event_type=AuditLogEventType.REMOTE_PLAN_TRANSFERRED_SERVER_TO_REALM,
|
||||||
event_time=event_time,
|
event_time=event_time,
|
||||||
extra_data={
|
extra_data={
|
||||||
"attr_name": "plan_type",
|
"attr_name": "plan_type",
|
||||||
|
|
Loading…
Reference in New Issue