diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java index d7fed0202..afb029c1e 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java @@ -167,7 +167,7 @@ public class APNSender implements Managed, PushNotificationSender { } else { accepted = false; rejectionReason = response.getRejectionReason(); - unregistered = response.getRejectionReason().map(reason -> "Unregistered".equals(reason) || "BadDeviceToken".equals(reason)) + unregistered = response.getRejectionReason().map(reason -> "Unregistered".equals(reason) || "BadDeviceToken".equals(reason) || "ExpiredToken".equals(reason)) .orElse(false); } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java index 2fe9ad4ed..6085e3d10 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java @@ -133,11 +133,12 @@ class APNSenderTest { verifyNoMoreInteractions(apnsClient); } - @Test - void testUnregisteredUser() { + @ParameterizedTest + @ValueSource(strings = {"Unregistered", "BadDeviceToken", "ExpiredToken"}) + void testUnregisteredUser(final String rejectionReason) { PushNotificationResponse response = mock(PushNotificationResponse.class); when(response.isAccepted()).thenReturn(false); - when(response.getRejectionReason()).thenReturn(Optional.of("Unregistered")); + when(response.getRejectionReason()).thenReturn(Optional.of(rejectionReason)); when(apnsClient.sendNotification(any(SimpleApnsPushNotification.class))) .thenAnswer( @@ -160,7 +161,7 @@ class APNSenderTest { assertThat(notification.getValue().getPriority()).isEqualTo(DeliveryPriority.IMMEDIATE); assertThat(result.accepted()).isFalse(); - assertThat(result.errorCode()).hasValue("Unregistered"); + assertThat(result.errorCode()).hasValue(rejectionReason); assertThat(result.unregistered()).isTrue(); }