push_notifications: Remove vestiges of base64 storage of tokens.

APNs tokens are provided by the client in hex, and we store them in
hex.  The existing code which attempts to "validate" them by parsing
them as base64 only works because base64 is a superset of hex.

Enforce that APNs tokens are hex, and remove all of the pieces of test
code which were incorrectly passing them in as base64 strings.
This commit is contained in:
Alex Vandiver
2025-07-16 04:43:47 +00:00
committed by Tim Abbott
parent 3bd8c28fca
commit 3e5af466e4
9 changed files with 52 additions and 77 deletions

View File

@@ -18,7 +18,6 @@ from zerver.actions.user_settings import do_change_user_setting
from zerver.actions.user_topics import do_set_user_topic_visibility_policy
from zerver.lib.push_notifications import (
UserPushIdentityCompat,
b64_to_hex,
handle_push_notification,
handle_remove_push_notification,
)
@@ -92,11 +91,11 @@ class HandlePushNotificationTest(PushNotificationTestCase):
self.assertLogs("zilencer.views", level="INFO") as views_logger,
):
apns_devices = [
(b64_to_hex(device.token), device.ios_app_id, device.token)
(device.token, device.ios_app_id, device.token)
for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.APNS)
]
gcm_devices = [
(b64_to_hex(device.token), device.ios_app_id, device.token)
(device.token, device.ios_app_id, device.token)
for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.FCM)
]
mock_fcm_messaging.send_each.return_value = self.make_fcm_success_response(
@@ -260,11 +259,11 @@ class HandlePushNotificationTest(PushNotificationTestCase):
self.assertLogs("zilencer.views", level="INFO") as views_logger,
):
apns_devices = [
(b64_to_hex(device.token), device.ios_app_id, device.token)
(device.token, device.ios_app_id, device.token)
for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.APNS)
]
gcm_devices = [
(b64_to_hex(device.token), device.ios_app_id, device.token)
(device.token, device.ios_app_id, device.token)
for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.FCM)
]