mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
remote_server: Migrate RemoteZulipServer.uuid to be UUIDField.
Given that these values are uuids, it's better to use UUIDField which is meant for exactly that, rather than an arbitrary CharField. This requires modifying some tests to use valid uuids.
This commit is contained in:
committed by
Tim Abbott
parent
e48120fd12
commit
c5c3ab66d6
@@ -90,7 +90,7 @@ if settings.ZILENCER_ENABLED:
|
||||
@skipUnless(settings.ZILENCER_ENABLED, "requires zilencer")
|
||||
class BouncerTestCase(ZulipTestCase):
|
||||
def setUp(self) -> None:
|
||||
self.server_uuid = "1234-abcd"
|
||||
self.server_uuid = "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
|
||||
server = RemoteZulipServer(
|
||||
uuid=self.server_uuid,
|
||||
api_key="magic_secret_api_key",
|
||||
@@ -234,12 +234,15 @@ class PushBouncerNotificationTest(BouncerTestCase):
|
||||
self.server_uuid, endpoint, dict(user_id=user_id, token_kind=token_kind, token=token)
|
||||
)
|
||||
self.assert_json_error(
|
||||
result, "Zulip server auth failure: key does not match role 1234-abcd", status_code=401
|
||||
result,
|
||||
"Zulip server auth failure: key does not match role 6cde5f7a-1f7e-4978-9716-49f69ebfc9fe",
|
||||
status_code=401,
|
||||
)
|
||||
|
||||
del self.API_KEYS[self.server_uuid]
|
||||
|
||||
credentials = "{}:{}".format("5678-efgh", "invalid")
|
||||
credentials_uuid = str(uuid.uuid4())
|
||||
credentials = "{}:{}".format(credentials_uuid, "invalid")
|
||||
api_auth = "Basic " + base64.b64encode(credentials.encode()).decode()
|
||||
result = self.client_post(
|
||||
endpoint,
|
||||
@@ -248,7 +251,7 @@ class PushBouncerNotificationTest(BouncerTestCase):
|
||||
)
|
||||
self.assert_json_error(
|
||||
result,
|
||||
"Zulip server auth failure: 5678-efgh is not registered -- did you run `manage.py register_server`?",
|
||||
f"Zulip server auth failure: {credentials_uuid} is not registered -- did you run `manage.py register_server`?",
|
||||
status_code=401,
|
||||
)
|
||||
|
||||
@@ -325,7 +328,7 @@ class PushBouncerNotificationTest(BouncerTestCase):
|
||||
logger.output,
|
||||
[
|
||||
"INFO:zilencer.views:"
|
||||
f"Sending mobile push notifications for remote user 1234-abcd:{hamlet.id}: "
|
||||
f"Sending mobile push notifications for remote user 6cde5f7a-1f7e-4978-9716-49f69ebfc9fe:{hamlet.id}: "
|
||||
"2 via FCM devices, 1 via APNs devices"
|
||||
],
|
||||
)
|
||||
@@ -673,7 +676,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||
self.assertEqual(
|
||||
warn_log.output,
|
||||
[
|
||||
"WARNING:root:Invalid data saving zilencer_remoteinstallationcount for server demo.example.com/1234-abcd"
|
||||
"WARNING:root:Invalid data saving zilencer_remoteinstallationcount for server demo.example.com/6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
|
||||
],
|
||||
)
|
||||
|
||||
@@ -784,7 +787,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
||||
send_analytics_to_remote_server()
|
||||
remote_log_entry = RemoteRealmAuditLog.objects.order_by("id").last()
|
||||
assert remote_log_entry is not None
|
||||
self.assertEqual(remote_log_entry.server.uuid, self.server_uuid)
|
||||
self.assertEqual(str(remote_log_entry.server.uuid), self.server_uuid)
|
||||
self.assertEqual(remote_log_entry.remote_id, log_entry.id)
|
||||
self.assertEqual(remote_log_entry.event_time, self.TIME_ZERO)
|
||||
self.assertEqual(remote_log_entry.backfilled, True)
|
||||
@@ -921,7 +924,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
||||
views_logger.output,
|
||||
[
|
||||
"INFO:zilencer.views:"
|
||||
f"Sending mobile push notifications for remote user 1234-abcd:{self.user_profile.id}: "
|
||||
f"Sending mobile push notifications for remote user 6cde5f7a-1f7e-4978-9716-49f69ebfc9fe:{self.user_profile.id}: "
|
||||
f"{len(gcm_devices)} via FCM devices, {len(apns_devices)} via APNs devices"
|
||||
],
|
||||
)
|
||||
@@ -982,7 +985,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
||||
views_logger.output,
|
||||
[
|
||||
"INFO:zilencer.views:"
|
||||
f"Sending mobile push notifications for remote user 1234-abcd:{self.user_profile.id}: "
|
||||
f"Sending mobile push notifications for remote user 6cde5f7a-1f7e-4978-9716-49f69ebfc9fe:{self.user_profile.id}: "
|
||||
f"{len(gcm_devices)} via FCM devices, {len(apns_devices)} via APNs devices"
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user