From 87ca4578b32cd360341229408b1a73a166025951 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Thu, 24 Sep 2026 18:22:26 -0400 Subject: [PATCH] =?UTF-8?q?Use=20singular=20=E2=80=9Ccredential=E2=80=9D?= =?UTF-8?q?=20when=20appropriate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OneTimeDonationController.java | 14 +++---- .../controllers/SubscriptionController.java | 14 +++---- .../grpc/OneTimeDonationsGrpcService.java | 20 ++++----- .../grpc/ProfileAnonymousGrpcService.java | 12 +++--- .../grpc/ProfileGrpcService.java | 14 +++---- .../grpc/SubscriptionsGrpcService.java | 29 +++++++------ .../storage/SubscriptionManager.java | 2 +- .../proto/org/signal/chat/donations.proto | 2 +- .../org/signal/chat/one_time_donations.proto | 12 +++--- .../main/proto/org/signal/chat/profile.proto | 32 +++++++------- .../proto/org/signal/chat/subscriptions.proto | 16 +++---- .../OneTimeDonationControllerTest.java | 2 +- .../SubscriptionControllerTest.java | 6 +-- .../grpc/OneTimeDonationsGrpcServiceTest.java | 26 ++++++------ .../grpc/ProfileAnonymousGrpcServiceTest.java | 30 ++++++------- .../grpc/ProfileGrpcServiceTest.java | 26 ++++++------ .../grpc/SubscriptionsGrpcServiceTest.java | 42 +++++++++---------- 17 files changed, 149 insertions(+), 150 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java index 5053ef7f7..4105ec3b4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java @@ -313,7 +313,7 @@ public class OneTimeDonationController { return new ConfirmPayPalBoostResponse(chargeSuccessDetails.paymentId()); } - public static class CreateBoostReceiptCredentialsRequest { + public static class CreateBoostReceiptCredentialRequest { /** * a payment ID from {@link #processor} @@ -327,10 +327,10 @@ public class OneTimeDonationController { public PaymentProvider processor = PaymentProvider.STRIPE; } - public record CreateBoostReceiptCredentialsSuccessResponse(byte[] receiptCredentialResponse) { + public record CreateBoostReceiptCredentialSuccessResponse(byte[] receiptCredentialResponse) { } - public record CreateBoostReceiptCredentialsErrorResponse( + public record CreateBoostReceiptCredentialErrorResponse( @JsonInclude(JsonInclude.Include.NON_NULL) ChargeFailure chargeFailure) {} @POST @@ -338,9 +338,9 @@ public class OneTimeDonationController { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ManagedAsync - public Response createBoostReceiptCredentials( + public Response createBoostReceiptCredential( @Auth final Optional authenticatedAccount, - @NotNull @Valid final CreateBoostReceiptCredentialsRequest request, + @NotNull @Valid final CreateBoostReceiptCredentialRequest request, @HeaderParam(HttpHeaders.USER_AGENT) final String userAgent) throws IOException { if (authenticatedAccount.isPresent()) { @@ -363,7 +363,7 @@ public class OneTimeDonationController { } if (paymentDetails.status() != PaymentStatus.SUCCEEDED) { throw new WebApplicationException(Response.status(Response.Status.PAYMENT_REQUIRED) - .entity(new CreateBoostReceiptCredentialsErrorResponse(paymentDetails.chargeFailure())).build()); + .entity(new CreateBoostReceiptCredentialErrorResponse(paymentDetails.chargeFailure())).build()); } // The payment was successful, try to issue the receipt credential @@ -406,7 +406,7 @@ public class OneTimeDonationController { UserAgentTagUtil.getPlatformTag(userAgent))) .increment(); return Response.ok( - new CreateBoostReceiptCredentialsSuccessResponse(receiptCredentialResponse.serialize())) + new CreateBoostReceiptCredentialSuccessResponse(receiptCredentialResponse.serialize())) .build(); } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java index 3a1b6f444..eeb110ab4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java @@ -688,12 +688,12 @@ public class SubscriptionController { .orElseGet(() -> new GetSubscriptionInformationResponse(null, null)); } - public record GetReceiptCredentialsRequest( + public record GetReceiptCredentialRequest( @Schema(description = "A ReceiptCredentialRequest encoded in standard base64 with padding") @NotEmpty byte[] receiptCredentialRequest) { } - public record GetReceiptCredentialsResponse( + public record GetReceiptCredentialResponse( @Schema(description = "A ReceiptCredentialResponse encoded in standard base64 with padding") @NotEmpty byte[] receiptCredentialResponse) { } @@ -711,7 +711,7 @@ public class SubscriptionController { invoice. Clients SHOULD retry requests at this endpoint with the same ReceiptCredentialRequest value until receiving a response. After receiving a response, clients should then compute the ReceiptCredentialPresentation and redeem it at the receipt redemption endpoint. Once the first attempt is made there, the same - ReceiptCredentialRequest MUST NOT be used again to request receipt credentials. + ReceiptCredentialRequest MUST NOT be used again to request a receipt credential. Note that you may in fact redeem TWO or more invoices for the same ReceiptCredentialRequest while retrying this operation if a later invoice gets paid while you are retrying. However, the returned receipt is always for the @@ -747,14 +747,14 @@ public class SubscriptionController { name = "Retry-After", description = "If present, a positive integer indicating the number of seconds before a subsequent attempt could succeed")) @ManagedAsync - public Response createSubscriptionReceiptCredentials( + public Response createSubscriptionReceiptCredential( @Auth Optional authenticatedAccount, @HeaderParam(HttpHeaders.USER_AGENT) final String userAgent, @PathParam("subscriberId") String subscriberId, - @NotNull @Valid GetReceiptCredentialsRequest request) throws SubscriptionException, RateLimitExceededException { + @NotNull @Valid GetReceiptCredentialRequest request) throws SubscriptionException, RateLimitExceededException { SubscriberCredentials subscriberCredentials = SubscriberCredentials.process(authenticatedAccount, subscriberId, clock); try { - final SubscriptionManager.ReceiptResult receiptCredential = subscriptionManager.createReceiptCredentials( + final SubscriptionManager.ReceiptResult receiptCredential = subscriptionManager.createReceiptCredential( subscriberCredentials, request.receiptCredentialRequest(), r -> SubscriptionsUtil.receiptExpirationWithGracePeriod(subscriptionConfiguration, r), userAgent); @@ -770,7 +770,7 @@ public class SubscriptionController { .toLowerCase(Locale.ROOT)), UserAgentTagUtil.getPlatformTag(userAgent))) .increment(); - return Response.ok(new GetReceiptCredentialsResponse(receiptCredentialResponse.serialize())).build(); + return Response.ok(new GetReceiptCredentialResponse(receiptCredentialResponse.serialize())).build(); } catch (SubscriptionReceiptRequestedForOpenPaymentException e) { return Response.noContent().build(); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcService.java index b6695f74e..821a01e89 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcService.java @@ -25,8 +25,8 @@ import org.signal.chat.purchase.AmountAboveSepaLimitError; import org.signal.chat.purchase.AmountBelowMinimumError; import org.signal.chat.purchase.ConfirmPayPalBoostRequest; import org.signal.chat.purchase.ConfirmPayPalBoostResponse; -import org.signal.chat.purchase.CreateBoostReceiptCredentialsRequest; -import org.signal.chat.purchase.CreateBoostReceiptCredentialsResponse; +import org.signal.chat.purchase.CreateBoostReceiptCredentialRequest; +import org.signal.chat.purchase.CreateBoostReceiptCredentialResponse; import org.signal.chat.purchase.CreateBoostRequest; import org.signal.chat.purchase.CreateBoostResponse; import org.signal.chat.purchase.CreatePayPalBoostRequest; @@ -261,8 +261,8 @@ public class OneTimeDonationsGrpcService extends SimpleOneTimeDonationsGrpc.OneT } @Override - public CreateBoostReceiptCredentialsResponse createBoostReceiptCredentials( - final CreateBoostReceiptCredentialsRequest request) throws IOException { + public CreateBoostReceiptCredentialResponse createBoostReceiptCredential( + final CreateBoostReceiptCredentialRequest request) throws IOException { final PaymentProvider processor = PaymentProvider.fromProto(request.getProcessor()) .orElseThrow(() -> GrpcExceptions.fieldViolation("processor", "Unsupported payment processor")); @@ -274,12 +274,12 @@ public class OneTimeDonationsGrpcService extends SimpleOneTimeDonationsGrpc.OneT }; if (maybePaymentDetails.isEmpty()) { - return CreateBoostReceiptCredentialsResponse.newBuilder() + return CreateBoostReceiptCredentialResponse.newBuilder() .setPaymentNotFound(NotFound.getDefaultInstance()).build(); } final PaymentDetails paymentDetails = maybePaymentDetails.get(); if (paymentDetails.status() == PaymentStatus.PROCESSING) { - return CreateBoostReceiptCredentialsResponse.newBuilder() + return CreateBoostReceiptCredentialResponse.newBuilder() .setPaymentStillProcessing(FailedPrecondition.getDefaultInstance()).build(); } if (paymentDetails.status() != PaymentStatus.SUCCEEDED) { @@ -287,7 +287,7 @@ public class OneTimeDonationsGrpcService extends SimpleOneTimeDonationsGrpc.OneT if (paymentDetails.chargeFailure() != null) { paymentRequiredBuilder.setChargeFailure(toChargeFailure(processor, paymentDetails.chargeFailure())); } - return CreateBoostReceiptCredentialsResponse.newBuilder() + return CreateBoostReceiptCredentialResponse.newBuilder() .setPaymentRequired(paymentRequiredBuilder).build(); } @@ -316,7 +316,7 @@ public class OneTimeDonationsGrpcService extends SimpleOneTimeDonationsGrpc.OneT issuedReceiptsManager.recordOneTimeIssuance( paymentDetails.id(), processor, receiptCredentialRequest, expiration); } catch (final WriteConflictException e) { - return CreateBoostReceiptCredentialsResponse.newBuilder() + return CreateBoostReceiptCredentialResponse.newBuilder() .setReceiptAlreadyIssued(FailedPrecondition.getDefaultInstance()).build(); } @@ -336,8 +336,8 @@ public class OneTimeDonationsGrpcService extends SimpleOneTimeDonationsGrpc.OneT UserAgentTagUtil.getPlatformTag(RequestAttributesUtil.getUserAgent().orElse(null)))) .increment(); - return CreateBoostReceiptCredentialsResponse.newBuilder() - .setResult(CreateBoostReceiptCredentialsResponse.CreateBoostReceiptCredentialsResult.newBuilder() + return CreateBoostReceiptCredentialResponse.newBuilder() + .setResult(CreateBoostReceiptCredentialResponse.CreateBoostReceiptCredentialResult.newBuilder() .setReceiptCredentialResponse(ByteString.copyFrom(receiptCredentialResponse.serialize())) .build()) .build(); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java index 03495299e..a575b53d6 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcService.java @@ -181,7 +181,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof try { presentation = new AvatarUploadCredentialPresentation( - request.getAvatarCredentialsPresentation().toByteArray()); + request.getAvatarCredentialPresentation().toByteArray()); presentation.verify(clock.instant(), this.genericServerSecretParams); @@ -190,7 +190,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof } catch (VerificationFailedException _) { return GetAvatarUploadFormResponse.newBuilder() - .setInvalidCredentialsPresentation(FailedZkAuthentication.getDefaultInstance()) + .setInvalidCredentialPresentation(FailedZkAuthentication.getDefaultInstance()) .build(); } @@ -212,7 +212,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof final AvatarUploadCredentialPresentation presentation; try { presentation = new AvatarUploadCredentialPresentation( - request.getAvatarCredentialsPresentation().toByteArray()); + request.getAvatarCredentialPresentation().toByteArray()); } catch (InvalidInputException _) { throw GrpcExceptions.invalidArguments("invalid credential presentation"); } @@ -222,7 +222,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof } catch (VerificationFailedException _) { return ExtendAvatarTTLResponse.newBuilder() - .setInvalidCredentialsPresentation(FailedZkAuthentication.getDefaultInstance()) + .setInvalidCredentialPresentation(FailedZkAuthentication.getDefaultInstance()) .build(); } @@ -242,7 +242,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof final AvatarUploadCredentialPresentation presentation; try { presentation = new AvatarUploadCredentialPresentation( - request.getAvatarCredentialsPresentation().toByteArray()); + request.getAvatarCredentialPresentation().toByteArray()); } catch (InvalidInputException _) { throw GrpcExceptions.invalidArguments("invalid credential presentation"); } @@ -252,7 +252,7 @@ public class ProfileAnonymousGrpcService extends SimpleProfileAnonymousGrpc.Prof } catch (VerificationFailedException _) { return DeleteAvatarResponse.newBuilder() - .setInvalidCredentialsPresentation(FailedZkAuthentication.getDefaultInstance()) + .setInvalidCredentialPresentation(FailedZkAuthentication.getDefaultInstance()) .build(); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java index fa8fc2219..0d491ca2b 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcService.java @@ -21,8 +21,8 @@ import java.util.stream.Collectors; import org.signal.chat.common.S3UploadForm; import org.signal.chat.errors.FailedPrecondition; import org.signal.chat.errors.NotFound; -import org.signal.chat.profile.GetAvatarCredentialsRequest; -import org.signal.chat.profile.GetAvatarCredentialsResponse; +import org.signal.chat.profile.GetAvatarCredentialRequest; +import org.signal.chat.profile.GetAvatarCredentialResponse; import org.signal.chat.profile.GetProfileRequest; import org.signal.chat.profile.GetProfileResponse; import org.signal.chat.profile.PaymentsForbiddenInRegion; @@ -213,7 +213,7 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase { } @Override - public GetAvatarCredentialsResponse getAvatarCredentials(final GetAvatarCredentialsRequest request) { + public GetAvatarCredentialResponse getAvatarCredential(final GetAvatarCredentialRequest request) { final AuthenticatedDevice authenticatedDevice = AuthenticationUtil.requireAuthenticatedDevice(); @@ -221,14 +221,14 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase { .orElseThrow(() -> GrpcExceptions.invalidCredentials("invalid credentials")); if (account.getZkCredentialKey().isEmpty()) { - return GetAvatarCredentialsResponse.newBuilder() + return GetAvatarCredentialResponse.newBuilder() .setMissingZkCredentialKey(FailedPrecondition.newBuilder().setDescription("account requires ZK credential key")) .build(); } try { final AvatarUploadCredentialRequest credentialRequest = new AvatarUploadCredentialRequest( - request.getAvatarCredentialsRequest().toByteArray()); + request.getAvatarCredentialRequest().toByteArray()); final AvatarUploadCredentialResponse credentialResponse = credentialRequest.issueCredential( new ServiceId.Aci(account.getAccountIdentifier()), @@ -237,8 +237,8 @@ public class ProfileGrpcService extends SimpleProfileGrpc.ProfileImplBase { clock.instant().truncatedTo(ChronoUnit.DAYS), this.genericServerSecretParams); - return GetAvatarCredentialsResponse.newBuilder() - .setAvatarCredentials(ByteString.copyFrom(credentialResponse.serialize())) + return GetAvatarCredentialResponse.newBuilder() + .setAvatarCredential(ByteString.copyFrom(credentialResponse.serialize())) .build(); } catch (InvalidInputException | VerificationFailedException _) { throw GrpcExceptions.invalidArguments("invalid credential request"); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java index 5cad0dc87..999721cbd 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcService.java @@ -5,16 +5,15 @@ import static org.whispersystems.textsecuregcm.grpc.SubscriptionsUtil.getPayPalL import com.google.protobuf.ByteString; import com.google.protobuf.Empty; +import io.micrometer.core.instrument.Metrics; +import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.Tags; import java.io.IOException; import java.io.UncheckedIOException; import java.time.Clock; import java.util.Locale; import java.util.Optional; -import io.micrometer.core.instrument.Metrics; -import io.micrometer.core.instrument.Tag; -import io.micrometer.core.instrument.Tags; import org.signal.chat.errors.FailedPrecondition; -import org.signal.chat.errors.FailedUnidentifiedAuthorization; import org.signal.chat.errors.FailedZkAuthentication; import org.signal.chat.errors.NotFound; import org.signal.chat.purchase.CreatePayPalPaymentMethodRequest; @@ -25,8 +24,8 @@ import org.signal.chat.purchase.DeleteSubscriberRequest; import org.signal.chat.purchase.DeleteSubscriberResponse; import org.signal.chat.purchase.GetBankMandateRequest; import org.signal.chat.purchase.GetBankMandateResponse; -import org.signal.chat.purchase.GetReceiptCredentialsRequest; -import org.signal.chat.purchase.GetReceiptCredentialsResponse; +import org.signal.chat.purchase.GetReceiptCredentialRequest; +import org.signal.chat.purchase.GetReceiptCredentialResponse; import org.signal.chat.purchase.GetSubscriptionInformationRequest; import org.signal.chat.purchase.GetSubscriptionInformationResponse; import org.signal.chat.purchase.PaymentRequired; @@ -434,12 +433,12 @@ public class SubscriptionsGrpcService extends SimpleSubscriptionsGrpc.Subscripti } @Override - public GetReceiptCredentialsResponse getReceiptCredentials(final GetReceiptCredentialsRequest request) + public GetReceiptCredentialResponse getReceiptCredential(final GetReceiptCredentialRequest request) throws RateLimitExceededException { final SubscriberCredentials subscriberCredentials = SubscriberCredentials.process( request.getSubscriberId().toByteArray(), clock); try { - final SubscriptionManager.ReceiptResult result = subscriptionManager.createReceiptCredentials( + final SubscriptionManager.ReceiptResult result = subscriptionManager.createReceiptCredential( subscriberCredentials, request.getReceiptCredentialRequest().toByteArray(), r -> SubscriptionsUtil.receiptExpirationWithGracePeriod(subscriptionConfiguration, r), RequestAttributesUtil.getUserAgent().orElse(null)); @@ -452,27 +451,27 @@ public class SubscriptionsGrpcService extends SimpleSubscriptionsGrpc.Subscripti .toLowerCase(Locale.ROOT)), UserAgentTagUtil.getPlatformTag(RequestAttributesUtil.getUserAgent().orElse(null)))) .increment(); - return GetReceiptCredentialsResponse.newBuilder().setSuccess( - GetReceiptCredentialsResponse.GetReceiptCredentialsResult.newBuilder() + return GetReceiptCredentialResponse.newBuilder().setSuccess( + GetReceiptCredentialResponse.GetReceiptCredentialResult.newBuilder() .setReceiptCredentialResponse(ByteString.copyFrom(result.receiptCredentialResponse().serialize())) .build()).build(); } catch (final SubscriptionReceiptRequestedForOpenPaymentException e) { - return GetReceiptCredentialsResponse.newBuilder().setNoPaidInvoice(FailedPrecondition.newBuilder().build()) + return GetReceiptCredentialResponse.newBuilder().setNoPaidInvoice(FailedPrecondition.newBuilder().build()) .build(); } catch (final SubscriptionChargeFailurePaymentRequiredException e) { - return GetReceiptCredentialsResponse.newBuilder().setPaymentRequired( + return GetReceiptCredentialResponse.newBuilder().setPaymentRequired( PaymentRequired.newBuilder() .setChargeFailure(SubscriptionsUtil.toChargeFailure(e.getProcessor(), e.getChargeFailure())).build()).build(); } catch (final SubscriptionPaymentRequiredException e) { - return GetReceiptCredentialsResponse.newBuilder() + return GetReceiptCredentialResponse.newBuilder() .setPaymentRequired(PaymentRequired.newBuilder().build()).build(); } catch (final SubscriptionInvalidArgumentsException e) { throw GrpcExceptions.invalidArguments(e.errorDetail().orElse("")); } catch (final SubscriptionReceiptAlreadyRedeemedException e) { - return GetReceiptCredentialsResponse.newBuilder().setAlreadyRedeemed(FailedPrecondition.newBuilder().build()) + return GetReceiptCredentialResponse.newBuilder().setAlreadyRedeemed(FailedPrecondition.newBuilder().build()) .build(); } catch (final SubscriptionNotFoundException | SubscriptionForbiddenException _) { - return GetReceiptCredentialsResponse.newBuilder().setSubscriberNotFound(NotFound.newBuilder().build()).build(); + return GetReceiptCredentialResponse.newBuilder().setSubscriberNotFound(NotFound.newBuilder().build()).build(); } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/SubscriptionManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/SubscriptionManager.java index d1b510a85..29007895a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/SubscriptionManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/SubscriptionManager.java @@ -201,7 +201,7 @@ public class SubscriptionManager { * request * @throws RateLimitExceededException if rate-limited */ - public ReceiptResult createReceiptCredentials( + public ReceiptResult createReceiptCredential( final SubscriberCredentials subscriberCredentials, final byte[] receiptCredentialRequestBytes, final Function expiration, diff --git a/service/src/main/proto/org/signal/chat/donations.proto b/service/src/main/proto/org/signal/chat/donations.proto index 0ea30226c..220514e8c 100644 --- a/service/src/main/proto/org/signal/chat/donations.proto +++ b/service/src/main/proto/org/signal/chat/donations.proto @@ -16,7 +16,7 @@ import "org/signal/chat/tag.proto"; service Donations { option (require.auth) = AUTH_ONLY_AUTHENTICATED; - // Redeem a receipt acquired from Subscriptions.CreateSubscriptionReceiptCredentials + // Redeem a receipt acquired from Subscriptions.GetReceiptCredential // to add a badge to the account. After successful redemption, profile // responses will include the corresponding badge (if configured as visible) // until the expiration time on the receipt. diff --git a/service/src/main/proto/org/signal/chat/one_time_donations.proto b/service/src/main/proto/org/signal/chat/one_time_donations.proto index 5c3d88723..6ad57e03d 100644 --- a/service/src/main/proto/org/signal/chat/one_time_donations.proto +++ b/service/src/main/proto/org/signal/chat/one_time_donations.proto @@ -21,7 +21,7 @@ service OneTimeDonations { option (require.auth) = AUTH_ONLY_ANONYMOUS; // Create a Stripe payment intent and return a client secret that can be used to complete the payment. - // Once the payment is complete, the paymentIntentId can be used with CreateBoostReceiptCredentials + // Once the payment is complete, the paymentIntentId can be used with CreateBoostReceiptCredential rpc CreateBoost(CreateBoostRequest) returns (CreateBoostResponse) {} // Create a PayPal one-time payment. @@ -41,7 +41,7 @@ service OneTimeDonations { // Obtain a ZK receipt credential for a completed one-time donation payment. // The receipt credential can then be used to redeem the one-time donation entitlement // via Donations.RedeemReceipt - rpc CreateBoostReceiptCredentials(CreateBoostReceiptCredentialsRequest) returns (CreateBoostReceiptCredentialsResponse) {} + rpc CreateBoostReceiptCredential(CreateBoostReceiptCredentialRequest) returns (CreateBoostReceiptCredentialResponse) {} } // The amount is below the minimum for the currency. @@ -149,7 +149,7 @@ message ConfirmPayPalBoostResponse { } } -message CreateBoostReceiptCredentialsRequest { +message CreateBoostReceiptCredentialRequest { // a payment ID from the processor string payment_intent_id = 1 [(require.nonEmpty) = true]; // ZK blind-signature receipt credential request bytes @@ -158,12 +158,12 @@ message CreateBoostReceiptCredentialsRequest { PaymentProvider processor = 3 [(require.specified) = true]; } -message CreateBoostReceiptCredentialsResponse { - message CreateBoostReceiptCredentialsResult { +message CreateBoostReceiptCredentialResponse { + message CreateBoostReceiptCredentialResult { bytes receipt_credential_response = 1; } oneof response { - CreateBoostReceiptCredentialsResult result = 1; + CreateBoostReceiptCredentialResult result = 1; // Payment is still processing; client should retry errors.FailedPrecondition payment_still_processing = 2 [(tag.reason) = "payment_still_processing"]; // Payment failed diff --git a/service/src/main/proto/org/signal/chat/profile.proto b/service/src/main/proto/org/signal/chat/profile.proto index 46d389b84..0f99fc9e9 100644 --- a/service/src/main/proto/org/signal/chat/profile.proto +++ b/service/src/main/proto/org/signal/chat/profile.proto @@ -20,19 +20,19 @@ import "org/signal/chat/tag.proto"; service Profile { option (require.auth) = AUTH_ONLY_AUTHENTICATED; - // Sets profile data and, if needed, returns credentials used by clients to upload a v1 avatar. + // Sets profile data and, if needed, returns a credential used by clients to upload a v1 avatar. rpc SetProfile(SetProfileRequest) returns (SetProfileResponse) {} // Retrieves profile data. Callers with an unidentified access key for the account // should use the version of this method in `ProfileAnonymous` instead. rpc GetProfile(GetProfileRequest) returns (GetProfileResponse) {} - // Returns anonymous credentials that may be presented with avatar operations in ProfilesAnonymous + // Returns an anonymous credential that may be presented with avatar operations in ProfilesAnonymous // // Note: `Accounts.SetZkCredentialKey` is a pre-requisite for this RPC - rpc GetAvatarCredentials(GetAvatarCredentialsRequest) returns (GetAvatarCredentialsResponse) {} + rpc GetAvatarCredential(GetAvatarCredentialRequest) returns (GetAvatarCredentialResponse) {} - // Returns credentials used by clients to upload a v1 avatar, deleting any current avatar. + // Returns a credential used by clients to upload a v1 avatar, deleting any current avatar. // // This RPC streamlines avatar changes during the v1 -> v2 transition by minimizing uploads: // 1. SetV1Avatar @@ -59,14 +59,14 @@ service ProfileAnonymous { // Retrieves a profile key credential. rpc GetExpiringProfileKeyCredential(GetExpiringProfileKeyCredentialRequest) returns (GetExpiringProfileKeyCredentialResponse) {} - // Returns credentials to upload a v2 avatar. After uploading the avatar, the client + // Returns a credential to upload a v2 avatar. After uploading the avatar, the client // must call SetProfile with the new avatar URL in the encrypted `data`. // // Because avatars are uploaded anonymously, they have an expiration equal to the // idle account expiration. Clients must periodically (recommended: every 90 days) // call ExtendAvatarTTL to extend the TTl. // - // Note: any existing avatar associated with these credentials will be deleted immediately + // Note: any existing avatar associated with this credential will be deleted immediately rpc GetAvatarUploadForm(GetAvatarUploadFormRequest) returns (GetAvatarUploadFormResponse) {} // Extends the TTL of the avatar currently associated with the request’s avatar auth credential @@ -366,13 +366,13 @@ enum CredentialType { // avatar auth -message GetAvatarCredentialsRequest { - bytes avatar_credentials_request = 1; +message GetAvatarCredentialRequest { + bytes avatar_credential_request = 1; } -message GetAvatarCredentialsResponse { +message GetAvatarCredentialResponse { oneof response { - bytes avatar_credentials = 1; + bytes avatar_credential = 1; // the client must call Accounts.SetZkCredentialKey to call this method errors.FailedPrecondition missing_zk_credential_key = 2 [(tag.reason) = "missing_zk_credential_key"]; @@ -380,7 +380,7 @@ message GetAvatarCredentialsResponse { } message GetAvatarUploadFormRequest { - bytes avatar_credentials_presentation = 1; + bytes avatar_credential_presentation = 1; // The length of the attachment for the requested upload form. Uploads // performed with this form will be limited to the provided length. @@ -392,31 +392,31 @@ message GetAvatarUploadFormResponse { // the policy and credential used by clients to upload an avatar to the CDN common.S3UploadForm avatar_upload_form = 1; - errors.FailedZkAuthentication invalid_credentials_presentation = 2 [(tag.reason) = "invalid_credentials_presentation"]; + errors.FailedZkAuthentication invalid_credential_presentation = 2 [(tag.reason) = "invalid_credential_presentation"]; } } message ExtendAvatarTTLRequest { - bytes avatar_credentials_presentation = 1; + bytes avatar_credential_presentation = 1; } message ExtendAvatarTTLResponse { oneof response { // The avatar that was extended. May be used as a check against state de-synchronization. string path = 1; - errors.FailedZkAuthentication invalid_credentials_presentation = 2 [(tag.reason) = "invalid_credentials_presentation"]; + errors.FailedZkAuthentication invalid_credential_presentation = 2 [(tag.reason) = "invalid_credential_presentation"]; // the identity does not have an active avatar errors.NotFound not_found = 3 [(tag.reason) = "no_active_avatar"]; } } message DeleteAvatarRequest { - bytes avatar_credentials_presentation = 1; + bytes avatar_credential_presentation = 1; } message DeleteAvatarResponse { oneof response { google.protobuf.Empty success = 1; - errors.FailedZkAuthentication invalid_credentials_presentation = 2 [(tag.reason) = "invalid_credentials_presentation"]; + errors.FailedZkAuthentication invalid_credential_presentation = 2 [(tag.reason) = "invalid_credential_presentation"]; } } diff --git a/service/src/main/proto/org/signal/chat/subscriptions.proto b/service/src/main/proto/org/signal/chat/subscriptions.proto index 922440c66..c9a270a81 100644 --- a/service/src/main/proto/org/signal/chat/subscriptions.proto +++ b/service/src/main/proto/org/signal/chat/subscriptions.proto @@ -65,7 +65,7 @@ service Subscriptions { // invoice. Clients SHOULD retry requests at this endpoint with the same ReceiptCredentialRequest value until // receiving a response. After receiving a response, clients should then compute the ReceiptCredentialPresentation // and redeem it at the receipt redemption endpoint. Once the first attempt is made there, the same - // ReceiptCredentialRequest MUST NOT be used again to request receipt credentials. + // ReceiptCredentialRequest MUST NOT be used again to request a receipt credential. // // Note that you may in fact redeem TWO or more invoices for the same ReceiptCredentialRequest while retrying this // operation if a later invoice gets paid while you are retrying. However, the returned receipt is always for the @@ -75,7 +75,7 @@ service Subscriptions { // cannot be redeemed. // // Clients MUST validate that the generated receipt credential's level and expiration matches their expectations. - rpc GetReceiptCredentials(GetReceiptCredentialsRequest) returns (GetReceiptCredentialsResponse) {} + rpc GetReceiptCredential(GetReceiptCredentialRequest) returns (GetReceiptCredentialResponse) {} // Set a token that represents an IAP subscription made with App Store/Google Play Billing. // @@ -84,7 +84,7 @@ service Subscriptions { // 2. [Create a subscription](https://developer.apple.com/documentation/storekit/in-app_purchase/) with the App Store // directly via StoreKit and obtain a originalTransactionId. // 3. Call this RPC with the originalTransactionId - // 4. Obtain a receipt via GetReceiptCredentials which can then be used to obtain the + // 4. Obtain a receipt via GetReceiptCredential which can then be used to obtain the // entitlement // // Play Billing: Set a purchaseToken that represents an IAP subscription made with Google Play Billing. @@ -95,7 +95,7 @@ service Subscriptions { // directly and obtain a purchaseToken. Do not [acknowledge](https://developer.android.com/google/play/billing/integrate#subscriptions) // the purchaseToken. // 3. Call this RPC with the purchaseToken - // 4. Obtain a receipt via GetReceiptCredentials which can then be used to obtain the + // 4. Obtain a receipt via GetReceiptCredential which can then be used to obtain the // entitlement // // After calling this method, the payment is confirmed. Callers must durably store their subscriberId before calling @@ -374,18 +374,18 @@ message SetIapSubscriptionResponse { } } -message GetReceiptCredentialsRequest { +message GetReceiptCredentialRequest { bytes subscriberId = 1 [(require.exactlySize) = 32]; bytes receiptCredentialRequest = 2 [(require.exactlySize) = 97]; } -message GetReceiptCredentialsResponse { - message GetReceiptCredentialsResult { +message GetReceiptCredentialResponse { + message GetReceiptCredentialResult { bytes receiptCredentialResponse = 1; } oneof response { - GetReceiptCredentialsResult success = 1; + GetReceiptCredentialResult success = 1; // The subscriber did not exist or it did not have an associated subscription errors.NotFound subscriber_not_found = 2 [(tag.reason) = "subscriber_not_found"]; // No invoice has been issued for this subscription OR invoice is in 'draft' or 'open' state diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationControllerTest.java index 7230727ca..1dd78ec39 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationControllerTest.java @@ -276,7 +276,7 @@ class OneTimeDonationControllerTest extends AbstractV1SubscriptionControllerTest assertThat(response.getStatus()).isEqualTo(402); if (expectChargeFailure) { - assertThat(response.readEntity(OneTimeDonationController.CreateBoostReceiptCredentialsErrorResponse.class) + assertThat(response.readEntity(OneTimeDonationController.CreateBoostReceiptCredentialErrorResponse.class) .chargeFailure()).isEqualTo(chargeFailure); } else { assertThat(response.readEntity(String.class)).isEqualTo("{}"); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java index a619b0d25..32857a198 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java @@ -835,7 +835,7 @@ class SubscriptionControllerTest extends AbstractV1SubscriptionControllerTest { try (Response response = RESOURCE_EXTENSION .target(String.format("/v1/subscription/%s/receipt_credentials", subscriberId)) .request() - .post(Entity.json(new SubscriptionController.GetReceiptCredentialsRequest(receiptRequest.serialize())))) { + .post(Entity.json(new SubscriptionController.GetReceiptCredentialRequest(receiptRequest.serialize())))) { assertThat(response.getStatus()).isEqualTo(402); responseMap = response.readEntity(Map.class); @@ -876,7 +876,7 @@ class SubscriptionControllerTest extends AbstractV1SubscriptionControllerTest { try (Response response = RESOURCE_EXTENSION .target(String.format("/v1/subscription/%s/receipt_credentials", subscriberId)) .request() - .post(Entity.json(new SubscriptionController.GetReceiptCredentialsRequest(receiptRequest.serialize())))) { + .post(Entity.json(new SubscriptionController.GetReceiptCredentialRequest(receiptRequest.serialize())))) { assertThat(response.getStatus()).isEqualTo(409); } @@ -917,7 +917,7 @@ class SubscriptionControllerTest extends AbstractV1SubscriptionControllerTest { try (Response response = RESOURCE_EXTENSION .target(String.format("/v1/subscription/%s/receipt_credentials", subscriberId)) .request() - .post(Entity.json(new SubscriptionController.GetReceiptCredentialsRequest(receiptRequest.serialize())))) { + .post(Entity.json(new SubscriptionController.GetReceiptCredentialRequest(receiptRequest.serialize())))) { assertThat(response.getStatus()).isEqualTo(200); } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcServiceTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcServiceTest.java index ad2fc0da0..97b8584cb 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcServiceTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/OneTimeDonationsGrpcServiceTest.java @@ -32,8 +32,8 @@ import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; import org.signal.chat.purchase.ConfirmPayPalBoostRequest; import org.signal.chat.purchase.ConfirmPayPalBoostResponse; -import org.signal.chat.purchase.CreateBoostReceiptCredentialsRequest; -import org.signal.chat.purchase.CreateBoostReceiptCredentialsResponse; +import org.signal.chat.purchase.CreateBoostReceiptCredentialRequest; +import org.signal.chat.purchase.CreateBoostReceiptCredentialResponse; import org.signal.chat.purchase.CreateBoostRequest; import org.signal.chat.purchase.CreateBoostResponse; import org.signal.chat.purchase.CreatePayPalBoostRequest; @@ -268,22 +268,22 @@ public class OneTimeDonationsGrpcServiceTest extends @ParameterizedTest @MethodSource - void createBoostReceiptCredentialsPaymentRequired( + void createBoostReceiptCredentialPaymentRequired( @Nullable final ChargeFailure chargeFailure, final boolean expectChargeFailure) throws IOException { when(stripeManager.claimOneTimePurchase(any())).thenReturn( Optional.of(new PaymentDetails("id", null, PaymentStatus.FAILED, clock.instant(), chargeFailure))); - final CreateBoostReceiptCredentialsResponse response = - unauthenticatedServiceStub().createBoostReceiptCredentials( - CreateBoostReceiptCredentialsRequest.newBuilder() + final CreateBoostReceiptCredentialResponse response = + unauthenticatedServiceStub().createBoostReceiptCredential( + CreateBoostReceiptCredentialRequest.newBuilder() .setPaymentIntentId("test-payment-intent-id") .setReceiptCredentialRequest(ByteString.copyFromUtf8("abcd")) .setProcessor(PaymentProvider.PAYMENT_PROVIDER_STRIPE) .build()); - assertEquals(CreateBoostReceiptCredentialsResponse.ResponseCase.PAYMENT_REQUIRED, + assertEquals(CreateBoostReceiptCredentialResponse.ResponseCase.PAYMENT_REQUIRED, response.getResponseCase()); if (expectChargeFailure) { assertEquals("generic_decline", response.getPaymentRequired().getChargeFailure().getCode()); @@ -292,7 +292,7 @@ public class OneTimeDonationsGrpcServiceTest extends } } - static Stream createBoostReceiptCredentialsPaymentRequired() { + static Stream createBoostReceiptCredentialPaymentRequired() { return Stream.of( Arguments.of(new ChargeFailure("generic_decline", "some failure message", null, null, null), true), Arguments.of(null, false) @@ -300,7 +300,7 @@ public class OneTimeDonationsGrpcServiceTest extends } @Test - void createBoostReceiptCredentialsAlreadyRedeemed() throws Exception { + void createBoostReceiptCredentialAlreadyRedeemed() throws Exception { final ReceiptCredentialRequest receiptCredentialRequest = new ClientZkReceiptOperations( ServerSecretParams.generate().getPublicParams()).createReceiptCredentialRequestContext( new ReceiptSerial(new byte[ReceiptSerial.SIZE])).getRequest(); @@ -312,15 +312,15 @@ public class OneTimeDonationsGrpcServiceTest extends doThrow(WriteConflictException.class).when(issuedReceiptsManager) .recordOneTimeIssuance(any(), any(), any(), any()); - final CreateBoostReceiptCredentialsResponse response = - unauthenticatedServiceStub().createBoostReceiptCredentials( - CreateBoostReceiptCredentialsRequest.newBuilder() + final CreateBoostReceiptCredentialResponse response = + unauthenticatedServiceStub().createBoostReceiptCredential( + CreateBoostReceiptCredentialRequest.newBuilder() .setPaymentIntentId("test-payment-intent-id") .setReceiptCredentialRequest(ByteString.copyFrom(receiptCredentialRequest.serialize())) .setProcessor(PaymentProvider.PAYMENT_PROVIDER_STRIPE) .build()); - assertEquals(CreateBoostReceiptCredentialsResponse.ResponseCase.RECEIPT_ALREADY_ISSUED, + assertEquals(CreateBoostReceiptCredentialResponse.ResponseCase.RECEIPT_ALREADY_ISSUED, response.getResponseCase()); } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java index 17562dfcb..3152d5b51 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java @@ -691,7 +691,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest avatarUploadCredentialRequestContext.receiveResponse( - new AvatarUploadCredentialResponse(response.getAvatarCredentials().toByteArray()), + new AvatarUploadCredentialResponse(response.getAvatarCredential().toByteArray()), genericServerSecretParams.getPublicParams())); } @@ -864,7 +864,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest authenticatedServiceStub().getAvatarCredentials(GetAvatarCredentialsRequest.getDefaultInstance())); + () -> authenticatedServiceStub().getAvatarCredential(GetAvatarCredentialRequest.getDefaultInstance())); assertEquals("invalid credentials", statusRuntimeException.getStatus().getDescription()); } @@ -872,8 +872,8 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest authenticatedServiceStub().getAvatarCredentials( - GetAvatarCredentialsRequest.newBuilder() - .setAvatarCredentialsRequest(ByteString.copyFrom(credentialRequest.serialize())) + () -> authenticatedServiceStub().getAvatarCredential( + GetAvatarCredentialRequest.newBuilder() + .setAvatarCredentialRequest(ByteString.copyFrom(credentialRequest.serialize())) .build())); assertEquals("invalid credential request", statusRuntimeException.getStatus().getDescription()); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java index b485c6eb5..fa886da60 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/SubscriptionsGrpcServiceTest.java @@ -42,8 +42,8 @@ import org.signal.chat.purchase.DeleteSubscriberRequest; import org.signal.chat.purchase.DeleteSubscriberResponse; import org.signal.chat.purchase.GetBankMandateRequest; import org.signal.chat.purchase.GetBankMandateResponse; -import org.signal.chat.purchase.GetReceiptCredentialsRequest; -import org.signal.chat.purchase.GetReceiptCredentialsResponse; +import org.signal.chat.purchase.GetReceiptCredentialRequest; +import org.signal.chat.purchase.GetReceiptCredentialResponse; import org.signal.chat.purchase.GetSubscriptionInformationRequest; import org.signal.chat.purchase.GetSubscriptionInformationResponse; import org.signal.chat.purchase.PaymentMethod; @@ -569,39 +569,39 @@ public class SubscriptionsGrpcServiceTest extends } @Test - void getReceiptCredentials() throws Exception { + void getReceiptCredential() throws Exception { final ReceiptCredentialResponse receiptCredentialResponse = mock(ReceiptCredentialResponse.class); final byte[] responseBytes = TestRandomUtil.nextBytes(16); when(receiptCredentialResponse.serialize()).thenReturn(responseBytes); - when(subscriptionManager.createReceiptCredentials(any(), any(), any(), any())) + when(subscriptionManager.createReceiptCredential(any(), any(), any(), any())) .thenReturn(new SubscriptionManager.ReceiptResult(receiptCredentialResponse, new SubscriptionPaymentProcessor.ReceiptItem("test-item-id", null, 5), PaymentProvider.STRIPE)); - final GetReceiptCredentialsResponse response = unauthenticatedServiceStub().getReceiptCredentials( - GetReceiptCredentialsRequest.newBuilder() + final GetReceiptCredentialResponse response = unauthenticatedServiceStub().getReceiptCredential( + GetReceiptCredentialRequest.newBuilder() .setSubscriberId(SUBSCRIBER_ID) .setReceiptCredentialRequest(ByteString.copyFrom(TestRandomUtil.nextBytes(97))) .build()); - assertEquals(GetReceiptCredentialsResponse.ResponseCase.SUCCESS, response.getResponseCase()); + assertEquals(GetReceiptCredentialResponse.ResponseCase.SUCCESS, response.getResponseCase()); assertArrayEquals(responseBytes, response.getSuccess().getReceiptCredentialResponse().toByteArray()); } - static Stream getReceiptCredentialsExceptions() { + static Stream getReceiptCredentialExceptions() { return Stream.of( Arguments.of(new SubscriptionReceiptRequestedForOpenPaymentException(), - GetReceiptCredentialsResponse.ResponseCase.NO_PAID_INVOICE), + GetReceiptCredentialResponse.ResponseCase.NO_PAID_INVOICE), Arguments.of(new SubscriptionPaymentRequiredException(), - GetReceiptCredentialsResponse.ResponseCase.PAYMENT_REQUIRED), + GetReceiptCredentialResponse.ResponseCase.PAYMENT_REQUIRED), Arguments.of(new SubscriptionReceiptAlreadyRedeemedException(), - GetReceiptCredentialsResponse.ResponseCase.ALREADY_REDEEMED) + GetReceiptCredentialResponse.ResponseCase.ALREADY_REDEEMED) ); } @ParameterizedTest @MethodSource - void getReceiptCredentialsExceptions(final SubscriptionException exception, - final GetReceiptCredentialsResponse.ResponseCase expectedCase) throws Exception { - doThrow(exception).when(subscriptionManager).createReceiptCredentials(any(), any(), any(), any()); - final GetReceiptCredentialsResponse response = unauthenticatedServiceStub().getReceiptCredentials( - GetReceiptCredentialsRequest.newBuilder() + void getReceiptCredentialExceptions(final SubscriptionException exception, + final GetReceiptCredentialResponse.ResponseCase expectedCase) throws Exception { + doThrow(exception).when(subscriptionManager).createReceiptCredential(any(), any(), any(), any()); + final GetReceiptCredentialResponse response = unauthenticatedServiceStub().getReceiptCredential( + GetReceiptCredentialRequest.newBuilder() .setSubscriberId(SUBSCRIBER_ID) .setReceiptCredentialRequest(ByteString.copyFrom(TestRandomUtil.nextBytes(97))) .build()); @@ -609,16 +609,16 @@ public class SubscriptionsGrpcServiceTest extends } @Test - void getReceiptCredentialsChargeFailure() throws Exception { + void getReceiptCredentialChargeFailure() throws Exception { doThrow(new SubscriptionChargeFailurePaymentRequiredException(PaymentProvider.STRIPE, new ChargeFailure("card_declined", "Insufficient funds", null, null, null))) - .when(subscriptionManager).createReceiptCredentials(any(), any(), any(), any()); - final GetReceiptCredentialsResponse response = unauthenticatedServiceStub().getReceiptCredentials( - GetReceiptCredentialsRequest.newBuilder() + .when(subscriptionManager).createReceiptCredential(any(), any(), any(), any()); + final GetReceiptCredentialResponse response = unauthenticatedServiceStub().getReceiptCredential( + GetReceiptCredentialRequest.newBuilder() .setSubscriberId(SUBSCRIBER_ID) .setReceiptCredentialRequest(ByteString.copyFrom(TestRandomUtil.nextBytes(97))) .build()); - assertEquals(GetReceiptCredentialsResponse.ResponseCase.PAYMENT_REQUIRED, response.getResponseCase()); + assertEquals(GetReceiptCredentialResponse.ResponseCase.PAYMENT_REQUIRED, response.getResponseCase()); assertEquals(org.signal.chat.purchase.PaymentProvider.PAYMENT_PROVIDER_STRIPE, response.getPaymentRequired().getChargeFailure().getProcessor()); assertEquals("card_declined", response.getPaymentRequired().getChargeFailure().getCode());