Treat a 410 for an IAP token as not found

This commit is contained in:
ravi-signal
2025-03-07 15:24:33 -06:00
committed by GitHub
parent d1c9dff2c5
commit 469955aec9
2 changed files with 48 additions and 15 deletions

View File

@@ -15,6 +15,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import com.google.api.client.http.HttpResponseException;
import com.google.api.services.androidpublisher.AndroidPublisher;
import com.google.api.services.androidpublisher.model.AutoRenewingPlan;
import com.google.api.services.androidpublisher.model.BasePlan;
@@ -33,11 +34,14 @@ import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.whispersystems.textsecuregcm.storage.SubscriptionException;
import org.whispersystems.textsecuregcm.util.CompletableFutureTestUtil;
import org.whispersystems.textsecuregcm.util.MockUtils;
@@ -257,4 +261,22 @@ class GooglePlayBillingManagerTest {
}
public static Stream<Arguments> tokenErrors() {
return Stream.of(
Arguments.of(404, SubscriptionException.NotFound.class),
Arguments.of(410, SubscriptionException.NotFound.class),
Arguments.of(400, HttpResponseException.class)
);
}
@ParameterizedTest
@MethodSource
public void tokenErrors(final int httpStatus, Class<? extends Exception> expected) throws IOException {
final HttpResponseException mockException = mock(HttpResponseException.class);
when(mockException.getStatusCode()).thenReturn(httpStatus);
when(subscriptionsv2Get.execute()).thenThrow(mockException);
CompletableFutureTestUtil.assertFailsWithCause(expected,
googlePlayBillingManager.getSubscriptionInformation(PURCHASE_TOKEN));
}
}