mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 11:46:53 +00:00
Scope multi-attempt configuration in IssuedReceiptsManager to subscriptions only
This commit is contained in:
1 parent
d6b80dfd16
commit
6e3106297b
13 files changed
+64
-26
No files matched your search
+1
-1
@@ -345,7 +345,7 @@ class OneTimeDonationControllerTest extends AbstractV1SubscriptionControllerTest
|
||||
PaymentStatus.SUCCEEDED,
|
||||
Instant.now(),
|
||||
null)));
|
||||
doThrow(WriteConflictException.class).when(ISSUED_RECEIPTS_MANAGER).recordIssuance(any(), any(), any(), any());
|
||||
doThrow(WriteConflictException.class).when(ISSUED_RECEIPTS_MANAGER).recordOneTimeIssuance(any(), any(), any(), any());
|
||||
|
||||
try (Response response = RESOURCE_EXTENSION.target("/v1/subscription/boost/receipt_credentials")
|
||||
.request()
|
||||
|
||||
+1
-1
@@ -308,7 +308,7 @@ public class OneTimeDonationsGrpcServiceTest extends
|
||||
Optional.of(new PaymentDetails("id", oneTimeDonationConfiguration.boost().level(),
|
||||
PaymentStatus.SUCCEEDED, clock.instant(), null)));
|
||||
doThrow(WriteConflictException.class).when(issuedReceiptsManager)
|
||||
.recordIssuance(any(), any(), any(), any());
|
||||
.recordOneTimeIssuance(any(), any(), any(), any());
|
||||
|
||||
final CreateBoostReceiptCredentialsResponse response =
|
||||
unauthenticatedServiceStub().createBoostReceiptCredentials(
|
||||
|
||||
+13
@@ -120,6 +120,19 @@ class IssuedReceiptsManagerTest {
|
||||
.isExactlyInstanceOf(WriteConflictException.class);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(PaymentProvider.class)
|
||||
void testSingleIssuance(final PaymentProvider processor) throws WriteConflictException {
|
||||
final Instant now = Instant.ofEpochSecond(NOW_EPOCH_SECONDS);
|
||||
final ReceiptCredentialRequest request = randomReceiptCredentialRequest();
|
||||
|
||||
issuedReceiptsManager.recordOneTimeIssuance("item-1", processor, request, now);
|
||||
// Retrying with the same request should still succeed
|
||||
issuedReceiptsManager.recordOneTimeIssuance("item-1", processor, request, now);
|
||||
assertThatThrownBy(
|
||||
() -> issuedReceiptsManager.recordOneTimeIssuance("item-1", processor, randomReceiptCredentialRequest(), now))
|
||||
.isExactlyInstanceOf(WriteConflictException.class);
|
||||
}
|
||||
|
||||
private GetItemResponse getItem(final PaymentProvider processor, final String itemId) {
|
||||
final DynamoDbClient client = DYNAMO_DB_EXTENSION.getDynamoDbClient();
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@ class LoginPurchaseManagerTest {
|
||||
.truncatedTo(ChronoUnit.DAYS)
|
||||
.getEpochSecond());
|
||||
|
||||
verify(issuedReceiptsManager).recordIssuance(
|
||||
verify(issuedReceiptsManager).recordOneTimeIssuance(
|
||||
PURCHASE_ID, PROVIDER, receiptCredentialRequestContext.getRequest(), NOW);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ class LoginPurchaseManagerTest {
|
||||
when(paymentProcessor.claimOneTimePurchase(PURCHASE_ID))
|
||||
.thenReturn(Optional.of(new PaymentDetails(PURCHASE_ID, LEVEL, PaymentStatus.SUCCEEDED, PURCHASED_AT, null)));
|
||||
doThrow(new WriteConflictException())
|
||||
.when(issuedReceiptsManager).recordIssuance(any(), any(), any(), any());
|
||||
.when(issuedReceiptsManager).recordOneTimeIssuance(any(), any(), any(), any());
|
||||
assertThatExceptionOfType(SubscriptionReceiptAlreadyRedeemedException.class).isThrownBy(() -> {
|
||||
loginPurchaseManager.generateReceipt(PROVIDER, PURCHASE_ID, receiptCredentialRequestContext.getRequest());
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user